Ticket #3401: structreePhasePairFix.patch
File structreePhasePairFix.patch, 5.5 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/structree/draw.js
function draw() 70 70 { 71 71 for (let prod of stru.production.technology[prod_pha]) 72 72 { 73 prod = ( prod.slice(0,5) == "phase") ? g_ParsedData.phases[prod] : g_ParsedData.techs[prod];73 prod = (depath(prod).slice(0,5) == "phase") ? g_ParsedData.phases[prod] : g_ParsedData.techs[prod]; 74 74 if (!drawProdIcon(i, s, r, p, prod)) 75 75 break; 76 76 p++; -
binaries/data/mods/public/gui/structree/load.js
function loadUnit(templateName) 46 46 47 47 if (unit.requiredTechnology) 48 48 { 49 if ( unit.requiredTechnology.slice(0, 5) == "phase")49 if (depath(unit.requiredTechnology).slice(0, 5) == "phase") 50 50 unit.phase = unit.requiredTechnology; 51 51 else if (unit.requiredTechnology.length) 52 52 unit.required = unit.requiredTechnology; … … function loadStructure(templateName) 80 80 81 81 if (structure.requiredTechnology) 82 82 { 83 if ( structure.requiredTechnology.slice(0, 5) == "phase")83 if (depath(structure.requiredTechnology).slice(0, 5) == "phase") 84 84 structure.phase = structure.requiredTechnology; 85 85 else if (structure.requiredTechnology.length) 86 86 structure.required = structure.requiredTechnology; -
binaries/data/mods/public/gui/structree/structree.js
var g_CallbackSet = false; 12 12 /** 13 13 * Initialize the dropdown containing all the available civs 14 14 */ 15 function init(data )15 function init(data = {}) 16 16 { 17 17 g_CivData = loadCivData(true); 18 18 … … function selectCiv(civCode) 94 94 { 95 95 let realcode = depath(techcode); 96 96 97 if (realcode.slice(0,4) == "pair" )97 if (realcode.slice(0,4) == "pair" || realcode.indexOf("_pair") > -1) 98 98 techPairs[techcode] = loadTechnologyPair(techcode); 99 99 else if (realcode.slice(0,5) == "phase") 100 100 g_ParsedData.phases[techcode] = loadPhase(techcode); … … function selectCiv(civCode) 108 108 let pair = techPairs[paircode]; 109 109 for (let techcode of pair.techs) 110 110 { 111 let newTech = loadTechnology(techcode);112 113 if (pair.req !== "")111 if (depath(techcode).slice(0, 5) === "phase") 112 g_ParsedData.phases[techcode] = loadPhase(techcode); 113 else 114 114 { 115 if ("generic" in newTech.reqs) 116 newTech.reqs.generic.concat(techPairs[pair.req].techs); 117 else 118 for (let civkey of Object.keys(newTech.reqs)) 119 newTech.reqs[civkey].concat(techPairs[pair.req].techs); 115 let newTech = loadTechnology(techcode); 116 if (pair.req !== "") 117 { 118 if ("generic" in newTech.reqs) 119 newTech.reqs.generic.concat(techPairs[pair.req].techs); 120 else 121 for (let civkey of Object.keys(newTech.reqs)) 122 newTech.reqs[civkey].concat(techPairs[pair.req].techs); 123 } 124 g_ParsedData.techs[techcode] = newTech; 120 125 } 121 g_ParsedData.techs[techcode] = newTech;122 126 } 123 127 } 124 128 125 129 // Establish phase order 126 130 g_ParsedData.phaseList = unravelPhases(g_ParsedData.techs); 127 131 for (let phasecode of g_ParsedData.phaseList) 132 { 133 let phaseInfo = loadTechData(phasecode); 128 134 g_ParsedData.phases[phasecode] = loadPhase(phasecode); 129 135 136 if ("requirements" in phaseInfo) 137 for (let op in phaseInfo.requirements) 138 { 139 let val = phaseInfo.requirements[op]; 140 if (op == "any") 141 for (let v of val) 142 { 143 let k = Object.keys(v); 144 k = k[0]; 145 v = v[k]; 146 if (k == "tech") 147 if (v in g_ParsedData.phases) 148 g_ParsedData.phases[v].actualPhase = phasecode; 149 else if (v in techPairs) 150 for (let t of techPairs[v].techs) 151 g_ParsedData.phases[t].actualPhase = phasecode; 152 } 153 } 154 } 155 130 156 // Group production lists of structures by phase 131 157 for (let structCode of g_Lists.structures) 132 158 { … … function selectCiv(civCode) 151 177 { 152 178 let phase = ""; 153 179 154 if ( prod.slice(0,5) === "phase")180 if (depath(prod).slice(0,5) === "phase") 155 181 { 156 182 phase = g_ParsedData.phaseList.indexOf(g_ParsedData.phases[prod].actualPhase); 157 183 if (phase > 0) … … function selectCiv(civCode) 193 219 let phase = ""; 194 220 195 221 if (unit.phase !== false) 196 phase = unit.phase; 222 if (g_ParsedData.phaseList.indexOf(unit.phase) < 0) 223 phase = g_ParsedData.phases[unit.phase].actualPhase; 224 else 225 phase = unit.phase; 197 226 else if (unit.required !== undefined) 198 227 { 199 let reqs = g_ParsedData.techs[unit.required].reqs; 200 if (g_SelectedCiv in reqs) 201 phase = reqs[g_SelectedCiv][0]; 228 if (unit.required in g_ParsedData.phases) 229 phase = g_ParsedData.phases[unit.required].actualPhase; 202 230 else 203 phase = reqs.generic[0]; 231 { 232 let reqs = g_ParsedData.techs[unit.required].reqs; 233 if (g_SelectedCiv in reqs) 234 phase = reqs[g_SelectedCiv][0]; 235 else 236 phase = reqs.generic[0]; 237 } 204 238 } 205 239 else if (structInfo.phase !== false) 206 240 phase = structInfo.phase; … … function selectCiv(civCode) 229 263 g_ParsedData.structures[structCode].phase = g_ParsedData.phaseList[0]; 230 264 231 265 let myPhase = g_ParsedData.structures[structCode].phase; 266 if (g_ParsedData.phaseList.indexOf(myPhase) === -1) 267 myPhase = g_ParsedData.phases[myPhase].actualPhase; 268 232 269 buildList[myPhase].push(structCode); 233 270 } 234 271