Ticket #2898: userNotify.5.patch

File userNotify.5.patch, 5.8 KB (added by Andy Alt, 8 years ago)

use of function object as static keyword in this patch

  • binaries/data/config/default.cfg

     
    237237milonly = Alt                ; Add only military units to selection
    238238idleonly = "I"               ; Select only idle units
    239239remove = Ctrl                ; Remove units from selection
    240 cancel = Esc                 ; Un-select all units and cancel building placement 
     240cancel = Esc                 ; Un-select all units and cancel building placement
    241241idleworker = Period          ; Select next idle worker
    242242idlewarrior = ForwardSlash   ; Select next idle warrior
    243243offscreen = Alt              ; Include offscreen units in selection
     
    381381actiongain = 0.7
    382382uigain = 0.7
    383383
     384[sound.notify]
     385nick = true
     386
    384387[tinygettext]
    385388debug = false                     ; Print error messages each time a translation for an English string is not found.
    386389
  • binaries/data/mods/public/gui/common/functions_utility.js

     
    173173    {
    174174        if (word.toLowerCase().indexOf(lastWord.toLowerCase()) != 0)
    175175            continue;
    176 
     176
    177177        text = wordSplit.join(" ");
    178178        if (text.length > 0)
    179179            text += " ";
     
    302302        });
    303303    }).join("\n\n");
    304304}
     305
     306/**
     307 * Plays a sound if user's nick is mentioned in chat
     308 */
     309function notifyUser(userName, msgText)
     310{
     311    if (Engine.ConfigDB_GetValue("user", "sound.notify.nick") != "true" ||
     312         msgText.toLowerCase().indexOf(userName.toLowerCase()) == -1)
     313            return;
     314
     315    let timeNow = new Date().getTime();
     316
     317    if (!notifyUser.lastPing || timeNow > notifyUser.lastPing + 3000)
     318        Engine.PlayUISound("audio/interface/select/resource/sel_metal_01.ogg", false);
     319
     320    notifyUser.lastPing = timeNow;
     321}
  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    2424            {"nick": "Alan", "name": "Alan Kemp"},
    2525            {"nick": "aBothe", "name": "Alexander Bothe"},
    2626            {"nick": "alpha123", "name": "Peter P. Cannici"},
     27            {"nick": "andy5995", "name": "Andy Alt"},
    2728            {"nick": "Aurium", "name": "Aurélio Heckert"},
    2829            {"nick": "badmadblacksad", "name": "Martin F"},
    2930            {"name": "Mikołaj \"Bajter\" Korcz"},
  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    18041804
    18051805function addChatMessage(msg)
    18061806{
     1807    if (msg.text)
     1808    {
     1809        let userName = g_PlayerAssignments[Engine.GetPlayerGUID() || "local"].name;
     1810
     1811        if (userName != g_PlayerAssignments[msg.guid].name)
     1812            notifyUser(userName, msg.text);
     1813    }
     1814
    18071815    if (!g_FormatChatMessage[msg.type])
    18081816        return;
    18091817
  • binaries/data/mods/public/gui/lobby/lobby.js

     
    821821
    822822        // Highlight local user's nick
    823823        if (g_Username != msg.from)
     824        {
    824825            msg.text = msg.text.replace(g_Username, colorPlayerName(g_Username));
     826            notifyUser(g_Username, msg.text);
     827        }
    825828
    826829        // Run spam test if it's not a historical message
    827830        if (!msg.datetime)
  • binaries/data/mods/public/gui/options/options.json

     
    165165        {
    166166            "type": "boolean",
    167167            "label": "Water Refraction",
    168             "tooltip": "Use a real water refraction map and not transparency", 
     168            "tooltip": "Use a real water refraction map and not transparency",
    169169            "parameters": { "config": "waterrefraction", "renderer": "WaterRefraction" }
    170170        },
    171171        {
     
    236236    [
    237237        {
    238238            "type": "number",
    239             "label": "Chat Backlog", 
    240             "tooltip": "Number of backlogged messages to load when joining the lobby", 
     239            "label": "Chat Backlog",
     240            "tooltip": "Number of backlogged messages to load when joining the lobby",
    241241            "parameters": { "config": "lobby.history", "min": "0" }
    242242        },
    243243        {
    244244            "type": "boolean",
    245245            "label": "Chat Timestamp",
    246             "tooltip": "Show time that messages are posted in the lobby chat", 
     246            "tooltip": "Show time that messages are posted in the lobby chat",
    247247            "parameters": { "config": "lobby.chattimestamp" }
     248        },
     249        {
     250            "type": "boolean",
     251            "label": "Nick Notification",
     252            "tooltip": "Receive audio notification when someone types your nick",
     253            "parameters": { "config": "sound.notify.nick" }
    248254        }
    249255    ]
    250256}
  • binaries/data/mods/public/gui/session/messages.js

     
    826826    // Translate or escape text
    827827    if (!msg.text)
    828828        return "";
     829
    829830    if (msg.translate)
    830831    {
    831832        msg.text = translate(msg.text);
     
    837838        }
    838839    }
    839840    else
     841    {
    840842        msg.text = escapeText(msg.text);
    841843
     844        let userName = g_PlayerAssignments[Engine.GetPlayerGUID() || "local"].name;
     845
     846        if (userName != g_PlayerAssignments[msg.guid].name)
     847            notifyUser(userName, msg.text);
     848    }
     849
    842850    // GUID for players, playerID for AIs
    843851    let coloredUsername = msg.guid != -1 ? colorizePlayernameByGUID(msg.guid) : colorizePlayernameByID(msg.player);
    844852