Ticket #3501: 3501.patch

File 3501.patch, 2.9 KB (added by Damien PIQUET, 8 years ago)

updated patch for ticket #3501

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

     
    4848    "clientlist": msg => getUsernameList(),
    4949    "message": msg => formatChatCommand(msg),
    5050    "defeat": msg => formatDefeatMessage(msg),
     51    "resign": msg => formatResignMessage(msg),
    5152    "diplomacy": msg => formatDiplomacyMessage(msg),
    5253    "tribute": msg => formatTributeMessage(msg),
    5354    "attack": msg => formatAttackMessage(msg)
     
    186187    "defeat": function(notification, player)
    187188    {
    188189        addChatMessage({
    189             "type": "defeat",
     190            "type": !!notification.resign ? "resign" : "defeat",
    190191            "guid": findGuidForPlayerID(player),
    191192            "player": player
    192193        });
     
    661662    });
    662663}
    663664
     665function formatResignMessage(msg)
     666{
     667    // In singleplayer, the local player is "You". "You has" is incorrect.
     668    if (!g_IsNetworked && msg.player == Engine.GetPlayerID())
     669        return translate("You have resigned.");
     670
     671    return sprintf(translate("%(player)s has resigned."), {
     672        "player": colorizePlayernameByID(msg.player)
     673    });
     674}
     675
    664676function formatDiplomacyMessage(msg)
    665677{
    666678    let messageType;
  • binaries/data/mods/public/gui/session/session.js

     
    426426
    427427    Engine.PostNetworkCommand({
    428428        "type": "defeat-player",
    429         "playerId": Engine.GetPlayerID()
     429        "playerId": Engine.GetPlayerID(),
     430        "resign": true
    430431    });
    431432
    432433    updateTopPanel();
  • binaries/data/mods/public/simulation/components/Player.js

     
    671671    var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    672672    cmpGUIInterface.PushNotification({
    673673        "type": "defeat",
    674         "players": [this.playerID]
     674        "players": [this.playerID],
     675        "resign": !!msg.resign
    675676    });
    676677};
    677678
  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    413413    "defeat-player": function(player, cmd, data)
    414414    {
    415415        // Send "OnPlayerDefeated" message to player
    416         Engine.PostMessage(data.playerEnt, MT_PlayerDefeated, { "playerId": player } );
     416        Engine.PostMessage(data.playerEnt, MT_PlayerDefeated, { "playerId": player, "resign": !!cmd.resign });
    417417    },
    418418
    419419    "garrison": function(player, cmd, data)