mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-01 10:40:38 +03:00
Script for updating map names
This commit is contained in:
@@ -41,16 +41,17 @@ jobs:
|
||||
git commit -m "Automatic bundle update"
|
||||
git push
|
||||
fi
|
||||
- name: Update scripts and class mappings
|
||||
- name: Update scripts, class mappings and map names
|
||||
if: ${{ github.repository == 'Anuken/Mindustry' }}
|
||||
run: |
|
||||
./gradlew updateScripts
|
||||
./gradlew updateScripts fixMaps
|
||||
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git config --global user.name "Github Actions"
|
||||
git config --global user.email "actions@github.com"
|
||||
git add core/assets/scripts/* core/src/mindustry/mod/ClassMap.java
|
||||
git commit -m "Automatic class mapping update"
|
||||
git add core/assets/maps/*
|
||||
git commit -m "Automatic class mapping and map name update"
|
||||
git push
|
||||
fi
|
||||
- name: Update JITpack repo
|
||||
|
||||
@@ -188,7 +188,7 @@ public class EditorTile extends Tile{
|
||||
}
|
||||
|
||||
private void updateStatic(){
|
||||
editor.renderer.updateStatic(x, y);
|
||||
if(!headless) editor.renderer.updateStatic(x, y);
|
||||
}
|
||||
|
||||
private boolean skip(){
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MapEditor{
|
||||
tags.put("steamid", map.file.parent().name());
|
||||
}
|
||||
load(() -> MapIO.loadMap(map, context));
|
||||
renderer.resize(width(), height());
|
||||
if(!headless) renderer.resize(width(), height());
|
||||
loading = false;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MapEditor{
|
||||
|
||||
createTiles(pixmap.width, pixmap.height);
|
||||
load(() -> MapIO.readImage(pixmap, tiles()));
|
||||
renderer.resize(width(), height());
|
||||
if(!headless) renderer.resize(width(), height());
|
||||
}
|
||||
|
||||
public void updateRenderer(){
|
||||
|
||||
@@ -246,8 +246,6 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
public String toString(){
|
||||
return "Map{" +
|
||||
"file='" + file + '\'' +
|
||||
", custom=" + custom +
|
||||
", tags=" + tags +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,6 +261,14 @@ tasks.register('updateScripts', JavaExec){
|
||||
workingDir = "../"
|
||||
}
|
||||
|
||||
tasks.register('fixMaps', JavaExec){
|
||||
dependsOn classes
|
||||
mainClass = "mindustry.tools.MapFixer"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
workingDir = "../core/assets"
|
||||
}
|
||||
|
||||
tasks.register('updateBundles'){
|
||||
doLast{
|
||||
def uniEscape = { String string ->
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package mindustry.tools;
|
||||
|
||||
import arc.*;
|
||||
import arc.backend.headless.*;
|
||||
import arc.files.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.editor.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.maps.Map;
|
||||
import mindustry.net.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapFixer{
|
||||
|
||||
public static void main(String[] args){
|
||||
Log.useColors = false;
|
||||
|
||||
Reflect.set(Maps.class, "useDefaultFolder", false);
|
||||
Reflect.set(Maps.class, "defaultMapNames", new Fi("maps")
|
||||
.findAll(f -> f.extEquals("msav"))
|
||||
.map(f -> f.path().replace(".msav", "").replace("maps/", "")).toArray(String.class));
|
||||
|
||||
ApplicationCore core = new ApplicationCore(){
|
||||
@Override
|
||||
public void setup(){
|
||||
Core.settings.setDataDirectory(new Fi("../../tools/build/test_data"));
|
||||
Core.bundle = I18NBundle.createBundle(Core.files.internal("bundles/bundle"), Locale.ENGLISH);
|
||||
headless = true;
|
||||
net = new Net(null);
|
||||
tree = new FileTree();
|
||||
Vars.init();
|
||||
world = new World();
|
||||
content.createBaseContent();
|
||||
mods.loadScripts();
|
||||
content.createModContent();
|
||||
|
||||
add(logic = new Logic());
|
||||
add(netServer = new NetServer());
|
||||
|
||||
content.init();
|
||||
editor = new MapEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
fixMapNames();
|
||||
}
|
||||
};
|
||||
|
||||
new HeadlessApplication(core);
|
||||
}
|
||||
|
||||
static void fixMapNames(){
|
||||
if(!Locale.getDefault().toString().contains("en")){
|
||||
throw new IllegalArgumentException("Language must be English!!! " + Locale.getDefault());
|
||||
}
|
||||
|
||||
Fi root = Core.files.local("maps");
|
||||
root.walk(f -> {
|
||||
try{
|
||||
Map map = maps.all().find(m -> m.file.absolutePath().equals(f.absolutePath()));
|
||||
if(map == null) return;
|
||||
|
||||
SectorPreset preset = content.sectors().find(s -> s.generator.map.file.absolutePath().equals(f.absolutePath()));
|
||||
if(preset == null) return;
|
||||
|
||||
String targetName = preset.requireUnlock ? preset.localizedName : f.nameWithoutExtension();
|
||||
|
||||
editor.beginEdit(map);
|
||||
|
||||
if(!map.name().equals(targetName)){
|
||||
Log.info("Changed name: '@' -> '@'", map.name(), targetName);
|
||||
map.tags.put("name", targetName);
|
||||
|
||||
MapIO.writeMap(f, map);
|
||||
}
|
||||
}catch(Throwable t){
|
||||
Log.err(t);
|
||||
System.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user