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:
@@ -27,7 +27,7 @@ public class GlobalVars{
|
||||
public static final Rand rand = new Rand();
|
||||
|
||||
//non-constants that depend on state
|
||||
private static int varTime, varTick, varSecond, varMinute, varWave, varWaveTime, varServer, varClient, varClientLocale, varClientUnit, varClientName, varClientTeam;
|
||||
private static int varTime, varTick, varSecond, varMinute, varWave, varWaveTime, varServer, varClient, varClientLocale, varClientUnit, varClientName, varClientTeam, varClientMobile;
|
||||
|
||||
private ObjectIntMap<String> namesToIds = new ObjectIntMap<>();
|
||||
private Seq<Var> vars = new Seq<>(Var.class);
|
||||
@@ -65,6 +65,7 @@ public class GlobalVars{
|
||||
varClientUnit = put("@clientUnit", null, true);
|
||||
varClientName = put("@clientName", null, true);
|
||||
varClientTeam = put("@clientTeam", 0, true);
|
||||
varClientMobile = put("@clientMobile", 0, true);
|
||||
|
||||
//special enums
|
||||
put("@ctrlProcessor", ctrlProcessor);
|
||||
@@ -168,6 +169,7 @@ public class GlobalVars{
|
||||
vars.items[varClientUnit].objval = player.unit();
|
||||
vars.items[varClientName].objval = player.name();
|
||||
vars.items[varClientTeam].numval = player.team().id;
|
||||
vars.items[varClientMobile].numval = mobile ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,14 +185,18 @@ public class GlobalVars{
|
||||
return arr != null && content.id >= 0 && content.id < arr.length ? arr[content.id] : -1;
|
||||
}
|
||||
|
||||
/** @return a constant ID > 0 if there is a constant with this name, otherwise -1.
|
||||
* Attempt to get privileged variable id from non-privileged logic executor returns null constant id. */
|
||||
/**
|
||||
* @return a constant ID > 0 if there is a constant with this name, otherwise -1.
|
||||
* Attempt to get privileged variable id from non-privileged logic executor returns null constant id.
|
||||
*/
|
||||
public int get(String name){
|
||||
return namesToIds.get(name, -1);
|
||||
}
|
||||
|
||||
/** @return a constant variable by ID. ID is not bound checked and must be positive.
|
||||
* Attempt to get privileged variable from non-privileged logic executor returns null constant */
|
||||
/**
|
||||
* @return a constant variable by ID. ID is not bound checked and must be positive.
|
||||
* Attempt to get privileged variable from non-privileged logic executor returns null constant
|
||||
*/
|
||||
public Var get(int id, boolean privileged){
|
||||
if(!privileged && privilegedIds.contains(id)) return vars.get(namesToIds.get("null"));
|
||||
return vars.items[id];
|
||||
|
||||
Reference in New Issue
Block a user