Ticket #1539: gate-cost-2.patch

File gate-cost-2.patch, 4.0 KB (added by Deiz, 12 years ago)
  • binaries/data/mods/public/gui/session/session.xml

     
    863863            size="10 12 100% 100%"
    864864        >
    865865            <object size="0 0 100% 100%">
    866             <repeat count="1">
    867                 <object name="unitGateButton[n]" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottom">
     866            <repeat count="2">
     867                <object name="unitGateButton[n]" hidden="true" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottom">
    868868                <object name="unitGateIcon[n]" type="image" ghost="true" size="3 3 43 43"/>
    869869                <object name="unitGateSelection[n]" hidden="true" type="image" ghost="true" size="3 3 43 43" sprite="stretched:session/icons/corners.png"/>
    870870                </object>
  • binaries/data/mods/public/gui/session/unit_commands.js

     
    2525const BARTER_RESOURCES = ["food", "wood", "stone", "metal"];
    2626const BARTER_ACTIONS = ["Sell", "Buy"];
    2727
     28// Gate constants
     29const GATE_ACTIONS = ["lock", "unlock"];
     30
    2831// The number of currently visible buttons (used to optimise showing/hiding)
    2932var g_unitPanelButtons = {"Selection": 0, "Queue": 0, "Formation": 0, "Garrison": 0, "Training": 0, "Research": 0, "Barter": 0, "Trading": 0, "Construction": 0, "Command": 0, "Stance": 0, "Gate": 0};
    3033
     
    206209            break;
    207210
    208211        case GATE:
    209             if(numberOfItems > 1)
    210                 numberOfItems = 1;
     212            if(numberOfItems > 2)
     213                numberOfItems = 2;
    211214            break;
    212215
    213216        default:
     
    324327                getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : "");
    325328                break;
    326329
     330            case GATE:
     331                var tooltip = toTitleCase(item.tooltip);
     332                if (item.template)
     333                    tooltip += "\n" + getEntityCostTooltip( GetTemplateData(item.template) );
     334                break;
     335
    327336            case STANCE:
    328337            case FORMATION:
    329             case GATE:
    330338                var tooltip = toTitleCase(item);
    331339                break;
    332340
     
    504512            var gateIcon;
    505513            // If already a gate, show (un)lock icon
    506514            if (unitEntState.gate)
    507                 gateIcon = unitEntState.gate.locked ? "gate_unlocked.png" : "gate_locked.png";
     515            {
     516                gateIcon = "lock_" + GATE_ACTIONS[i] + "ed.png";
     517                selection.hidden = unitEntState.gate.locked != item.locked;
     518            }
     519            // otherwise show gate upgrade icon
    508520            else
    509             //  otherwise show gate upgrade icon
    510                 gateIcon = "production.png";
     521            {
     522                gateIcon = "gate_locked.png";
     523                selection.hidden = true;
     524            }
    511525
    512526            icon.sprite = "stretched:session/icons/" + gateIcon;
    513527        }
     
    828842        {
    829843            if (entState.gate)
    830844            {
    831                 var action = entState.gate.locked ? "Unlock gate": "Lock gate";
    832                 setupUnitPanel(GATE, usedPanels, entState, [action],
    833                     function (item) { lockGate(!entState.gate.locked); } );
     845                var items = [];
     846                for (var i = 0; i < GATE_ACTIONS.length; ++i)
     847                    items.push({
     848                        "tooltip": toTitleCase(GATE_ACTIONS[i]) + " Gate",
     849                        "locked": Boolean(!i)
     850                    });
     851                setupUnitPanel(GATE, usedPanels, entState, items,
     852                    function (item) { lockGate(item.locked); } );
    834853            }
    835854            else // Wall
    836855            {
     
    838857                var longPos = entState.template.indexOf("long");
    839858                if (longPos != -1)
    840859                {
    841                     var template = entState.template.substr(0, longPos) + "gate";
    842                     setupUnitPanel(GATE, usedPanels, entState, ["Convert to gate"],
    843                         function (item) { transformWallToGate(template); } );
     860                    var action = { "tooltip": "Convert to Gate" };
     861                    action.template = entState.template.substr(0, longPos) + "gate";
     862                    setupUnitPanel(GATE, usedPanels, entState, [action],
     863                        function (item) { transformWallToGate(action.template); } );
    844864                }
    845865            }
    846866        }