Ticket #3215: t3215_fix_observer_statusbars.patch

File t3215_fix_observer_statusbars.patch, 2.9 KB (added by elexis, 9 years ago)
  • binaries/data/mods/public/gui/session/session.js

     
    809809}
    810810
    811811// Toggles the display of status bars for all of the player's entities.
    812812function recalculateStatusBarDisplay()
    813813{
    814     if (g_ShowAllStatusBars)
    815         var entities = Engine.PickFriendlyEntitiesOnScreen(Engine.GetPlayerID());
     814    if (g_IsObserver)
     815    {
     816        var entities = [];
     817        var numPlayers = GetSimState().players.length;
     818        for (let i = 1; i < numPlayers; ++i)
     819            entities = entities.concat(Engine.GuiInterfaceCall("GetPlayerEntities", i));
     820    }
    816821    else
    817822    {
    818         var selected = g_Selection.toList();
    819         for each (var ent in g_Selection.highlighted)
    820             selected.push(ent);
    821 
    822         // Remove selected entities from the 'all entities' array, to avoid disabling their status bars.
    823         var entities = Engine.GuiInterfaceCall("GetPlayerEntities").filter(
    824                 function(idx) { return (selected.indexOf(idx) == -1); }
    825         );
     823        if (g_ShowAllStatusBars)
     824            var entities = Engine.PickFriendlyEntitiesOnScreen(Engine.GetPlayerID());
     825        else
     826        {
     827            // Get selected entities
     828            var selected = g_Selection.toList();
     829            for each (var ent in g_Selection.highlighted)
     830                selected.push(ent);
     831           
     832            // Remove selected entities from the 'all entities' array, to avoid disabling their status bars.
     833            entities = Engine.GuiInterfaceCall("GetPlayerEntities").filter(
     834                    function(idx) { return (selected.indexOf(idx) == -1); }
     835            );
     836        }
    826837    }
    827 
    828838    Engine.GuiInterfaceCall("SetStatusBars", { "entities": entities, "enabled": g_ShowAllStatusBars });
    829839}
    830840
    831841// Update the additional list of entities to be highlighted.
    832842function updateAdditionalHighlight()
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    887887        if (cmpStatusBars)
    888888            cmpStatusBars.RegenerateSprites();
    889889    }
    890890};
    891891
    892 GuiInterface.prototype.GetPlayerEntities = function(player)
     892// The player variable will be set to the current player ID automatically.
     893// If you want the entity IDs of another player, use the specificPlayer argument.
     894GuiInterface.prototype.GetPlayerEntities = function(player, specificPlayer)
    893895{
    894896    var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    895     return cmpRangeManager.GetEntitiesByPlayer(player);
     897    if (specificPlayer)
     898        return cmpRangeManager.GetEntitiesByPlayer(specificPlayer);
     899    else
     900        return cmpRangeManager.GetEntitiesByPlayer(player);
    896901};
    897902
    898903/**
    899904 * Displays the rally points of a given list of entities (carried in cmd.entities).
    900905 *