Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/structree/structree.js
var g_ParsedData = { | var g_ParsedData = { | ||||
"units": {}, | "units": {}, | ||||
"structures": {}, | "structures": {}, | ||||
"techs": {}, | "techs": {}, | ||||
"phases": {} | "phases": {} | ||||
}; | }; | ||||
var g_Lists = {}; | var g_Lists = {}; | ||||
var g_CivData = {}; | var g_CivData = {}; | ||||
var g_SelectedCiv = ""; | var g_SelectedCiv = ""; | ||||
var g_CurrentModifiers = {}; | |||||
var g_CallbackSet = false; | var g_CallbackSet = false; | ||||
var g_ResourceData = new Resources(); | var g_ResourceData = new Resources(); | ||||
var g_AutoResearchTechList = []; | |||||
bb: Perhaps move this to helper file where it is used.
I believe it is good to have this global, so… | |||||
/** | /** | ||||
* Initialize the dropdown containing all the available civs | * Initialize the dropdown containing all the available civs | ||||
*/ | */ | ||||
function init(data = {}) | function init(data = {}) | ||||
{ | { | ||||
g_CivData = loadCivData(true); | g_CivData = loadCivData(true); | ||||
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) | ||||
return; | return; | ||||
g_AutoResearchTechList = findAllAutoResearchedTechs(); | |||||
bbUnsubmitted Done Inline ActionsI guess this can be merged with variable definition. bb: I guess this can be merged with variable definition. | |||||
var civSelection = Engine.GetGUIObjectByName("civSelection"); | var 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); | ||||
if(data.civ) | if(data.civ) | ||||
bbUnsubmitted Not Done Inline Actionssry have to notice this ugliness, no change needed in this patch. bb: sry have to notice this ugliness, no change needed in this patch. | |||||
{ | { | ||||
civSelection.selected = civSelection.list_data.indexOf(data.civ); | civSelection.selected = civSelection.list_data.indexOf(data.civ); | ||||
selectCiv(data.civ); | selectCiv(data.civ); | ||||
} | } | ||||
else | else | ||||
civSelection.selected = 0; | civSelection.selected = 0; | ||||
if (data.callback) | if (data.callback) | ||||
Show All 9 Lines | function selectCiv(civCode) | ||||
// If a buildList already exists, then this civ has already been parsed | // If a buildList already exists, then this civ has already been parsed | ||||
if (g_CivData[g_SelectedCiv].buildList) | if (g_CivData[g_SelectedCiv].buildList) | ||||
{ | { | ||||
draw(); | draw(); | ||||
return; | return; | ||||
} | } | ||||
deriveCurrentModifications(); | |||||
g_Lists = { | g_Lists = { | ||||
"units": [], | "units": [], | ||||
"structures": [], | "structures": [], | ||||
"techs": [] | "techs": [] | ||||
}; | }; | ||||
g_ParsedData.techs[civCode] = {}; | g_ParsedData.techs[civCode] = {}; | ||||
// get initial units | // get initial units | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Perhaps move this to helper file where it is used.
I believe it is good to have this global, so we don't recalculate on civ selection.