Ticket #3501: 3501-3.patch

File 3501-3.patch, 3.4 KB (added by Damien PIQUET, 8 years ago)

Improvements to 3501-2.patch

  • 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        });
     
    652653
    653654function formatDefeatMessage(msg)
    654655{
     656    let defeatMsg;
     657
    655658    // In singleplayer, the local player is "You". "You has" is incorrect.
    656659    if (!g_IsNetworked && msg.player == Engine.GetPlayerID())
    657         return translate("You have been defeated.");
     660        defeatMsg = "%(player)s have been defeated.";
     661    else
     662        defeatMsg = "%(player)s has been defeated.";
    658663
    659     return sprintf(translate("%(player)s has been defeated."), {
     664    return sprintf(translate(defeatMsg), {
    660665        "player": colorizePlayernameByID(msg.player)
    661666    });
    662667}
    663668
     669function formatResignMessage(msg)
     670{
     671    let resignMsg;
     672
     673    // In singleplayer, the local player is "You". "You has" is incorrect.
     674    if (!g_IsNetworked && msg.player == Engine.GetPlayerID())
     675        resignMsg = "%(player)s have resigned";
     676    else
     677        resignMsg = "%(player)s has resigned";
     678
     679    return sprintf(translate(resignMsg), {
     680        "player": colorizePlayernameByID(msg.player)
     681    });
     682}
     683
    664684function formatDiplomacyMessage(msg)
    665685{
    666686    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)