1
0
forked from 0ad/0ad

Implement hotkeys and mousescroll to change tabs in tabbed pages (credits, summary and options).

Save the latest page and graph in the summary screen
Implement a hotkey to open and close the summary screen for the
replaymenu and ingame.

Patch By: ffffffff
Comments By: elexis
Differential Revision: https://code.wildfiregames.com/D810
This was SVN commit r20644.
This commit is contained in:
bb 2017-12-11 22:16:01 +00:00
parent 3eef53b124
commit 8ae67ed15f
13 changed files with 149 additions and 11 deletions

View File

@ -147,9 +147,10 @@ screenshot = F2 ; Take PNG screenshot
bigscreenshot = "Shift+F2" ; Take large BMP screenshot
togglefullscreen = "Alt+Return" ; Toggle fullscreen/windowed mode
screenshot.watermark = "Alt+K" ; Toggle product/company watermark for official screenshots
wireframe = "Alt+W" ; Toggle wireframe mode
silhouettes = "Alt+S" ; Toggle unit silhouettes
wireframe = "Alt+Shift+W" ; Toggle wireframe mode
silhouettes = "Alt+Shift+S" ; Toggle unit silhouettes
showsky = "Alt+Z" ; Toggle sky
summary = "Ctrl+Tab" ; Toggle in-game summary
; > CLIPBOARD CONTROLS
copy = "Ctrl+C" ; Copy to clipboard
@ -329,6 +330,10 @@ noconfirmation = Shift ; Do not ask confirmation when deleting a game
fastforward = Space ; If timewarp mode enabled, speed up the game
rewind = Backspace ; If timewarp mode enabled, go back to earlier point in the game
[hotkey.tab]
next = "Alt+S" ; Show the next tab
prev = "Alt+W" ; Show the previous tab
[hotkey.text] ; > GUI TEXTBOX HOTKEYS
delete.left = "Ctrl+Backspace" ; Delete word to the left of cursor
delete.right = "Ctrl+Del" ; Delete word to the right of cursor

View File

