Ticket #3841: 3841_ingame_summary_v1.1.patch

File 3841_ingame_summary_v1.1.patch, 8.0 KB (added by Imarok, 2 years ago)

style fixes. use map and filter. Don't introduce a new variable for hasSharedLos

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

     
    617617    pauseGame();
    618618
    619619    let extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState");
     620    let playersToShow = [];
     621
     622    playersToShow = extendedSimState.players.filter((state,player) =>
     623                        g_IsObserver || player == 0 || player == g_ViewedPlayer ||
     624                        extendedSimState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]);
     625
    620626    Engine.PushGuiPage("page_summary.xml", {
    621627        "sim": {
    622628            "mapSettings": g_GameAttributes.settings,
    623             "playerStates": extendedSimState.players,
     629            "playerStates": playersToShow,
    624630            "timeElapsed" : extendedSimState.timeElapsed
    625631        },
    626632        "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

     
    480480    // Disable stuff observers shouldn't use
    481481    Engine.GetGUIObjectByName("pauseButton").enabled = !g_IsObserver || !g_IsNetworked;
    482482    Engine.GetGUIObjectByName("menuResignButton").enabled = !g_IsObserver;
    483     Engine.GetGUIObjectByName("summaryButton").enabled = g_IsObserver;
    484483}
    485484
    486485function reportPerformance(time)
     
    933932    debug.caption = text.replace(/\[/g, "\\[");
    934933}
    935934
     935function getAllyStatTooltip(resource)
     936{
     937    let playersState = GetSimState().players;
     938
     939    return playersState.map((state, player) => sprintf(translate("\n%(playername)s: %(statValue)s"),{
     940        "playername": colorizePlayernameByID(player),
     941        "statValue": resource == "pop" ? state.popCount + "/" + state.popLimit : state.resourceCounts[resource]
     942    })).filter((state, player) =>
     943        player != 0 && player != g_ViewedPlayer &&
     944        (g_IsObserver || playersState[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer])).join("");
     945}
     946
    936947function updatePlayerDisplay()
    937948{
    938949    let playerState = GetSimState().players[g_ViewedPlayer];
     
    939950    if (!playerState)
    940951        return;
    941952
    942     Engine.GetGUIObjectByName("resourceFood").caption = Math.floor(playerState.resourceCounts.food);
    943     Engine.GetGUIObjectByName("resourceWood").caption = Math.floor(playerState.resourceCounts.wood);
    944     Engine.GetGUIObjectByName("resourceStone").caption = Math.floor(playerState.resourceCounts.stone);
    945     Engine.GetGUIObjectByName("resourceMetal").caption = Math.floor(playerState.resourceCounts.metal);
     953    let translatedResources = {
     954        "food": translate("Food"),
     955        "wood": translate("Wood"),
     956        "stone": translate("Stone"),
     957        "metal": translate("Metal")
     958    }
     959    for (let res of RESOURCES)
     960    {
     961        Engine.GetGUIObjectByName("resource_" + res).caption = Math.floor(playerState.resourceCounts[res]);
     962        Engine.GetGUIObjectByName(res).tooltip = translatedResources[res] + getAllyStatTooltip(res);
     963    }
    946964    Engine.GetGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
    947965    Engine.GetGUIObjectByName("population").tooltip = translate("Population (current / limit)") + "\n" +
    948                     sprintf(translate("Maximum population: %(popCap)s"), { "popCap": playerState.popMax });
     966                    sprintf(translate("Maximum population: %(popCap)s"), { "popCap": playerState.popMax }) +
     967                    getAllyStatTooltip("pop");
    949968
    950969    g_IsTrainingBlocked = playerState.trainingBlocked;
    951970}
  • 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

     
    106106            "teamsLocked": cmpPlayer.GetLockTeams(),
    107107            "cheatsEnabled": cmpPlayer.GetCheatsEnabled(),
    108108            "disabledTemplates": cmpPlayer.GetDisabledTemplates(),
     109            "hasSharedLos": cmpTechnologyManager ? cmpTechnologyManager.IsTechnologyResearched("unlock_shared_los") : null,
    109110            "hasSharedDropsites": cmpPlayer.HasSharedDropsites(),
    110111            "phase": phase,
    111112            "isAlly": allies,