Ticket #4366: 4366_barterUI_v1-1.patch

File 4366_barterUI_v1-1.patch, 22.1 KB (added by s0600204, 2 years ago)

Updated patch

  • binaries/data/mods/public/gui/session/menu.js

    diff --git a/binaries/data/mods/public/gui/session/menu.js b/binaries/data/mods/public/gui/session/menu.js
    index 12f2a025e..b966e0533 100644
    a b const STEP = 5; 
    2828// Shown in the trade dialog.
    2929const g_IdleTraderTextColor = "orange";
    3030
     31const BARTER_RESOURCE_AMOUNT_TO_SELL = 100;
     32const BARTER_BUNCH_MULTIPLIER = 5;
     33const BARTER_ACTIONS = ["Buy", "Sell"];
     34var g_BarterSell;
     35
    3136var g_IsMenuOpen = false;
    3237
    3338var g_IsDiplomacyOpen = false;
    function openTrade() 
    489494
    490495    g_IsTradeOpen = true;
    491496
    492     var updateButtons = function()
     497    let updateTradeButtons = function()
    493498    {
    494499        for (let res in button)
    495500        {
    function openTrade() 
    510515
    511516    for (let i = 0; i < resCodes.length; ++i)
    512517    {
     518        let resCode = resCodes[i];
     519
     520        // Barter
     521        let barterButton = {};
     522        for (let action of BARTER_ACTIONS)
     523            barterButton[action] = Engine.GetGUIObjectByName("barter" + action + "Button[" + i + "]");
     524
     525        if (!g_BarterSell)
     526            g_BarterSell = g_ResourceData.GetCodes()[0];
     527
     528        let resource = getLocalizedResourceName(g_ResourceData.GetNames()[resCode], "withinSentence");
     529        barterButton.Buy.tooltip = sprintf(translate("Buy %(resource)s"), { "resource": resource });
     530        barterButton.Sell.tooltip = sprintf(translate("Sell %(resource)s"), { "resource": resource });
     531
     532        barterButton.Sell.onPress = function() {
     533            g_BarterSell = resCode;
     534        };
     535
     536        setPanelObjectPosition(Engine.GetGUIObjectByName("barterResource[" + i + "]"), i, i+1);
     537
     538        // Trade
    513539        let tradeResource = Engine.GetGUIObjectByName("tradeResource["+i+"]");
    514540        if (!tradeResource)
    515541        {
    function openTrade() 
    519545
    520546        setPanelObjectPosition(tradeResource, i, i+1);
    521547
    522         let resCode = resCodes[i];
    523         proba[resCode] = proba[resCode] || 0;
    524 
    525548        let icon = Engine.GetGUIObjectByName("tradeResourceIcon["+i+"]");
    526549        icon.sprite = "stretched:session/icons/resources/" + resCode + ".png";
    527550
    function openTrade() 
    535558            "sel": Engine.GetGUIObjectByName("tradeResourceSelection["+i+"]")
    536559        };
    537560
     561        proba[resCode] = proba[resCode] || 0;
     562
    538563        let buttonResource = Engine.GetGUIObjectByName("tradeResourceButton["+i+"]");
    539564        buttonResource.enabled = controlsPlayer(g_ViewedPlayer);
    540565        buttonResource.onpress = (function(resource){
    function openTrade() 
    547572                    Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba});
    548573                }
    549574                selec = resource;
    550                 updateButtons();
     575                updateTradeButtons();
    551576            };
    552577        })(resCode);
    553578
    function openTrade() 
    557582                proba[resource] += Math.min(STEP, proba[selec]);
    558583                proba[selec]    -= Math.min(STEP, proba[selec]);
    559584                Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba});
    560                 updateButtons();
     585                updateTradeButtons();
    561586            };
    562587        })(resCode);
    563588
    function openTrade() 
    567592                proba[selec]    += Math.min(STEP, proba[resource]);
    568593                proba[resource] -= Math.min(STEP, proba[resource]);
    569594                Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba});
    570                 updateButtons();
     595                updateTradeButtons();
    571596            };
    572597        })(resCode);
    573598    }
    574     updateButtons();
     599    updateTradeButtons();
    575600
    576601    let traderNumber = Engine.GuiInterfaceCall("GetTraderNumber", g_ViewedPlayer);
    577     Engine.GetGUIObjectByName("landTraders").caption = getIdleLandTradersText(traderNumber);
    578     Engine.GetGUIObjectByName("shipTraders").caption = getIdleShipTradersText(traderNumber);
     602    Engine.GetGUIObjectByName("traders").caption = getIdleLandTradersText(traderNumber) + "\n\n" + getIdleShipTradersText(traderNumber);
    579603    Engine.GetGUIObjectByName("tradeDialogPanel").hidden = false;
    580604}
    581605
     606function updateBarterButtons()
     607{
     608    let resCodes = g_ResourceData.GetCodes();
     609    if (!g_BarterSell)
     610        g_BarterSell = resCodes[0];
     611
     612    let canBarter = Engine.GuiInterfaceCall("PlayerCanBarter", g_ViewedPlayer);
     613    Engine.GetGUIObjectByName("barterNoMarketsMessage").hidden = canBarter;
     614    Engine.GetGUIObjectByName("barterResources").hidden = !canBarter;
     615    if (!canBarter)
     616        return;
     617
     618    for (let i = 0; i < resCodes.length; ++i)
     619    {
     620        let resCode = resCodes[i];
     621        let barterButton = {};
     622        let barterIcon = {};
     623        let barterAmount = {};
     624        for (let action of BARTER_ACTIONS)
     625        {
     626            barterButton[action] = Engine.GetGUIObjectByName("barter" + action + "Button[" + i + "]");
     627            barterIcon[action] = Engine.GetGUIObjectByName("barter" + action + "Icon[" + i + "]");
     628            barterAmount[action] = Engine.GetGUIObjectByName("barter" + action + "Amount[" + i + "]");
     629        }
     630        let selectionIcon = Engine.GetGUIObjectByName("barterSellSelection[" + i + "]");
     631
     632        let amountToSell = BARTER_RESOURCE_AMOUNT_TO_SELL;
     633        if (Engine.HotkeyIsPressed("session.massbarter"))
     634            amountToSell *= BARTER_BUNCH_MULTIPLIER;
     635
     636        let isSelected = resCode == g_BarterSell;
     637        let grayscale = isSelected ? "color: 0 0 0 100:grayscale:" : "";
     638
     639        // do we have enough of this resource to sell?
     640        let neededRes = {};
     641        neededRes[resCode] = amountToSell;
     642        let canSellCurrent = Engine.GuiInterfaceCall("GetNeededResources", {
     643            "cost": neededRes,
     644            "player": g_ViewedPlayer
     645        }) ? "color:255 0 0 80:" : "";
     646
     647        // Let's see if we have enough resources to barter.
     648        neededRes = {};
     649        neededRes[g_BarterSell] = amountToSell;
     650        let canBuyAny = Engine.GuiInterfaceCall("GetNeededResources", {
     651            "cost": neededRes,
     652            "player": g_ViewedPlayer
     653        }) ? "color:255 0 0 80:" : "";
     654
     655        barterIcon.Sell.sprite = canSellCurrent + "stretched:" + grayscale + "session/icons/resources/" + resCode + ".png";
     656        barterIcon.Buy.sprite = canBuyAny + "stretched:" + grayscale + "session/icons/resources/" + resCode + ".png";
     657
     658        barterAmount.Sell.caption = "-" + amountToSell;
     659        let prices = Engine.GuiInterfaceCall("GetBarterPrices");
     660        barterAmount.Buy.caption = "+" + Math.round(prices.sell[g_BarterSell] / prices.buy[resCode] * amountToSell);
     661
     662        barterButton.Buy.onPress = function() {
     663            Engine.PostNetworkCommand({
     664                "type": "barter",
     665                "sell": g_BarterSell,
     666                "buy": resCode,
     667                "amount": amountToSell
     668            });
     669        };
     670
     671        barterButton.Buy.hidden = isSelected;
     672        barterButton.Buy.enabled = controlsPlayer(g_ViewedPlayer);
     673        barterButton.Sell.hidden = false;
     674        selectionIcon.hidden = !isSelected;
     675    }
     676};
     677
    582678function getIdleLandTradersText(traderNumber)
    583679{
    584680    let active = traderNumber.landTrader.trading;
  • binaries/data/mods/public/gui/session/selection_panels.js

    diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js
    index 6bc6e12be..b7a98d06b 100644
    a b let g_FormationsInfo = new Map(); 
    3333
    3434let g_SelectionPanels = {};
    3535
    36 let g_BarterSell;
    37 
    3836g_SelectionPanels.Alert = {
    3937    "getMaxNumberOfItems": function()
    4038    {
    4139        return 3;
    4240    },
    43     "conflictsWith": ["Barter"],
     41    "conflictsWith": [],
    4442    "getItems": function(unitEntStates)
    4543    {
    4644        let ret = [];
    g_SelectionPanels.Alert = { 
    9593    }
    9694};
    9795
    98 g_SelectionPanels.Barter = {
    99     "getMaxNumberOfItems": function()
    100     {
    101         return 4;
    102     },
    103     "rowLength": 4,
    104     "conflictsWith": ["Alert", "Garrison"],
    105     "getItems": function(unitEntStates)
    106     {
    107         if (unitEntStates.every(state => !state.barterMarket))
    108             return [];
    109         return g_ResourceData.GetCodes();
    110     },
    111     "setupButton": function(data)
    112     {
    113         // data.item is the resource name in this case
    114         let button = {};
    115         let icon = {};
    116         let amount = {};
    117         for (let a of BARTER_ACTIONS)
    118         {
    119             button[a] = Engine.GetGUIObjectByName("unitBarter" + a + "Button[" + data.i + "]");
    120             icon[a] = Engine.GetGUIObjectByName("unitBarter" + a + "Icon[" + data.i + "]");
    121             amount[a] = Engine.GetGUIObjectByName("unitBarter" + a + "Amount[" + data.i + "]");
    122         }
    123         let selectionIcon = Engine.GetGUIObjectByName("unitBarterSellSelection[" + data.i + "]");
    124 
    125         let amountToSell = BARTER_RESOURCE_AMOUNT_TO_SELL;
    126         if (Engine.HotkeyIsPressed("session.massbarter"))
    127             amountToSell *= BARTER_BUNCH_MULTIPLIER;
    128 
    129         if (!g_BarterSell)
    130             g_BarterSell = g_ResourceData.GetCodes()[0];
    131 
    132         amount.Sell.caption = "-" + amountToSell;
    133         let prices;
    134         for (let state of data.unitEntStates)
    135             if (state.barterMarket)
    136             {
    137                 prices = state.barterMarket.prices;
    138                 break;
    139             }
    140 
    141         amount.Buy.caption = "+" + Math.round(prices.sell[g_BarterSell] / prices.buy[data.item] * amountToSell);
    142 
    143         let resource = getLocalizedResourceName(g_ResourceData.GetNames()[data.item], "withinSentence");
    144         button.Buy.tooltip = sprintf(translate("Buy %(resource)s"), { "resource": resource });
    145         button.Sell.tooltip = sprintf(translate("Sell %(resource)s"), { "resource": resource });
    146 
    147         button.Sell.onPress = function() {
    148             g_BarterSell = data.item;
    149             updateSelectionDetails();
    150         };
    151 
    152         button.Buy.onPress = function() {
    153             Engine.PostNetworkCommand({
    154                 "type": "barter",
    155                 "sell": g_BarterSell,
    156                 "buy": data.item,
    157                 "amount": amountToSell
    158             });
    159         };
    160 
    161         let isSelected = data.item == g_BarterSell;
    162         let grayscale = isSelected ? "color: 0 0 0 100:grayscale:" : "";
    163 
    164         // do we have enough of this resource to sell?
    165         let neededRes = {};
    166         neededRes[data.item] = amountToSell;
    167         let canSellCurrent = Engine.GuiInterfaceCall("GetNeededResources", {
    168             "cost": neededRes,
    169             "player": data.player
    170         }) ? "color:255 0 0 80:" : "";
    171 
    172         // Let's see if we have enough resources to barter.
    173         neededRes = {};
    174         neededRes[g_BarterSell] = amountToSell;
    175         let canBuyAny = Engine.GuiInterfaceCall("GetNeededResources", {
    176             "cost": neededRes,
    177             "player": data.player
    178         }) ? "color:255 0 0 80:" : "";
    179 
    180         icon.Sell.sprite = canSellCurrent + "stretched:" + grayscale + "session/icons/resources/" + data.item + ".png";
    181         icon.Buy.sprite = canBuyAny + "stretched:" + grayscale + "session/icons/resources/" + data.item + ".png";
    182 
    183         button.Buy.hidden = isSelected;
    184         button.Buy.enabled = controlsPlayer(data.player);
    185         button.Sell.hidden = false;
    186         selectionIcon.hidden = !isSelected;
    187 
    188         setPanelObjectPosition(button.Sell, data.i, data.rowLength);
    189         setPanelObjectPosition(button.Buy, data.i + data.rowLength, data.rowLength);
    190         return true;
    191     }
    192 };
    193 
    19496g_SelectionPanels.Command = {
    19597    "getMaxNumberOfItems": function()
    19698    {
    g_SelectionPanels.Garrison = { 
    430332        return 12;
    431333    },
    432334    "rowLength": 4,
    433     "conflictsWith": ["Barter"],
     335    "conflictsWith": [],
    434336    "getItems": function(unitEntStates)
    435337    {
    436338        if (unitEntStates.every(state => !state.garrisonHolder))
    g_SelectionPanels.Upgrade = { 
    12171119 */
    12181120let g_PanelsOrder = [
    12191121    // LEFT PANE
    1220     "Barter", // Must always be visible on markets
    12211122    "Garrison", // More important than Formation, as you want to see the garrisoned units in ships
    12221123    "Alert",
    12231124    "Formation",
  • binaries/data/mods/public/gui/session/selection_panels_helpers.js

    diff --git a/binaries/data/mods/public/gui/session/selection_panels_helpers.js b/binaries/data/mods/public/gui/session/selection_panels_helpers.js
    index 6b9f507d6..e5b1f0354 100644
    a b  
    1 const BARTER_RESOURCE_AMOUNT_TO_SELL = 100;
    2 const BARTER_BUNCH_MULTIPLIER = 5;
    3 const BARTER_ACTIONS = ["Sell", "Buy"];
    41const GATE_ACTIONS = ["lock", "unlock"];
    52
    63const UPGRADING_NOT_STARTED = -2;
  • deleted file binaries/data/mods/public/gui/session/selection_panels_left/barter_panel.xml

    diff --git a/binaries/data/mods/public/gui/session/selection_panels_left/barter_panel.xml b/binaries/data/mods/public/gui/session/selection_panels_left/barter_panel.xml
    deleted file mode 100644
    index 85de11deb..000000000
    + -  
    1 <?xml version="1.0" encoding="utf-8"?>
    2 <object name="unitBarterPanel"
    3     size="4 68 100% 100%"
    4     hidden="true"
    5 >
    6     <repeat count="4">
    7 
    8         <!-- Sell -->
    9         <object name="unitBarterSellButton[n]" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottomBold" hidden="true">
    10             <object name="unitBarterSellIcon[n]" type="image" ghost="true" size="3 3 100%-3 100%-3"/>
    11             <object name="unitBarterSellAmount[n]" ghost="true" style="resourceText" type="text" size="0 0 100% 50%"/>
    12             <object name="unitBarterSellSelection[n]" hidden="true" type="image" ghost="true" size="3 3 100%-3 100%-3" sprite="stretched:session/icons/corners.png"/>
    13         </object>
    14 
    15         <!-- Buy -->
    16         <object name="unitBarterBuyButton[n]" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottomBold" hidden="true">
    17             <object name="unitBarterBuyIcon[n]" type="image" ghost="true" size="3 3 100%-3 100%-3"/>
    18             <object name="unitBarterBuyAmount[n]" ghost="true" style="resourceText" type="text" size="0 0 100% 50%"/>
    19         </object>
    20 
    21     </repeat>
    22 
    23 </object>
  • binaries/data/mods/public/gui/session/session.js

    diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js
    index e2b43aae5..469ede741 100644
    a b function updateGUIObjects() 
    768768    updateBuildingPlacementPreview();
    769769    updateTimeNotifications();
    770770    updateIdleWorkerButton();
     771    updateBarterButtons();
    771772
    772773    if (g_ViewedPlayer > 0)
    773774    {
  • binaries/data/mods/public/gui/session/top_panel/button_trade.xml

    diff --git a/binaries/data/mods/public/gui/session/top_panel/button_trade.xml b/binaries/data/mods/public/gui/session/top_panel/button_trade.xml
    index 787c1f760..6f59e92aa 100644
    a b  
    77>
    88    <!-- TODO make the button less ugly -->
    99    <object size="0 0 100% 100%" name="tradeButtonImage" type="image" sprite="stretched:session/icons/economics.png" ghost="true"/>
    10     <translatableAttribute id="tooltip">Trade</translatableAttribute>
     10    <translatableAttribute id="tooltip">Barter &amp; Trade</translatableAttribute>
    1111    <action on="Press">
    1212        toggleTrade();
    1313    </action>
  • binaries/data/mods/public/gui/session/trade_window.xml

    diff --git a/binaries/data/mods/public/gui/session/trade_window.xml b/binaries/data/mods/public/gui/session/trade_window.xml
    index 537eac505..f4d0d66de 100644
    a b  
    11<?xml version="1.0" encoding="utf-8"?>
    22<object name="tradeDialogPanel"
    3     size="50%-134 50%-130 50%+134 50%+100"
     3    size="50%-80 50%-280 50%+80 50%+136"
    44    type="image"
    55    hidden="true"
    66    sprite="ModernDialog"
     7    z="100"
    78>
    89    <object type="text" style="TitleText" size="50%-96 -16 50%+96 16">
    9         <translatableAttribute id="caption">Trade</translatableAttribute>
     10        <translatableAttribute id="caption">Barter &amp; Trade Goods</translatableAttribute>
    1011    </object>
    1112
    12     <!-- Trading goods -->
    13     <object name="tradeGoods" size="20 50 100%-20 82">
    14         <object name="tradeHeader" size="0 0 180 100%" type="text" style="ModernLabelText" text_align="left" ghost="true">
    15             <translatableAttribute id="caption">Trading goods selection:</translatableAttribute>
     13
     14    <!-- Barter Goods -->
     15    <object size="24 24 100%-24 33%">
     16
     17        <object name="barterHeader" size="8 0 100% 32" type="text" style="ModernLeftLabelText">
     18            <translatableAttribute id="caption">Barter</translatableAttribute>
    1619        </object>
     20        <object size="0 28 100% 29" type="image" sprite="ModernGoldLine"/>
     21
     22        <object size="0 38 100% 122">
     23
     24            <object size="0 0 60 41" type="text" style="ModernRightLabelText">
     25                <translatableAttribute id="caption">Sell:</translatableAttribute>
     26            </object>
     27
     28            <object size="0 100%-41 60 100%" type="text" style="ModernRightLabelText">
     29                <translatableAttribute id="caption">Buy:</translatableAttribute>
     30            </object>
     31
     32            <object size="72 0 100% 100%" type="text" style="ModernLabelText" name="barterNoMarketsMessage">
     33                <translatableAttribute id="caption">No Markets Available</translatableAttribute>
     34            </object>
     35
     36            <object name="barterResources" size="72 0 100% 100%">
     37                <repeat count="8">
     38                    <object name="barterResource[n]" size="0 0 58 100%">
     39
     40                        <!-- Sell -->
     41                        <object name="barterSellButton[n]" style="iconButton" type="button" size="0 0 41 41" tooltip_style="sessionToolTipBottomBold" hidden="true">
     42                            <object name="barterSellIcon[n]" type="image" ghost="true" size="3 3 100%-3 100%-3"/>
     43                            <object name="barterSellAmount[n]" ghost="true" style="resourceText" type="text" size="0 0 100% 50%"/>
     44                            <object name="barterSellSelection[n]" hidden="true" type="image" ghost="true" size="3 3 100%-3 100%-3" sprite="stretched:session/icons/corners.png"/>
     45                        </object>
     46
     47                        <!-- Buy -->
     48                        <object name="barterBuyButton[n]" style="iconButton" type="button" size="0 100%-41 41 100%" tooltip_style="sessionToolTipBottomBold" hidden="true">
     49                            <object name="barterBuyIcon[n]" type="image" ghost="true" size="3 3 100%-3 100%-3"/>
     50                            <object name="barterBuyAmount[n]" ghost="true" style="resourceText" type="text" size="0 0 100% 50%"/>
     51                        </object>
    1752
    18         <object size="180 0 100% 100%" name="tradeResources">
    19             <repeat count="8">
    20                 <object name="tradeResource[n]" size="0 0 58 32">
    21                     <object name="tradeResourceButton[n]" size="4 0 36 100%" type="button" style="StoneButton">
    22                         <object name="tradeResourceIcon[n]" type="image" ghost="true"/>
    23                         <object name="tradeResourceSelection[n]" type="image" sprite="stretched:session/icons/corners.png" ghost="true"/>
    24                         <object name="tradeResourceText[n]" type="text" style="ModernLabelText" ghost="true"/>
    25                     </object>
    26                     <object name="tradeArrowUp[n]" size="36 0 52 50%" type="button" style="iconButton">
    27                         <object type="image" ghost="true" sprite="StoneArrowUp"/>
    2853                    </object>
    29                     <object name="tradeArrowDn[n]" size="36 50% 52 100%" type="button" style="iconButton">
    30                         <object type="image" ghost="true" sprite="StoneArrowDn"/>
     54                </repeat>
     55            </object>
     56
     57        </object>
     58    </object>
     59
     60    <!-- Trading goods -->
     61    <object size="24 33%+32 100%-24 100%-64">
     62
     63        <object name="tradeHeader" size="8 0 100% 32" type="text" style="ModernLeftLabelText">
     64            <translatableAttribute id="caption">Trade</translatableAttribute>
     65        </object>
     66        <object size="0 28 100% 29" type="image" sprite="ModernGoldLine"/>
     67
     68        <object name="tradeGoods" size="0 38 100% 70">
     69
     70            <object size="0 0 60 100%" type="text" style="ModernRightLabelText">
     71                <translatableAttribute id="caption">Goods:</translatableAttribute>
     72            </object>
     73
     74            <object size="72 0 100% 100%" name="tradeResources">
     75                <repeat count="8">
     76                    <object name="tradeResource[n]" size="0 0 58 32">
     77
     78                        <object name="tradeResourceButton[n]" size="4 0 36 100%" type="button" style="StoneButton">
     79                            <object name="tradeResourceIcon[n]" type="image" ghost="true"/>
     80                            <object name="tradeResourceSelection[n]" type="image" sprite="stretched:session/icons/corners.png" ghost="true"/>
     81                            <object name="tradeResourceText[n]" type="text" style="ModernLabelText" ghost="true"/>
     82                        </object>
     83                        <object name="tradeArrowUp[n]" size="36 0 52 50%" type="button" style="iconButton">
     84                            <object type="image" ghost="true" sprite="StoneArrowUp"/>
     85                        </object>
     86                        <object name="tradeArrowDn[n]" size="36 50% 52 100%" type="button" style="iconButton">
     87                            <object type="image" ghost="true" sprite="StoneArrowDn"/>
     88                        </object>
     89
    3190                    </object>
    32                 </object>
    33             </repeat>
     91                </repeat>
     92            </object>
     93
    3494            <object name="tradeHelp" size="100%-24 4 100% 28" enabled="false" type="button" style="StoneButton" tooltip_style="sessionToolTipBold">
    3595                <object size="20% 15% 80% 75%" type="image" ghost="true" sprite="iconInfoWhite"/>
    3696            </object>
     97
    3798        </object>
    38     </object>
    3999
    40     <object name="tradeStatistics" size="20 90 100%-20 168">
    41         <object name="landTraders" size="0 0 100% 50%" type="text" style="ModernLabelText" text_align="left" ghost="true" />
    42         <object name="shipTraders" size="0 50% 100% 100%" type="text" style="ModernLabelText" text_align="left" ghost="true" />
     100        <object name="traders" size="8 88 100% 100%" type="text" style="ModernLeftTabLabelText"/>
     101
    43102    </object>
    44103
    45104    <object size="50%-64 100%-50 50%+64 100%-22" type="button" style="StoneButton">
  • binaries/data/mods/public/gui/session/unit_actions.js

    diff --git a/binaries/data/mods/public/gui/session/unit_actions.js b/binaries/data/mods/public/gui/session/unit_actions.js
    index 4f8e7b2ef..297dc9176 100644
    a b var g_EntityCommands = 
    12601260                return false;
    12611261
    12621262            return {
    1263                 "tooltip": translate("Select trading goods"),
     1263                "tooltip": translate("Barter & Trade"),
    12641264                "icon": "economics.png"
    12651265            };
    12661266        },
  • binaries/data/mods/public/simulation/components/GuiInterface.js

    diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js
    index 932c8cd3d..f548fc3f0 100644
    a b GuiInterface.prototype.GetSimulationState = function() 
    150150    ret.alliedVictory = cmpEndGameManager.GetAlliedVictory();
    151151
    152152    // Add bartering prices
    153     let cmpBarter = Engine.QueryInterface(SYSTEM_ENTITY, IID_Barter);
    154     ret.barterPrices = cmpBarter.GetPrices();
     153    ret.barterPrices = this.GetBarterPrices();
    155154
    156155    // Add Resource Codes, untranslated names and AI Analysis
    157156    ret.resources = {
    GuiInterface.prototype.GetExtendedEntityState = function(player, ent) 
    565564        };
    566565
    567566    if (!cmpFoundation && cmpIdentity && cmpIdentity.HasClass("BarterMarket"))
    568     {
    569         let cmpBarter = Engine.QueryInterface(SYSTEM_ENTITY, IID_Barter);
    570         ret.barterMarket = { "prices": cmpBarter.GetPrices() };
    571     }
     567        ret.barterMarket = { "prices": this.GetBarterPrices() };
    572568
    573569    let cmpHeal = Engine.QueryInterface(ent, IID_Heal);
    574570    if (cmpHeal)
    GuiInterface.prototype.GetTradingGoods = function(player) 
    19541950    return QueryPlayerIDInterface(player).GetTradingGoods();
    19551951};
    19561952
     1953GuiInterface.prototype.GetBarterPrices = function()
     1954{
     1955    return Engine.QueryInterface(SYSTEM_ENTITY, IID_Barter).GetPrices();
     1956};
     1957
     1958GuiInterface.prototype.PlayerCanBarter = function(player)
     1959{
     1960    let playerEnt = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetPlayerByID(player);
     1961    return Engine.QueryInterface(SYSTEM_ENTITY, IID_Barter).PlayerHasMarket(playerEnt);
     1962};
     1963
    19571964GuiInterface.prototype.OnGlobalEntityRenamed = function(msg)
    19581965{
    19591966    this.renamedEntities.push(msg);
    let exposedFunctions = { 
    20182025
    20192026    "GetTraderNumber": 1,
    20202027    "GetTradingGoods": 1,
     2028    "GetBarterPrices": 1,
     2029    "PlayerCanBarter": 1,
    20212030};
    20222031
    20232032GuiInterface.prototype.ScriptCall = function(player, name, args)