@ -1,6 +1,7 @@
var g_PanelNames = ["special", "programming", "art", "translators", "misc", "donators"];
var g_ButtonNames = {};
var g_PanelTexts = {};
var g_SelectedPanel = 0;
function init()
{
@ -21,9 +22,17 @@ function init()
selectPanel(0);
}
/*
* Show next/previous panel.
* @param direction - 1/-1 forward, backward panel.
*/
function selectNextTab(direction)
{
selectPanel((g_SelectedPanel + direction + g_PanelNames.length) % g_PanelNames.length);
}
function placeButtons()
{
for (let i = 0; i < g_PanelNames.length; ++i)
{
let button = Engine.GetGUIObjectByName("creditsPanelButton[" + i + "]");
@ -32,6 +41,8 @@ function placeButtons()
warn("Could not display some credits.");
break;
}
button.onMouseWheelUp = () => selectNextTab(1);
button.onMouseWheelDown = () => selectNextTab(-1);
button.hidden = false;
let size = button.size;
size.top = i * 35;
@ -84,6 +95,7 @@ function parseHelper(list)
function selectPanel(i)
{
g_SelectedPanel = i;
Engine.GetGUIObjectByName("creditsPanelButtons").children.forEach((button, j) => {
button.sprite = i == j ? "ModernTabVerticalForeground" : "ModernTabVerticalBackground";
});

View File

@ -14,6 +14,14 @@
<!-- Add a translucent black background to fade out the menu page -->
<object type="image" z="0" sprite="ModernFade"/>
<object hotkey="tab.next">
<action on="Press">selectNextTab(1);</action>
</object>
<object hotkey="tab.prev">
<action on="Press">selectNextTab(-1);</action>
</object>
<object type="image" style="ModernDialog" size="50%-473 24 50%+473 100%-24">
<object style="ModernLabelText" name="dialogTitle" type="text" size="50%-128 -18 50%+128 14">
<translatableAttribute id="caption">0 A.D. Credits</translatableAttribute>

View File

@ -49,6 +49,8 @@ F11: Enable/disable real-time profiler (toggles through the displays of informat
Shift + F11: Save current profiler data to "logs/profile.txt"
F2: Take screenshot (in .png format, location is displayed in the top left of the GUI after the file has been saved, and can also be seen in the console/logs if you miss it there)
Shift + F2: Take huge screenshot (6400px*4800px, in .bmp format, location is displayed in the top left of the GUI after the file has been saved, and can also be seen in the console/logs if you miss it there)
Alt + S: Switch to the next tab.
Alt + W: Switch to the previous tab.
[font="sans-bold-14"]In Game
[font="sans-14"]Double Left Click \[on unit]: Select all of your units of the same kind on the screen (even if they're different ranks)
@ -87,6 +89,7 @@ Z, X, C, V, B, N, M: With training buildings selected. Add the 1st, 2nd, ... uni
PageUp with units selected: Highlights the units/buildings guarded by the selection.
PageDown with units/buildings selected: Highlights the units guarding the selection.
Tab: See all status bars (which would also show the building progress)
Ctrl + Tab: Toggle summary window.
[font="sans-bold-14"]Modify mouse action
[font="sans-14"]Ctrl + Right Click on building: Garrison
@ -110,8 +113,8 @@ Ctrl + Right Click with units selected:
[font="sans-bold-14"]Overlays
[font="sans-14"]Alt + G: Hide/show the GUI
Alt + D: Show/hide developer overlay (with developer options)
Alt + W: Toggle wireframe mode (press once to get wireframes overlaid over the textured models, twice to get just the wireframes colored by the textures, thrice to get back to normal textured mode)
Alt + S: Toggle unit silhouettes (might give a small performance boost)
Alt + Shift + W: Toggle wireframe mode (press once to get wireframes overlaid over the textured models, twice to get just the wireframes colored by the textures, thrice to get back to normal textured mode)
Alt + Shift + S: Toggle unit silhouettes (might give a small performance boost)
Alt + Z: Toggle sky
Alt + C: Toggle attack range visualizations of selected defensive structures
Alt + V: Toggle aura range visualizations of selected units and structures

View File

@ -160,6 +160,17 @@ function getHotloadData()
};
}
/*
* Show next/previous panel.
* @param direction - 1/-1 forward, backward panel.
*/
function selectNextTab(direction)
{
g_SelectedCategory = (g_SelectedCategory + direction + Object.keys(g_Options).length) %
Object.keys(g_Options).length;
displayOptions();
}
function placeTabButtons()
{
for (let category in g_Options)
@ -171,6 +182,8 @@ function placeTabButtons()
break;
}
button.onMouseWheelUp = () => selectNextTab(1);
button.onMouseWheelDown = () => selectNextTab(-1);
button.hidden = false;
let size = button.size;

View File

@ -8,6 +8,14 @@
<!-- Add a translucent black background to fade out the menu page -->
<object type="image" sprite="ModernFade"/>
<object hotkey="tab.next">
<action on="Press">selectNextTab(1);</action>
</object>
<object hotkey="tab.prev">
<action on="Press">selectNextTab(-1);</action>
</object>
<!-- Settings Window -->
<object name="options" type="image" style="ModernDialog" size="50%-350 50%-330 50%+350 50%+330">

View File

@ -127,7 +127,8 @@ function showReplaySummary()
"isReplay": true,
"replayDirectory": g_ReplaysFiltered[selected].directory,
"replaySelectionData": createReplaySelectionData(g_ReplaysFiltered[selected].directory)
}
},
"selectedData": g_SummarySelectedData
});
}

View File

@ -48,6 +48,11 @@ var g_SelectedReplayDirectory = "";
*/
var g_ReplaysLoaded = false;
/**
* Remember the name of the currently opened view panel.
*/
var g_SummarySelectedData = "";
/**
* Initializes globals, loads replays and displays the list.
*/
@ -69,6 +74,9 @@ function init(data)
initHotkeyTooltips();
displayReplayList();
if (data && data.summarySelectedData)
g_SummarySelectedData = data.summarySelectedData;
}
/**

View File

@ -239,7 +239,7 @@
</object>
<!-- Summary Button -->
<object name="summaryButton" type="button" style="StoneButton" size="65%-50 0 82%-50 100%">
<object name="summaryButton" type="button" style="StoneButton" size="65%-50 0 82%-50 100%" hotkey="summary">
<translatableAttribute id="caption">Summary</translatableAttribute>
<action on="Press">showReplaySummary();</action>
</object>

View File

@ -28,6 +28,10 @@
<action on="Press">toggleTrade();</action>
</object>
<object hotkey="summary">
<action on="Press">openGameSummary();</action>
</object>
<object hotkey="silhouettes">
<action on="Press">toggleConfigBool("silhouettes");</action>
</object>

View File

@ -58,6 +58,11 @@ var g_IsObjectivesOpen = false;
*/
var g_BribeButtonsWaiting = {};
/**
* Currently viewed summary panel.
*/
var g_SummarySelectedData = "";
// Redefined every time someone makes a tribute (so we can save some data in a closure). Called in input.js handleInputBeforeGui.
var g_FlushTributing = function() {};
@ -1075,7 +1080,8 @@ function openGameSummary()
"gui": {
"isInGame": true
},
"callback": "resumeGame"
"selectedData": g_SummarySelectedData,
"callback": "resumeGameAndSaveSummarySelectedData"
});
}
@ -1123,6 +1129,12 @@ function resumeGame(explicit = false)
pauseGame(false, explicit);
}
function resumeGameAndSaveSummarySelectedData(data)
{
g_SummarySelectedData = data.summarySelectedData;
resumeGame(data.explicitResume);
}
/**
* Called when the current player toggles a pause button.
*/

