Index: ps/trunk/binaries/data/mods/public/gui/page_aiconfig.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/page_aiconfig.xml (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/page_aiconfig.xml (nonexistent)
@@ -1,8 +0,0 @@
-
-
- common/modern/setup.xml
- common/modern/styles.xml
- common/modern/sprites.xml
-
- aiconfig/aiconfig.xml
-
Property changes on: ps/trunk/binaries/data/mods/public/gui/page_aiconfig.xml
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.xml (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.xml (nonexistent)
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
Property changes on: ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.xml
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js (nonexistent)
@@ -1,82 +0,0 @@
-/**
- * Is this user in control of game settings (i.e. is a network server, or offline player).
- */
-const g_IsController = !Engine.HasNetClient() || Engine.HasNetServer();
-
-var g_PlayerSlot;
-
-var g_AIDescriptions = [{
- "id": "",
- "data": {
- "name": translateWithContext("ai", "None"),
- "description": translate("AI will be disabled for this player.")
- }
-}].concat(g_Settings.AIDescriptions);
-
-var g_AIControls = {
- "aiSelection": {
- "labels": g_AIDescriptions.map(ai => ai.data.name),
- "selected": settings => g_AIDescriptions.findIndex(ai => ai.id == settings.id)
- },
- "aiDifficulty": {
- "labels": prepareForDropdown(g_Settings.AIDifficulties).Title,
- "selected": settings => settings.difficulty
- },
- "aiBehavior": {
- "labels": prepareForDropdown(g_Settings.AIBehaviors).Title,
- "selected": settings => g_Settings.AIBehaviors.findIndex(b => b.Name == settings.behavior)
- }
-};
-
-function init(settings)
-{
- // Remember the player ID that we change the AI settings for
- g_PlayerSlot = settings.playerSlot;
-
- let enabled = g_IsController && !settings.fixed;
-
- for (let name in g_AIControls)
- {
- let control = Engine.GetGUIObjectByName(name);
- control.list = g_AIControls[name].labels;
- control.selected = g_AIControls[name].selected(settings);
- control.hidden = !enabled;
-
- let label = Engine.GetGUIObjectByName(name + "Text");
- label.caption = control.list[control.selected];
- label.hidden = enabled;
- }
-
- checkBehavior();
-}
-
-function selectAI(idx)
-{
- Engine.GetGUIObjectByName("aiDescription").caption = g_AIDescriptions[idx].data.description;
-}
-
-/** Behavior choice does not apply for Sandbox level */
-function checkBehavior()
-{
- if (g_Settings.AIDifficulties[Engine.GetGUIObjectByName("aiDifficulty").selected].Name != "sandbox")
- {
- Engine.GetGUIObjectByName("aiBehavior").enabled = true;
- return;
- }
- let aiBehavior = Engine.GetGUIObjectByName("aiBehavior");
- aiBehavior.enabled = false;
- aiBehavior.selected = g_Settings.AIBehaviors.findIndex(b => b.Name == "balanced");
-}
-
-function returnAI(save = true)
-{
- let idx = Engine.GetGUIObjectByName("aiSelection").selected;
- Engine.PopGuiPage({
- "save": save,
- "id": g_AIDescriptions[idx].id,
- "name": g_AIDescriptions[idx].data.name,
- "difficulty": Engine.GetGUIObjectByName("aiDifficulty").selected,
- "behavior": g_Settings.AIBehaviors[Engine.GetGUIObjectByName("aiBehavior").selected].Name,
- "playerSlot": g_PlayerSlot
- });
-}
Property changes on: ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameSettingWarning.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameSettingWarning.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameSettingWarning.js (revision 23419)
@@ -1,41 +1,41 @@
class GameSettingWarning
{
- constructor(gameSettingsControl, cancelButton)
+ constructor(setupWindow, cancelButton)
{
if (!g_IsNetworked)
return;
this.gameSettingWarning = Engine.GetGUIObjectByName("gameSettingWarning");
- gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
+ setupWindow.controls.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
cancelButton.registerCancelButtonResizeHandler(this.onCancelButtonResize.bind(this));
}
onGameAttributesBatchChange()
{
let caption =
g_GameAttributes.settings.CheatsEnabled ?
this.CheatsEnabled :
g_GameAttributes.settings.RatingEnabled ?
this.RatingEnabled :
"";
this.gameSettingWarning.caption = caption;
this.gameSettingWarning.hidden = !caption;
}
onCancelButtonResize(cancelButton)
{
let size = this.gameSettingWarning.size;
size.right = cancelButton.size.left - this.Margin;
this.gameSettingWarning.size = size;
}
}
GameSettingWarning.prototype.Margin = 10;
GameSettingWarning.prototype.CheatsEnabled =
translate("Cheats enabled.");
GameSettingWarning.prototype.RatingEnabled =
translate("Rated game.");
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js (revision 23419)
@@ -1,36 +1,36 @@
class MapPreview
{
- constructor(gameSettingsControl, mapCache)
+ constructor(setupWindow)
{
- this.gameSettingsControl = gameSettingsControl;
- this.mapCache = mapCache;
+ this.gameSettingsControl = setupWindow.controls.gameSettingsControl;
+ this.mapCache = setupWindow.controls.mapCache;
this.mapInfoName = Engine.GetGUIObjectByName("mapInfoName");
this.mapPreview = Engine.GetGUIObjectByName("mapPreview");
- gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this));
- gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
+ this.gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this));
+ this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
}
onMapChange(mapData)
{
let preview = mapData && mapData.settings && mapData.settings.Preview;
if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != preview)
{
g_GameAttributes.settings.Preview = preview;
this.gameSettingsControl.updateGameAttributes();
}
}
onGameAttributesBatchChange()
{
if (!g_GameAttributes.map || !g_GameAttributes.mapType)
return;
this.mapInfoName.caption = this.mapCache.translateMapName(
this.mapCache.getTranslatableMapName(g_GameAttributes.mapType, g_GameAttributes.map));
this.mapPreview.sprite =
this.mapCache.getMapPreview(g_GameAttributes.mapType, g_GameAttributes.map, g_GameAttributes);
}
}
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/LoadingPage/LoadingPage.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/LoadingPage/LoadingPage.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/LoadingPage/LoadingPage.js (revision 23419)
@@ -1,25 +1,25 @@
/**
* The purpose of this page is to display a placeholder in multiplayer until the settings from the server have been received.
* This is not technically necessary, but only performed to avoid confusion or irritation when showing the clients first the
* default settings and then switching to the server settings quickly thereafter.
*/
-class LoadingPage
+SetupWindowPages.LoadingPage = class
{
- constructor(netMessages)
+ constructor(setupWindow)
{
if (g_IsNetworked)
- netMessages.registerNetMessageHandler("gamesetup", this.hideLoadingPage.bind(this));
+ setupWindow.controls.netMessages.registerNetMessageHandler("gamesetup", this.hideLoadingPage.bind(this));
else
this.hideLoadingPage();
}
hideLoadingPage()
{
let loadingPage = Engine.GetGUIObjectByName("loadingPage");
if (loadingPage.hidden)
return;
loadingPage.hidden = true;
Engine.GetGUIObjectByName("setupWindow").hidden = false;
}
}
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.xml (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.xml (revision 23419)
@@ -1,31 +1,34 @@
+
+
Match Setup
+
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.js (revision 23419)
@@ -0,0 +1,69 @@
+/**
+ * This class contains all controls modifying the AI settings of a player.
+ */
+class AIGameSettingControls
+{
+}
+
+SetupWindowPages.AIConfigPage = class
+{
+ constructor(setupWindow)
+ {
+ this.gameSettingsControl = setupWindow.controls.gameSettingsControl;
+
+ this.playerIndex = undefined;
+ this.row = 0;
+ this.openPageHandlers = new Set();
+ this.AIGameSettingControls = {};
+
+ for (let name of this.AIGameSettingControlOrder)
+ this.AIGameSettingControls[name] =
+ new AIGameSettingControls[name](this, undefined, undefined, setupWindow);
+
+ this.aiDescription = new AIDescription(this, setupWindow);
+
+ this.aiConfigPage = Engine.GetGUIObjectByName("aiConfigPage");
+ Engine.GetGUIObjectByName("aiConfigOkButton").onPress = this.closePage.bind(this);
+
+ this.gameSettingsControl.registerGameAttributesBatchChangeHandler(
+ this.onGameAttributesBatchChange.bind(this));
+ }
+
+ registerOpenPageHandler(handler)
+ {
+ this.openPageHandlers.add(handler);
+ }
+
+ getRow()
+ {
+ return this.row++;
+ }
+
+ openPage(playerIndex)
+ {
+ this.playerIndex = playerIndex;
+
+ for (let handler of this.openPageHandlers)
+ handler(playerIndex);
+
+ this.aiConfigPage.hidden = false;
+ }
+
+ onGameAttributesBatchChange()
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ if (!pData)
+ this.closePage();
+ }
+
+ closePage()
+ {
+ this.aiConfigPage.hidden = true;
+ }
+}
+
+SetupWindowPages.AIConfigPage.prototype.AIGameSettingControlOrder = [
+ "AISelection",
+ "AIDifficulty",
+ "AIBehavior"
+];
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.xml (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.xml (revision 23419)
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+ AI Configuration
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OK
+
+
+
+
+
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIConfigPage.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIDescription.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIDescription.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIDescription.js (revision 23419)
@@ -0,0 +1,37 @@
+class AIDescription
+{
+ constructor(aiConfigPage, setupWindow)
+ {
+ this.playerIndex = undefined;
+
+ this.aiDescription = Engine.GetGUIObjectByName("aiDescription");
+
+ this.gameSettingsControl = setupWindow.controls.gameSettingsControl;
+ this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
+
+ aiConfigPage.registerOpenPageHandler(this.onOpenPage.bind(this));
+ }
+
+ onOpenPage(playerIndex)
+ {
+ this.playerIndex = playerIndex;
+ this.updateSelectedValue();
+ }
+
+ onGameAttributesBatchChange()
+ {
+ this.updateSelectedValue();
+ }
+
+ updateSelectedValue()
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ if (!pData)
+ return;
+ let AI = g_Settings.AIDescriptions.find(AI => AI.id == pData.AI);
+ this.aiDescription.caption = AI ? AI.data.description : this.NoAIDescription;
+ }
+}
+
+AIDescription.prototype.NoAIDescription =
+ translate("AI will be disabled for this player.");
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIDescription.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIGameSettingControl.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIGameSettingControl.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIGameSettingControl.js (revision 23419)
@@ -0,0 +1,50 @@
+class AIGameSettingControlDropdown extends GameSettingControlDropdown
+{
+ constructor(...args)
+ {
+ super(...args);
+
+ this.gameSettingsControl.registerAssignPlayerHandler(this.onAssignPlayer.bind(this));
+ }
+
+ setControl(aiConfigPage)
+ {
+ aiConfigPage.registerOpenPageHandler(this.onOpenPage.bind(this));
+
+ let i = aiConfigPage.getRow();
+
+ this.frame = Engine.GetGUIObjectByName("aiSettingFrame[" + i + "]");
+ this.title = this.frame.children[0];
+ this.dropdown = this.frame.children[1];
+ this.label = this.frame.children[2];
+
+ let size = this.frame.size;
+ size.top = i * (this.Height + this.Margin);
+ size.bottom = size.top + this.Height;
+ this.frame.size = size;
+
+ this.setHidden(false);
+ }
+
+ onOpenPage(playerIndex)
+ {
+ this.playerIndex = playerIndex;
+ this.updateSelectedValue();
+ this.updateVisibility();
+ }
+
+ onGameAttributesChange()
+ {
+ for (let playerIndex = 0; playerIndex < g_MaxPlayers; ++playerIndex)
+ this.onGameAttributesChangePlayer(playerIndex);
+ }
+
+ onGameAttributesBatchChange()
+ {
+ this.updateSelectedValue();
+ }
+}
+
+AIGameSettingControlDropdown.prototype.Height= 28;
+
+AIGameSettingControlDropdown.prototype.Margin= 7;
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIGameSettingControl.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIBehavior.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIBehavior.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIBehavior.js (revision 23419)
@@ -0,0 +1,93 @@
+AIGameSettingControls.AIBehavior = class extends AIGameSettingControlDropdown
+{
+ constructor(...args)
+ {
+ super(...args);
+
+ this.fixedAIBehavior = [];
+ this.defaultBehavior = Engine.ConfigDB_GetValue("user", this.ConfigBehavior);
+
+ this.dropdown.list = g_Settings.AIBehaviors.map(AIBehavior => AIBehavior.Title);
+ this.dropdown.list_data = g_Settings.AIBehaviors.map(AIBehavior => AIBehavior.Name);
+ }
+
+ onAssignPlayer(source, target)
+ {
+ if (source && target.AIBehavior)
+ source.AIBehavior = target.AIBehavior;
+
+ delete target.AIBehavior;
+ }
+
+ onMapChange(mapData)
+ {
+ for (let playerIndex = 0; playerIndex < g_MaxPlayers; ++playerIndex)
+ {
+ let mapPData = this.gameSettingsControl.getPlayerData(mapData, playerIndex);
+ this.fixedAIBehavior[playerIndex] =
+ mapPData && mapPData.AI ?
+ (mapPData.AIBehavior !== undefined ?
+ mapPData.AIBehavior :
+ g_Settings.PlayerDefaults[this.playerIndex + 1].AIBehavior) :
+ undefined;
+ }
+ }
+
+ onGameAttributesChangePlayer(playerIndex)
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, playerIndex);
+ if (!pData)
+ return;
+
+ if (pData.AI)
+ {
+ if (this.fixedAIBehavior[playerIndex] && pData.AIBehavior !== this.fixedAIBehavior[playerIndex])
+ {
+ pData.AIBehavior = this.fixedAIBehavior[playerIndex];
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ else if (pData.AIDiff !== undefined &&
+ g_Settings.AIDifficulties[pData.AIDiff].Name == "sandbox" &&
+ pData.AIBehavior != "balanced")
+ {
+ pData.AIBehavior = "balanced";
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ else if (pData.AIBehavior === undefined)
+ {
+ pData.AIBehavior = this.defaultBehavior;
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ }
+ else if (pData.AIBehavior !== undefined)
+ {
+ delete pData.AIBehavior;
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ }
+
+ updateSelectedValue()
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ this.setHidden(!pData || !pData.AI || g_Settings.AIDifficulties[pData.AIDiff].Name == "sandbox");
+ if (pData && pData.AI && pData.AIDiff !== undefined && pData.AIBehavior !== undefined)
+ this.setSelectedValue(pData.AIBehavior);
+ }
+
+ onSelectionChange(itemIdx)
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ if (!g_IsController || !pData)
+ return;
+
+ pData.AIBehavior = g_Settings.AIBehaviors[itemIdx].Name;
+ this.gameSettingsControl.updateGameAttributes();
+ this.gameSettingsControl.setNetworkGameAttributes();
+ }
+}
+
+AIGameSettingControls.AIBehavior.prototype.ConfigBehavior =
+ "gui.gamesetup.aibehavior";
+
+AIGameSettingControls.AIBehavior.prototype.TitleCaption =
+ translate("AI Behavior");
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIBehavior.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIDifficulty.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIDifficulty.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIDifficulty.js (revision 23419)
@@ -0,0 +1,87 @@
+AIGameSettingControls.AIDifficulty = class extends AIGameSettingControlDropdown
+{
+ constructor(...args)
+ {
+ super(...args);
+
+ this.fixedAIDiff = [];
+ this.defaultAIDiff = +Engine.ConfigDB_GetValue("user", this.ConfigDifficulty);
+
+ this.dropdown.list = g_Settings.AIDifficulties.map(AI => AI.Title);
+ this.dropdown.list_data = g_Settings.AIDifficulties.map((AI, i) => i);
+ }
+
+ onAssignPlayer(source, target)
+ {
+ if (source && target.AIDiff !== undefined)
+ source.AIDiff = target.AIDiff;
+
+ delete target.AIDiff;
+ }
+
+ onMapChange(mapData)
+ {
+ for (let playerIndex = 0; playerIndex < g_MaxPlayers; ++playerIndex)
+ {
+ let mapPData = this.gameSettingsControl.getPlayerData(mapData, playerIndex);
+ this.fixedAIDiff[playerIndex] =
+ mapPData && mapPData.AI ?
+ (mapPData.AIDiff !== undefined ?
+ mapPData.AIDiff :
+ g_Settings.PlayerDefaults[this.playerIndex + 1].AIDiff) :
+ undefined;
+ }
+ }
+
+ onGameAttributesChangePlayer(playerIndex)
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, playerIndex);
+ if (!pData)
+ return;
+
+ if (pData.AI)
+ {
+ if (this.fixedAIDiff[playerIndex] !== undefined && pData.AIDiff !== this.fixedAIDiff[playerIndex])
+ {
+ pData.AIDiff = this.fixedAIDiff[playerIndex];
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ else if (pData.AIDiff === undefined)
+ {
+ pData.AIDiff = this.defaultAIDiff;
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ }
+ else if (pData.AIDiff !== undefined)
+ {
+ delete pData.AIDiff;
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ }
+
+ updateSelectedValue()
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ this.setHidden(!pData || !pData.AI);
+
+ if (pData && pData.AIDiff !== undefined)
+ this.setSelectedValue(pData.AIDiff);
+ }
+
+ onSelectionChange(itemIdx)
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ if (!g_IsController || !pData)
+ return;
+
+ pData.AIDiff = itemIdx;
+ this.gameSettingsControl.updateGameAttributes();
+ this.gameSettingsControl.setNetworkGameAttributes();
+ }
+};
+
+AIGameSettingControls.AIDifficulty.prototype.ConfigDifficulty =
+ "gui.gamesetup.aidifficulty";
+
+AIGameSettingControls.AIDifficulty.prototype.TitleCaption =
+ translate("AI Difficulty");
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AIDifficulty.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AISelection.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AISelection.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AISelection.js (revision 23419)
@@ -0,0 +1,91 @@
+AIGameSettingControls.AISelection = class extends AIGameSettingControlDropdown
+{
+ constructor(...args)
+ {
+ super(...args);
+
+ this.fixedAI = [];
+
+ this.values = prepareForDropdown([
+ this.NoAI,
+ ...g_Settings.AIDescriptions.map(AI => ({
+ "Title": AI.data.name,
+ "Id": AI.id
+ }))
+ ]);
+
+ this.dropdown.list = this.values.Title;
+ this.dropdown.list_data = this.values.Id.map((v, i) => i);
+ }
+
+ onAssignPlayer(source, target)
+ {
+ if (source && target.AI)
+ source.AI = target.AI;
+
+ target.AI = false;
+ }
+
+ onMapChange(mapData)
+ {
+ for (let playerIndex = 0; playerIndex < g_MaxPlayers; ++playerIndex)
+ {
+ let mapPData = this.gameSettingsControl.getPlayerData(mapData, playerIndex);
+ this.fixedAI[playerIndex] = mapPData && mapPData.AI || undefined;
+ }
+ }
+
+ onGameAttributesChangePlayer(playerIndex)
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, playerIndex);
+ if (!pData)
+ return;
+
+ if (this.fixedAI[playerIndex] && pData.AI !== this.fixedAI[playerIndex])
+ {
+ pData.AI = this.fixedAI[playerIndex];
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ else if (pData.AI === undefined)
+ {
+ let assignedGUID;
+ for (let guid in g_PlayerAssignments)
+ if (g_PlayerAssignments[guid].player == playerIndex + 1)
+ {
+ assignedGUID = guid;
+ break;
+ }
+
+ pData.AI = assignedGUID ? false : g_Settings.PlayerDefaults[playerIndex + 1].AI;
+ this.gameSettingsControl.updateGameAttributes();
+ }
+ }
+
+ updateSelectedValue()
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ if (!pData || pData.AI === undefined)
+ return;
+
+ this.setSelectedValue(this.values.Id.indexOf(pData.AI));
+ }
+
+ onSelectionChange(itemIdx)
+ {
+ let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
+ if (!pData)
+ return;
+
+ pData.AI = this.values.Id[itemIdx];
+ this.gameSettingsControl.updateGameAttributes();
+ this.gameSettingsControl.setNetworkGameAttributes();
+ }
+}
+
+AIGameSettingControls.AISelection.prototype.NoAI = {
+ "Title": translateWithContext("ai", "None"),
+ "Id": false
+};
+
+AIGameSettingControls.AISelection.prototype.TitleCaption =
+ translate("AI Player");
Property changes on: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/Controls/AISelection.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js (revision 23419)
@@ -1,178 +1,178 @@
/**
* The GameSettingControl is an abstract class that is inherited by gamesetting control classes specific to a GUI object type,
* such as the GameSettingControlCheckbox or GameSettingControlDropdown.
*
* These classes are abstract classes too and are implemented by each handler class specific to one logical setting of g_GameAttributes.
* The purpose of these classes is to control precisely one logical setting of g_GameAttributes.
* Having one class per logical setting allows to handle each setting without making a restriction as to how the property should be written to g_GameAttributes or g_PlayerAssignments.
* The base classes allow implementing that while avoiding duplication.
*
* A GameSettingControl may depend on and read from other g_GameAttribute values,
* but the class instance is to be the sole instance writing to its setting value in g_GameAttributes and
* shall not write to setting values of other logical settings.
*
* The derived classes shall not make assumptions on the validity of g_GameAttributes,
* sanitize or delete their value if it is incompatible.
*
* A class should only write values to g_GameAttributes that it itself has confirmed to be accurate.
* This means that handlers may not copy an entire object or array of values, for example on mapchange.
* This avoids writing a setting value to g_GameAttributes that is not tracked and deleted when it becomes invalid.
*
* Since GameSettingControls shall be able to subscribe to g_GameAttributes changes,
* it is an obligation of the derived GameSettingControl class to broadcast the GameAttributesChange event each time it changes g_GameAttributes.
*/
class GameSettingControl
{
// The constructor and inherited constructors shall not modify game attributes,
// since all GameSettingControl shall be able to subscribe to any gamesetting change.
- constructor(gameSettingControlManager, category, playerIndex, setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl)
+ constructor(gameSettingControlManager, category, playerIndex, setupWindow)
{
// Store arguments
{
this.category = category;
- if (playerIndex !== undefined)
- this.playerIndex = playerIndex;
+ this.playerIndex = playerIndex;
+
this.setupWindow = setupWindow;
- this.gameSettingsControl = gameSettingsControl;
- this.mapCache = mapCache;
- this.mapFilters = mapFilters;
- this.netMessages = netMessages;
- this.playerAssignmentsControl = playerAssignmentsControl;
+ this.gameSettingsControl = setupWindow.controls.gameSettingsControl;
+ this.mapCache = setupWindow.controls.mapCache;
+ this.mapFilters = setupWindow.controls.mapFilters;
+ this.netMessages = setupWindow.controls.netMessages;
+ this.playerAssignmentsControl = setupWindow.controls.playerAssignmentsControl;
}
// enabled and hidden should only be modified through their setters or
// by calling updateVisibility after modification.
this.enabled = true;
this.hidden = false;
if (this.setControl)
this.setControl(gameSettingControlManager);
// This variable also used for autocompleting chat.
this.autocompleteTitle = undefined;
if (this.title && this.TitleCaption)
this.setTitle(this.TitleCaption);
if (this.Tooltip)
this.setTooltip(this.Tooltip);
this.setHidden(false);
if (this.onMapChange)
- gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this));
+ this.gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this));
if (this.onLoad)
- setupWindow.registerLoadHandler(this.onLoad.bind(this));
+ this.setupWindow.registerLoadHandler(this.onLoad.bind(this));
if (this.onGameAttributesChange)
- gameSettingsControl.registerGameAttributesChangeHandler(this.onGameAttributesChange.bind(this));
+ this.gameSettingsControl.registerGameAttributesChangeHandler(this.onGameAttributesChange.bind(this));
if (this.onGameAttributesBatchChange)
- gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
+ this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
if (this.onAssignPlayer && this.playerIndex === 0)
this.gameSettingsControl.registerAssignPlayerHandler(this.onAssignPlayer.bind(this));
if (this.onPickRandomItems)
- gameSettingsControl.registerPickRandomItemsHandler(this.onPickRandomItems.bind(this));
+ this.gameSettingsControl.registerPickRandomItemsHandler(this.onPickRandomItems.bind(this));
if (this.onGameAttributesFinalize)
- gameSettingsControl.registerGameAttributesFinalizeHandler(this.onGameAttributesFinalize.bind(this));
+ this.gameSettingsControl.registerGameAttributesFinalizeHandler(this.onGameAttributesFinalize.bind(this));
if (this.onPlayerAssignmentsChange)
- playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.onPlayerAssignmentsChange.bind(this));
+ this.playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.onPlayerAssignmentsChange.bind(this));
}
setTitle(titleCaption)
{
this.autocompleteTitle = titleCaption;
this.title.caption = sprintf(this.TitleCaptionFormat, {
"setting": titleCaption
});
}
setTooltip(tooltip)
{
if (this.title)
this.title.tooltip = tooltip;
if (this.label)
this.label.tooltip = tooltip;
if (this.setControlTooltip)
this.setControlTooltip(tooltip);
}
/**
* Do not call functions calling updateVisibility onMapChange but onGameAttributesChange,
* so that changes take effect when increasing the playercount as well.
*/
setEnabled(enabled)
{
this.enabled = enabled;
this.updateVisibility();
}
setHidden(hidden)
{
this.hidden = hidden;
this.updateVisibility();
}
updateVisibility()
{
let hidden =
this.hidden ||
this.playerIndex === undefined &&
this.category != g_TabCategorySelected ||
this.playerIndex !== undefined &&
g_GameAttributes.settings && this.playerIndex >= g_GameAttributes.settings.PlayerData.length;
if (this.frame)
this.frame.hidden = hidden;
if (hidden)
return;
let enabled = g_IsController && this.enabled;
if (this.setControlHidden)
this.setControlHidden(!enabled);
if (this.label)
this.label.hidden = !!enabled;
}
/**
* Returns whether the control specifies an order but didn't implement the function.
*/
addAutocompleteEntries(name, autocomplete)
{
if (this.autocompleteTitle)
autocomplete[0].push(this.autocompleteTitle);
if (!Number.isInteger(this.AutocompleteOrder))
return;
if (!this.getAutocompleteEntries)
{
error(name + " specifies AutocompleteOrder but didn't implement getAutocompleteEntries");
return;
}
let newEntries = this.getAutocompleteEntries();
if (newEntries)
autocomplete[this.AutocompleteOrder] =
(autocomplete[this.AutocompleteOrder] || []).concat(newEntries);
}
}
GameSettingControl.prototype.TitleCaptionFormat =
translateWithContext("Title for specific setting", "%(setting)s:");
/**
* Derived classes can set this to a number to enable chat autocompleting of setting values.
* Higher numbers are autocompleted first.
*/
GameSettingControl.prototype.AutocompleteOrder = undefined;
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlManager.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlManager.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlManager.js (revision 23419)
@@ -1,64 +1,64 @@
/**
* Each property of this class is a class that inherits GameSettingControl and is
* instantiated by the GameSettingControlManager.
*/
class GameSettingControls
{
}
/**
* The GameSettingControlManager owns all classes that handle a logical property of g_GameAttributes.
*/
class GameSettingControlManager
{
- constructor(setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl)
+ constructor(setupWindow)
{
+ this.setupWindow = setupWindow;
+
this.rows = {};
this.gameSettingControls = {};
- let args = Array.from(arguments);
-
let getCategory = name =>
g_GameSettingsLayout.findIndex(category => category.settings.indexOf(name) != -1);
for (let name in GameSettingControls)
this.gameSettingControls[name] =
new GameSettingControls[name](
- this, getCategory(name), undefined, ...args);
+ this, getCategory(name), undefined, setupWindow);
for (let victoryCondition of g_VictoryConditions)
this.gameSettingControls[victoryCondition.Name] =
new VictoryConditionCheckbox(
- victoryCondition, this, getCategory(victoryCondition.Name), undefined, ...args);
+ victoryCondition, this, getCategory(victoryCondition.Name), undefined, setupWindow);
this.playerSettingControlManagers = Array.from(
new Array(g_MaxPlayers),
(value, playerIndex) =>
- new PlayerSettingControlManager(playerIndex, ...args));
+ new PlayerSettingControlManager(playerIndex, setupWindow));
}
getNextRow(name)
{
if (this.rows[name] === undefined)
this.rows[name] = 0;
else
++this.rows[name];
return this.rows[name];
}
updateSettingVisibility()
{
for (let name in this.gameSettingControls)
this.gameSettingControls[name].updateVisibility();
}
addAutocompleteEntries(entries)
{
for (let name in this.gameSettingControls)
this.gameSettingControls[name].addAutocompleteEntries(name, entries);
for (let playerSettingControlManager of this.playerSettingControlManagers)
playerSettingControlManager.addAutocompleteEntries(entries);
}
}
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/AIConfigButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/AIConfigButton.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/AIConfigButton.js (revision 23419)
@@ -1,188 +1,32 @@
PlayerSettingControls.AIConfigButton = class extends GameSettingControl
{
constructor(...args)
{
super(...args);
- this.playerConfig = Engine.GetGUIObjectByName("playerConfig[" + this.playerIndex + "]");
-
- this.isPageOpen = false;
- this.guid = undefined;
- this.fixedAI = undefined;
-
- this.defaultAIDiff = +Engine.ConfigDB_GetValue("user", this.ConfigDifficulty);
- this.defaultBehavior = Engine.ConfigDB_GetValue("user", this.ConfigBehavior);
+ this.aiConfigButton = Engine.GetGUIObjectByName("aiConfigButton[" + this.playerIndex + "]");
// Save little performance by not reallocating every call
this.sprintfArgs = {};
-
- this.playerConfig.onPress = this.openConfigPage.bind(this, this.playerIndex);
- }
-
- onMapChange(mapData)
- {
- let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
- if (!pData)
- return;
-
- let isScenario = g_GameAttributes.mapType == "scenario";
-
- let mapPData = this.gameSettingsControl.getPlayerData(mapData, this.playerIndex);
- if (mapPData && mapPData.AI)
- {
- let defaultPData = g_Settings.PlayerDefaults[this.playerIndex + 1];
-
- this.fixedAI = {
- "AI": mapPData.AI,
- "AIDiff":
- mapPData.AIDiff !== undefined ?
- mapPData.AIDiff :
- defaultPData.AIDiff,
- "AIBehavior":
- mapPData.AIBehavior !== undefined ?
- mapPData.AIBehavior :
- defaultPData.AIBehavior
- };
- }
- else
- this.fixedAI = undefined;
- }
-
- onAssignPlayer(source, target)
- {
- if (source && target.AI)
- {
- source.AI = target.AI;
- source.AIDiff = target.AIDiff;
- source.AIBehavior = target.AIBehavior;
- }
-
- target.AI = false;
- delete target.AIDiff;
- delete target.AIBehavior;
- }
-
- onPlayerAssignmentsChange()
- {
- this.guid = undefined;
-
- for (let guid in g_PlayerAssignments)
- if (g_PlayerAssignments[guid].player == this.playerIndex + 1)
- this.guid = guid;
}
- onGameAttributesChange()
+ onLoad()
{
- let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
- if (!pData)
- return;
-
- // Enforce map specified AI
- if (this.fixedAI &&
- (pData.AI !== this.fixedAI.AI ||
- pData.AIDiff !== this.fixedAI.AIDiff ||
- pData.AIBehavior !== this.fixedAI.AIBehavior))
- {
- pData.AI = this.fixedAI.AI;
- pData.AIDiff = this.fixedAI.AIDiff;
- pData.AIBehavior = this.fixedAI.AIBehavior;
- this.gameSettingsControl.updateGameAttributes();
- }
-
- // Sanitize, make AI state self-consistent
- if (pData.AI)
- {
- if (pData.AIDiff === undefined || pData.AIBehavior === undefined)
- {
- if (pData.AIDiff === undefined)
- pData.AIDiff = this.defaultAIDiff;
-
- if (pData.AIBehavior === undefined)
- pData.AIBehavior = this.defaultBehavior;
-
- this.gameSettingsControl.updateGameAttributes();
- }
- }
- else if (pData.AI === undefined)
- {
- if (this.guid)
- pData.AI = false;
- else
- {
- pData.AI = g_Settings.PlayerDefaults[this.playerIndex + 1].AI;
- pData.AIDiff = this.defaultAIDiff;
- pData.AIBehavior = this.defaultBehavior;
- }
- this.gameSettingsControl.updateGameAttributes();
- }
- else if (pData.AIBehavior !== undefined || pData.AIDiff !== undefined)
- {
- pData.AI = false;
- delete pData.AIBehavior;
- delete pData.AIDiff;
- this.gameSettingsControl.updateGameAttributes();
- }
+ let aiConfigPage = this.setupWindow.pages.AIConfigPage;
+ this.aiConfigButton.onPress = aiConfigPage.openPage.bind(aiConfigPage, this.playerIndex);
}
onGameAttributesBatchChange()
{
- let isPageOpen = this.isPageOpen;
- if (isPageOpen)
- Engine.PopGuiPage();
-
let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
if (!pData)
return;
this.sprintfArgs.description = translateAISettings(pData);
- this.playerConfig.tooltip = sprintf(this.Tooltip, this.sprintfArgs);
- this.playerConfig.hidden = !pData.AI;
-
- if (isPageOpen)
- this.openConfigPage();
- }
-
- openConfigPage()
- {
- let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
- if (!pData || !pData.AI)
- return;
-
- this.isPageOpen = true;
- Engine.PushGuiPage(
- "page_aiconfig.xml",
- {
- "playerSlot": this.playerIndex,
- "id": pData.AI,
- "difficulty": pData.AIDiff,
- "behavior": pData.AIBehavior,
- "fixed": !!this.fixedAI
- },
- this.onConfigPageClosed.bind(this));
- }
-
- onConfigPageClosed(data)
- {
- this.isPageOpen = false;
-
- let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex);
- if (!data || !data.save || !g_IsController || !pData)
- return;
-
- pData.AI = data.id;
- pData.AIDiff = data.difficulty;
- pData.AIBehavior = data.behavior;
-
- this.gameSettingsControl.updateGameAttributes();
- this.gameSettingsControl.setNetworkGameAttributes();
+ this.aiConfigButton.tooltip = sprintf(this.Tooltip, this.sprintfArgs);
+ this.aiConfigButton.hidden = !pData.AI;
}
};
PlayerSettingControls.AIConfigButton.prototype.Tooltip =
translate("Configure AI: %(description)s.");
-
-PlayerSettingControls.AIConfigButton.prototype.ConfigDifficulty =
- "gui.gamesetup.aidifficulty";
-
-PlayerSettingControls.AIConfigButton.prototype.ConfigBehavior =
- "gui.gamesetup.aibehavior";
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/PlayersPanel.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/PlayersPanel.xml (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/PlayersPanel.xml (revision 23419)
@@ -1,55 +1,55 @@
Player Name
Color
Player Placement
Civilization
Team
-
+
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PlayerSettingControlManager.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PlayerSettingControlManager.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PlayerSettingControlManager.js (revision 23419)
@@ -1,29 +1,27 @@
/**
* Each property of this class is a class that inherits GameSettingControl and is
* instantiated by the PlayerSettingControlManager.
*/
class PlayerSettingControls
{
}
/**
* The purpose of the PlayerSettingControlManager is to own all controls that handle a property of g_GameAttributes.settings.PlayerData.
*/
class PlayerSettingControlManager
{
- constructor(playerIndex, setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl)
+ constructor(...args)
{
this.playerSettingControls = {};
for (let name in PlayerSettingControls)
- this.playerSettingControls[name] =
- new PlayerSettingControls[name](
- undefined, undefined, playerIndex, setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl);
+ this.playerSettingControls[name] = new PlayerSettingControls[name](undefined, undefined, ...args);
}
addAutocompleteEntries(autocomplete)
{
for (let name in this.playerSettingControls)
this.playerSettingControls[name].addAutocompleteEntries(name, autocomplete);
}
}
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSetupPage.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSetupPage.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSetupPage.js (revision 23419)
@@ -1,50 +1,49 @@
/**
* This class owns all handlers of the gamesetup page, excluding controllers that apply to all subpages and handlers for specific subpages.
*/
-class GameSetupPage
+SetupWindowPages.GameSetupPage = class
{
- constructor(setupWindow, gameSettingsControl, playerAssignmentsControl, netMessages, gameRegisterStanza, mapCache, mapFilters, startGameControl, readyControl)
+ constructor(setupWindow)
{
Engine.ProfileStart("GameSetupPage");
// This class instance owns all gamesetting GUI controls such as dropdowns and checkboxes visible in this page.
- this.gameSettingControlManager =
- new GameSettingControlManager(setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl);
+ this.gameSettingControlManager = new GameSettingControlManager(setupWindow);
// These classes manage GUI buttons.
{
- let startGameButton = new StartGameButton(setupWindow, startGameControl, netMessages, readyControl, playerAssignmentsControl);
- let readyButton = new ReadyButton(readyControl, netMessages, playerAssignmentsControl);
+ let startGameButton = new StartGameButton(setupWindow);
+ let readyButton = new ReadyButton(setupWindow);
this.panelButtons = {
- "cancelButton": new CancelButton(setupWindow, startGameButton, readyButton, gameRegisterStanza),
+ "cancelButton": new CancelButton(setupWindow, startGameButton, readyButton),
"civInfoButton": new CivInfoButton(),
"lobbyButton": new LobbyButton(),
"readyButton": readyButton,
"startGameButton": startGameButton
};
}
// These classes manage GUI Objects.
{
let gameSettingTabs = new GameSettingTabs(setupWindow, this.panelButtons.lobbyButton);
let gameSettingsPanel = new GameSettingsPanel(
- setupWindow, gameSettingTabs, gameSettingsControl, this.gameSettingControlManager);
+ setupWindow, gameSettingTabs, this.gameSettingControlManager);
this.panels = {
- "chatPanel": new ChatPanel(this.gameSettingControlManager, gameSettingsControl, netMessages, playerAssignmentsControl, readyControl, gameSettingsPanel),
- "gameSettingWarning": new GameSettingWarning(gameSettingsControl, this.panelButtons.cancelButton),
- "gameDescription": new GameDescription(mapCache, gameSettingTabs, gameSettingsControl),
+ "chatPanel": new ChatPanel(setupWindow, this.gameSettingControlManager, gameSettingsPanel),
+ "gameSettingWarning": new GameSettingWarning(setupWindow, this.panelButtons.cancelButton),
+ "gameDescription": new GameDescription(setupWindow, gameSettingTabs),
"gameSettingsPanel": gameSettingsPanel,
"gameSettingsTabs": gameSettingTabs,
- "mapPreview": new MapPreview(gameSettingsControl, mapCache),
- "resetCivsButton": new ResetCivsButton(gameSettingsControl),
- "resetTeamsButton": new ResetTeamsButton(gameSettingsControl),
- "soundNotification": new SoundNotification(netMessages, playerAssignmentsControl),
+ "mapPreview": new MapPreview(setupWindow),
+ "resetCivsButton": new ResetCivsButton(setupWindow),
+ "resetTeamsButton": new ResetTeamsButton(setupWindow),
+ "soundNotification": new SoundNotification(setupWindow),
"tipsPanel": new TipsPanel(gameSettingsPanel),
"tooltip": new Tooltip(this.panelButtons.cancelButton)
};
}
Engine.ProfileStop();
}
}
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CancelButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CancelButton.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CancelButton.js (revision 23419)
@@ -1,47 +1,44 @@
class CancelButton
{
- constructor(setupWindow, startGameButton, readyButton, gameSettingsControl)
+ constructor(setupWindow, startGameButton, readyButton)
{
this.setupWindow = setupWindow;
- this.startGameButton = startGameButton;
- this.readyButton = readyButton;
- this.gameSettingsControl = gameSettingsControl;
this.cancelButtonResizeHandlers = new Set();
this.buttonPositions = Engine.GetGUIObjectByName("bottomRightPanel").children;
this.cancelButton = Engine.GetGUIObjectByName("cancelButton");
this.cancelButton.caption = this.Caption;
this.cancelButton.tooltip = Engine.HasXmppClient() ? this.TooltipLobby : this.TooltipMenu;
this.cancelButton.onPress = setupWindow.closePage.bind(setupWindow);
readyButton.registerButtonHiddenChangeHandler(this.onNeighborButtonHiddenChange.bind(this));
startGameButton.registerButtonHiddenChangeHandler(this.onNeighborButtonHiddenChange.bind(this));
}
registerCancelButtonResizeHandler(handler)
{
this.cancelButtonResizeHandlers.add(handler);
}
onNeighborButtonHiddenChange()
{
this.cancelButton.size = this.buttonPositions[
this.buttonPositions[1].children.every(button => button.hidden) ? 1 : 0].size;
for (let handler of this.cancelButtonResizeHandlers)
handler(this.cancelButton);
}
}
CancelButton.prototype.Caption =
translate("Back");
CancelButton.prototype.TooltipLobby =
translate("Return to the lobby.");
CancelButton.prototype.TooltipMenu =
translate("Return to the main menu.");
CancelButton.prototype.Margin = 0;
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ReadyButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ReadyButton.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ReadyButton.js (revision 23419)
@@ -1,88 +1,88 @@
class ReadyButton
{
- constructor(readyControl, netMessages, playerAssignmentsControl)
+ constructor(setupWindow)
{
- this.readyControl = readyControl;
+ this.readyControl = setupWindow.controls.readyControl;
this.hidden = undefined;
this.buttonHiddenChangeHandlers = new Set();
this.readyButtonPressHandlers = new Set();
this.readyButton = Engine.GetGUIObjectByName("readyButton");
this.readyButton.onPress = this.onPress.bind(this);
this.readyButton.onPressRight = this.onPressRight.bind(this);
- playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.onPlayerAssignmentsChange.bind(this));
- netMessages.registerNetMessageHandler("netstatus", this.onNetStatusMessage.bind(this));
+ setupWindow.controls.playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.onPlayerAssignmentsChange.bind(this));
+ setupWindow.controls.netMessages.registerNetMessageHandler("netstatus", this.onNetStatusMessage.bind(this));
if (g_IsController && g_IsNetworked)
this.readyControl.setReady(this.readyControl.StayReady, true);
}
registerButtonHiddenChangeHandler(handler)
{
this.buttonHiddenChangeHandlers.add(handler);
}
onNetStatusMessage(message)
{
if (message.status == "disconnected")
this.readyButton.enabled = false;
}
onPlayerAssignmentsChange()
{
let playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
let hidden = g_IsController || !playerAssignment || playerAssignment.player == -1;
if (!hidden)
{
this.readyButton.caption = this.Caption[playerAssignment.status];
this.readyButton.tooltip = this.Tooltip[playerAssignment.status];
}
if (hidden == this.hidden)
return;
this.hidden = hidden;
this.readyButton.hidden = hidden;
for (let handler of this.buttonHiddenChangeHandlers)
handler(this.readyButton);
}
registerReadyButtonPressHandler(handler)
{
this.readyButtonPressHandlers.add(handler);
}
onPress()
{
let newState =
(g_PlayerAssignments[Engine.GetPlayerGUID()].status + 1) % (this.readyControl.StayReady + 1);
for (let handler of this.readyButtonPressHandlers)
handler(newState);
this.readyControl.setReady(newState, true);
}
onPressRight()
{
if (g_PlayerAssignments[Engine.GetPlayerGUID()].status != this.readyControl.NotReady)
this.readyControl.setReady(this.readyControl.NotReady, true);
}
}
ReadyButton.prototype.Caption = [
translate("I'm ready"),
translate("Stay ready"),
translate("I'm not ready!")
];
ReadyButton.prototype.Tooltip = [
translate("State that you are ready to play."),
translate("Stay ready even when the game settings change."),
translate("State that you are not ready to play.")
];
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetCivsButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetCivsButton.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetCivsButton.js (revision 23419)
@@ -1,36 +1,36 @@
class ResetCivsButton
{
- constructor(gameSettingsControl)
+ constructor(setupWindow)
{
- this.gameSettingsControl = gameSettingsControl;
+ this.gameSettingsControl = setupWindow.controls.gameSettingsControl;
this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
this.civResetButton = Engine.GetGUIObjectByName("civResetButton");
this.civResetButton.tooltip = this.Tooltip;
this.civResetButton.onPress = this.onPress.bind(this);
}
onGameAttributesBatchChange()
{
if (g_GameAttributes.mapType)
this.civResetButton.hidden = g_GameAttributes.mapType == "scenario" || !g_IsController;
}
onPress()
{
if (!g_GameAttributes.settings || !g_GameAttributes.settings.PlayerData)
return;
for (let pData of g_GameAttributes.settings.PlayerData)
pData.Civ = this.RandomCivId;
this.gameSettingsControl.updateGameAttributes();
this.gameSettingsControl.setNetworkGameAttributes();
}
}
ResetCivsButton.prototype.Tooltip =
translate("Reset any civilizations that have been selected to the default (random).");
ResetCivsButton.prototype.RandomCivId =
"random";
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetTeamsButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetTeamsButton.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetTeamsButton.js (revision 23419)
@@ -1,35 +1,35 @@
class ResetTeamsButton
{
- constructor(gameSettingsControl)
+ constructor(setupWindow)
{
- this.gameSettingsControl = gameSettingsControl;
+ this.gameSettingsControl = setupWindow.controls.gameSettingsControl;
this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
this.teamResetButton = Engine.GetGUIObjectByName("teamResetButton");
this.teamResetButton.tooltip = this.Tooltip;
this.teamResetButton.onPress = this.onPress.bind(this);
}
onGameAttributesBatchChange()
{
if (!g_GameAttributes.mapType)
return;
this.teamResetButton.hidden = g_GameAttributes.mapType == "scenario" || !g_IsController;
}
onPress()
{
if (!g_GameAttributes.settings || !g_GameAttributes.settings.PlayerData)
return;
for (let pData of g_GameAttributes.settings.PlayerData)
pData.Team = -1;
this.gameSettingsControl.updateGameAttributes();
this.gameSettingsControl.setNetworkGameAttributes();
}
}
ResetTeamsButton.prototype.Tooltip =
translate("Reset all teams to the default.");
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/StartGameButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/StartGameButton.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/StartGameButton.js (revision 23419)
@@ -1,72 +1,71 @@
class StartGameButton
{
- constructor(setupWindow, startGameControl, netMessages, readyControl, playerAssignmentsControl)
+ constructor(setupWindow)
{
- this.startGameControl = startGameControl;
- this.readyControl = readyControl;
+ this.setupWindow = setupWindow;
this.gameStarted = false;
this.buttonHiddenChangeHandlers = new Set();
this.startGameButton = Engine.GetGUIObjectByName("startGameButton");
this.startGameButton.caption = this.Caption;
this.startGameButton.onPress = this.onPress.bind(this);
setupWindow.registerLoadHandler(this.onLoad.bind(this));
- playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.update.bind(this));
+ setupWindow.controls.playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.update.bind(this));
}
registerButtonHiddenChangeHandler(handler)
{
this.buttonHiddenChangeHandlers.add(handler);
}
onLoad()
{
this.startGameButton.hidden = !g_IsController;
for (let handler of this.buttonHiddenChangeHandlers)
handler();
}
update()
{
let isEveryoneReady = this.isEveryoneReady();
this.startGameButton.enabled = !this.gameStarted && isEveryoneReady;
this.startGameButton.tooltip =
!g_IsNetworked || isEveryoneReady ?
this.ReadyTooltip :
this.ReadyTooltipWaiting;
}
isEveryoneReady()
{
if (!g_IsNetworked)
return true;
for (let guid in g_PlayerAssignments)
if (g_PlayerAssignments[guid].player != -1 &&
- g_PlayerAssignments[guid].status == this.readyControl.NotReady)
+ g_PlayerAssignments[guid].status == this.setupWindow.controls.readyControl.NotReady)
return false;
return true;
}
onPress()
{
if (this.gameStarted)
return;
this.gameStarted = true;
this.update();
- this.startGameControl.launchGame();
+ this.setupWindow.controls.startGameControl.launchGame();
}
}
StartGameButton.prototype.Caption =
translate("Start Game!");
StartGameButton.prototype.ReadyTooltip =
translate("Start a new game with the current settings.");
StartGameButton.prototype.ReadyTooltipWaiting =
translate("Start a new game with the current settings (disabled until all players are ready).");
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientChat.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientChat.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientChat.js (revision 23419)
@@ -1,53 +1,54 @@
ChatMessageEvents.ClientChat = class
{
- constructor(chatMessagesPanel, netMessages)
+ constructor(setupWindow, chatMessagesPanel)
{
this.chatMessagesPanel = chatMessagesPanel;
- netMessages.registerNetMessageHandler("chat", this.onClientChat.bind(this));
this.usernameArgs = {};
this.messageArgs = {};
// TODO: Remove this global required by gui/common/
global.colorizePlayernameByGUID = this.colorizePlayernameByGUID.bind(this);
+
+ setupWindow.controls.netMessages.registerNetMessageHandler("chat", this.onClientChat.bind(this));
}
onClientChat(message)
{
this.usernameArgs.username = this.colorizePlayernameByGUID(message.guid);
this.messageArgs.username = setStringTags(sprintf(this.SenderFormat, this.usernameArgs), this.SenderTags);
this.messageArgs.message = escapeText(message.text);
this.chatMessagesPanel.addText(sprintf(this.MessageFormat, this.messageArgs));
}
colorizePlayernameByGUID(guid)
{
// TODO: Controllers should have the moderator-prefix
let username = g_PlayerAssignments[guid] ? escapeText(g_PlayerAssignments[guid].name) : translate("Unknown Player");
let playerID = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].player : -1;
let color = "white";
if (playerID > 0)
{
color = g_GameAttributes.settings.PlayerData[playerID - 1].Color;
// Enlighten playercolor to improve readability
let [h, s, l] = rgbToHsl(color.r, color.g, color.b);
let [r, g, b] = hslToRgb(h, s, Math.max(0.6, l));
color = rgbToGuiColor({ "r": r, "g": g, "b": b });
}
return coloredText(username, color);
}
};
ChatMessageEvents.ClientChat.prototype.SenderFormat =
translate("<%(username)s>");
ChatMessageEvents.ClientChat.prototype.MessageFormat =
translate("%(username)s %(message)s");
ChatMessageEvents.ClientChat.prototype.SenderTags = {
"font": "sans-bold-13"
};
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientConnection.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientConnection.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientConnection.js (revision 23419)
@@ -1,30 +1,30 @@
ChatMessageEvents.ClientConnection = class
{
- constructor(chatMessagesPanel, netMessages, gameSettingsControl, playerAssignmentsControl)
+ constructor(setupWindow, chatMessagesPanel)
{
this.chatMessagesPanel = chatMessagesPanel;
- playerAssignmentsControl.registerClientJoinHandler(this.onClientJoin.bind(this));
- playerAssignmentsControl.registerClientLeaveHandler(this.onClientLeave.bind(this));
+ setupWindow.controls.playerAssignmentsControl.registerClientJoinHandler(this.onClientJoin.bind(this));
+ setupWindow.controls.playerAssignmentsControl.registerClientLeaveHandler(this.onClientLeave.bind(this));
this.args = {};
}
onClientJoin(newGUID, newAssignments)
{
this.args.username = newAssignments[newGUID].name;
this.chatMessagesPanel.addStatusMessage(sprintf(this.JoinText, this.args));
}
onClientLeave(guid)
{
this.args.username = g_PlayerAssignments[guid].name;
this.chatMessagesPanel.addStatusMessage(sprintf(this.LeaveText, this.args));
}
};
ChatMessageEvents.ClientConnection.prototype.JoinText =
translate("%(username)s has joined");
ChatMessageEvents.ClientConnection.prototype.LeaveText =
translate("%(username)s has left");
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientKicked.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientKicked.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientKicked.js (revision 23419)
@@ -1,25 +1,25 @@
ChatMessageEvents.ClientKicked = class
{
- constructor(chatMessagesPanel, netMessages)
+ constructor(setupWindow, chatMessagesPanel)
{
this.chatMessagesPanel = chatMessagesPanel;
this.messageArgs = {};
- netMessages.registerNetMessageHandler("kicked", this.onClientKicked.bind(this));
+ setupWindow.controls.netMessages.registerNetMessageHandler("kicked", this.onClientKicked.bind(this));
}
onClientKicked(message)
{
this.messageArgs.username = message.username;
this.chatMessagesPanel.addStatusMessage(sprintf(
message.banned ? this.BannedMessage : this.KickedMessage,
this.messageArgs));
}
};
ChatMessageEvents.ClientKicked.prototype.KickedMessage =
translate("%(username)s has been kicked");
ChatMessageEvents.ClientKicked.prototype.BannedMessage =
translate("%(username)s has been banned");
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientReady.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientReady.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/ClientReady.js (revision 23419)
@@ -1,30 +1,30 @@
ChatMessageEvents.ClientReady = class
{
- constructor(chatMessagesPanel, netMessages, gameSettingsControl, playerAssignmentsControl, readyControl)
+ constructor(setupWindow, chatMessagesPanel)
{
this.chatMessagesPanel = chatMessagesPanel;
this.args = {};
- netMessages.registerNetMessageHandler("ready", this.onReadyMessage.bind(this));
+ setupWindow.controls.netMessages.registerNetMessageHandler("ready", this.onReadyMessage.bind(this));
}
onReadyMessage(message)
{
let playerAssignment = g_PlayerAssignments[message.guid];
if (!playerAssignment || playerAssignment.player == -1)
return;
let text = this.ReadyMessage[message.status] || undefined;
if (!text)
return;
this.args.username = playerAssignment.name;
this.chatMessagesPanel.addText(sprintf(text, this.args));
}
};
ChatMessageEvents.ClientReady.prototype.ReadyMessage = [
translate("* %(username)s is not ready."),
translate("* %(username)s is ready!")
];
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/GameSettingsChanged.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/GameSettingsChanged.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatMessages/GameSettingsChanged.js (revision 23419)
@@ -1,22 +1,22 @@
/**
* The purpose of this message is to indicate to the local player when settings they had agreed on changed.
*/
ChatMessageEvents.GameSettingsChanged = class
{
- constructor(chatMessagesPanel, netMessages, gameSettingsControl, playerAssignmentsControl, readyControl)
+ constructor(setupWindow, chatMessagesPanel)
{
- this.readyControl = readyControl;
+ this.readyControl = setupWindow.controls.readyControl;
this.chatMessagesPanel = chatMessagesPanel;
- readyControl.registerResetReadyHandler(this.onResetReady.bind(this));
+ this.readyControl.registerResetReadyHandler(this.onResetReady.bind(this));
}
onResetReady()
{
if (this.readyControl.getLocalReadyState() == this.readyControl.Ready)
this.chatMessagesPanel.addStatusMessage(this.MessageText);
}
};
ChatMessageEvents.GameSettingsChanged.prototype.MessageText =
translate("Game settings have been changed");
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatPanel.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatPanel.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Chat/ChatPanel.js (revision 23419)
@@ -1,26 +1,29 @@
/**
* Properties of this prototype are classes that subscribe to one or more events and
* construct a formatted chat message to be displayed on that event.
*
* Important: Apply escapeText on player provided input to avoid players breaking the game for everybody.
*/
class ChatMessageEvents
{
}
class ChatPanel
{
- constructor(gameSettingControlManager, gameSettingsControl, netMessages, playerAssignmentsControl, readyControl, gameSettingsPanel)
+ constructor(setupWindow, gameSettingControlManager, gameSettingsPanel)
{
this.statusMessageFormat = new StatusMessageFormat();
this.chatMessagesPanel = new ChatMessagesPanel(gameSettingsPanel);
- this.chatInputAutocomplete = new ChatInputAutocomplete(gameSettingControlManager, gameSettingsControl, playerAssignmentsControl);
- this.chatInputPanel = new ChatInputPanel(netMessages, this.chatInputAutocomplete);
+
+ this.chatInputAutocomplete = new ChatInputAutocomplete(
+ gameSettingControlManager, setupWindow.controls.gameSettingsControl, setupWindow.controls.playerAssignmentsControl);
+
+ this.chatInputPanel = new ChatInputPanel(
+ setupWindow.controls.netMessages, this.chatInputAutocomplete);
this.chatMessageEvents = [];
for (let name in ChatMessageEvents)
- this.chatMessageEvents.push(new ChatMessageEvents[name](
- this.chatMessagesPanel, netMessages, gameSettingsControl, playerAssignmentsControl, readyControl));
+ this.chatMessageEvents.push(new ChatMessageEvents[name](setupWindow, this.chatMessagesPanel));
}
}
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription.js (revision 23419)
@@ -1,27 +1,27 @@
class GameDescription
{
- constructor(mapCache, gameSettingTabs, gameSettingsControl)
+ constructor(setupWindow, gameSettingTabs)
{
- this.mapCache = mapCache;
+ this.mapCache = setupWindow.controls.mapCache;
this.gameDescriptionFrame = Engine.GetGUIObjectByName("gameDescriptionFrame");
this.gameDescription = Engine.GetGUIObjectByName("gameDescription");
- gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
+ setupWindow.controls.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
gameSettingTabs.registerTabsResizeHandler(this.onTabsResize.bind(this));
}
onTabsResize(settingsTabButtonsFrame)
{
let size = this.gameDescriptionFrame.size;
size.top = settingsTabButtonsFrame.size.bottom + this.Margin;
this.gameDescriptionFrame.size = size;
}
onGameAttributesBatchChange()
{
this.gameDescription.caption = getGameDescription(this.mapCache);
}
}
GameDescription.prototype.Margin = 3;
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameSettingsPanel.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameSettingsPanel.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameSettingsPanel.js (revision 23419)
@@ -1,188 +1,188 @@
class GameSettingsPanel
{
- constructor(setupWindow, gameSettingTabs, gameSettingsControl, gameSettingControlManager)
+ constructor(setupWindow, gameSettingTabs, gameSettingControlManager)
{
this.centerRightPanel = Engine.GetGUIObjectByName("centerRightPanel");
this.settingTabButtonsFrame = Engine.GetGUIObjectByName("settingTabButtonsFrame");
this.settingsPanelFrame = Engine.GetGUIObjectByName("settingsPanelFrame");
this.gameSettingControlManager = gameSettingControlManager;
this.gameSettingsPanelResizeHandlers = new Set();
this.setupWindow = Engine.GetGUIObjectByName("setupWindow");
this.setupWindow.onWindowResized = this.onWindowResized.bind(this);
this.settingsPanel = Engine.GetGUIObjectByName("settingsPanel");
this.enabled = Engine.ConfigDB_GetValue("user", this.ConfigNameSlide) == "true";
this.slideSpeed = this.enabled ? this.SlideSpeed : Infinity;
this.lastTickTime = undefined;
gameSettingTabs.registerTabSelectHandler(this.updateSize.bind(this));
- gameSettingsControl.registerGameAttributesBatchChangeHandler(this.updateSize.bind(this));
+ setupWindow.controls.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.updateSize.bind(this));
setupWindow.registerLoadHandler(this.triggerResizeHandlers.bind(this));
}
registerGameSettingsPanelResizeHandler(handler)
{
this.gameSettingsPanelResizeHandlers.add(handler);
}
triggerResizeHandlers()
{
for (let handler of this.gameSettingsPanelResizeHandlers)
handler(this.settingsPanelFrame);
}
onWindowResized()
{
this.updateSize();
this.triggerResizeHandlers();
}
updateSize()
{
this.gameSettingControlManager.updateSettingVisibility();
this.positionSettings();
this.lastTickTime = undefined;
this.settingsPanelFrame.onTick = this.onTick.bind(this);
}
onTick()
{
let now = Date.now();
let tickLength = now - this.lastTickTime;
let previousTime = this.lastTickTime;
this.lastTickTime = now;
if (previousTime === undefined)
return;
let distance = this.slideSpeed * tickLength;
let rightBorder = this.settingTabButtonsFrame.size.left;
let offset = 0;
if (g_TabCategorySelected === undefined)
{
let maxOffset = rightBorder - this.settingsPanelFrame.size.left;
if (maxOffset > 0)
offset = Math.min(distance, maxOffset);
}
else if (rightBorder > this.settingsPanelFrame.size.right)
{
offset = Math.min(distance, rightBorder - this.settingsPanelFrame.size.right);
}
else
{
let maxOffset = this.settingsPanelFrame.size.left - rightBorder + (this.settingsPanelFrame.size.right - this.settingsPanelFrame.size.left);
if (maxOffset > 0)
offset = -Math.min(distance, maxOffset);
}
if (offset)
this.changePanelWidth(offset);
else
{
delete this.settingsPanelFrame.onTick;
this.lastTickTime = undefined;
}
}
changePanelWidth(offset)
{
if (!offset)
return;
let size = this.settingsPanelFrame.size;
size.left += offset;
size.right += offset;
this.settingsPanelFrame.size = size;
this.triggerResizeHandlers();
}
/**
* Distribute the currently visible settings over the settings panel.
* First calculate the number of columns required, then place the setting frames.
*/
positionSettings()
{
let setupWindowSize = this.setupWindow.getComputedSize();
let columnWidth = Math.min(
this.MaxColumnWidth,
(setupWindowSize.right - setupWindowSize.left + this.centerRightPanel.size.left) / 2);
let settingsPerColumn;
{
let settingPanelSize = this.settingsPanel.getComputedSize();
let maxSettingsPerColumn = Math.floor((settingPanelSize.bottom - settingPanelSize.top) / this.SettingHeight);
let settingCount = this.settingsPanel.children.filter(child => !child.children[0].hidden).length;
settingsPerColumn = settingCount / Math.ceil(settingCount / maxSettingsPerColumn);
}
let yPos = this.SettingMarginBottom;
let column = 0;
let settingsThisColumn = 0;
let selectedTab = g_GameSettingsLayout[g_TabCategorySelected];
if (!selectedTab)
return;
for (let name of selectedTab.settings)
{
let settingFrame = this.gameSettingControlManager.gameSettingControls[name].frame;
if (settingFrame.hidden)
continue;
if (settingsThisColumn >= settingsPerColumn)
{
yPos = this.SettingMarginBottom;
++column;
settingsThisColumn = 0;
}
settingFrame.size = new GUISize(
columnWidth * column,
yPos,
columnWidth * (column + 1) - this.SettingMarginRight,
yPos + this.SettingHeight - this.SettingMarginBottom);
yPos += this.SettingHeight;
++settingsThisColumn;
}
{
let size = this.settingsPanelFrame.size;
size.right = size.left + (column + 1) * columnWidth;
this.settingsPanelFrame.size = size;
}
}
}
GameSettingsPanel.prototype.ConfigNameSlide =
"gui.gamesetup.settingsslide";
/**
* Maximum width of a column in the settings panel.
*/
GameSettingsPanel.prototype.MaxColumnWidth = 470;
/**
* Pixels per millisecond the settings panel slides when opening/closing.
*/
GameSettingsPanel.prototype.SlideSpeed = 1.2;
/**
* Vertical size of a setting frame.
*/
GameSettingsPanel.prototype.SettingHeight = 32;
/**
* Horizontal space between two setting frames.
*/
GameSettingsPanel.prototype.SettingMarginRight = 10;
/**
* Vertical space between two setting frames.
*/
GameSettingsPanel.prototype.SettingMarginBottom = 2;
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/SoundNotification.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/SoundNotification.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/SoundNotification.js (revision 23419)
@@ -1,28 +1,28 @@
class SoundNotification
{
- constructor(netMessages, playerAssignmentsControl)
+ constructor(setupWindow)
{
- netMessages.registerNetMessageHandler("chat", this.onClientChat.bind(this));
- playerAssignmentsControl.registerClientJoinHandler(this.onClientJoin.bind(this));
+ setupWindow.controls.netMessages.registerNetMessageHandler("chat", this.onClientChat.bind(this));
+ setupWindow.controls.playerAssignmentsControl.registerClientJoinHandler(this.onClientJoin.bind(this));
}
onClientJoin(guid)
{
if (guid != Engine.GetPlayerGUID())
soundNotification(this.ConfigJoinNotification);
}
onClientChat(message)
{
if (message.guid != Engine.GetPlayerGUID() &&
message.text.toLowerCase().indexOf(
splitRatingFromNick(g_PlayerAssignments[Engine.GetPlayerGUID()].name).nick.toLowerCase()) != -1)
soundNotification(this.ConfigNickNotification);
}
}
SoundNotification.prototype.ConfigJoinNotification =
"gamesetup.join";
SoundNotification.prototype.ConfigNickNotification =
"nick";
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/SetupWindow.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/SetupWindow.js (revision 23418)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/SetupWindow.js (revision 23419)
@@ -1,112 +1,114 @@
/**
+ * This class stores the GameSetupPage and every subpage that is shown in the gamesetup.
+ */
+class SetupWindowPages
+{
+}
+
+/**
* The SetupWindow is the root class owning all other class instances.
* The class shall be ineligible to perform any GUI object logic and shall defer that task to owned classes.
*/
class SetupWindow
{
constructor(initData, hotloadData)
{
if (!g_Settings)
return;
Engine.ProfileStart("SetupWindow");
this.loadHandlers = new Set();
this.closePageHandlers = new Set();
this.getHotloadDataHandlers = new Set();
let netMessages = new NetMessages(this);
let startGameControl = new StartGameControl(netMessages);
let mapCache = new MapCache();
let mapFilters = new MapFilters(mapCache);
let gameSettingsControl = new GameSettingsControl(this, netMessages, startGameControl, mapCache);
let playerAssignmentsControl = new PlayerAssignmentsControl(this, netMessages);
let readyControl = new ReadyControl(netMessages, gameSettingsControl, startGameControl, playerAssignmentsControl);
// These class instances control central data and do not manage any GUI Object.
this.controls = {
"gameSettingsControl": gameSettingsControl,
"playerAssignmentsControl": playerAssignmentsControl,
"mapCache": mapCache,
"mapFilters": mapFilters,
"readyControl": readyControl,
- "startGameControl": startGameControl
- };
-
- // These class instances are interfaces to networked messages and do not manage any GUI Object.
- this.networkControls = {
+ "startGameControl": startGameControl,
"netMessages": netMessages,
"gameRegisterStanza":
Engine.HasXmppClient() &&
new GameRegisterStanza(
initData, this, netMessages, gameSettingsControl, playerAssignmentsControl, mapCache)
};
// These are the pages within the setup window that may use the controls defined above
- this.pages = {
- "loadingPage": new LoadingPage(netMessages),
- "gameSetupPage": new GameSetupPage(this, gameSettingsControl, playerAssignmentsControl, netMessages, this.networkControls.gameRegisterStanza, mapCache, mapFilters, startGameControl, readyControl)
- };
+ this.pages = {};
+ for (let name in SetupWindowPages)
+ this.pages[name] = new SetupWindowPages[name](this);
setTimeout(displayGamestateNotifications, 1000);
Engine.GetGUIObjectByName("setupWindow").onTick = updateTimers;
// This event is triggered after all classes have been instantiated and subscribed to each others events
for (let handler of this.loadHandlers)
handler(initData, hotloadData);
Engine.ProfileStop();
if (gameSettingsControl.autostart)
startGameControl.launchGame();
}
registerLoadHandler(handler)
{
this.loadHandlers.add(handler);
}
unregisterLoadHandler(handler)
{
this.loadHandlers.delete(handler);
}
registerClosePageHandler(handler)
{
this.closePageHandlers.add(handler);
}
unregisterClosePageHandler(handler)
{
this.closePageHandlers.delete(handler);
}
registerGetHotloadDataHandler(handler)
{
this.getHotloadDataHandlers.add(handler);
}
unregisterGetHotloadDataHandler(handler)
{
this.getHotloadDataHandlers.delete(handler);
}
getHotloadData()
{
let object = {};
for (let handler of this.getHotloadDataHandlers)
handler(object);
return object;
}
closePage()
{
for (let handler of this.closePageHandlers)
handler();
if (Engine.HasXmppClient())
Engine.SwitchGuiPage("page_lobby.xml", { "dialog": false });
else
Engine.SwitchGuiPage("page_pregame.xml");
}
}
Index: ps/trunk/binaries/data/mods/public/l10n/messages.json
===================================================================
--- ps/trunk/binaries/data/mods/public/l10n/messages.json (revision 23418)
+++ ps/trunk/binaries/data/mods/public/l10n/messages.json (revision 23419)
@@ -1,756 +1,754 @@
[
{
"output": "public-civilizations.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "json",
"filemasks": [
"simulation/data/civs/**.json"
],
"options": {
"keywords": [
"Name",
"Description",
"History",
"Special",
"AINames"
]
}
}
]
},
{
"output": "public-gui-ingame.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
"gui/session/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"translate": [1],
"translatePlural": [1, 2],
"translateWithContext": [[1], 2],
"translatePluralWithContext": [[1], 2, 3],
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
"gui/session/**.xml"
],
"options": {
"keywords": {
"translatableAttribute": {
"locationAttributes": ["id"]
},
"translate": {}
}
}
}
]
},
{
"output": "public-gui-gamesetup.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
- "gui/aiconfig/**.js",
"gui/gamesetup/**.js",
"gui/gamesetup_mp/**.js",
"gui/loading/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"translate": [1],
"translatePlural": [1, 2],
"translateWithContext": [[1], 2],
"translatePluralWithContext": [[1], 2, 3],
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
- "gui/aiconfig/**.xml",
"gui/gamesetup/**.xml",
"gui/gamesetup_mp/**.xml",
"gui/loading/**.xml"
],
"options": {
"keywords": {
"translatableAttribute": {
"locationAttributes": ["id"]
},
"translate": {}
}
}
},
{
"extractor": "txt",
"filemasks": [
"gui/text/quotes.txt"
],
"options": {
}
}
]
},
{
"output": "public-gui-lobby.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
"gui/lobby/**.js",
"gui/prelobby/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"translate": [1],
"translatePlural": [1, 2],
"translateWithContext": [[1], 2],
"translatePluralWithContext": [[1], 2, 3],
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
"gui/lobby/**.xml",
"gui/prelobby/**.xml"
],
"options": {
"keywords": {
"translatableAttribute": {
"locationAttributes": ["id"]
},
"translate": {}
}
}
},
{
"extractor": "txt",
"filemasks": [
"gui/prelobby/common/terms/*.txt"
],
"options": {
}
}
]
},
{
"output": "public-gui-manual.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
"gui/manual/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"translate": [1],
"translatePlural": [1, 2],
"translateWithContext": [[1], 2],
"translatePluralWithContext": [[1], 2, 3],
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
"gui/manual/**.xml"
],
"options": {
"keywords": {
"translatableAttribute": {
"locationAttributes": ["id"]
},
"translate": {}
}
}
},
{
"extractor": "txt",
"filemasks": [
"gui/manual/intro.txt"
],
"options": {
}
}
]
},
{
"output": "public-gui-userreport.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "txt",
"filemasks": [
"gui/userreport/**.txt"
],
"options": {
}
}
]
},
{
"output": "public-gui-other.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
"globalscripts/**.js",
"gui/civinfo/**.js",
"gui/common/**.js",
"gui/credits/**.js",
"gui/loadgame/**.js",
"gui/locale/**.js",
"gui/options/**.js",
"gui/pregame/**.js",
"gui/reference/common/**.js",
"gui/reference/structree/**.js",
"gui/reference/viewer/**.js",
"gui/replaymenu/**.js",
"gui/splashscreen/**.js",
"gui/summary/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"translate": [1],
"translatePlural": [1, 2],
"translateWithContext": [[1], 2],
"translatePluralWithContext": [[1], 2, 3],
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"dennis-ignore:",
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
"globalscripts/**.xml",
"gui/civinfo/**.xml",
"gui/common/**.xml",
"gui/credits/**.xml",
"gui/loadgame/**.xml",
"gui/locale/**.xml",
"gui/options/**.xml",
"gui/pregame/**.xml",
"gui/reference/structree/**.xml",
"gui/reference/viewer/**.xml",
"gui/replaymenu/**.xml",
"gui/splashscreen/**.xml",
"gui/summary/**.xml"
],
"options": {
"keywords": {
"translatableAttribute": {
"locationAttributes": ["id"]
},
"translate": {}
}
}
},
{
"extractor": "json",
"filemasks": [
"gui/credits/texts/**.json"
],
"options": {
"keywords": [
"Title",
"Subtitle"
]
}
},
{
"extractor": "json",
"filemasks": [
"gui/options/**.json"
],
"options": {
"keywords": [
"label",
"tooltip"
]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/resources/**.json"
],
"options": {
"keywords": [
"description"
]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/resources/**.json"
],
"options": {
"keywords": [
"name",
"subtypes"
],
"comments": [
"Translation: Word as used at the beginning of a sentence or as a single-word sentence."
],
"context": "firstWord"
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/resources/**.json"
],
"options": {
"keywords": [
"name",
"subtypes"
],
"comments": [
"Translation: Word as used in the middle of a sentence (which may require using lowercase for your language)."
],
"context": "withinSentence"
}
},
{
"extractor": "txt",
"filemasks": [
"gui/gamesetup/**.txt",
"gui/splashscreen/splashscreen.txt",
"gui/text/tips/**.txt"
],
"options": {
}
}
]
},
{
"output": "public-templates-units.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "xml",
"filemasks": [
"simulation/templates/template_unit_*.xml",
"simulation/templates/units/**.xml"
],
"options": {
"keywords": {
"GenericName": {},
"SpecificName": {},
"History": {},
"VisibleClasses": {
"splitOnWhitespace": true
},
"Tooltip": {},
"DisabledTooltip": {},
"FormationName": {},
"FromClass": {},
"Rank": {
"tagAsContext": true
}
}
}
}
]
},
{
"output": "public-templates-buildings.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "xml",
"filemasks": [
"simulation/templates/template_structure_*.xml",
"simulation/templates/structures/**.xml"
],
"options": {
"keywords": {
"GenericName": {},
"SpecificName": {},
"History": {},
"VisibleClasses": {
"splitOnWhitespace": true
},
"Tooltip": {},
"DisabledTooltip": {},
"FormationName": {},
"FromClass": {},
"Rank": {
"tagAsContext": true
}
}
}
}
]
},
{
"output": "public-templates-other.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "xml",
"filemasks": {
"includeMasks": [
"simulation/templates/**.xml"
],
"excludeMasks": [
"simulation/templates/structures/**.xml",
"simulation/templates/template_structure_*.xml",
"simulation/templates/template_unit_*.xml",
"simulation/templates/units/**.xml"
]
},
"options": {
"keywords": {
"GenericName": {},
"SpecificName": {},
"History": {},
"VisibleClasses": {
"splitOnWhitespace": true
},
"Tooltip": {},
"DisabledTooltip": {},
"FormationName": {},
"FromClass": {},
"Rank": {
"tagAsContext": true
}
}
}
}
]
},
{
"output": "public-simulation-auras.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "json",
"filemasks": [
"simulation/data/auras/**.json"
],
"options": {
"keywords": [
"auraName",
"auraDescription"
]
}
}
]
},
{
"output": "public-simulation-technologies.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "json",
"filemasks": [
"simulation/data/technologies/**.json"
],
"options": {
"keywords": [
"specificName",
"genericName",
"description",
"tooltip",
"requirementsTooltip"
]
}
}
]
},
{
"output": "public-simulation-other.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
"simulation/ai/**.js",
"simulation/components/**.js",
"simulation/helpers/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"translate": [1],
"translatePlural": [1, 2],
"translateWithContext": [[1], 2],
"translatePluralWithContext": [[1], 2, 3],
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/settings/player_defaults.json"
],
"options": {
"keywords": [
"Name"
]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/settings/game_speeds.json"
],
"options": {
"keywords": ["Title"]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/settings/victory_conditions/*.json"
],
"options": {
"keywords": ["Title", "Description"]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/settings/starting_resources.json"
],
"options": {
"keywords": ["Title"],
"context": "startingResources"
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/settings/trigger_difficulties.json"
],
"options": {
"keywords": ["Title", "Tooltip"]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/settings/map_sizes.json"
],
"options": {
"keywords": [
"Name",
"Tooltip"
]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/ai/**.json"
],
"options": {
"keywords": [
"name",
"description"
]
}
}
]
},
{
"output": "public-maps.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "json",
"filemasks": {
"includeMasks": [
"maps/random/**.json"
],
"excludeMasks": [
"maps/random/rmbiome/**.json"
]
},
"options": {
"keywords": [
"Name",
"Description"
]
}
},
{
"extractor": "javascript",
"filemasks": [
"maps/scenarios/**.js",
"maps/skirmishes/**.js",
"maps/random/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
"maps/scenarios/**.xml",
"maps/skirmishes/**.xml"
],
"options": {
"keywords": {
"ScriptSettings": {
"extractJson": {
"keywords": [
"Name",
"Description"
]
}
}
}
}
},
{
"extractor": "json",
"filemasks": [
"maps/random/rmbiome/**.json"
],
"options": {
"keywords": ["Description"],
"context": "biome definition"
}
}
]
},
{
"output": "public-tutorials.pot",
"inputRoot": "..",
"project": "0 A.D. — Empires Ascendant",
"copyrightHolder": "Wildfire Games",
"rules": [
{
"extractor": "javascript",
"filemasks": [
"maps/tutorials/**.js"
],
"options": {
"format": "javascript-format",
"keywords": {
"markForTranslation": [1],
"markForTranslationWithContext": [[1], 2],
"markForPluralTranslation": [1, 2]
},
"commentTags": [
"Translation:"
]
}
},
{
"extractor": "xml",
"filemasks": [
"maps/tutorials/**.xml"
],
"options": {
"keywords": {
"ScriptSettings": {
"extractJson": {
"keywords": [
"Name",
"Description"
]
}
}
}
}
}
]
}
]