Ticket #3213: rh-side_updated.patch

File rh-side_updated.patch, 7.2 KB (added by s0600204, 9 years ago)

Updated to work with current SVN state

  • binaries/data/mods/public/gui/structree/draw.js

     
    102102            hideRemaining("phase["+i+"]_struct["+s+"]_row[", r, "]");
    103103            ++s;
    104104        }
     105       
    105106        hideRemaining("phase["+i+"]_struct[", s, "]");
    106107        ++i;
    107108    }
     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    }
    108164}
    109165
    110 function drawProdIcon(pha, s, r, p, prod)
     166function drawProdIcon(pha = null, s, r, p, prod)
    111167{
    112168    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
    113172    if (prodEle === undefined)
    114173    {
    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");
    116175        return false;
    117176    }
    118177
     
    236295    }
    237296    hideRemaining("phase[", i, "]");
    238297    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;
    239336}
    240337
    241338/**
  • binaries/data/mods/public/gui/structree/load.js

     
    5454
    5555    unit.gather = getGatherRates(templateName);
    5656
     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
    5769    if (template.Heal)
    5870        unit.healer = {
    5971            "Range": +template.Heal.Range || 0,
  • binaries/data/mods/public/gui/structree/structree.js

     
    224224
    225225    // Determine the buildList for the civ (grouped by phase)
    226226    var buildList = {};
     227    var trainerList = [];
    227228    for (let pha of g_ParsedData.phaseList)
    228229        buildList[pha] = [];
    229230    for (let structCode of g_Lists.structures)
     
    234235        let myPhase = g_ParsedData.structures[structCode].phase;
    235236        buildList[myPhase].push(structCode);
    236237    }
     238    for (let unitCode of g_Lists.units)
     239        if (g_ParsedData.units[unitCode] && g_ParsedData.units[unitCode].trainer)
     240            trainerList.push(unitCode);
    237241
    238242    g_CivData[g_SelectedCiv].buildList = buildList;
     243    g_CivData[g_SelectedCiv].trainList = trainerList;
    239244
    240245    // Draw tree
    241246    draw();
  • binaries/data/mods/public/gui/structree/structree.xml

     
    6161            size="104 52 100%-8 100%"
    6262        />
    6363
    64         <!-- Data display -->
    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">
    6666            <repeat count="4" var="n">
    6767                <object name="phase[n]_phase" type="image"/>
    6868                <object name="phase[n]_bar">
     
    7474                </object>
    7575            </repeat>
    7676
    77             <object type="image" style="TreeDisplay" size="48+16+8 0 100%-16 100%">
     77            <object type="image" style="TreeDisplay" size="48+16+8 0 100%-12 100%">
    7878                <include file="gui/structree/rows.xml"/>
    7979            </object>
     80        </object>
    8081
     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>
    81110        </object>
    82111
    83112        <!-- Close dialog -->