Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show All 16 Lines | |||||
* 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); | ||||
/** | /** | ||||
* Store civilization code and page (structree or history) opened in civilization info. | * Store civilization code and page (structree or history) opened in civilization info. | ||||
*/ | */ | ||||
var g_CivInfo = { | var g_CivInfo = { | ||||
"code": "", | "civ": "", | ||||
"page": "page_civinfo.xml" | "page": "page_civinfo.xml" | ||||
}; | }; | ||||
/** | /** | ||||
* Highlight the "random" dropdownlist item. | * Highlight the "random" dropdownlist item. | ||||
*/ | */ | ||||
var g_ColorRandom = "orange"; | var g_ColorRandom = "orange"; | ||||
▲ Show 20 Lines • Show All 1,008 Lines • ▼ Show 20 Lines | var g_MiscControls = { | ||||
}, | }, | ||||
"civInfoButton": { | "civInfoButton": { | ||||
"tooltip": () => sprintf( | "tooltip": () => sprintf( | ||||
translate("%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click."), { | translate("%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click."), { | ||||
"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"), | "hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"), | ||||
"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree") | "hotkey_structree": colorizeHotkey("%(hotkey)s", "structree") | ||||
}), | }), | ||||
"onPress": () => function() { | "onPress": () => function() { | ||||
Engine.PushGuiPage(g_CivInfo.page, { | Engine.PushGuiPage( | ||||
"civ": g_CivInfo.code, | g_CivInfo.page, | ||||
"callback": "storeCivInfoPage" | { "civ": g_CivInfo.civ }, | ||||
}); | storeCivInfoPage); | ||||
} | } | ||||
}, | }, | ||||
"civResetButton": { | "civResetButton": { | ||||
"hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | "hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | ||||
}, | }, | ||||
"teamResetButton": { | "teamResetButton": { | ||||
"hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | "hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 1,356 Lines • ▼ Show 20 Lines | function updateGameAttributes() | ||||
else | else | ||||
updateGUIObjects(); | updateGUIObjects(); | ||||
} | } | ||||
function openAIConfig(playerSlot) | function openAIConfig(playerSlot) | ||||
{ | { | ||||
g_LastViewedAIPlayer = playerSlot; | g_LastViewedAIPlayer = playerSlot; | ||||
Engine.PushGuiPage("page_aiconfig.xml", { | Engine.PushGuiPage( | ||||
"callback": "AIConfigCallback", | "page_aiconfig.xml", | ||||
{ | |||||
"playerSlot": playerSlot, | "playerSlot": playerSlot, | ||||
"id": g_GameAttributes.settings.PlayerData[playerSlot].AI, | "id": g_GameAttributes.settings.PlayerData[playerSlot].AI, | ||||
"difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff, | "difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff, | ||||
"behavior": g_GameAttributes.settings.PlayerData[playerSlot].AIBehavior | "behavior": g_GameAttributes.settings.PlayerData[playerSlot].AIBehavior | ||||
}); | }, | ||||
} | ai => { | ||||
/** | |||||
* Called after closing the dialog. | |||||
*/ | |||||
function AIConfigCallback(ai) | |||||
{ | |||||
g_LastViewedAIPlayer = -1; | g_LastViewedAIPlayer = -1; | ||||
if (!ai.save || !g_IsController) | 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; | ||||
g_GameAttributes.settings.PlayerData[ai.playerSlot].AIBehavior = ai.behavior; | g_GameAttributes.settings.PlayerData[ai.playerSlot].AIBehavior = ai.behavior; | ||||
updateGameAttributes(); | updateGameAttributes(); | ||||
}); | |||||
} | } | ||||
function reloadPlayerAssignmentChoices() | 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 | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | for (let name in dropdown) | ||||
autocomplete[priority] = (autocomplete[priority] || []).concat(dropdown[name].labels()); | autocomplete[priority] = (autocomplete[priority] || []).concat(dropdown[name].labels()); | ||||
} | } | ||||
g_Autocomplete = Object.keys(autocomplete).sort().reverse().reduce((all, priority) => all.concat(autocomplete[priority]), []); | g_Autocomplete = Object.keys(autocomplete).sort().reverse().reduce((all, priority) => all.concat(autocomplete[priority]), []); | ||||
} | } | ||||
function storeCivInfoPage(data) | function storeCivInfoPage(data) | ||||
{ | { | ||||
g_CivInfo.code = data.civ; | if (data.nextPage) | ||||
g_CivInfo.page = data.page; | Engine.PushGuiPage( | ||||
data.nextPage, | |||||
{ "civ": data.civ }, | |||||
storeCivInfoPage); | |||||
else | |||||
g_CivInfo = data; | |||||
} | } |
Wildfire Games · Phabricator