Ticket #3841: 3841_ingame_summary_v1.5.patch

File 3841_ingame_summary_v1.5.patch, 10.5 KB (added by Imarok, 3 years ago)

Some style fixes and one translate more proposed by elexis

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

     
    610610    let gameSpeed = Engine.GetGUIObjectByName("gameSpeed");
    611611    gameSpeed.hidden = !gameSpeed.hidden;
    612612}
    613 
     613/**
     614 * Allows players to see their own summary.
     615 * If they have SharedLos researched, they are able to see the summary of there allies too.
     616 */
    614617function openGameSummary()
    615618{
    616619    closeOpenDialogs();
     
    620623    Engine.PushGuiPage("page_summary.xml", {
    621624        "sim": {
    622625            "mapSettings": g_GameAttributes.settings,
    623             "playerStates": extendedSimState.players,
     626            "playerStates":extendedSimState.players.filter((state,player) =>
     627                g_IsObserver || player == 0 || player == g_ViewedPlayer ||
     628                extendedSimState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]),
    624629            "timeElapsed" : extendedSimState.timeElapsed
    625630        },
    626631        "gui": {
  • binaries/data/mods/public/gui/session/menu.xml

     
    4848            style="StoneButtonFancy"
    4949            size="0 96 100% 124"
    5050            tooltip_style="sessionToolTip"
    51             enabled="false"
    5251        >
    5352            <translatableAttribute id="caption">Summary</translatableAttribute>
    5453            <action on="Press">openGameSummary();</action>
  • binaries/data/mods/public/gui/session/session.js

     
    483483    // Disable stuff observers shouldn't use
    484484    Engine.GetGUIObjectByName("pauseButton").enabled = !g_IsObserver || !g_IsNetworked;
    485485    Engine.GetGUIObjectByName("menuResignButton").enabled = !g_IsObserver;
    486     Engine.GetGUIObjectByName("summaryButton").enabled = g_IsObserver;
    487486}
    488487
    489488function reportPerformance(time)
     
    936935    debug.caption = text.replace(/\[/g, "\\[");
    937936}
    938937
     938function getAllyStatTooltip(resource)
     939{
     940    let playersState = GetSimState().players;
     941    let ret = "";
     942    for (let player in playersState)
     943        if (player != 0 && player != g_ViewedPlayer &&
     944            (g_IsObserver || playersState[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]))
     945            ret += "\n" + sprintf(translate("%(playername)s: %(statValue)s"),{
     946                "playername": colorizePlayernameHelper("■", player) + " " + g_Players[player].name,
     947                "statValue": resource == "pop" ?
     948                    sprintf(translate("%(popCount)s/%(popLimit)s/%(popMax)s"),playersState[player]) :
     949                    playersState[player].resourceCounts[resource]
     950            });
     951    return ret;
     952}
     953
    939954function updatePlayerDisplay()
    940955{
    941956    let playerState = GetSimState().players[g_ViewedPlayer];
     
    942957    if (!playerState)
    943958        return;
    944959
    945     Engine.GetGUIObjectByName("resourceFood").caption = Math.floor(playerState.resourceCounts.food);
    946     Engine.GetGUIObjectByName("resourceWood").caption = Math.floor(playerState.resourceCounts.wood);
    947     Engine.GetGUIObjectByName("resourceStone").caption = Math.floor(playerState.resourceCounts.stone);
    948     Engine.GetGUIObjectByName("resourceMetal").caption = Math.floor(playerState.resourceCounts.metal);
    949     Engine.GetGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
     960    for (let res of RESOURCES)
     961    {
     962        Engine.GetGUIObjectByName("resource_" + res).caption = Math.floor(playerState.resourceCounts[res]);
     963        Engine.GetGUIObjectByName(res).tooltip = localisedResourceNames.firstWord[res] + getAllyStatTooltip(res);
     964    }
     965    Engine.GetGUIObjectByName("resourcePop").caption = sprintf(translate("%(popCount)s/%(popLimit)s"), playerState);
    950966    Engine.GetGUIObjectByName("population").tooltip = translate("Population (current / limit)") + "\n" +
    951                     sprintf(translate("Maximum population: %(popCap)s"), { "popCap": playerState.popMax });
     967        sprintf(translate("Maximum population: %(popCap)s"), { "popCap": playerState.popMax }) +
     968        getAllyStatTooltip("pop");
    952969
    953970    g_IsTrainingBlocked = playerState.trainingBlocked;
    954971}
  • binaries/data/mods/public/gui/session/top_panel/resource_food.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22<object name="food" size="10 0 100 100%" type="image" style="resourceCounter" tooltip_style="sessionToolTipBold">
    3         <translatableAttribute id="tooltip">Food</translatableAttribute>
    43        <object size="0 -4 40 36" type="image" sprite="stretched:session/icons/resources/food.png" ghost="true"/>
    5         <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resourceFood"/>
     4        <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resource_food"/>
    65</object>
  • binaries/data/mods/public/gui/session/top_panel/resource_metal.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22<object name="metal" size="280 0 370 100%" type="image" style="resourceCounter" tooltip_style="sessionToolTipBold">
    3         <translatableAttribute id="tooltip">Metal</translatableAttribute>
    43        <object size="0 -4 40 36" type="image" sprite="stretched:session/icons/resources/metal.png" ghost="true"/>
    5         <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resourceMetal"/>
     4        <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resource_metal"/>
    65</object>
  • binaries/data/mods/public/gui/session/top_panel/resource_stone.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22<object name="stone" size="190 0 280 100%" type="image" style="resourceCounter" tooltip_style="sessionToolTipBold">
    3         <translatableAttribute id="tooltip">Stone</translatableAttribute>
    43        <object size="0 -4 40 36" type="image" sprite="stretched:session/icons/resources/stone.png" ghost="true"/>
    5         <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resourceStone"/>
     4        <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resource_stone"/>
    65</object>
  • binaries/data/mods/public/gui/session/top_panel/resource_wood.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22<object name="wood" size="100 0 190 100%" type="image" style="resourceCounter" tooltip_style="sessionToolTipBold">
    3         <translatableAttribute id="tooltip">Wood</translatableAttribute>
    43        <object size="0 -4 40 36" type="image" sprite="stretched:session/icons/resources/wood.png" ghost="true"/>
    5         <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resourceWood"/>
     4        <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resource_wood"/>
    65</object>
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    107107            "cheatsEnabled": cmpPlayer.GetCheatsEnabled(),
    108108            "disabledTemplates": cmpPlayer.GetDisabledTemplates(),
    109109            "hasSharedDropsites": cmpPlayer.HasSharedDropsites(),
     110            "hasSharedLos": cmpPlayer.HasSharedLos(),
    110111            "phase": phase,
    111112            "isAlly": allies,
    112113            "isMutualAlly": mutualAllies,
  • binaries/data/mods/public/simulation/components/Player.js

     
    545545    return this.startCam !== undefined;
    546546};
    547547
     548Player.prototype.HasSharedLos = function()
     549{
     550    let cmpTechnologyManager = Engine.QueryInterface(this.entity, IID_TechnologyManager);
     551    return cmpTechnologyManager && cmpTechnologyManager.IsTechnologyResearched(this.template.SharedLosTech);
     552};
    548553Player.prototype.HasSharedDropsites = function()
    549554{
    550555    return this.sharedDropsites;
  • binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js

     
    9191    IsEnemy: function() { return true; },
    9292    GetDisabledTemplates: function() { return {}; },
    9393    HasSharedDropsites: function() { return false; },
     94    HasSharedLos: function() { return false; },
    9495});
    9596
    9697AddMock(100, IID_EntityLimits, {
     
    174175    IsEnemy: function() { return false; },
    175176    GetDisabledTemplates: function() { return {}; },
    176177    HasSharedDropsites: function() { return false; },
     178    HasSharedLos: function() { return false; },
    177179});
    178180
    179181AddMock(101, IID_EntityLimits, {
     
    257259            cheatsEnabled: false,
    258260            disabledTemplates: {},
    259261            hasSharedDropsites: false,
     262            hasSharedLos: false,
    260263            phase: "village",
    261264            isAlly: [false, false],
    262265            isMutualAlly: [false, false],
     
    298301            cheatsEnabled: false,
    299302            disabledTemplates: {},
    300303            hasSharedDropsites: false,
     304            hasSharedLos: false,
    301305            phase: "village",
    302306            isAlly: [true, true],
    303307            isMutualAlly: [false, false],
     
    348352            cheatsEnabled: false,
    349353            disabledTemplates: {},
    350354            hasSharedDropsites: false,
     355            hasSharedLos: false,
    351356            phase: "village",
    352357            isAlly: [false, false],
    353358            isMutualAlly: [false, false],
     
    402407            cheatsEnabled: false,
    403408            disabledTemplates: {},
    404409            hasSharedDropsites: false,
     410            hasSharedLos: false,
    405411            phase: "village",
    406412            isAlly: [true, true],
    407413            isMutualAlly: [false, false],