Ticket #4145: autocomplete_hotkey_tooltips_v1.patch

File autocomplete_hotkey_tooltips_v1.patch, 5.8 KB (added by elexis, 8 years ago)
  • binaries/data/mods/public/gui/common/color.js

    function colorizeHotkey(text, hotkey)  
    142142            "[color=\"" + g_HotkeyColor + "\"]" +
    143143            "\\[" + key + "]" +
    144144            "[/color]"
    145145    });
    146146}
     147
     148/**
     149 * The autocomplete hotkey is hardcoded in SDLK_TAB of CInput.cpp,
     150 * as we don't want hotkeys interfering with typing text.
     151 */
     152function colorizeAutocompleteHotkey()
     153{
     154    return sprintf(translate("Press %(hotkey)s to autocomplete playernames."), {
     155        "hotkey": "[color=\"" + g_HotkeyColor + "\"]" + "\\[Tab]" + "[/color]"
     156    });
     157}
  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

    function initRadioButtons()  
    522522        g_GameAttributes.settings.LastManStanding = false;
    523523        updateGameAttributes();
    524524    };
    525525}
    526526
     527function updateTooltips()
     528{
     529    Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
     530}
     531
    527532/**
    528533 * If we're a network client, hide the controls and show the text instead.
    529534 */
    530535function hideControls()
    531536{
    function updateGUIObjects()  
    14561461            pColorPicker.selected = g_PlayerColors.findIndex(col => sameColor(col, color));
    14571462    }
    14581463
    14591464    updateMapDescription();
    14601465    resizeMoreOptionsWindow();
     1466    updateTooltips();
    14611467
    14621468    g_IsInGuiUpdate = false;
    14631469
    14641470    // Game attributes include AI settings, so update the player list
    14651471    updatePlayerList();
  • binaries/data/mods/public/gui/lobby/lobby.js

    function init(attribs)  
    222222
    223223    // When rejoining the lobby after a game, we don't need to process presence changes
    224224    Engine.LobbyClearPresenceUpdates();
    225225    updatePlayerList();
    226226    updateSubject(Engine.LobbyGetRoomSubject());
     227    updateTooltips();
    227228}
    228229
    229230function returnToMainMenu()
    230231{
    231232    Engine.StopXmppClient();
    function filterGame(game)  
    296297        return true;
    297298
    298299    return false;
    299300}
    300301
     302function updateTooltips()
     303{
     304    Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
     305}
     306
    301307/**
    302308 * Update the subject GUI object.
    303309 *
    304310 * @param {string} newSubject
    305311 */
  • binaries/data/mods/public/gui/replaymenu/replay_menu.js

    function displayReplayList()  
    220220    replaySelection.list_data = list.directories || [];
    221221
    222222    replaySelection.selected = replaySelection.list.findIndex(directory => directory == g_SelectedReplayDirectory);
    223223
    224224    displayReplayDetails();
     225    updateTooltips();
    225226}
    226227
    227228/**
    228229 * Shows preview image, description and player text in the right panel.
    229230 */
    function displayReplayDetails()  
    265266    Engine.GetGUIObjectByName("summaryButton").hidden = !Engine.HasReplayMetadata(replay.directory);
    266267
    267268    setMapPreviewImage("sgMapPreview", mapData.preview);
    268269}
    269270
     271function updateTooltips()
     272{
     273    Engine.GetGUIObjectByName("playersFilter").tooltip =
     274        translate("Filter replays by typing one or more, partial or complete playernames.") + " " +
     275        colorizeAutocompleteHotkey();
     276
     277    let deleteTooltip = colorizeHotkey(
     278        translate("Delete the selected replay using %(hotkey)s."),
     279        "session.savedgames.delete");
     280
     281    if (deleteTooltip)
     282        deleteTooltip += " " + colorizeHotkey(
     283            translate("Press %(hotkey)s to delete without confirmation."),
     284            "session.savedgames.noconfirmation");
     285
     286    Engine.GetGUIObjectByName("deleteReplayButton").tooltip = deleteTooltip;
     287}
     288
    270289/**
    271290 * Adds grey font if replay is not compatible.
    272291 */
    273292function greyout(text, isCompatible)
    274293{
  • binaries/data/mods/public/gui/session/session.js

    function init(initData, hotloadData)  
    280280
    281281    // If in Atlas editor, disable the exit button
    282282    if (Engine.IsAtlasRunning())
    283283        Engine.GetGUIObjectByName("menuExitButton").enabled = false;
    284284
    285     initHotkeyTooltips();
     285    updateTooltips();
    286286
    287287    if (hotloadData)
    288288        g_Selection.selected = hotloadData.selection;
    289289
    290290    sendLobbyPlayerlistUpdate();
    function init(initData, hotloadData)  
    300300    // and it generates a massive amount of data to transmit and store
    301301    //setTimeout(function() { reportPerformance(5); }, 5000);
    302302    //setTimeout(function() { reportPerformance(60); }, 60000);
    303303}
    304304
    305 function initHotkeyTooltips()
     305function updateTooltips()
    306306{
     307    Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey() +
     308        colorizeHotkey("\n" + translate("Press %(hotkey)s to chat with everyone."), "chat") +
     309        colorizeHotkey("\n" +
     310            (g_IsObserver ?
     311                translate("Press %(hotkey)s to chat with observers.") :
     312                translate("Press %(hotkey)s to chat with allies.")),
     313            "teamchat");
     314
    307315    Engine.GetGUIObjectByName("idleWorkerButton").tooltip =
    308316        colorizeHotkey("%(hotkey)s" + " ", "selection.idleworker") +
    309317        translate("Find idle worker");
    310318
    311319    Engine.GetGUIObjectByName("tradeHelp").tooltip =
    function selectViewPlayer(playerID)  
    376384    }
    377385
    378386    Engine.SetViewedPlayer(g_ViewedPlayer);
    379387
    380388    updateTopPanel();
    381 
    382389    updateChatAddressees();
     390    updateTooltips();
    383391
    384392    // Update GUI and clear player-dependent cache
    385393    onSimulationUpdate();
    386394
    387395    if (g_IsDiplomacyOpen)