Ticket #3730: t3730_show_rallypoints_to_observers_v1.patch

File t3730_show_rallypoints_to_observers_v1.patch, 3.9 KB (added by elexis, 8 years ago)
  • binaries/data/mods/public/gui/session/messages.js

    var g_NotificationsTypes =  
    234234    "resetselectionpannel": function(notification, player)
    235235    {
    236236        if (player != Engine.GetPlayerID())
    237237            return;
    238238        g_Selection.rebuildSelection({});
     239    },
     240    "set-rallypoint": function(notification, player)
     241    {
     242        // GUI update needed in case another client sent the command
     243        // (change-perspective, control-all-units or observer)
     244        Engine.GuiInterfaceCall("DisplayRallyPoint", {
     245            "entities": notification.entities,
     246            "x": notification.x,
     247            "z": notification.z,
     248            "queued": notification.queued,
     249            "isObserver": g_IsObserver
     250        });
     251        Engine.GuiInterfaceCall("DisplayRallyPoint", { "entities": g_Selection.toList(), "isObserver": g_IsObserver });
     252    },
     253    "unset-rallypoint": function(notification, player)
     254    {
     255        Engine.GuiInterfaceCall("DisplayRallyPoint", { "entities": g_Selection.toList(), "isObserver": g_IsObserver });
    239256    }
    240257};
    241258
    242259/**
    243260 * Loads all known cheat commands.
  • binaries/data/mods/public/gui/session/session.js

    function onTick()  
    441441        g_Selection.dirty = false;
    442442
    443443        onSimulationUpdate();
    444444
    445445        // Display rally points for selected buildings
    446         if (!g_IsObserver)
    447             Engine.GuiInterfaceCall("DisplayRallyPoint", { "entities": g_Selection.toList() });
     446        Engine.GuiInterfaceCall("DisplayRallyPoint", { "entities": g_Selection.toList(), "isObserver": g_IsObserver });
    448447    }
    449448
    450449    updateTimers();
    451450
    452451    updateMenuPosition(tickLength);
  • binaries/data/mods/public/simulation/components/GuiInterface.js

    GuiInterface.prototype.DisplayRallyPoint  
    890890        if (!cmpRallyPoint)
    891891            continue;
    892892
    893893        // Verify the owner
    894894        let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership);
    895         if (!(cmpPlayer && cmpPlayer.CanControlAllUnits()))
     895        if (!cmd.isObserver && !(cmpPlayer && cmpPlayer.CanControlAllUnits()))
    896896            if (!cmpOwnership || cmpOwnership.GetOwner() != player)
    897897                continue;
    898898
    899899        // If the command was passed an explicit position, use that and
    900900        // override the real rally point position; otherwise use the real position
  • binaries/data/mods/public/simulation/helpers/Commands.js

    var g_Commands = {  
    393393
    394394                cmpRallyPoint.AddPosition(cmd.x, cmd.z);
    395395                cmpRallyPoint.AddData(cmd.data);
    396396            }
    397397        }
     398
     399        var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     400        cmpGuiInterface.PushNotification({
     401            "type": "set-rallypoint",
     402            "players": [player],
     403            "entities": cmd.entities,
     404            "x": cmd.x,
     405            "z": cmd.z,
     406            "queued": cmd.queued
     407        });
    398408    },
    399409
    400410    "unset-rallypoint": function(player, cmd, data)
    401411    {
    402412        for each (var ent in data.entities)
    403413        {
    404414            var cmpRallyPoint = Engine.QueryInterface(ent, IID_RallyPoint);
    405415            if (cmpRallyPoint)
    406416                cmpRallyPoint.Reset();
    407417        }
     418
     419        var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     420        cmpGuiInterface.PushNotification({
     421            "type": "unset-rallypoint",
     422            "players": [player],
     423            "entities": data.entities
     424        });
    408425    },
    409426
    410427    "defeat-player": function(player, cmd, data)
    411428    {
    412429        // Send "OnPlayerDefeated" message to player