Ticket #4145: autocomplete_hotkey_tooltips_v2.patch

File autocomplete_hotkey_tooltips_v2.patch, 8.4 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":
     156            "[color=\"" + g_HotkeyColor + "\"]" +
     157            "\\[" + translateWithContext("hotkey", "Tab") + "]" +
     158            "[/color]"
     159    });
     160}
  • binaries/data/mods/public/gui/common/functions_utility_loadsave.js

    function reallyDeleteGame(gameID)  
    7373        error("Could not delete saved game: " + gameID);
    7474
    7575    // Run init again to refresh saved game list
    7676    init();
    7777}
     78
     79function deleteTooltip()
     80{
     81    let deleteTooltip = colorizeHotkey(
     82        translate("Delete the selected entry using %(hotkey)s."),
     83        "session.savedgames.delete");
     84
     85    if (deleteTooltip)
     86        deleteTooltip += colorizeHotkey(
     87            " "  + translate("Hold %(hotkey)s to delete without confirmation."),
     88            "session.savedgames.noconfirmation");
     89
     90    return deleteTooltip;
     91}
  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

    function initGUIObjects()  
    292292    initMultiplayerSettings();
    293293    initPlayerAssignments();
    294294
    295295    resizeMoreOptionsWindow();
    296296
     297    Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
     298
    297299    if (g_IsNetworked)
    298300        Engine.GetGUIObjectByName("chatInput").focus();
    299301
    300302    if (g_IsController)
    301303    {
  • 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
     228    Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
    227229}
    228230
    229231function returnToMainMenu()
    230232{
    231233    Engine.StopXmppClient();
  • binaries/data/mods/public/gui/replaymenu/replay_menu.js

    function init(data)  
    6565    {
    6666        Engine.SwitchGuiPage("page_pregame.xml");
    6767        return;
    6868    }
    6969
     70    initHotkeyTooltips();
    7071    displayReplayList();
    7172}
    7273
    7374/**
    7475 * Store the list of replays loaded in C++ in g_Replays.
    function sanitizeGameAttributes(attribs)  
    183184        if (!pData.Name)
    184185            pData.Name = "";
    185186    });
    186187}
    187188
     189function initHotkeyTooltips()
     190{
     191    Engine.GetGUIObjectByName("playersFilter").tooltip =
     192        translate("Filter replays by typing one or more, partial or complete playernames.") +
     193        " " + colorizeAutocompleteHotkey();
     194
     195    Engine.GetGUIObjectByName("deleteReplayButton").tooltip = deleteTooltip();
     196}
     197
    188198/**
    189199 * Filter g_Replays, fill the GUI list with that data and show the description of the current replay.
    190200 */
    191201function displayReplayList()
    192202{
  • binaries/data/mods/public/gui/replaymenu/replay_menu.xml

     
    1010    <script file="gui/common/settings.js" />
    1111
    1212    <!-- Used to display message boxes. -->
    1313    <script file="gui/common/functions_global_object.js" />
    1414
    15     <!-- Used for engine + mod version checks. -->
     15    <!-- Used for engine + mod version checks and deleteTooltip -->
    1616    <script file="gui/common/functions_utility_loadsave.js" />
    1717
    1818    <!-- Actual replay scripts after settings.js, as it initializes g_Settings. -->
    1919    <script file="gui/replaymenu/replay_menu.js" />
    2020    <script file="gui/replaymenu/replay_actions.js" />
  • binaries/data/mods/public/gui/savedgames/load.js

    function init()  
    3232        gameSelection.selected = 0;
    3333    else if (gameSelection.selected >= savedGames.length) // happens when deleting the last saved game
    3434        gameSelection.selected = savedGames.length - 1;
    3535    else
    3636        selectionChanged();
     37
     38    Engine.GetGUIObjectByName("deleteGameButton").tooltip = deleteTooltip();
    3739}
    3840
    3941function selectionChanged()
    4042{
    4143    let gameSelection = Engine.GetGUIObjectByName("gameSelection");
  • binaries/data/mods/public/gui/savedgames/save.js

    function init(data)  
    3535        g_Descriptions[game.id] = game.metadata.description || "";
    3636
    3737    gameSelection.list = savedGames.map(game => generateLabel(game.metadata));
    3838    gameSelection.list_data = savedGames.map(game => game.id);
    3939    gameSelection.selected = -1;
     40
     41    Engine.GetGUIObjectByName("deleteGameButton").tooltip = deleteTooltip();
    4042}
    4143
    4244function saveGame()
    4345{
    4446    let gameSelection = Engine.GetGUIObjectByName("gameSelection");
  • binaries/data/mods/public/gui/savedgames/save.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22
    33<objects>
    44
     5    <script file="gui/common/color.js"/>
    56    <script file="gui/common/functions_global_object.js" />
    67    <script file="gui/common/functions_utility_loadsave.js" />
    78    <script file="gui/savedgames/save.js" />
    89
    910    <!-- Add a translucent black background to fade out the page -->
  • binaries/data/mods/public/gui/session/session.js

    function init(initData, hotloadData)  
    291291
    292292    // If in Atlas editor, disable the exit button
    293293    if (Engine.IsAtlasRunning())
    294294        Engine.GetGUIObjectByName("menuExitButton").enabled = false;
    295295
    296     initHotkeyTooltips();
    297 
    298296    if (hotloadData)
    299297        g_Selection.selected = hotloadData.selection;
    300298
    301299    sendLobbyPlayerlistUpdate();
    302300    onSimulationUpdate();
    function init(initData, hotloadData)  
    311309    // and it generates a massive amount of data to transmit and store
    312310    //setTimeout(function() { reportPerformance(5); }, 5000);
    313311    //setTimeout(function() { reportPerformance(60); }, 60000);
    314312}
    315313
    316 function initHotkeyTooltips()
     314/**
     315 * Depends on the current player (g_IsObserver).
     316 */
     317function updateHotkeyTooltips()
    317318{
     319    Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey() +
     320        colorizeHotkey("\n" + translate("Press %(hotkey)s to open the public chat."), "chat") +
     321        colorizeHotkey(
     322            "\n" + (g_IsObserver ?
     323                translate("Press %(hotkey)s to open the observer chat.") :
     324                translate("Press %(hotkey)s to open the ally chat.")),
     325            "teamchat");
     326
    318327    Engine.GetGUIObjectByName("idleWorkerButton").tooltip =
    319328        colorizeHotkey("%(hotkey)s" + " ", "selection.idleworker") +
    320329        translate("Find idle worker");
    321330
    322331    Engine.GetGUIObjectByName("tradeHelp").tooltip =
    function selectViewPlayer(playerID)  
    387396    }
    388397
    389398    Engine.SetViewedPlayer(g_ViewedPlayer);
    390399
    391400    updateTopPanel();
    392 
    393401    updateChatAddressees();
     402    updateHotkeyTooltips();
    394403
    395404    // Update GUI and clear player-dependent cache
    396405    onSimulationUpdate();
    397406
    398407    if (g_IsDiplomacyOpen)