View File

@ -125,11 +125,30 @@ var g_SelectedChart = {
"type": [0, 0]
};
/*
* Array of the panel button names.
*/
var g_PanelButtons = [];
/*
* Remember the name of the currently opened view panel.
*/
var g_SelectedPanel = "";
function init(data)
{
// Fill globals
g_GameData = data;
g_ScorePanelsData = getScorePanelsData();
g_PanelButtons = Object.keys(g_ScorePanelsData).concat(["charts"]).map(panel => panel + "PanelButton");
g_SelectedPanel = g_PanelButtons[0];
if (data && data.selectedData)
{
g_SelectedPanel = data.selectedData.panel;
g_SelectedChart = data.selectedData.charts;
}
initTeamData();
calculateTeamCounterDataHelper();
@ -137,7 +156,23 @@ function init(data)
initPlayerBoxPositions();
initGUICharts();
initGUILabelsAndButtons();
selectPanel(Engine.GetGUIObjectByName("scorePanelButton"));
selectPanel(Engine.GetGUIObjectByName(g_SelectedPanel));
for (let button of g_PanelButtons)
{
let tab = Engine.GetGUIObjectByName(button);
tab.onMouseWheelUp = () => selectNextTab(1);
tab.onMouseWheelDown = () => selectNextTab(-1);
}
}
/*
* Show next/previous panel.
* @param direction - 1/-1 forward, backward panel.
*/
function selectNextTab(direction)
{
selectPanel(Engine.GetGUIObjectByName(g_PanelButtons[
(g_PanelButtons.indexOf(g_SelectedPanel) + direction + g_PanelButtons.length) % g_PanelButtons.length]));
}
function selectPanel(panel)
@ -161,6 +196,8 @@ function selectPanel(panel)
updatePanelData(g_ScorePanelsData[panel.name.substr(0, panel.name.length - "PanelButton".length)]);
else
[0, 1].forEach(updateCategoryDropdown);
g_SelectedPanel = panel.name;
}
function initGUICharts()
@ -395,11 +432,19 @@ function confirmStartReplay()
function continueButton()
{
let summarySelectedData = {
"panel": g_SelectedPanel,
"charts": g_SelectedChart
};
if (g_GameData.gui.isInGame)
Engine.PopGuiPageCB(0);
Engine.PopGuiPageCB({
"explicitResume": 0,
"summarySelectedData": summarySelectedData
});
else if (g_GameData.gui.isReplay)
Engine.SwitchGuiPage("page_replaymenu.xml", {
"replaySelectionData": g_GameData.gui.replaySelectionData
"replaySelectionData": g_GameData.gui.replaySelectionData,
"summarySelectedData": summarySelectedData
});
else if (Engine.HasXmppClient())
Engine.SwitchGuiPage("page_lobby.xml");

View File

@ -5,6 +5,25 @@
<script directory="gui/common/"/>
<script directory="gui/summary/"/>
<object hotkey="summary">
<action on="Press">continueButton();</action>
</object>
<object hotkey="cancel">
<action on="Press">
if (g_GameData.gui.isInGame)
continueButton();
</action>
</object>
<object hotkey="tab.next">
<action on="Press">selectNextTab(1);</action>
</object>
<object hotkey="tab.prev">
<action on="Press">selectNextTab(-1);</action>
</object>
<object name="summaryWindow"
type="image"
style="ModernWindow"