Ticket #3841: 3841_ingame_summary_v1.patch

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

Enable ingame summary for everyone. You can ony see your own score. If you unlock shared vision you can see the score of your allies in the summary and in the tooltip of your own resource/pop (top panel)stat

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

     
    617617    pauseGame();
    618618
    619619    let extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState");
     620    let playersToShow = [];
     621
     622    if (g_ViewedPlayer < 1 || extendedSimState.players[g_ViewedPlayer].state != "active")
     623        playersToShow = extendedSimState.players;
     624    else
     625        for (let player in g_Players)
     626            if (player == 0 || player == g_ViewedPlayer || extendedSimState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer])
     627                playersToShow.push(extendedSimState.players[player]);
     628
    620629    Engine.PushGuiPage("page_summary.xml", {
    621630        "sim": {
    622631            "mapSettings": g_GameAttributes.settings,
    623             "playerStates": extendedSimState.players,
     632            "playerStates": playersToShow,
    624633            "timeElapsed" : extendedSimState.timeElapsed
    625634        },
    626635        "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    let ret = "";
     939    for (let player in playersState)
     940        if (player != 0 && player != g_ViewedPlayer &&
     941            (g_ViewedPlayer < 1 || playersState[g_ViewedPlayer].state != "active" ||
     942                playersState[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]))
     943            ret += '\n[color="'+ rgbToGuiColor(g_Players[player].color) +'"]' + playersState[player].name + '[/color]: ' +
     944                (resource == "pop" ?
     945                    (playersState[player].popCount + "/" + playersState[player].popLimit) :
     946                    playersState[player].resourceCounts[resource]);
     947    return ret;
     948}
     949
    936950function updatePlayerDisplay()
    937951{
    938952    let playerState = GetSimState().players[g_ViewedPlayer];
     
    939953    if (!playerState)
    940954        return;
    941955
    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);
     956    let translatedResources = {
     957        "food": translate("Food"),
     958        "wood": translate("Wood"),
     959        "stone": translate("Stone"),
     960        "metal": translate("Metal")
     961    }
     962    for (let res of RESOURCES)
     963    {
     964        Engine.GetGUIObjectByName("resource_" + res).caption = Math.floor(playerState.resourceCounts[res]);
     965        Engine.GetGUIObjectByName(res).tooltip = translatedResources[res] + getAllyStatTooltip(res);
     966    }
    946967    Engine.GetGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
    947968    Engine.GetGUIObjectByName("population").tooltip = translate("Population (current / limit)") + "\n" +
    948                     sprintf(translate("Maximum population: %(popCap)s"), { "popCap": playerState.popMax });
     969                    sprintf(translate("Maximum population: %(popCap)s"), { "popCap": playerState.popMax }) +
     970                    getAllyStatTooltip("pop");
    949971
    950972    g_IsTrainingBlocked = playerState.trainingBlocked;
    951973}
  • 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": cmpPlayer.HasSharedLos(),
    109110            "hasSharedDropsites": cmpPlayer.HasSharedDropsites(),
    110111            "phase": phase,
    111112            "isAlly": allies,
  • binaries/data/mods/public/simulation/components/Player.js

     
    3434    this.teamsLocked = false;
    3535    this.state = "active"; // game state - one of "active", "defeated", "won"
    3636    this.diplomacy = [];    // array of diplomatic stances for this player with respect to other players (including gaia and self)
     37    this.sharedLos = false;
    3738    this.sharedDropsites = false;
    3839    this.formations = [];
    3940    this.startCam = undefined;
     
    545546    return this.startCam !== undefined;
    546547};
    547548
     549Player.prototype.HasSharedLos = function()
     550{
     551    return this.sharedLos;
     552};
     553
    548554Player.prototype.HasSharedDropsites = function()
    549555{
    550556    return this.sharedDropsites;
     
    702708Player.prototype.OnResearchFinished = function(msg)
    703709{
    704710    if (msg.tech == this.template.SharedLosTech)
     711    {
    705712        this.UpdateSharedLos();
     713        this.sharedLos = true;
     714    }
    706715    else if (msg.tech == this.template.SharedDropsitesTech)
    707716        this.sharedDropsites = true;
    708717};