Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js
const g_MatchSettings_SP = "config/matchsettings.json"; | const g_MatchSettings_SP = "config/matchsettings.json"; | ||||
const g_MatchSettings_MP = "config/matchsettings.mp.json"; | const g_MatchSettings_MP = "config/matchsettings.mp.json"; | ||||
const g_Ceasefire = prepareForDropdown(g_Settings && g_Settings.Ceasefire); | const g_Ceasefire = prepareForDropdown(g_Settings && g_Settings.Ceasefire); | ||||
const g_GameSpeeds = prepareForDropdown(g_Settings && g_Settings.GameSpeeds.filter(speed => !speed.ReplayOnly)); | |||||
const g_MapSizes = prepareForDropdown(g_Settings && g_Settings.MapSizes); | const g_MapSizes = prepareForDropdown(g_Settings && g_Settings.MapSizes); | ||||
const g_MapTypes = prepareForDropdown(g_Settings && g_Settings.MapTypes); | const g_MapTypes = prepareForDropdown(g_Settings && g_Settings.MapTypes); | ||||
const g_PopulationCapacities = prepareForDropdown(g_Settings && g_Settings.PopulationCapacities); | const g_PopulationCapacities = prepareForDropdown(g_Settings && g_Settings.PopulationCapacities); | ||||
const g_StartingResources = prepareForDropdown(g_Settings && g_Settings.StartingResources); | const g_StartingResources = prepareForDropdown(g_Settings && g_Settings.StartingResources); | ||||
const g_VictoryConditions = prepareForDropdown(g_Settings && g_Settings.VictoryConditions); | const g_VictoryConditions = prepareForDropdown(g_Settings && g_Settings.VictoryConditions); | ||||
const g_VictoryDurations = prepareForDropdown(g_Settings && g_Settings.VictoryDurations); | const g_VictoryDurations = prepareForDropdown(g_Settings && g_Settings.VictoryDurations); | ||||
var g_GameSpeeds = getGameSpeedChoices(false); | |||||
/** | /** | ||||
* Offer users to select playable civs only. | * Offer users to select playable civs only. | ||||
* Load unselectable civs as they could appear in scenario maps. | * Load unselectable civs as they could appear in scenario maps. | ||||
*/ | */ | ||||
const g_CivData = loadCivData(false, false); | const g_CivData = loadCivData(false, false); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 611 Lines • ▼ Show 20 Lines | "wonderDuration": { | ||||
"initOrder": 1000 | "initOrder": 1000 | ||||
}, | }, | ||||
"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": () => g_GameAttributes.gameSpeed !== undefined, | "defined": () => | ||||
g_GameAttributes.gameSpeed !== undefined && | |||||
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 | ||||
}, | }, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 875 Lines • ▼ Show 20 Lines | [{ | ||||
"Title": biome.Title, | "Title": biome.Title, | ||||
"Description": biome.Description, | "Description": biome.Description, | ||||
"Color": g_ColorRegular | "Color": g_ColorRegular | ||||
})))); | })))); | ||||
initDropdown("biome"); | initDropdown("biome"); | ||||
} | } | ||||
function reloadGameSpeedChoices() | |||||
{ | |||||
g_GameSpeeds = getGameSpeedChoices(Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player == -1)); | |||||
initDropdown("gameSpeed"); | |||||
supplementDefaults(); | |||||
} | |||||
function loadMapData(name) | function loadMapData(name) | ||||
{ | { | ||||
if (!name || !g_MapPath[g_GameAttributes.mapType]) | if (!name || !g_MapPath[g_GameAttributes.mapType]) | ||||
return undefined; | return undefined; | ||||
if (name == "random") | if (name == "random") | ||||
return { "settings": { "Name": "", "Description": "" } }; | return { "settings": { "Name": "", "Description": "" } }; | ||||
▲ Show 20 Lines • Show All 450 Lines • ▼ Show 20 Lines | |||||
* Unless the mapsettings don't specify a property and the user didn't set it in g_GameAttributes previously. | * Unless the mapsettings don't specify a property and the user didn't set it in g_GameAttributes previously. | ||||
*/ | */ | ||||
function updateGUIObjects() | function updateGUIObjects() | ||||
{ | { | ||||
g_IsInGuiUpdate = true; | g_IsInGuiUpdate = true; | ||||
reloadMapFilterList(); | reloadMapFilterList(); | ||||
reloadBiomeList(); | reloadBiomeList(); | ||||
updatePlayerAssignmentChoices(); | reloadGameSpeedChoices(); | ||||
reloadPlayerAssignmentChoices(); | |||||
// Hide exceeding dropdowns and checkboxes | // Hide exceeding dropdowns and checkboxes | ||||
for (let panel in g_OptionOrderGUI) | for (let panel in g_OptionOrderGUI) | ||||
for (let child of Engine.GetGUIObjectByName(panel + "Options").children) | for (let child of Engine.GetGUIObjectByName(panel + "Options").children) | ||||
child.hidden = true; | child.hidden = true; | ||||
// Show the relevant ones | // Show the relevant ones | ||||
for (let name in g_Dropdowns) | for (let name in g_Dropdowns) | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | if (!ai.save || !g_IsController) | ||||
return; | return; | ||||
g_GameAttributes.settings.PlayerData[ai.playerSlot].AI = ai.id; | g_GameAttributes.settings.PlayerData[ai.playerSlot].AI = ai.id; | ||||
g_GameAttributes.settings.PlayerData[ai.playerSlot].AIDiff = ai.difficulty; | g_GameAttributes.settings.PlayerData[ai.playerSlot].AIDiff = ai.difficulty; | ||||
updateGameAttributes(); | updateGameAttributes(); | ||||
} | } | ||||
function updatePlayerAssignmentChoices() | function reloadPlayerAssignmentChoices() | ||||
{ | { | ||||
let playerChoices = sortGUIDsByPlayerID().map(guid => ({ | let playerChoices = sortGUIDsByPlayerID().map(guid => ({ | ||||
"Choice": "guid:" + guid, | "Choice": "guid:" + guid, | ||||
"Color": g_PlayerAssignments[guid].player == -1 ? g_PlayerAssignmentColors.observer : g_PlayerAssignmentColors.player, | "Color": g_PlayerAssignments[guid].player == -1 ? g_PlayerAssignmentColors.observer : g_PlayerAssignmentColors.player, | ||||
"Name": g_PlayerAssignments[guid].name | "Name": g_PlayerAssignments[guid].name | ||||
})); | })); | ||||
// Only display hidden AIs if the map preselects them | // Only display hidden AIs if the map preselects them | ||||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator