1
0
forked from mirrors/0ad

Autocomplete hotkey tooltips for the gamesetup-, session- and lobby chat and replay playerlist filter.

Delete hotkey tooltips for replay menu and save and load dialogs.
Reviewed by bb, fixes #4145.

This was SVN commit r18751.
This commit is contained in:
elexis
2016-09-23 21:16:12 +00:00
parent 22efe2fa8a
commit ad1a4d6121
11 changed files with 63 additions and 6 deletions
@@ -144,3 +144,17 @@ function colorizeHotkey(text, hotkey)
"[/color]"
});
}
/**
* The autocomplete hotkey is hardcoded in SDLK_TAB of CInput.cpp,
* as we don't want hotkeys interfering with typing text.
*/
function colorizeAutocompleteHotkey()
{
return sprintf(translate("Press %(hotkey)s to autocomplete playernames."), {
"hotkey":
"[color=\"" + g_HotkeyColor + "\"]" +
"\\[" + translateWithContext("hotkey", "Tab") + "]" +
"[/color]"
});
}
@@ -75,3 +75,17 @@ function reallyDeleteGame(gameID)
// Run init again to refresh saved game list
init();
}
function deleteTooltip()
{
let deleteTooltip = colorizeHotkey(
translate("Delete the selected entry using %(hotkey)s."),
"session.savedgames.delete");
if (deleteTooltip)
deleteTooltip += colorizeHotkey(
"\n" + translate("Hold %(hotkey)s to delete without confirmation."),
"session.savedgames.noconfirmation");
return deleteTooltip;
}
@@ -294,6 +294,8 @@ function initGUIObjects()
resizeMoreOptionsWindow();
Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
if (g_IsNetworked)
Engine.GetGUIObjectByName("chatInput").focus();
@@ -224,6 +224,8 @@ function init(attribs)
Engine.LobbyClearPresenceUpdates();
updatePlayerList();
updateSubject(Engine.LobbyGetRoomSubject());
Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
}
function returnToMainMenu()
@@ -67,6 +67,7 @@ function init(data)
return;
}
initHotkeyTooltips();
displayReplayList();
}
@@ -185,6 +186,15 @@ function sanitizeGameAttributes(attribs)
});
}
function initHotkeyTooltips()
{
Engine.GetGUIObjectByName("playersFilter").tooltip =
translate("Filter replays by typing one or more, partial or complete playernames.") +
" " + colorizeAutocompleteHotkey();
Engine.GetGUIObjectByName("deleteReplayButton").tooltip = deleteTooltip();
}
/**
* Filter g_Replays, fill the GUI list with that data and show the description of the current replay.
*/
@@ -12,7 +12,7 @@
<!-- Used to display message boxes. -->
<script file="gui/common/functions_global_object.js" />
<!-- Used for engine + mod version checks. -->
<!-- Used for engine + mod version checks and deleteTooltip. -->
<script file="gui/common/functions_utility_loadsave.js" />
<!-- Actual replay scripts after settings.js, as it initializes g_Settings. -->
@@ -34,6 +34,8 @@ function init()
gameSelection.selected = savedGames.length - 1;
else
selectionChanged();
Engine.GetGUIObjectByName("deleteGameButton").tooltip = deleteTooltip();
}
function selectionChanged()
@@ -37,6 +37,8 @@ function init(data)
gameSelection.list = savedGames.map(game => generateLabel(game.metadata));
gameSelection.list_data = savedGames.map(game => game.id);
gameSelection.selected = -1;
Engine.GetGUIObjectByName("deleteGameButton").tooltip = deleteTooltip();
}
function saveGame()
@@ -2,6 +2,7 @@
<objects>
<script file="gui/common/color.js"/>
<script file="gui/common/functions_global_object.js" />
<script file="gui/common/functions_utility_loadsave.js" />
<script file="gui/savedgames/save.js" />
@@ -15,7 +15,6 @@
<translatableAttribute id="caption" context="chat input">Text:</translatableAttribute>
</object>
<object name="chatInput" size="75 44 100%-16 68" type="input" style="ModernInput" max_length="80">
<translatableAttribute id="tooltip" context="chat input">Type the message to send.</translatableAttribute>
<action on="Press">submitChatInput();</action>
<action on="Tab">
let playernames = [];
@@ -293,8 +293,6 @@ function init(initData, hotloadData)
if (Engine.IsAtlasRunning())
Engine.GetGUIObjectByName("menuExitButton").enabled = false;
initHotkeyTooltips();
if (hotloadData)
g_Selection.selected = hotloadData.selection;
@@ -313,8 +311,21 @@ function init(initData, hotloadData)
//setTimeout(function() { reportPerformance(60); }, 60000);
}
function initHotkeyTooltips()
/**
* Depends on the current player (g_IsObserver).
*/
function updateHotkeyTooltips()
{
Engine.GetGUIObjectByName("chatInput").tooltip =
translateWithContext("chat input", "Type the message to send.") + "\n" +
colorizeAutocompleteHotkey() +
colorizeHotkey("\n" + translate("Press %(hotkey)s to open the public chat."), "chat") +
colorizeHotkey(
"\n" + (g_IsObserver ?
translate("Press %(hotkey)s to open the observer chat.") :
translate("Press %(hotkey)s to open the ally chat.")),
"teamchat");
Engine.GetGUIObjectByName("idleWorkerButton").tooltip =
colorizeHotkey("%(hotkey)s" + " ", "selection.idleworker") +
translate("Find idle worker");
@@ -389,8 +400,8 @@ function selectViewPlayer(playerID)
Engine.SetViewedPlayer(g_ViewedPlayer);
updateTopPanel();
updateChatAddressees();
updateHotkeyTooltips();
// Update GUI and clear player-dependent cache
onSimulationUpdate();