Changeset View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | var g_NetMessageTypes = { | ||||
"kicked": msg => addChatMessage({ | "kicked": msg => addChatMessage({ | ||||
"type": msg.banned ? "banned" : "kicked", | "type": msg.banned ? "banned" : "kicked", | ||||
"username": msg.username | "username": msg.username | ||||
}), | }), | ||||
"chat": msg => addChatMessage({ "type": "chat", "guid": msg.guid, "text": msg.text }), | "chat": msg => addChatMessage({ "type": "chat", "guid": msg.guid, "text": msg.text }), | ||||
}; | }; | ||||
var g_FormatChatMessage = { | var g_FormatChatMessage = { | ||||
"system": (msg, user) => systemMessage(msg.text), | "settings": (msg, user) => systemMessage(translate('We shouldn\'t get this message, please report this')), // fallback | ||||
vladislavbelov: Why `system` was removed? | |||||
elexisUnsubmitted Done Inline ActionsIt's sufficient if we get a JS error message elexis: It's sufficient if we get a JS error message | |||||
"settings": (msg, user) => systemMessage(translate('Game settings have been changed')), | "settings-settings-VictoryScripts": (msg, user) => systemMessage(translate('We shouldn\'t get this message, please report this')), // fallback | ||||
"settings-mapPath": (msg, user) => systemMessage(translate('We shouldn\'t get this message, please report this')), // fallback | |||||
"settings-settings-VictoryDuration": (msg, user) => systemMessage(translate('We shouldn\'t get this message, please report this')), // fallback | |||||
"settings-settings-Name": (msg, user) => systemMessage(translate('We shouldn\'t get this message, please report this')), // fallback | |||||
"settings-settings-Description": (msg, user) => systemMessage(translate('We shouldn\'t get this message, please report this')), // fallback | |||||
"settings-host": (msg, user) => systemMessage(translate('You have changed some settings')), | |||||
"settings-map": (msg, user) => systemMessage(translate(g_Dropdowns.mapSelection.changedMessage)), | |||||
"settings-mapType": (msg, user) => systemMessage(translate(g_Dropdowns.mapType,changedMessage)), | |||||
"settings-mapFilter": (msg, user) => systemMessage(translate(g_Dropdowns.mapFilter.changedMessage)), | |||||
"settings-gameSpeed": (msg, user) => systemMessage(translate(g_Dropdowns.gameSpeed.changedMessage)), | |||||
"settings-settings-TriggerDifficulty": (msg, user) => systemMessage(translate(g_Dropdowns.triggerDifficulty.changedMessage)), | |||||
"settings-settings-Biome": (msg, user) => systemMessage(translate(g_Dropdowns.biome.changedMessage)), | |||||
"settings-settings-Size": (msg, user) => systemMessage(translate(g_Dropdowns.mapSize.changes)), | |||||
"settings-settings-PopulationCap": (msg, user) => systemMessage(translate(g_Dropdowns.populationCap.changedMessage)), | |||||
"settings-settings-StartingResources": (msg, user) => systemMessage(translate(g_Dropdowns.startingResources.changedMessage)), | |||||
"settings-settings-Ceasefire": (msg, user) => systemMessage(translate(g_Dropdowns.ceasefire.changedMessage)), | |||||
"settings-settings-GameType": (msg, user) => systemMessage(translate(g_Dropdowns.victoryCondition.changedMessage)), | |||||
Not Done Inline ActionsThe wheather strings are half-sentences. Also it should be possible to clarify depending on the given value. For example "Wonder Victory timer something is now 20 minutes", or "Garrisoning heroes has been disabled". elexis: The wheather strings are half-sentences. Also it should be possible to clarify depending on… | |||||
"settings-settings-PlayerData": (msg, user) => systemMessage(translate(g_Dropdowns.numPlayers.changedMessage)), // used for all playerdata related things | |||||
"settings-settings-RelicCount": (msg, user) => systemMessage(translate(g_Dropdowns.relicCount.changedMessage)), | |||||
"settings-settings-RelicDuration": (msg, user) => systemMessage(translate(g_Dropdowns.relicDuration.changedMessage)), | |||||
"settings-settings-WonderDuration": (msg, user) => systemMessage(translate(g_Dropdowns.wonderDuration.changedMessage)), | |||||
"settings-settings-RegicideGarrison": (msg, user) => systemMessage(translate(g_Checkboxes.regicideGarrison.changedMessage)), | |||||
"settings-settings-RevealMap": (msg, user) => systemMessage(translate(g_Checkboxes.revealMap.changedMessage)), | |||||
"settings-settings-ExploreMap": (msg, user) => systemMessage(translate(g_Checkboxes.exploreMap.changedMessage)), | |||||
"settings-settings-DisableTreasures": (msg, user) => systemMessage(translate(g_Checkboxes.disableTreasures.changedMessage)), | |||||
"settings-settings-DisableSpies": (msg, user) => systemMessage(translate(g_Checkboxes.disableSpies.changedMessage)), | |||||
"settings-settings-LockTeams": (msg, user) => systemMessage(translate(g_Checkboxes.lockTeams.changedMessage)), | |||||
Done Inline ActionsNot like that. elexis: Not like that.
The gamesetup is supposed to be unaware of the existence of any seting besides… | |||||
Done Inline ActionsGood strings! Just the code style needs change. : ) ffffffff: Good strings! Just the code style needs change. : ) | |||||
Done Inline ActionsAll strings must be moved to g_Dropdowns and g_Checkboxes. elexis: All strings must be moved to `g_Dropdowns` and `g_Checkboxes`. | |||||
"settings-settings-LastManStanding": (msg, user) => systemMessage(translate(g_Checkboxes.lastManStanding.changedMessage)), | |||||
"settings-settings-CheatsEnabled": (msg, user) => systemMessage(translate(g_Checkboxes.enableCheats.changedMessage)), | |||||
"settings-settings-RatingEnabled": (msg, user) => systemMessage(translate(g_Checkboxes.enableRating.changedMessage)), | |||||
elexisUnsubmitted Not Done Inline ActionsThe lines above shouldn't be needed, at most one entry elexis: The lines above shouldn't be needed, at most one entry | |||||
Not Done Inline ActionsI don't think, that it's good to have many similar names: settings-*. It'd be better to have the one settings node, like: "settings": [ "host": ..., "map": ..., ... ] vladislavbelov: I don't think, that it's good to have many similar names: `settings-*`. It'd be better to have… | |||||
"connect": (msg, user) => systemMessage(sprintf(translate("%(username)s has joined"), { "username": user })), | "connect": (msg, user) => systemMessage(sprintf(translate("%(username)s has joined"), { "username": user })), | ||||
"disconnect": (msg, user) => systemMessage(sprintf(translate("%(username)s has left"), { "username": user })), | "disconnect": (msg, user) => systemMessage(sprintf(translate("%(username)s has left"), { "username": user })), | ||||
"kicked": (msg, user) => systemMessage(sprintf(translate("%(username)s has been kicked"), { "username": user })), | "kicked": (msg, user) => systemMessage(sprintf(translate("%(username)s has been kicked"), { "username": user })), | ||||
"banned": (msg, user) => systemMessage(sprintf(translate("%(username)s has been banned"), { "username": user })), | "banned": (msg, user) => systemMessage(sprintf(translate("%(username)s has been banned"), { "username": user })), | ||||
"chat": (msg, user) => sprintf(translate("%(username)s %(message)s"), { | "chat": (msg, user) => sprintf(translate("%(username)s %(message)s"), { | ||||
"username": senderFont(sprintf(translate("<%(username)s>"), { "username": user })), | "username": senderFont(sprintf(translate("<%(username)s>"), { "username": user })), | ||||
"message": escapeText(msg.text || "") | "message": escapeText(msg.text || "") | ||||
}), | }), | ||||
▲ Show 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | "select": (itemIdx) => { | ||||
if (g_GameAttributes.mapType != "scenario") | if (g_GameAttributes.mapType != "scenario") | ||||
g_GameAttributes.settings = { | g_GameAttributes.settings = { | ||||
"PlayerData": clone(g_DefaultPlayerData.slice(0, 4)) | "PlayerData": clone(g_DefaultPlayerData.slice(0, 4)) | ||||
}; | }; | ||||
reloadMapFilterList(); | reloadMapFilterList(); | ||||
}, | }, | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 1 | "initOrder": 1, | ||||
"changedMessage": "The map type has been changed" | |||||
elexisUnsubmitted Done Inline Actionsenglish strings in the GUI must be marked with translate() or equivalent elexis: english strings in the GUI must be marked with `translate()` or equivalent
https://trac. | |||||
gentzAuthorUnsubmitted Done Inline ActionsThey are marked with translate() in g_FormatChatMessage, do you want it moved? gentz: They are marked with translate() in g_FormatChatMessage, do you want it moved? | |||||
elexisUnsubmitted Done Inline ActionsIt must, since the python script extracting the strings from all kinds of textual files, doesnt infer any logic, but reads those lines one by one and forgets about the next line right after elexis: It must, since the python script extracting the strings from all kinds of textual files, doesnt… | |||||
gentzAuthorUnsubmitted Done Inline ActionsI was under the assumption it was a function, will fix. gentz: I was under the assumption it was a function, will fix. | |||||
}, | }, | ||||
"mapFilter": { | "mapFilter": { | ||||
"title": () => translate("Map Filter"), | "title": () => translate("Map Filter"), | ||||
"tooltip": (hoverIdx) => g_MapFilterList.tooltip[hoverIdx] || translate("Select a map filter."), | "tooltip": (hoverIdx) => g_MapFilterList.tooltip[hoverIdx] || translate("Select a map filter."), | ||||
"labels": () => g_MapFilterList.name, | "labels": () => g_MapFilterList.name, | ||||
"ids": () => g_MapFilterList.id, | "ids": () => g_MapFilterList.id, | ||||
"default": () => g_MapFilterList.Default, | "default": () => g_MapFilterList.Default, | ||||
"defined": () => g_MapFilterList.id.indexOf(g_GameAttributes.mapFilter || "") != -1, | "defined": () => g_MapFilterList.id.indexOf(g_GameAttributes.mapFilter || "") != -1, | ||||
"get": () => g_GameAttributes.mapFilter, | "get": () => g_GameAttributes.mapFilter, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.mapFilter = g_MapFilterList.id[itemIdx]; | g_GameAttributes.mapFilter = g_MapFilterList.id[itemIdx]; | ||||
delete g_GameAttributes.map; | delete g_GameAttributes.map; | ||||
reloadMapList(); | reloadMapList(); | ||||
}, | }, | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 2 | "initOrder": 2, | ||||
"changedMessage": "The map filter has been changed" | |||||
}, | }, | ||||
"mapSelection": { | "mapSelection": { | ||||
"title": () => translate("Select Map"), | "title": () => translate("Select Map"), | ||||
"tooltip": (hoverIdx) => g_MapSelectionList.description[hoverIdx] || translate("Select a map to play on."), | "tooltip": (hoverIdx) => g_MapSelectionList.description[hoverIdx] || translate("Select a map to play on."), | ||||
"labels": () => g_MapSelectionList.name, | "labels": () => g_MapSelectionList.name, | ||||
"colors": () => g_MapSelectionList.color, | "colors": () => g_MapSelectionList.color, | ||||
"ids": () => g_MapSelectionList.file, | "ids": () => g_MapSelectionList.file, | ||||
"default": () => 0, | "default": () => 0, | ||||
"defined": () => g_GameAttributes.map !== undefined, | "defined": () => g_GameAttributes.map !== undefined, | ||||
"get": () => g_GameAttributes.map, | "get": () => g_GameAttributes.map, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
selectMap(g_MapSelectionList.file[itemIdx]); | selectMap(g_MapSelectionList.file[itemIdx]); | ||||
}, | }, | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 3 | "initOrder": 3, | ||||
"changedMessage": "The map has been changed" | |||||
}, | }, | ||||
"mapSize": { | "mapSize": { | ||||
"title": () => translate("Map Size"), | "title": () => translate("Map Size"), | ||||
"tooltip": (hoverIdx) => g_MapSizes.Tooltip[hoverIdx] || translate("Select map size. (Larger sizes may reduce performance.)"), | "tooltip": (hoverIdx) => g_MapSizes.Tooltip[hoverIdx] || translate("Select map size. (Larger sizes may reduce performance.)"), | ||||
"labels": () => g_MapSizes.Name, | "labels": () => g_MapSizes.Name, | ||||
"ids": () => g_MapSizes.Tiles, | "ids": () => g_MapSizes.Tiles, | ||||
"default": () => g_MapSizes.Default, | "default": () => g_MapSizes.Default, | ||||
"defined": () => g_GameAttributes.settings.Size !== undefined, | "defined": () => g_GameAttributes.settings.Size !== undefined, | ||||
"get": () => g_GameAttributes.settings.Size, | "get": () => g_GameAttributes.settings.Size, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.Size = g_MapSizes.Tiles[itemIdx]; | g_GameAttributes.settings.Size = g_MapSizes.Tiles[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => g_GameAttributes.mapType != "random", | "hidden": () => g_GameAttributes.mapType != "random", | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The map size has been changed" | |||||
}, | }, | ||||
"biome": { | "biome": { | ||||
"title": () => translate("Biome"), | "title": () => translate("Biome"), | ||||
"tooltip": (hoverIdx) => g_BiomeList && g_BiomeList.Description && g_BiomeList.Description[hoverIdx] || translate("Select the flora and fauna."), | "tooltip": (hoverIdx) => g_BiomeList && g_BiomeList.Description && g_BiomeList.Description[hoverIdx] || translate("Select the flora and fauna."), | ||||
"labels": () => g_BiomeList ? g_BiomeList.Title : [], | "labels": () => g_BiomeList ? g_BiomeList.Title : [], | ||||
"colors": (itemIdx) => g_BiomeList ? g_BiomeList.Color : [], | "colors": (itemIdx) => g_BiomeList ? g_BiomeList.Color : [], | ||||
"ids": () => g_BiomeList ? g_BiomeList.Id : [], | "ids": () => g_BiomeList ? g_BiomeList.Id : [], | ||||
"default": () => 0, | "default": () => 0, | ||||
"defined": () => g_GameAttributes.settings.Biome !== undefined, | "defined": () => g_GameAttributes.settings.Biome !== undefined, | ||||
"get": () => g_GameAttributes.settings.Biome, | "get": () => g_GameAttributes.settings.Biome, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.Biome = g_BiomeList && g_BiomeList.Id[itemIdx]; | g_GameAttributes.settings.Biome = g_BiomeList && g_BiomeList.Id[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => !g_BiomeList, | "hidden": () => !g_BiomeList, | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The biome has been changed" | |||||
}, | }, | ||||
"numPlayers": { | "numPlayers": { | ||||
"title": () => translate("Number of Players"), | "title": () => translate("Number of Players"), | ||||
"tooltip": (hoverIdx) => translate("Select number of players."), | "tooltip": (hoverIdx) => translate("Select number of players."), | ||||
"labels": () => g_NumPlayersList, | "labels": () => g_NumPlayersList, | ||||
"ids": () => g_NumPlayersList, | "ids": () => g_NumPlayersList, | ||||
"default": () => g_MaxPlayers - 1, | "default": () => g_MaxPlayers - 1, | ||||
"defined": () => g_GameAttributes.settings.PlayerData !== undefined, | "defined": () => g_GameAttributes.settings.PlayerData !== undefined, | ||||
"get": () => g_GameAttributes.settings.PlayerData.length, | "get": () => g_GameAttributes.settings.PlayerData.length, | ||||
"enabled": () => g_GameAttributes.mapType == "random", | "enabled": () => g_GameAttributes.mapType == "random", | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
let num = itemIdx + 1; | let num = itemIdx + 1; | ||||
let pData = g_GameAttributes.settings.PlayerData; | let pData = g_GameAttributes.settings.PlayerData; | ||||
g_GameAttributes.settings.PlayerData = | g_GameAttributes.settings.PlayerData = | ||||
num > pData.length ? | num > pData.length ? | ||||
pData.concat(clone(g_DefaultPlayerData.slice(pData.length, num))) : | pData.concat(clone(g_DefaultPlayerData.slice(pData.length, num))) : | ||||
pData.slice(0, num); | pData.slice(0, num); | ||||
unassignInvalidPlayers(num); | unassignInvalidPlayers(num); | ||||
sanitizePlayerData(g_GameAttributes.settings.PlayerData); | sanitizePlayerData(g_GameAttributes.settings.PlayerData); | ||||
}, | }, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The player data has been changed" // used for all changes to .PlayerData | |||||
}, | }, | ||||
"populationCap": { | "populationCap": { | ||||
"title": () => translate("Population Cap"), | "title": () => translate("Population Cap"), | ||||
"tooltip": (hoverIdx) => { | "tooltip": (hoverIdx) => { | ||||
let popCap = g_PopulationCapacities.Population[hoverIdx]; | let popCap = g_PopulationCapacities.Population[hoverIdx]; | ||||
let players = g_GameAttributes.settings.PlayerData.length; | let players = g_GameAttributes.settings.PlayerData.length; | ||||
Show All 11 Lines | "populationCap": { | ||||
"ids": () => g_PopulationCapacities.Population, | "ids": () => g_PopulationCapacities.Population, | ||||
"default": () => g_PopulationCapacities.Default, | "default": () => g_PopulationCapacities.Default, | ||||
"defined": () => g_GameAttributes.settings.PopulationCap !== undefined, | "defined": () => g_GameAttributes.settings.PopulationCap !== undefined, | ||||
"get": () => g_GameAttributes.settings.PopulationCap, | "get": () => g_GameAttributes.settings.PopulationCap, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[itemIdx]; | g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[itemIdx]; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The population cap has been changed" | |||||
}, | }, | ||||
"startingResources": { | "startingResources": { | ||||
"title": () => translate("Starting Resources"), | "title": () => translate("Starting Resources"), | ||||
"tooltip": (hoverIdx) => { | "tooltip": (hoverIdx) => { | ||||
return hoverIdx >= 0 ? | return hoverIdx >= 0 ? | ||||
sprintf(translate("Initial amount of each resource: %(resources)s."), { | sprintf(translate("Initial amount of each resource: %(resources)s."), { | ||||
"resources": g_StartingResources.Resources[hoverIdx] | "resources": g_StartingResources.Resources[hoverIdx] | ||||
}) : | }) : | ||||
translate("Select the game's starting resources."); | translate("Select the game's starting resources."); | ||||
}, | }, | ||||
"labels": () => g_StartingResources.Title, | "labels": () => g_StartingResources.Title, | ||||
"ids": () => g_StartingResources.Resources, | "ids": () => g_StartingResources.Resources, | ||||
"default": () => g_StartingResources.Default, | "default": () => g_StartingResources.Default, | ||||
"defined": () => g_GameAttributes.settings.StartingResources !== undefined, | "defined": () => g_GameAttributes.settings.StartingResources !== undefined, | ||||
"get": () => g_GameAttributes.settings.StartingResources, | "get": () => g_GameAttributes.settings.StartingResources, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[itemIdx]; | g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => g_GameAttributes.mapType == "scenario", | "hidden": () => g_GameAttributes.mapType == "scenario", | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The amount of starting resources has been changed" | |||||
}, | }, | ||||
"ceasefire": { | "ceasefire": { | ||||
"title": () => translate("Ceasefire"), | "title": () => translate("Ceasefire"), | ||||
"tooltip": (hoverIdx) => translate("Set time where no attacks are possible."), | "tooltip": (hoverIdx) => translate("Set time where no attacks are possible."), | ||||
"labels": () => g_Ceasefire.Title, | "labels": () => g_Ceasefire.Title, | ||||
"ids": () => g_Ceasefire.Duration, | "ids": () => g_Ceasefire.Duration, | ||||
"default": () => g_Ceasefire.Default, | "default": () => g_Ceasefire.Default, | ||||
"defined": () => g_GameAttributes.settings.Ceasefire !== undefined, | "defined": () => g_GameAttributes.settings.Ceasefire !== undefined, | ||||
"get": () => g_GameAttributes.settings.Ceasefire, | "get": () => g_GameAttributes.settings.Ceasefire, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.Ceasefire = g_Ceasefire.Duration[itemIdx]; | g_GameAttributes.settings.Ceasefire = g_Ceasefire.Duration[itemIdx]; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The length of the ceasefire has been changed" | |||||
}, | }, | ||||
"victoryCondition": { | "victoryCondition": { | ||||
"title": () => translate("Victory Condition"), | "title": () => translate("Victory Condition"), | ||||
"tooltip": (hoverIdx) => g_VictoryConditions.Description[hoverIdx] || translate("Select victory condition."), | "tooltip": (hoverIdx) => g_VictoryConditions.Description[hoverIdx] || translate("Select victory condition."), | ||||
"labels": () => g_VictoryConditions.Title, | "labels": () => g_VictoryConditions.Title, | ||||
"ids": () => g_VictoryConditions.Name, | "ids": () => g_VictoryConditions.Name, | ||||
"default": () => g_VictoryConditions.Default, | "default": () => g_VictoryConditions.Default, | ||||
"defined": () => g_GameAttributes.settings.GameType !== undefined, | "defined": () => g_GameAttributes.settings.GameType !== undefined, | ||||
"get": () => g_GameAttributes.settings.GameType, | "get": () => g_GameAttributes.settings.GameType, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.GameType = g_VictoryConditions.Name[itemIdx]; | g_GameAttributes.settings.GameType = g_VictoryConditions.Name[itemIdx]; | ||||
g_GameAttributes.settings.VictoryScripts = g_VictoryConditions.Scripts[itemIdx]; | g_GameAttributes.settings.VictoryScripts = g_VictoryConditions.Scripts[itemIdx]; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"autocomplete": 0, | "autocomplete": 0, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The victory condition has been changed" | |||||
}, | }, | ||||
"relicCount": { | "relicCount": { | ||||
"title": () => translate("Relic Count"), | "title": () => translate("Relic Count"), | ||||
"tooltip": (hoverIdx) => translate("Total number of relics spawned on the map. Relic victory is most realistic with only one or two relics. With greater numbers, the relics are important to capture to receive aura bonuses."), | "tooltip": (hoverIdx) => translate("Total number of relics spawned on the map. Relic victory is most realistic with only one or two relics. With greater numbers, the relics are important to capture to receive aura bonuses."), | ||||
"labels": () => g_RelicCountList, | "labels": () => g_RelicCountList, | ||||
"ids": () => g_RelicCountList, | "ids": () => g_RelicCountList, | ||||
"default": () => g_RelicCountList.indexOf(2), | "default": () => g_RelicCountList.indexOf(2), | ||||
"defined": () => g_GameAttributes.settings.RelicCount !== undefined, | "defined": () => g_GameAttributes.settings.RelicCount !== undefined, | ||||
"get": () => g_GameAttributes.settings.RelicCount, | "get": () => g_GameAttributes.settings.RelicCount, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.RelicCount = g_RelicCountList[itemIdx]; | g_GameAttributes.settings.RelicCount = g_RelicCountList[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => g_GameAttributes.settings.GameType != "capture_the_relic", | "hidden": () => g_GameAttributes.settings.GameType != "capture_the_relic", | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The relic count has been changed" | |||||
}, | }, | ||||
"relicDuration": { | "relicDuration": { | ||||
"title": () => translate("Relic Duration"), | "title": () => translate("Relic Duration"), | ||||
"tooltip": (hoverIdx) => translate("Minutes until the player has achieved Relic Victory."), | "tooltip": (hoverIdx) => translate("Minutes until the player has achieved Relic Victory."), | ||||
"labels": () => g_VictoryDurations.Title, | "labels": () => g_VictoryDurations.Title, | ||||
"ids": () => g_VictoryDurations.Duration, | "ids": () => g_VictoryDurations.Duration, | ||||
"default": () => g_VictoryDurations.Default, | "default": () => g_VictoryDurations.Default, | ||||
"defined": () => g_GameAttributes.settings.RelicDuration !== undefined, | "defined": () => g_GameAttributes.settings.RelicDuration !== undefined, | ||||
"get": () => g_GameAttributes.settings.RelicDuration, | "get": () => g_GameAttributes.settings.RelicDuration, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.RelicDuration = g_VictoryDurations.Duration[itemIdx]; | g_GameAttributes.settings.RelicDuration = g_VictoryDurations.Duration[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => g_GameAttributes.settings.GameType != "capture_the_relic", | "hidden": () => g_GameAttributes.settings.GameType != "capture_the_relic", | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The relic duration has been changed" | |||||
}, | }, | ||||
"wonderDuration": { | "wonderDuration": { | ||||
"title": () => translate("Wonder Duration"), | "title": () => translate("Wonder Duration"), | ||||
"tooltip": (hoverIdx) => translate("Minutes until the player has achieved Wonder Victory."), | "tooltip": (hoverIdx) => translate("Minutes until the player has achieved Wonder Victory."), | ||||
"labels": () => g_VictoryDurations.Title, | "labels": () => g_VictoryDurations.Title, | ||||
"ids": () => g_VictoryDurations.Duration, | "ids": () => g_VictoryDurations.Duration, | ||||
"default": () => g_VictoryDurations.Default, | "default": () => g_VictoryDurations.Default, | ||||
"defined": () => g_GameAttributes.settings.WonderDuration !== undefined, | "defined": () => g_GameAttributes.settings.WonderDuration !== undefined, | ||||
"get": () => g_GameAttributes.settings.WonderDuration, | "get": () => g_GameAttributes.settings.WonderDuration, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.WonderDuration = g_VictoryDurations.Duration[itemIdx]; | g_GameAttributes.settings.WonderDuration = g_VictoryDurations.Duration[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => g_GameAttributes.settings.GameType != "wonder", | "hidden": () => g_GameAttributes.settings.GameType != "wonder", | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The wonder duration has been changed" | |||||
}, | }, | ||||
"gameSpeed": { | "gameSpeed": { | ||||
"title": () => translate("Game Speed"), | "title": () => translate("Game Speed"), | ||||
"tooltip": (hoverIdx) => translate("Select game speed."), | "tooltip": (hoverIdx) => translate("Select game speed."), | ||||
"labels": () => g_GameSpeeds.Title, | "labels": () => g_GameSpeeds.Title, | ||||
"ids": () => g_GameSpeeds.Speed, | "ids": () => g_GameSpeeds.Speed, | ||||
"default": () => g_GameSpeeds.Default, | "default": () => g_GameSpeeds.Default, | ||||
"defined": () => | "defined": () => | ||||
g_GameAttributes.gameSpeed !== undefined && | g_GameAttributes.gameSpeed !== undefined && | ||||
g_GameSpeeds.Speed.indexOf(g_GameAttributes.gameSpeed) != -1, | g_GameSpeeds.Speed.indexOf(g_GameAttributes.gameSpeed) != -1, | ||||
"get": () => g_GameAttributes.gameSpeed, | "get": () => g_GameAttributes.gameSpeed, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.gameSpeed = g_GameSpeeds.Speed[itemIdx]; | g_GameAttributes.gameSpeed = g_GameSpeeds.Speed[itemIdx]; | ||||
}, | }, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The game speed has been changed" | |||||
}, | }, | ||||
"triggerDifficulty": { | "triggerDifficulty": { | ||||
"title": () => translate("Difficulty"), | "title": () => translate("Difficulty"), | ||||
"tooltip": (hoverIdx) => g_TriggerDifficultyList && g_TriggerDifficultyList.Description[hoverIdx] || | "tooltip": (hoverIdx) => g_TriggerDifficultyList && g_TriggerDifficultyList.Description[hoverIdx] || | ||||
translate("Select the difficulty of this scenario."), | translate("Select the difficulty of this scenario."), | ||||
"labels": () => g_TriggerDifficultyList ? g_TriggerDifficultyList.Title : [], | "labels": () => g_TriggerDifficultyList ? g_TriggerDifficultyList.Title : [], | ||||
"ids": () => g_TriggerDifficultyList ? g_TriggerDifficultyList.Id : [], | "ids": () => g_TriggerDifficultyList ? g_TriggerDifficultyList.Id : [], | ||||
"default": () => g_TriggerDifficultyList ? g_TriggerDifficultyList.Default : 0, | "default": () => g_TriggerDifficultyList ? g_TriggerDifficultyList.Default : 0, | ||||
"defined": () => g_GameAttributes.settings.TriggerDifficulty !== undefined, | "defined": () => g_GameAttributes.settings.TriggerDifficulty !== undefined, | ||||
"get": () => g_GameAttributes.settings.TriggerDifficulty, | "get": () => g_GameAttributes.settings.TriggerDifficulty, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.TriggerDifficulty = g_TriggerDifficultyList && g_TriggerDifficultyList.Id[itemIdx]; | g_GameAttributes.settings.TriggerDifficulty = g_TriggerDifficultyList && g_TriggerDifficultyList.Id[itemIdx]; | ||||
}, | }, | ||||
"hidden": () => !g_TriggerDifficultyList, | "hidden": () => !g_TriggerDifficultyList, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "The difficulty has been changed" | |||||
}, | }, | ||||
}; | }; | ||||
/** | /** | ||||
* These dropdowns provide a setting that is repeated once for each player | * These dropdowns provide a setting that is repeated once for each player | ||||
* (where playerIdx is starting from 0 for player 1). | * (where playerIdx is starting from 0 for player 1). | ||||
*/ | */ | ||||
var g_PlayerDropdowns = { | var g_PlayerDropdowns = { | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | "regicideGarrison": { | ||||
"default": () => false, | "default": () => false, | ||||
"defined": () => g_GameAttributes.settings.RegicideGarrison !== undefined, | "defined": () => g_GameAttributes.settings.RegicideGarrison !== undefined, | ||||
"get": () => g_GameAttributes.settings.RegicideGarrison, | "get": () => g_GameAttributes.settings.RegicideGarrison, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.RegicideGarrison = checked; | g_GameAttributes.settings.RegicideGarrison = checked; | ||||
}, | }, | ||||
"hidden": () => g_GameAttributes.settings.GameType != "regicide", | "hidden": () => g_GameAttributes.settings.GameType != "regicide", | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether heroes can garrison has been changed" | |||||
}, | }, | ||||
"revealMap": { | "revealMap": { | ||||
"title": () => | "title": () => | ||||
// Translation: Make sure to differentiate between the revealed map and explored map options! | // Translation: Make sure to differentiate between the revealed map and explored map options! | ||||
translate("Revealed Map"), | translate("Revealed Map"), | ||||
"tooltip": | "tooltip": | ||||
// Translation: Make sure to differentiate between the revealed map and explored map options! | // Translation: Make sure to differentiate between the revealed map and explored map options! | ||||
() => translate("Toggle revealed map (see everything)."), | () => translate("Toggle revealed map (see everything)."), | ||||
"default": () => false, | "default": () => false, | ||||
"defined": () => g_GameAttributes.settings.RevealMap !== undefined, | "defined": () => g_GameAttributes.settings.RevealMap !== undefined, | ||||
"get": () => g_GameAttributes.settings.RevealMap, | "get": () => g_GameAttributes.settings.RevealMap, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.RevealMap = checked; | g_GameAttributes.settings.RevealMap = checked; | ||||
if (checked) | if (checked) | ||||
g_Checkboxes.exploreMap.set(true); | g_Checkboxes.exploreMap.set(true); | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the map is revealed has been changed" | |||||
}, | }, | ||||
"exploreMap": { | "exploreMap": { | ||||
"title": | "title": | ||||
// Translation: Make sure to differentiate between the revealed map and explored map options! | // Translation: Make sure to differentiate between the revealed map and explored map options! | ||||
() => translate("Explored Map"), | () => translate("Explored Map"), | ||||
"tooltip": | "tooltip": | ||||
// Translation: Make sure to differentiate between the revealed map and explored map options! | // Translation: Make sure to differentiate between the revealed map and explored map options! | ||||
() => translate("Toggle explored map (see initial map)."), | () => translate("Toggle explored map (see initial map)."), | ||||
"default": () => false, | "default": () => false, | ||||
"defined": () => g_GameAttributes.settings.ExploreMap !== undefined, | "defined": () => g_GameAttributes.settings.ExploreMap !== undefined, | ||||
"get": () => g_GameAttributes.settings.ExploreMap, | "get": () => g_GameAttributes.settings.ExploreMap, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.ExploreMap = checked; | g_GameAttributes.settings.ExploreMap = checked; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario" && !g_GameAttributes.settings.RevealMap, | "enabled": () => g_GameAttributes.mapType != "scenario" && !g_GameAttributes.settings.RevealMap, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the map is explored has been changed" | |||||
}, | }, | ||||
"disableTreasures": { | "disableTreasures": { | ||||
"title": () => translate("Disable Treasures"), | "title": () => translate("Disable Treasures"), | ||||
"tooltip": () => translate("Disable all treasures on the map."), | "tooltip": () => translate("Disable all treasures on the map."), | ||||
"default": () => false, | "default": () => false, | ||||
"defined": () => g_GameAttributes.settings.DisableTreasures !== undefined, | "defined": () => g_GameAttributes.settings.DisableTreasures !== undefined, | ||||
"get": () => g_GameAttributes.settings.DisableTreasures, | "get": () => g_GameAttributes.settings.DisableTreasures, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.DisableTreasures = checked; | g_GameAttributes.settings.DisableTreasures = checked; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the map has treasures has been changed" | |||||
}, | }, | ||||
"disableSpies": { | "disableSpies": { | ||||
"title": () => translate("Disable Spies"), | "title": () => translate("Disable Spies"), | ||||
"tooltip": () => translate("Disable spies during the game."), | "tooltip": () => translate("Disable spies during the game."), | ||||
"default": () => false, | "default": () => false, | ||||
"defined": () => g_GameAttributes.settings.DisableSpies !== undefined, | "defined": () => g_GameAttributes.settings.DisableSpies !== undefined, | ||||
"get": () => g_GameAttributes.settings.DisableSpies, | "get": () => g_GameAttributes.settings.DisableSpies, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.DisableSpies = checked; | g_GameAttributes.settings.DisableSpies = checked; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the map allows spies has been changed" | |||||
}, | }, | ||||
"lockTeams": { | "lockTeams": { | ||||
"title": () => translate("Teams Locked"), | "title": () => translate("Teams Locked"), | ||||
"tooltip": () => translate("Toggle locked teams."), | "tooltip": () => translate("Toggle locked teams."), | ||||
"default": () => Engine.HasXmppClient(), | "default": () => Engine.HasXmppClient(), | ||||
"defined": () => g_GameAttributes.settings.LockTeams !== undefined, | "defined": () => g_GameAttributes.settings.LockTeams !== undefined, | ||||
"get": () => g_GameAttributes.settings.LockTeams, | "get": () => g_GameAttributes.settings.LockTeams, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.LockTeams = checked; | g_GameAttributes.settings.LockTeams = checked; | ||||
g_GameAttributes.settings.LastManStanding = false; | g_GameAttributes.settings.LastManStanding = false; | ||||
}, | }, | ||||
"enabled": () => | "enabled": () => | ||||
g_GameAttributes.mapType != "scenario" && | g_GameAttributes.mapType != "scenario" && | ||||
!g_GameAttributes.settings.RatingEnabled, | !g_GameAttributes.settings.RatingEnabled, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the teams are locked has been changed" | |||||
}, | }, | ||||
"lastManStanding": { | "lastManStanding": { | ||||
"title": () => translate("Last Man Standing"), | "title": () => translate("Last Man Standing"), | ||||
"tooltip": () => translate("Toggle whether the last remaining player or the last remaining set of allies wins."), | "tooltip": () => translate("Toggle whether the last remaining player or the last remaining set of allies wins."), | ||||
"default": () => false, | "default": () => false, | ||||
"defined": () => g_GameAttributes.settings.LastManStanding !== undefined, | "defined": () => g_GameAttributes.settings.LastManStanding !== undefined, | ||||
"get": () => g_GameAttributes.settings.LastManStanding, | "get": () => g_GameAttributes.settings.LastManStanding, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.LastManStanding = checked; | g_GameAttributes.settings.LastManStanding = checked; | ||||
}, | }, | ||||
"enabled": () => | "enabled": () => | ||||
g_GameAttributes.mapType != "scenario" && | g_GameAttributes.mapType != "scenario" && | ||||
!g_GameAttributes.settings.LockTeams, | !g_GameAttributes.settings.LockTeams, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the game is last man standing has been changed" | |||||
}, | }, | ||||
"enableCheats": { | "enableCheats": { | ||||
"title": () => translate("Cheats"), | "title": () => translate("Cheats"), | ||||
"tooltip": () => translate("Toggle the usability of cheats."), | "tooltip": () => translate("Toggle the usability of cheats."), | ||||
"default": () => !g_IsNetworked, | "default": () => !g_IsNetworked, | ||||
"hidden": () => !g_IsNetworked, | "hidden": () => !g_IsNetworked, | ||||
"defined": () => g_GameAttributes.settings.CheatsEnabled !== undefined, | "defined": () => g_GameAttributes.settings.CheatsEnabled !== undefined, | ||||
"get": () => g_GameAttributes.settings.CheatsEnabled, | "get": () => g_GameAttributes.settings.CheatsEnabled, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.CheatsEnabled = !g_IsNetworked || | g_GameAttributes.settings.CheatsEnabled = !g_IsNetworked || | ||||
checked && !g_GameAttributes.settings.RatingEnabled; | checked && !g_GameAttributes.settings.RatingEnabled; | ||||
}, | }, | ||||
"enabled": () => !g_GameAttributes.settings.RatingEnabled, | "enabled": () => !g_GameAttributes.settings.RatingEnabled, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the game allows cheats has been changed" | |||||
}, | }, | ||||
"enableRating": { | "enableRating": { | ||||
"title": () => translate("Rated Game"), | "title": () => translate("Rated Game"), | ||||
"tooltip": () => translate("Toggle if this game will be rated for the leaderboard."), | "tooltip": () => translate("Toggle if this game will be rated for the leaderboard."), | ||||
"default": () => Engine.HasXmppClient(), | "default": () => Engine.HasXmppClient(), | ||||
"hidden": () => !Engine.HasXmppClient(), | "hidden": () => !Engine.HasXmppClient(), | ||||
"defined": () => g_GameAttributes.settings.RatingEnabled !== undefined, | "defined": () => g_GameAttributes.settings.RatingEnabled !== undefined, | ||||
"get": () => !!g_GameAttributes.settings.RatingEnabled, | "get": () => !!g_GameAttributes.settings.RatingEnabled, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient() ? checked : undefined; | g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient() ? checked : undefined; | ||||
Engine.SetRankedGame(!!g_GameAttributes.settings.RatingEnabled); | Engine.SetRankedGame(!!g_GameAttributes.settings.RatingEnabled); | ||||
if (checked) | if (checked) | ||||
{ | { | ||||
g_Checkboxes.lockTeams.set(true); | g_Checkboxes.lockTeams.set(true); | ||||
g_Checkboxes.enableCheats.set(false); | g_Checkboxes.enableCheats.set(false); | ||||
} | } | ||||
}, | }, | ||||
"initOrder": 1000 | "initOrder": 1000, | ||||
"changedMessage": "Whether the game is rated has been changed" | |||||
}, | }, | ||||
}; | }; | ||||
/** | /** | ||||
* For setting up arbitrary GUI objects. | * For setting up arbitrary GUI objects. | ||||
*/ | */ | ||||
var g_MiscControls = { | var g_MiscControls = { | ||||
"chatPanel": { | "chatPanel": { | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | "playerConfig": { | ||||
}, | }, | ||||
"tooltip": (playerIdx) => sprintf(translate("Configure AI: %(description)s."), { | "tooltip": (playerIdx) => sprintf(translate("Configure AI: %(description)s."), { | ||||
"description": translateAISettings(g_GameAttributes.settings.PlayerData[playerIdx]) | "description": translateAISettings(g_GameAttributes.settings.PlayerData[playerIdx]) | ||||
}), | }), | ||||
}, | }, | ||||
}; | }; | ||||
/** | /** | ||||
* Last changed setting. | |||||
*/ | |||||
var g_LastChangedSetting = ""; | |||||
/** | |||||
* Allows the host to see the next message. | |||||
*/ | |||||
var g_AllowNextMessage = false; | |||||
/** | |||||
* The number of setting changed messages which have been silenced. | |||||
*/ | |||||
var g_NumberOfSettingChangedMessages = 0; | |||||
/** | |||||
* Initializes some globals without touching the GUI. | * Initializes some globals without touching the GUI. | ||||
* | * | ||||
* @param {Object} attribs - context data sent by the lobby / mainmenu | * @param {Object} attribs - context data sent by the lobby / mainmenu | ||||
*/ | */ | ||||
function init(attribs) | function init(attribs) | ||||
{ | { | ||||
if (!g_Settings) | if (!g_Settings) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | function handleGamestartMessage(message) | ||||
Engine.SwitchGuiPage("page_loading.xml", { | Engine.SwitchGuiPage("page_loading.xml", { | ||||
"attribs": g_GameAttributes, | "attribs": g_GameAttributes, | ||||
"isNetworked": g_IsNetworked, | "isNetworked": g_IsNetworked, | ||||
"playerAssignments": g_PlayerAssignments, | "playerAssignments": g_PlayerAssignments, | ||||
"isController": g_IsController | "isController": g_IsController | ||||
}); | }); | ||||
} | } | ||||
/* | |||||
* Checks if the parameter is an object | |||||
*/ | |||||
function IsObject(obj) | |||||
Not Done Inline ActionsThese functions are pretty common, so they should be in common folder to be able use your code in other places (i.e. binaries/data/mods/public/globalscripts/utility.js). Also we use lower camel case in CC. vladislavbelov: These functions are pretty common, so they should be in common folder to be able use your code… | |||||
{ | |||||
return obj === Object(obj); | |||||
} | |||||
/* | |||||
* Compares two objects, returns true if they are equal | |||||
*/ | |||||
function DeepCompare(obj1, obj2) | |||||
{ | |||||
return PartialDeepCompare(obj1, obj2) && PartialDeepCompare(obj2, obj1); | |||||
} | |||||
/* | |||||
* Compares two objects, returns true if object one's parameters match object two's | |||||
* Note: it won't check if obj2 has parameters that obj1 doesn't, which is why we have DeepCompare | |||||
*/ | |||||
function PartialDeepCompare(obj1, obj2) | |||||
Not Done Inline ActionsI guess @Imarok would say that we want a gamesetup rewrite so that we can identify changed settings uniquely, not the resulting g_GameAttributes object. elexis: I guess @Imarok would say that we want a gamesetup rewrite so that we can identify changed… | |||||
Not Done Inline ActionsI agree with @elexis, we need to refactoring attributes. vladislavbelov: I agree with @elexis, we need to refactoring attributes. | |||||
{ | |||||
for (var iproperty in obj1) | |||||
{ | |||||
if (obj1.hasOwnProperty(iproperty)) | |||||
{ | |||||
if (!(iproperty in obj2)) | |||||
{ | |||||
return false; | |||||
} | |||||
var isObjInObj1 = IsObject(obj1[iproperty]); | |||||
var isObjInObj2 = IsObject(obj2[iproperty]); | |||||
if (isObjInObj1 != isObjInObj2) | |||||
{ | |||||
return false; | |||||
} | |||||
if (isObjInObj1 == true) | |||||
{ | |||||
if (!DeepCompare(obj1[iproperty], obj2[iproperty])) | |||||
{ | |||||
return false; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
if (obj1[iproperty] !== obj2[iproperty]) | |||||
{ | |||||
return false; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return true; | |||||
} | |||||
/** | /** | ||||
* Called whenever the host changed any setting. | * Called whenever the host changed any setting. | ||||
*/ | */ | ||||
function handleGamesetupMessage(message) | function handleGamesetupMessage(message) | ||||
{ | { | ||||
if (!message.data) | if (!message.data) | ||||
return; | return; | ||||
var settingThatChanged = ""; | |||||
if (message.data.map != g_GameAttributes.map) | |||||
elexisUnsubmitted Not Done Inline ActionsAll of this shouldn't be here either but in g_Dropdowns and g_Checkboxes elexis: All of this shouldn't be here either but in g_Dropdowns and g_Checkboxes | |||||
elexisUnsubmitted Not Done Inline ActionsAll of this shouldn't be here either. It should be(come) possible to derive the changed setting directly. This is related to the rewrite by Imarok mentioned above. If someone wants to change a setting, only that one setting name should be sent by the server. Then we don't need to use black magic to find which setting changed. This will also allow other players to setup the game and giving privileges which settings they are allowed to change. I would say we must find a way to get Imarok to finish the rewrite, perhaps we have to threaten him to help him ;-) elexis: All of this shouldn't be here either. It should be(come) possible to derive the changed setting… | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsTo many similar code, we need to avoid it. vladislavbelov: To many similar code, we need to avoid it. | |||||
settingThatChanged = "-map"; | |||||
else if (message.data.mapType != g_GameAttributes.mapType) | |||||
settingThatChanged = "-mapType"; | |||||
else if (message.data.mapFilter != g_GameAttributes.mapFilter) | |||||
settingThatChanged = "-mapFilter"; | |||||
else if (message.data.mapPath != g_GameAttributes.mapPath) | |||||
settingThatChanged = "-mapPath"; | |||||
else if (message.data.gameSpeed != g_GameAttributes.gameSpeed) | |||||
settingThatChanged = "-gameSpeed"; | |||||
else if (message.data.settings.Biome != g_GameAttributes.settings.Biome) | |||||
settingThatChanged = "-settings-Biome"; | |||||
else if (message.data.settings.TriggerDifficulty != g_GameAttributes.settings.TriggerDifficulty) | |||||
settingThatChanged = "-settings-TriggerDifficulty"; | |||||
else if (message.data.settings.Size != g_GameAttributes.settings.Size) | |||||
settingThatChanged = "-settings-Size"; | |||||
else if (message.data.settings.PopulationCap != g_GameAttributes.settings.PopulationCap) | |||||
settingThatChanged = "-settings-PopulationCap"; | |||||
else if (message.data.settings.StartingResources != g_GameAttributes.settings.StartingResources) | |||||
settingThatChanged = "-settings-StartingResources"; | |||||
else if (message.data.settings.Ceasefire != g_GameAttributes.settings.Ceasefire) | |||||
settingThatChanged = "-settings-Ceasefire"; | |||||
else if (message.data.settings.GameType != g_GameAttributes.settings.GameType) | |||||
settingThatChanged = "-settings-GameType"; | |||||
else if (message.data.settings.RelicCount != g_GameAttributes.settings.RelicCount) | |||||
settingThatChanged = "-settings-RelicCount"; | |||||
else if (message.data.settings.RelicDuration != g_GameAttributes.settings.RelicDuration) | |||||
settingThatChanged = "-settings-RelicDuration"; | |||||
else if (message.data.settings.WonderDuration != g_GameAttributes.settings.WonderDuration) | |||||
settingThatChanged = "-settings-WonderDuration"; | |||||
else if (message.data.settings.RegicideGarrison != g_GameAttributes.settings.RegicideGarrison) | |||||
settingThatChanged = "-settings-RegicideGarrison"; | |||||
else if (!!message.data.settings.VictoryDuration && !!g_GameAttributes.settings.VictoryDuration // Sometimes doesn't exist | |||||
&& message.data.settings.VictoryDuration != g_GameAttributes.settings.VictoryDuration) | |||||
settingThatChanged = "-settings-VictoryDuration"; | |||||
else if (message.data.settings.RevealMap != g_GameAttributes.settings.RevealMap) | |||||
settingThatChanged = "-settings-RevealMap"; | |||||
else if (message.data.settings.ExploreMap != g_GameAttributes.settings.ExploreMap) | |||||
settingThatChanged = "-settings-ExploreMap"; | |||||
else if (message.data.settings.DisableTreasures != g_GameAttributes.settings.DisableTreasures) | |||||
settingThatChanged = "-settings-DisableTreasures"; | |||||
else if (message.data.settings.DisableSpies != g_GameAttributes.settings.DisableSpies) | |||||
settingThatChanged = "-settings-DisableSpies"; | |||||
else if (message.data.settings.LockTeams != g_GameAttributes.settings.LockTeams) | |||||
settingThatChanged = "-settings-LockTeams"; | |||||
else if (message.data.settings.LastManStanding != g_GameAttributes.settings.LastManStanding) | |||||
settingThatChanged = "-settings-LastManStanding"; | |||||
else if (message.data.settings.CheatsEnabled != g_GameAttributes.settings.CheatsEnabled) | |||||
settingThatChanged = "-settings-CheatsEnabled"; | |||||
else if (message.data.settings.RatingEnabled != g_GameAttributes.settings.RatingEnabled) | |||||
settingThatChanged = "-settings-RatingEnabled"; | |||||
else if (!!message.data.settings.Name && !!g_GameAttributes.settings.Name // Sometimes doesn't exist | |||||
&& message.data.settings.Name != g_GameAttributes.settings.Name) | |||||
settingThatChanged = "-settings-Name"; | |||||
else if (!!message.data.settings.Description && !!g_GameAttributes.settings.Description // Sometimes doesn't exist | |||||
&& message.data.settings.Description != g_GameAttributes.settings.Description) | |||||
settingThatChanged = "-settings-Description"; | |||||
else if (!DeepCompare(message.data.settings.PlayerData, g_GameAttributes.settings.PlayerData)) | |||||
settingThatChanged = "-settings-PlayerData"; | |||||
else if (!DeepCompare(message.data.settings.VictoryScripts, g_GameAttributes.settings.VictoryScripts)) | |||||
settingThatChanged = "-settings-VictoryScripts"; | |||||
else if (DeepCompare(message.data, g_GameAttributes)) // if you scroll fast enought the game will send two identical change requests, so we ignore the secound | |||||
settingThatChanged = "-nothing" | |||||
g_GameAttributes = message.data; | g_GameAttributes = message.data; | ||||
if (!!g_GameAttributes.settings.RatingEnabled) | if (!!g_GameAttributes.settings.RatingEnabled) | ||||
{ | { | ||||
g_GameAttributes.settings.CheatsEnabled = false; | g_GameAttributes.settings.CheatsEnabled = false; | ||||
g_GameAttributes.settings.LockTeams = true; | g_GameAttributes.settings.LockTeams = true; | ||||
g_GameAttributes.settings.LastManStanding = false; | g_GameAttributes.settings.LastManStanding = false; | ||||
} | } | ||||
Engine.SetRankedGame(!!g_GameAttributes.settings.RatingEnabled); | Engine.SetRankedGame(!!g_GameAttributes.settings.RatingEnabled); | ||||
resetReadyData(); | resetReadyData(settingThatChanged); | ||||
updateGUIObjects(); | updateGUIObjects(); | ||||
hideLoadingWindow(); | hideLoadingWindow(); | ||||
} | } | ||||
/** | /** | ||||
* Called whenever a client joins/leaves or any gamesetting is changed. | * Called whenever a client joins/leaves or any gamesetting is changed. | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | function onClientJoin(newGUID, newAssignments) | ||||
// Client is not and cannot become assigned as player | // Client is not and cannot become assigned as player | ||||
if (!isRejoiningPlayer && freeSlot == -1) | if (!isRejoiningPlayer && freeSlot == -1) | ||||
return; | return; | ||||
// Assign the joining client to the free slot | // Assign the joining client to the free slot | ||||
if (g_IsController && !isRejoiningPlayer) | if (g_IsController && !isRejoiningPlayer) | ||||
Engine.AssignNetworkPlayer(freeSlot + 1, newGUID); | Engine.AssignNetworkPlayer(freeSlot + 1, newGUID); | ||||
resetReadyData(); | g_AllowNextMessage = true; | ||||
resetReadyData("-settings-PlayerData"); | |||||
} | } | ||||
function onClientLeave(guid) | function onClientLeave(guid) | ||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
"type": "disconnect", | "type": "disconnect", | ||||
"guid": guid | "guid": guid | ||||
}); | }); | ||||
if (g_PlayerAssignments[guid].player != -1) | if (g_PlayerAssignments[guid].player != -1) | ||||
resetReadyData(); | { | ||||
g_AllowNextMessage = true; | |||||
resetReadyData("-settings-PlayerData"); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Doesn't translate, so that lobby clients can do that locally | * Doesn't translate, so that lobby clients can do that locally | ||||
* (even if they don't have that map). | * (even if they don't have that map). | ||||
*/ | */ | ||||
function getMapDisplayName(map) | function getMapDisplayName(map) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 711 Lines • ▼ Show 20 Lines | function updateGameAttributes() | ||||
if (g_IsInGuiUpdate || !g_IsController) | if (g_IsInGuiUpdate || !g_IsController) | ||||
return; | return; | ||||
if (g_IsNetworked) | if (g_IsNetworked) | ||||
{ | { | ||||
Engine.SetNetworkGameAttributes(g_GameAttributes); | Engine.SetNetworkGameAttributes(g_GameAttributes); | ||||
if (g_LoadingState >= 2) | if (g_LoadingState >= 2) | ||||
sendRegisterGameStanza(); | sendRegisterGameStanza(); | ||||
resetReadyData(); | resetReadyData("-host"); | ||||
} | } | ||||
else | else | ||||
updateGUIObjects(); | updateGUIObjects(); | ||||
} | } | ||||
function openAIConfig(playerSlot) | function openAIConfig(playerSlot) | ||||
{ | { | ||||
g_LastViewedAIPlayer = playerSlot; | g_LastViewedAIPlayer = playerSlot; | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | function setReady(ready, sendMessage) | ||||
g_IsReady = ready; | g_IsReady = ready; | ||||
if (sendMessage) | if (sendMessage) | ||||
Engine.SendNetworkReady(g_IsReady); | Engine.SendNetworkReady(g_IsReady); | ||||
updateGUIObjects(); | updateGUIObjects(); | ||||
} | } | ||||
function resetReadyData() | function resetReadyData(setting) | ||||
{ | { | ||||
if (g_GameStarted) | if (g_GameStarted) | ||||
return; | return; | ||||
if (g_ReadyChanged < 1) | if (g_IsController && !g_AllowNextMessage) | ||||
addChatMessage({ "type": "settings" }); | setting = "-host" | ||||
else if (g_ReadyChanged == 2 && !g_ReadyInit) | else | ||||
g_AllowNextMessage = false; | |||||
if (g_ReadyChanged < 1 || setting != g_LastChangedSetting) | |||||
{ | |||||
if (g_NumberOfSettingChangedMessages >= 3 && setting != "-nothing") | |||||
{ | |||||
addChatMessage({ "type": "settings" + setting}); | |||||
g_LastChangedSetting = setting; | |||||
} | |||||
else | |||||
g_NumberOfSettingChangedMessages += 1; | |||||
} | |||||
if (g_ReadyChanged >= 1 && !g_ReadyInit) | |||||
return; // duplicate calls on init | return; // duplicate calls on init | ||||
else | else | ||||
g_ReadyInit = false; | g_ReadyInit = false; | ||||
g_ReadyChanged = 2; | g_ReadyChanged = 2; | ||||
if (!g_IsNetworked) | if (!g_IsNetworked) | ||||
g_IsReady = 2; | g_IsReady = 2; | ||||
else if (g_IsController) | else if (g_IsController) | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |
Why system was removed?