Ticket #3413: t3413_hide_diplomacy_ceasefire_counter_and_dont_spam_v2.patch

File t3413_hide_diplomacy_ceasefire_counter_and_dont_spam_v2.patch, 2.7 KB (added by elexis, 9 years ago)

The previous patch showed the ceasefire overlay counter even if the setting was disabled.

  • binaries/data/mods/public/gui/common/functions_global_object.js

    function updateCounters()  
    108108            else
    109109                caption += timeToString(g_SimState.timeElapsed);
    110110            caption += "\n";
    111111            ++linesCount;
    112112        }
    113         if (Engine.ConfigDB_GetValue("user", "gui.session.ceasefirecounter") === "true" && g_SimState.ceasefireActive)
     113
     114        var diplomacyCeasefireCounter = Engine.GetGUIObjectByName("diplomacyCeasefireCounter");
     115        if (g_SimState.ceasefireActive)
    114116        {
     117            // Update ceasefire counter in the diplomacy window
    115118            var remainingTimeString = timeToString(g_SimState.ceasefireTimeRemaining);
    116             caption += remainingTimeString + "\n";
    117            
    118             var diplomacyCeasefireCounter = Engine.GetGUIObjectByName("diplomacyCeasefireCounter");
    119119            diplomacyCeasefireCounter.caption = sprintf(translateWithContext("ceasefire", "Time remaining until ceasefire is over: %(time)s."), {"time": remainingTimeString});
    120             ++linesCount;
     120
     121            // Update ceasefire overlay counter
     122            if (Engine.ConfigDB_GetValue("user", "gui.session.ceasefirecounter") === "true")
     123            {
     124                caption += remainingTimeString + "\n";
     125                ++linesCount;
     126            }
     127        }
     128        else if (!diplomacyCeasefireCounter.hidden)
     129        {
     130            diplomacyCeasefireCounter.hidden = true;
     131            updateDiplomacy();
    121132        }
    122133
    123134        g_ResearchListTop = 4;
    124135        if (linesCount)
    125136            g_ResearchListTop += 14 * linesCount;
  • binaries/data/mods/public/simulation/components/CeasefireManager.js

    CeasefireManager.prototype.StopCeasefire  
    121121   
    122122    // Reset diplomacies to original settings
    123123    var playerEntities = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetAllPlayerEntities();
    124124    for (var i = 1; i < playerEntities.length; ++i)
    125125        Engine.QueryInterface(playerEntities[i], IID_Player).SetDiplomacy(this.diplomacyBeforeCeasefire[i-1]);
    126 
    127     // Send chat notifications and update the diplomacy screen
    128     for (var i = 1; i < playerEntities.length; ++i)
    129         for (var j = 1; j < playerEntities.length; ++j)
    130             if (i != j && this.diplomacyBeforeCeasefire[i-1][j] == -1)
    131                 cmpGuiInterface.PushNotification({"type": "diplomacy", "players": [j], "player1": [i], "status": "enemy"});
    132126   
    133127    // Reset values
    134128    this.ceasefireIsActive = false;
    135129    this.ceasefireTime = 0;
    136130    this.ceasefireStartedTime = 0;