Map-specific locale bundles system (#9199)

* Fix text setting in marker control

* Fix marker and bridge calculation game crashes, minor marker instruction code fixes

* Add privileged desynced client constant global variables

* Remove broken attempt to not initialize client vars on server

* Make @clientLocale variable non-constant, make @server and @client privileged

* WIP Implementation of map-specific locale bundles

* Progress on map locale bundles: add locale data to saves, make objectives use map locales if possible

* Add print formatting and map locale printing to world processors

* 🗿

* Minor map locales dialog ui changes

* Make map locale bundles load when joining multiplayer server

* Remove static declaration of current locale in MapLocales to fix tests failing

* Unify name of localeprint instruction, minor instruction description change, fix map locales incorrectly loading from clipboard

* Fix locale bundles not saving in game state, add  global var, make objective markers use map locale bundles and .mobile properties on mobile devices

* Even more map locales dialog improvements

* Fix english locale picking (when property isn't presented in current locale but english version has it) not working

* Add icon pasting to map locales dialog, minor ui changes

* Fix inconsistent game crash with null text in objectives, define player.locale on game loading (for clientLocale var)

* Change format instruction placeholders to backslash, fix map locales system incorrectly handling default locale

* understood
This commit is contained in:
ApsZoldat
2023-12-02 05:14:10 +03:00
committed by GitHub
parent 2d6e1cdf65
commit 862d3153d9
15 changed files with 1070 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ import mindustry.game.MapObjectives.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.maps.Map;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.*;
@@ -141,6 +142,7 @@ public abstract class SaveVersion extends SaveFileReader{
"wavetime", state.wavetime,
"stats", JsonIO.write(state.stats),
"rules", JsonIO.write(state.rules),
"locales", JsonIO.write(state.mapLocales),
"mods", JsonIO.write(mods.getModStrings().toArray(String.class)),
"controlGroups", headless || control == null ? "null" : JsonIO.write(control.input.controlGroups),
"width", world.width(),
@@ -160,6 +162,7 @@ public abstract class SaveVersion extends SaveFileReader{
state.tick = map.getFloat("tick");
state.stats = JsonIO.read(GameStats.class, map.get("stats", "{}"));
state.rules = JsonIO.read(Rules.class, map.get("rules", "{}"));
state.mapLocales = JsonIO.read(MapLocales.class, map.get("locales", "{}"));
if(state.rules.spawns.isEmpty()) state.rules.spawns = waves.get();
lastReadBuild = map.getInt("build", -1);