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-01 21:14:10 -05:00
committed by GitHub
parent 2d6e1cdf65
commit 862d3153d9
15 changed files with 1070 additions and 12 deletions
+69
View File
@@ -1099,6 +1099,41 @@ public class LExecutor{
}
}
public static class FormatI implements LInstruction{
public int value;
public FormatI(int value){
this.value = value;
}
FormatI(){}
@Override
public void run(LExecutor exec){
if(exec.textBuffer.length() >= maxTextBuffer) return;
int placeholderIndex = exec.textBuffer.indexOf("@");
if(placeholderIndex == -1) return;
//this should avoid any garbage allocation
Var v = exec.var(value);
if(v.isobj && value != 0){
String strValue = PrintI.toString(v.objval);
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 1, strValue);
}else{
//display integer version when possible
if(Math.abs(v.numval - (long)v.numval) < 0.00001){
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 1, (long)v.numval + "");
}else{
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 1, v.numval + "");
}
}
}
}
public static class PrintFlushI implements LInstruction{
public int target;
@@ -1996,5 +2031,39 @@ public class LExecutor{
}
}
public static class LocalePrintI implements LInstruction{
public int name;
public LocalePrintI(int name){
this.name = name;
}
public LocalePrintI(){
}
@Override
public void run(LExecutor exec){
if(exec.textBuffer.length() >= maxTextBuffer) return;
//this should avoid any garbage allocation
Var v = exec.var(name);
if(v.isobj){
String name = PrintI.toString(v.objval);
String strValue;
if(mobile){
strValue = state.mapLocales.containsProperty(name + ".mobile") ?
state.mapLocales.getProperty(name + ".mobile") :
state.mapLocales.getProperty(name);
}else{
strValue = state.mapLocales.getProperty(name);
}
exec.textBuffer.append(strValue);
}
}
}
//endregion
}