Ticket #2723: gamesetup.js_NoSpam.patch

File gamesetup.js_NoSpam.patch, 1.3 KB (added by dan_trev, 10 years ago)

Timer based no spam. Allows immediate revocation of ready status. Timer updates to current time only after a successful selection.

  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    16411641    Engine.GetGUIObjectByName("moreOptions").hidden = !Engine.GetGUIObjectByName("moreOptions").hidden;
    16421642}
    16431643
     1644
     1645var lastToggleReady = new Date(0); // Start at Unix Epoch to enable the first click.
     1646var spamMsgShown = false;
    16441647function toggleReady()
    16451648{
     1649    var now = new Date;
     1650    var tickLength = now - lastToggleReady;
     1651
     1652    // Allow ready status once every five seconds but allow immediate revocation of the ready status.
     1653    if (tickLength < 5000 && !g_IsReady)
     1654    {
     1655        if(!spamMsgShown)
     1656        {
     1657            g_ChatMessages.push(translate(" * Please do not spam the other players."));
     1658            Engine.GetGUIObjectByName("chatText").caption = g_ChatMessages.join("\n");
     1659        }
     1660        spamMsgShown = true;
     1661        return;
     1662    }
     1663   
    16461664    g_IsReady = !g_IsReady;
    16471665    if (g_IsReady)
    16481666    {
     
    16561674        Engine.GetGUIObjectByName("startGame").caption = translate("I'm ready!");
    16571675        Engine.GetGUIObjectByName("startGame").tooltip = translate("State that you are ready to play!");
    16581676    }
     1677
     1678    spamMsgShown = false;  // Allow showing the message again.
     1679    lastToggleReady = now; // Update the timer.
    16591680}
    16601681
    16611682function updateReadyUI()