mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-26 22:12:39 +00:00
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:
@@ -144,3 +144,17 @@ function colorizeHotkey(text, hotkey)
|
|||||||
"[/color]"
|
"[/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
|
// Run init again to refresh saved game list
|
||||||
init();
|
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();
|
resizeMoreOptionsWindow();
|
||||||
|
|
||||||
|
Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
|
||||||
|
|
||||||
if (g_IsNetworked)
|
if (g_IsNetworked)
|
||||||
Engine.GetGUIObjectByName("chatInput").focus();
|
Engine.GetGUIObjectByName("chatInput").focus();
|
||||||
|
|
||||||
|
|||||||
@@ -224,6 +224,8 @@ function init(attribs)
|
|||||||
Engine.LobbyClearPresenceUpdates();
|
Engine.LobbyClearPresenceUpdates();
|
||||||
updatePlayerList();
|
updatePlayerList();
|
||||||
updateSubject(Engine.LobbyGetRoomSubject());
|
updateSubject(Engine.LobbyGetRoomSubject());
|
||||||
|
|
||||||
|
Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey();
|
||||||
}
|
}
|
||||||
|
|
||||||
function returnToMainMenu()
|
function returnToMainMenu()
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ function init(data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initHotkeyTooltips();
|
||||||
displayReplayList();
|
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.
|
* 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. -->
|
<!-- Used to display message boxes. -->
|
||||||
<script file="gui/common/functions_global_object.js" />
|
<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" />
|
<script file="gui/common/functions_utility_loadsave.js" />
|
||||||
|
|
||||||
<!-- Actual replay scripts after settings.js, as it initializes g_Settings. -->
|
<!-- Actual replay scripts after settings.js, as it initializes g_Settings. -->
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ function init()
|
|||||||
gameSelection.selected = savedGames.length - 1;
|
gameSelection.selected = savedGames.length - 1;
|
||||||
else
|
else
|
||||||
selectionChanged();
|
selectionChanged();
|
||||||
|
|
||||||
|
Engine.GetGUIObjectByName("deleteGameButton").tooltip = deleteTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectionChanged()
|
function selectionChanged()
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ function init(data)
|
|||||||
gameSelection.list = savedGames.map(game => generateLabel(game.metadata));
|
gameSelection.list = savedGames.map(game => generateLabel(game.metadata));
|
||||||
gameSelection.list_data = savedGames.map(game => game.id);
|
gameSelection.list_data = savedGames.map(game => game.id);
|
||||||
gameSelection.selected = -1;
|
gameSelection.selected = -1;
|
||||||
|
|
||||||
|
Engine.GetGUIObjectByName("deleteGameButton").tooltip = deleteTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGame()
|
function saveGame()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<objects>
|
<objects>
|
||||||
|
|
||||||
|
<script file="gui/common/color.js"/>
|
||||||
<script file="gui/common/functions_global_object.js" />
|
<script file="gui/common/functions_global_object.js" />
|
||||||
<script file="gui/common/functions_utility_loadsave.js" />
|
<script file="gui/common/functions_utility_loadsave.js" />
|
||||||
<script file="gui/savedgames/save.js" />
|
<script file="gui/savedgames/save.js" />
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
<translatableAttribute id="caption" context="chat input">Text:</translatableAttribute>
|
<translatableAttribute id="caption" context="chat input">Text:</translatableAttribute>
|
||||||
</object>
|
</object>
|
||||||
<object name="chatInput" size="75 44 100%-16 68" type="input" style="ModernInput" max_length="80">
|
<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="Press">submitChatInput();</action>
|
||||||
<action on="Tab">
|
<action on="Tab">
|
||||||
let playernames = [];
|
let playernames = [];
|
||||||
|
|||||||
@@ -293,8 +293,6 @@ function init(initData, hotloadData)
|
|||||||
if (Engine.IsAtlasRunning())
|
if (Engine.IsAtlasRunning())
|
||||||
Engine.GetGUIObjectByName("menuExitButton").enabled = false;
|
Engine.GetGUIObjectByName("menuExitButton").enabled = false;
|
||||||
|
|
||||||
initHotkeyTooltips();
|
|
||||||
|
|
||||||
if (hotloadData)
|
if (hotloadData)
|
||||||
g_Selection.selected = hotloadData.selection;
|
g_Selection.selected = hotloadData.selection;
|
||||||
|
|
||||||
@@ -313,8 +311,21 @@ function init(initData, hotloadData)
|
|||||||
//setTimeout(function() { reportPerformance(60); }, 60000);
|
//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 =
|
Engine.GetGUIObjectByName("idleWorkerButton").tooltip =
|
||||||
colorizeHotkey("%(hotkey)s" + " ", "selection.idleworker") +
|
colorizeHotkey("%(hotkey)s" + " ", "selection.idleworker") +
|
||||||
translate("Find idle worker");
|
translate("Find idle worker");
|
||||||
@@ -389,8 +400,8 @@ function selectViewPlayer(playerID)
|
|||||||
Engine.SetViewedPlayer(g_ViewedPlayer);
|
Engine.SetViewedPlayer(g_ViewedPlayer);
|
||||||
|
|
||||||
updateTopPanel();
|
updateTopPanel();
|
||||||
|
|
||||||
updateChatAddressees();
|
updateChatAddressees();
|
||||||
|
updateHotkeyTooltips();
|
||||||
|
|
||||||
// Update GUI and clear player-dependent cache
|
// Update GUI and clear player-dependent cache
|
||||||
onSimulationUpdate();
|
onSimulationUpdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user