Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/structree/structree.js
/** | /** | ||||
* Array of structure template names when given a civ and a phase name. | * Array of structure template names when given a civ and a phase name. | ||||
*/ | */ | ||||
var g_BuildList = {}; | var g_BuildList = {}; | ||||
/** | /** | ||||
* Array of template names that can be trained from a unit, given a civ and unit template name. | * Array of template names that can be trained from a unit, given a civ and unit template name. | ||||
*/ | */ | ||||
var g_TrainList = {}; | var g_TrainList = {}; | ||||
var g_Callback = ""; | |||||
/** | /** | ||||
* Initialize the page | * Initialize the page | ||||
* | * | ||||
* @param {object} data - Parameters passed from the code that calls this page into existence. | * @param {object} data - Parameters passed from the code that calls this page into existence. | ||||
*/ | */ | ||||
function init(data = {}) | function init(data = {}) | ||||
{ | { | ||||
if (data.callback) | if (data.callback) | ||||
{ | |||||
g_CallbackSet = true; | g_CallbackSet = true; | ||||
g_Callback = data.callback; | |||||
} | |||||
let civList = Object.keys(g_CivData).map(civ => ({ | let civList = Object.keys(g_CivData).map(civ => ({ | ||||
"name": g_CivData[civ].Name, | "name": g_CivData[civ].Name, | ||||
"code": civ, | "code": civ, | ||||
})).sort(sortNameIgnoreCase); | })).sort(sortNameIgnoreCase); | ||||
if (!civList.length) | if (!civList.length) | ||||
{ | { | ||||
Show All 9 Lines | function init(data = {}) | ||||
}; | }; | ||||
let civSelection = Engine.GetGUIObjectByName("civSelection"); | let civSelection = Engine.GetGUIObjectByName("civSelection"); | ||||
civSelection.list = civList.map(c => c.name); | civSelection.list = civList.map(c => c.name); | ||||
civSelection.list_data = civList.map(c => c.code); | civSelection.list_data = civList.map(c => c.code); | ||||
civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0; | civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0; | ||||
} | } | ||||
function switchHistoryPage() | |||||
{ | |||||
Engine.PopGuiPage(); | |||||
Engine.PushGuiPage("page_civinfo.xml", { "civ": g_SelectedCiv, "callback": g_Callback }); | |||||
} | |||||
/** | /** | ||||
* @param {string} civCode | * @param {string} civCode | ||||
*/ | */ | ||||
function selectCiv(civCode) | function selectCiv(civCode) | ||||
{ | { | ||||
if (civCode === g_SelectedCiv || !g_CivData[civCode]) | if (civCode === g_SelectedCiv || !g_CivData[civCode]) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator