Ticket #2898: userNotify.3.patch

File userNotify.3.patch, 6.6 KB (added by Andy Alt, 8 years ago)

applied elexis's suggestions

  • 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 (g_LastNickNotification == -1 || timeNow > g_LastNickNotification + 3000)
     318        Engine.PlayUISound("audio/interface/select/resource/sel_metal_01.ogg", false);
     319
     320    g_LastNickNotification = 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

     
    203203var g_ChatMessages = [];
    204204
    205205/**
     206 * Used by notifyUser() to limit the number of pings
     207 */
     208var g_LastNickNotification = -1;
     209
     210/**
    206211 * Cache containing the mapsettings for scenario/skirmish maps. Just-in-time loading.
    207212 */
    208213var g_MapData = {};
     
    18041809
    18051810function addChatMessage(msg)
    18061811{
     1812    if (msg.text)
     1813    {
     1814        let userName = g_PlayerAssignments[Engine.GetPlayerGUID() || "local"].name;
     1815
     1816        if (userName != g_PlayerAssignments[msg.guid].name)
     1817            notifyUser(userName, msg.text);
     1818    }
     1819
    18071820    if (!g_FormatChatMessage[msg.type])
    18081821        return;
    18091822
  • binaries/data/mods/public/gui/lobby/lobby.js

     
    9797var g_SpamMonitor = {};
    9898
    9999/**
     100 * Used by notifyUser() to limit the number of pings
     101 */
     102var g_LastNickNotification = -1;
     103
     104/**
    100105 * Used to restore the selection after updating the playerlist.
    101106 */
    102107var g_SelectedPlayer = "";
     
    821826
    822827        // Highlight local user's nick
    823828        if (g_Username != msg.from)
     829        {
    824830            msg.text = msg.text.replace(g_Username, colorPlayerName(g_Username));
     831            notifyUser(g_Username, msg.text);
     832        }
    825833
    826834        // Run spam test if it's not a historical message
    827835        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

     
    2525var g_ChatTimers = [];
    2626
    2727/**
     28 * Used by notifyUser() to limit the number of pings
     29 */
     30var g_LastNickNotification = -1;
     31
     32/**
    2833 * Handle all netmessage types that can occur.
    2934 */
    3035var g_NetMessageTypes = {
     
    826831    // Translate or escape text
    827832    if (!msg.text)
    828833        return "";
     834
    829835    if (msg.translate)
    830836    {
    831837        msg.text = translate(msg.text);
     
    837843        }
    838844    }
    839845    else
     846    {
    840847        msg.text = escapeText(msg.text);
    841848
     849        let userName = g_PlayerAssignments[Engine.GetPlayerGUID() || "local"].name;
     850
     851        if (userName != g_PlayerAssignments[msg.guid].name)
     852            notifyUser(userName, msg.text);
     853    }
     854
    842855    // GUID for players, playerID for AIs
    843856    let coloredUsername = msg.guid != -1 ? colorizePlayernameByGUID(msg.guid) : colorizePlayernameByID(msg.player);
    844857