Ticket #3213: rh-side.patch
File rh-side.patch, 7.6 KB (added by , 9 years ago) |
---|
-
gui/structree/draw.js
function draw() 102 102 hideRemaining("phase["+i+"]_struct["+s+"]_row[", r, "]"); 103 103 ++s; 104 104 } 105 105 106 hideRemaining("phase["+i+"]_struct[", s, "]"); 106 107 ++i; 107 108 } 109 110 var t = 0; 111 for (let trainer of g_CivData[g_SelectedCiv].trainList) 112 { 113 let thisEle = Engine.GetGUIObjectByName("trainer["+t+"]"); 114 if (thisEle === undefined) 115 { 116 error("\""+g_SelectedCiv+"\" has more unit trainers than can be supported by the current GUI layout"); 117 break; 118 } 119 120 trainer = g_ParsedData.units[trainer]; 121 Engine.GetGUIObjectByName("trainer["+t+"]_icon").sprite = "stretched:session/portraits/"+trainer.icon; 122 Engine.GetGUIObjectByName("trainer["+t+"]_icon").tooltip = assembleTooltip(trainer); 123 Engine.GetGUIObjectByName("trainer["+t+"]_name").caption = translate(trainer.name.specific); 124 thisEle.hidden = false; 125 126 let p = 0; 127 for (let prod of trainer.trainer) 128 { 129 prod = g_ParsedData.units[prod]; 130 if (!drawProdIcon(null, t, null, p, prod)) 131 break; 132 p++; 133 } 134 hideRemaining("trainer["+t+"]_prod[", p, "]"); 135 136 let size = thisEle.size; 137 size.right = size.left + ((p*24 < defWidth)?defWidth:p*24)+4; 138 thisEle.size = size; 139 140 let eleWidth = size.right - size.left; 141 let wid = p * 24 - 4; 142 let phaEle = Engine.GetGUIObjectByName("trainer["+t+"]_row"); 143 size = phaEle.size; 144 size.left = (eleWidth - wid)/2; 145 phaEle.size = size; 146 ++t; 147 } 148 hideRemaining("trainer[", t, "]"); 149 150 if (t > 0) 151 { 152 Engine.GetGUIObjectByName("display_trainers").hidden = false; 153 var size = Engine.GetGUIObjectByName("display_tree").size; 154 size.right = -124; 155 Engine.GetGUIObjectByName("display_tree").size = size; 156 } 157 else 158 { 159 Engine.GetGUIObjectByName("display_trainers").hidden = true; 160 var size = Engine.GetGUIObjectByName("display_tree").size; 161 size.right = -4; 162 Engine.GetGUIObjectByName("display_tree").size = size; 163 } 108 164 } 109 165 110 function drawProdIcon(pha , s, r, p, prod)166 function drawProdIcon(pha = null, s, r, p, prod) 111 167 { 112 168 var prodEle = Engine.GetGUIObjectByName("phase["+pha+"]_struct["+s+"]_row["+r+"]_prod["+p+"]"); 169 if (pha === null) 170 prodEle = Engine.GetGUIObjectByName("trainer["+s+"]_prod["+p+"]"); 171 113 172 if (prodEle === undefined) 114 173 { 115 error("The structures of \""+g_SelectedCiv+"\" have more production icons in phase "+pha+"than can be supported by the current GUI layout");174 error("The "+(pha === null ? "trainer units" : "structures")+" of \""+g_SelectedCiv+"\" have more production icons than can be supported by the current GUI layout"); 116 175 return false; 117 176 } 118 177 … … function predraw() 236 295 } 237 296 hideRemaining("phase[", i, "]"); 238 297 hideRemaining("phase[", i, "]_bar"); 298 299 var t = 0; 300 var ele = Engine.GetGUIObjectByName("trainer["+t+"]"); 301 g_DrawLimits.trainer = { 302 trainerQuant: 0, 303 prodQuant: 0 304 } 305 306 var x = 4; 307 do 308 { 309 let p = 0; 310 let prodEle = Engine.GetGUIObjectByName("trainer["+t+"]_prod["+p+"]"); 311 do 312 { 313 let prodsize = prodEle.size; 314 prodsize.left = (initIconSize.right+4) * p; 315 prodsize.right = (initIconSize.right+4) * (p+1) - 4; 316 prodEle.size = prodsize; 317 318 p++; 319 prodEle = Engine.GetGUIObjectByName("trainer["+t+"]_prod["+p+"]"); 320 } while (prodEle !== undefined); 321 Engine.GetGUIObjectByName("trainer["+t+"]_row").size = "4 100%-24"+" 100%-4 100%"; 322 g_DrawLimits.trainer.prodQuant = p; 323 324 let size = ele.size; 325 size.top += x 326 size.bottom += x + 24; 327 x += size.bottom - size.top + 8; 328 ele.size = size; 329 330 t++; 331 ele = Engine.GetGUIObjectByName("trainer["+t+"]"); 332 333 } while (ele !== undefined); 334 335 g_DrawLimits.trainer.trainerQuant = t; 239 336 } 240 337 241 338 /** -
gui/structree/load.js
function loadUnit(templateName) 54 54 55 55 unit.gather = getGatherRates(templateName); 56 56 57 if (template.ProductionQueue) 58 { 59 unit.trainer = []; 60 for (let build of template.ProductionQueue.Entities._string.split(" ")) 61 { 62 build = build.replace("{civ}", g_SelectedCiv); 63 unit.trainer.push(build); 64 if (g_Lists.units.indexOf(build) < 0) 65 g_Lists.units.push(build); 66 } 67 } 68 57 69 if (template.Heal) 58 70 unit.healer = { 59 71 "Range": +template.Heal.Range || 0, -
gui/structree/rows.xml
3 3 <object name="phase_rows"> 4 4 <repeat count="4" var="k"> 5 5 <object name="phase[k]"> 6 <repeat count="1 1" var="s">6 <repeat count="12" var="s"> 7 7 <object type="image" style="StructBox" name="phase[k]_struct[s]"> 8 8 <object type="text" style="StructNameSpecific" name="phase[k]_struct[s]_name"/> 9 9 <object type="image" style="StructIcon" name="phase[k]_struct[s]_icon" -
gui/structree/structree.js
function selectCiv(civCode) 221 221 222 222 // Determine the buildList for the civ (grouped by phase) 223 223 var buildList = {}; 224 var trainerList = []; 224 225 for (let pha of g_ParsedData.phaseList) 225 226 buildList[pha] = []; 226 227 for (let structCode of g_Lists.structures) … … function selectCiv(civCode) 231 232 let myPhase = g_ParsedData.structures[structCode].phase; 232 233 buildList[myPhase].push(structCode); 233 234 } 235 for (let unitCode of g_Lists.units) 236 if (g_ParsedData.units[unitCode] && g_ParsedData.units[unitCode].trainer) 237 trainerList.push(unitCode); 234 238 235 239 g_CivData[g_SelectedCiv].buildList = buildList; 240 g_CivData[g_SelectedCiv].trainList = trainerList; 236 241 237 242 // Draw tree 238 243 draw(); -
gui/structree/structree.xml
61 61 size="104 52 100%-8 100%" 62 62 /> 63 63 64 <!-- Datadisplay -->65 <object size="0 54+64 100% 100%-54">64 <!-- Structure Tree display --> 65 <object size="0 54+64 100%-124 100%-54" name="display_tree"> 66 66 <repeat count="4" var="n"> 67 67 <object name="phase[n]_phase" type="image"/> 68 68 <object name="phase[n]_bar"> … … 74 74 </object> 75 75 </repeat> 76 76 77 <object type="image" style="TreeDisplay" size="48+16+8 0 100%-1 6100%">77 <object type="image" style="TreeDisplay" size="48+16+8 0 100%-12 100%"> 78 78 <include file="gui/structree/rows.xml"/> 79 79 </object> 80 </object> 80 81 82 <!-- Trainer Units display --> 83 <object size="100%-124 54+64 100%-16 100%-54" name="display_trainers"> 84 <object 85 type="text" 86 font="sans-bold-14" 87 textcolor="white" 88 text_align="center" 89 text_valign="top" 90 size="0 0 100% 16" 91 > 92 <translatableAttribute id="caption">Trainer Units</translatableAttribute> 93 </object> 94 95 <object type="image" style="TreeDisplay" size="0 24 100% 100%"> 96 <repeat count="3" var="t"> 97 <object type="image" style="StructBox" name="trainer[t]"> 98 <object type="text" style="StructNameSpecific" name="trainer[t]_name"/> 99 <object type="image" style="StructIcon" name="trainer[t]_icon" 100 sprite="stretched:pregame/shell/logo/wfg_logo_white.png" 101 /> 102 <object name="trainer[t]_row"> 103 <repeat count="4" var="p"> 104 <object type="image" style="ProdBox" name="trainer[t]_prod[p]"/> 105 </repeat> 106 </object> 107 </object> 108 </repeat> 109 </object> 81 110 </object> 82 111 83 112 <!-- Close dialog -->