Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js
/** | /** | ||||
* Display selectable civs only. | * Display selectable civs only. | ||||
*/ | */ | ||||
const g_CivData = loadCivData(true, false); | const g_CivData = loadCivData(true, false); | ||||
/** | |||||
* Callback function name on closing gui via Engine.PopGuiPage(). | |||||
*/ | |||||
var g_Callback = ""; | |||||
var g_SelectedCiv = ""; | var g_SelectedCiv = ""; | ||||
/** | /** | ||||
* Initialize the dropdown containing all the available civs. | * Initialize the dropdown containing all the available civs. | ||||
*/ | */ | ||||
function init(data = {}) | function init(data = {}) | ||||
{ | { | ||||
if (data.callback) | |||||
g_Callback = data.callback; | |||||
var civList = Object.keys(g_CivData).map(civ => ({ "name": g_CivData[civ].Name, "code": civ })).sort(sortNameIgnoreCase); | var civList = Object.keys(g_CivData).map(civ => ({ "name": g_CivData[civ].Name, "code": civ })).sort(sortNameIgnoreCase); | ||||
var civSelection = Engine.GetGUIObjectByName("civSelection"); | var civSelection = Engine.GetGUIObjectByName("civSelection"); | ||||
civSelection.list = civList.map(civ => civ.name); | civSelection.list = civList.map(civ => civ.name); | ||||
civSelection.list_data = civList.map(civ => civ.code); | civSelection.list_data = civList.map(civ => civ.code); | ||||
civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0; | civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0; | ||||
Engine.GetGUIObjectByName("structreeButton").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to Structure Tree."), "structree"); | Engine.GetGUIObjectByName("structreeButton").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to Structure Tree."), "structree"); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (obj.History) | ||||
string += '[icon="iconInfo" tooltip="' + escapeQuotation(obj.History) + '" tooltip_style="civInfoTooltip"]'; | string += '[icon="iconInfo" tooltip="' + escapeQuotation(obj.History) + '" tooltip_style="civInfoTooltip"]'; | ||||
if (obj.Description) | if (obj.Description) | ||||
string += '\n ' + obj.Description; | string += '\n ' + obj.Description; | ||||
return coloredText(string + "\n", "white"); | return coloredText(string + "\n", "white"); | ||||
} | } | ||||
function switchToStrucTreePage() | function switchToStrucTreePage() | ||||
{ | { | ||||
Engine.PopGuiPage(); | Engine.PopGuiPage({ "civ": g_SelectedCiv, "nextPage": "page_structree.xml" }); | ||||
Engine.PushGuiPage("page_structree.xml", { "civ": g_SelectedCiv, "callback": g_Callback }); | |||||
} | } | ||||
function closePage() | function closePage() | ||||
{ | { | ||||
if (g_Callback) | Engine.PopGuiPage({ "civ": g_SelectedCiv, "page": "page_civinfo.xml" }); | ||||
Engine.PopGuiPageCB({ "civ": g_SelectedCiv, "page": "page_civinfo.xml" }); | |||||
else | |||||
Engine.PopGuiPage(); | |||||
} | } | ||||
/** | /** | ||||
* Updates the GUI after the user selected a civ from dropdown. | * Updates the GUI after the user selected a civ from dropdown. | ||||
* | * | ||||
* @param code {string} | * @param code {string} | ||||
*/ | */ | ||||
function selectCiv(code) | function selectCiv(code) | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator