Changeset View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | "Dropdown": [ | ||||
"victoryCondition", | "victoryCondition", | ||||
"relicCount", | "relicCount", | ||||
"victoryDuration", | "victoryDuration", | ||||
"populationCap", | "populationCap", | ||||
"startingResources", | "startingResources", | ||||
"ceasefire", | "ceasefire", | ||||
], | ], | ||||
"Checkbox": [ | "Checkbox": [ | ||||
"regicideGarrison", | |||||
"exploreMap", | "exploreMap", | ||||
"revealMap", | "revealMap", | ||||
"disableTreasures", | "disableTreasures", | ||||
"disableSpies", | "disableSpies", | ||||
"lockTeams", | "lockTeams", | ||||
"lastManStanding", | "lastManStanding", | ||||
"enableCheats", | "enableCheats", | ||||
"enableRating", | "enableRating", | ||||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | "playerColorPicker": { | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
}, | }, | ||||
}; | }; | ||||
/** | /** | ||||
* Contains the logic of all boolean gamesettings. | * Contains the logic of all boolean gamesettings. | ||||
*/ | */ | ||||
var g_Checkboxes = { | var g_Checkboxes = { | ||||
"regicideGarrison": { | |||||
"title": () => translate("Hero Garrison"), | |||||
"tooltip": () => translate("Toggle whether heroes can be garrisoned."), | |||||
"default": () => false, | |||||
"defined": () => g_GameAttributes.settings.RegicideGarrison !== undefined, | |||||
"get": () => g_GameAttributes.settings.RegicideGarrison, | |||||
"set": checked => { | |||||
g_GameAttributes.settings.RegicideGarrison = checked; | |||||
elexis: (This will keep the setting saved even if the victory condition is changed again, but fixing… | |||||
SandaracAuthorUnsubmitted Not Done Inline Actions(Yes, also an issue for RelicCount and VictoryDuration, and it's not so nice when these are written to the commands.txt for no reason.) Sandarac: (Yes, also an issue for `RelicCount` and `VictoryDuration`, and it's not so nice when these are… | |||||
}, | |||||
"hidden": () => g_GameAttributes.settings.GameType != "regicide", | |||||
"enabled": () => g_GameAttributes.mapType != "scenario", | |||||
}, | |||||
"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, | ||||
▲ Show 20 Lines • Show All 572 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* 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) | ||||
{ | { | ||||
if (map == "random") | if (map == "random") | ||||
Not Done Inline Actionsdelete is slow and messes up some structure information internally, if we have to do that (which I think we do here, but this diff is lacking context) we might want to reorder the structure so we delete the last property added (or defined). leper: `delete` is slow and messes up some structure information internally, if we have to do that… | |||||
Not Done Inline ActionsContext should be clear, when changing the map, these settings can be persisted unless it is a scenario map. elexis: Context should be clear, when changing the map, these settings can be persisted unless it is a… | |||||
return map; | return map; | ||||
let mapData = loadMapData(map); | let mapData = loadMapData(map); | ||||
if (!mapData || !mapData.settings || !mapData.settings.Name) | if (!mapData || !mapData.settings || !mapData.settings.Name) | ||||
return map; | return map; | ||||
return mapData.settings.Name; | return mapData.settings.Name; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | if (g_GameAttributes.mapType != "random") | ||||
g_GameAttributes.settings.GameType = g_VictoryConditions.Name[victoryIdx]; | g_GameAttributes.settings.GameType = g_VictoryConditions.Name[victoryIdx]; | ||||
g_GameAttributes.settings.VictoryScripts = g_VictoryConditions.Scripts[victoryIdx]; | g_GameAttributes.settings.VictoryScripts = g_VictoryConditions.Scripts[victoryIdx]; | ||||
} | } | ||||
if (g_GameAttributes.mapType == "scenario") | if (g_GameAttributes.mapType == "scenario") | ||||
{ | { | ||||
delete g_GameAttributes.settings.VictoryDuration; | delete g_GameAttributes.settings.VictoryDuration; | ||||
delete g_GameAttributes.settings.LastManStanding; | delete g_GameAttributes.settings.LastManStanding; | ||||
delete g_GameAttributes.settings.RegicideGarrison; | |||||
elexisUnsubmitted Not Done Inline Actions(Correct, must be in this check because it's a user setting, as opposed to the properties deleted in the loop above.) elexis: (Correct, must be in this check because it's a user setting, as opposed to the properties… | |||||
} | } | ||||
if (mapSettings.PlayerData) | if (mapSettings.PlayerData) | ||||
sanitizePlayerData(mapSettings.PlayerData); | sanitizePlayerData(mapSettings.PlayerData); | ||||
// Copy any new settings | // Copy any new settings | ||||
g_GameAttributes.map = name; | g_GameAttributes.map = name; | ||||
g_GameAttributes.script = mapSettings.Script; | g_GameAttributes.script = mapSettings.Script; | ||||
▲ Show 20 Lines • Show All 620 Lines • Show Last 20 Lines |
(This will keep the setting saved even if the victory condition is changed again, but fixing this is out-of-scope as it isn't trivial.)