mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Add buttons for changing between, and hotkeys for opening, the civinfo and structree
Patch by: fpre Reviewed By: s0600204 Fixes: #4970 Differential Revision: https://code.wildfiregames.com/D846 This was SVN commit r21339.
This commit is contained in:
parent
70172519b7
commit
760a47335d
13 changed files with 187 additions and 21 deletions
|
|
@ -154,6 +154,8 @@ showsky = "Alt+Z" ; Toggle sky
|
|||
; > DIALOG HOTKEYS
|
||||
summary = "Ctrl+Tab" ; Toggle in-game summary
|
||||
lobby = "Alt+L" ; Show the multiplayer lobby in a dialog window.
|
||||
structree = "Alt+Shift+S" ; Show structure tree
|
||||
civinfo = "Alt+Shift+H" ; Show civilization info
|
||||
|
||||
; > CLIPBOARD CONTROLS
|
||||
copy = "Ctrl+C" ; Copy to clipboard
|
||||
|
|
|
|||
|
|
@ -3,17 +3,30 @@
|
|||
*/
|
||||
const g_CivData = loadCivData(true, false);
|
||||
|
||||
/**
|
||||
* Callback function name on closing gui via Engine.PopGuiPage().
|
||||
*/
|
||||
var g_Callback = "";
|
||||
|
||||
var g_SelectedCiv = "";
|
||||
|
||||
/**
|
||||
* Initialize the dropdown containing all the available civs.
|
||||
*/
|
||||
function init(settings)
|
||||
function init(data = {})
|
||||
{
|
||||
if (data.callback)
|
||||
g_Callback = data.callback;
|
||||
|
||||
var civList = Object.keys(g_CivData).map(civ => ({ "name": g_CivData[civ].Name, "code": civ })).sort(sortNameIgnoreCase);
|
||||
var civSelection = Engine.GetGUIObjectByName("civSelection");
|
||||
|
||||
civSelection.list = civList.map(civ => civ.name);
|
||||
civSelection.list_data = civList.map(civ => civ.code);
|
||||
civSelection.selected = 0;
|
||||
civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0;
|
||||
|
||||
Engine.GetGUIObjectByName("structreeButton").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to Structure Tree."), "structree");
|
||||
Engine.GetGUIObjectByName("close").tooltip = colorizeHotkey(translate("%(hotkey)s: Close History."), "cancel");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -79,6 +92,20 @@ function subHeading(obj)
|
|||
return coloredText(string + "\n", "white");
|
||||
}
|
||||
|
||||
function switchToStrucTreePage()
|
||||
{
|
||||
Engine.PopGuiPage();
|
||||
Engine.PushGuiPage("page_structree.xml", { "civ": g_SelectedCiv, "callback": g_Callback });
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
if (g_Callback)
|
||||
Engine.PopGuiPageCB({ "civ": g_SelectedCiv, "page": "page_civinfo.xml" });
|
||||
else
|
||||
Engine.PopGuiPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the GUI after the user selected a civ from dropdown.
|
||||
*
|
||||
|
|
@ -88,6 +115,8 @@ function selectCiv(code)
|
|||
{
|
||||
var civInfo = g_CivData[code];
|
||||
|
||||
g_SelectedCiv = code;
|
||||
|
||||
if(!civInfo)
|
||||
error(sprintf("Error loading civ data for \"%(code)s\"", { "code": code }));
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@
|
|||
<script directory="gui/common/"/>
|
||||
<script directory="gui/civinfo/"/>
|
||||
|
||||
<object hotkey="civinfo">
|
||||
<action on="Press">
|
||||
close();
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<!-- Add a translucent black background to fade out the menu page -->
|
||||
<object type="image" z="0" sprite="BackgroundTranslucent"/>
|
||||
|
||||
|
|
@ -108,17 +114,29 @@
|
|||
|
||||
</object>
|
||||
|
||||
<!-- Structure tree page -->
|
||||
<object
|
||||
type="button"
|
||||
style="StoneButton"
|
||||
size="100%-309 100%-52 100%-169 100%-24"
|
||||
name="structreeButton"
|
||||
hotkey="structree"
|
||||
>
|
||||
<translatableAttribute id="caption">Structure Tree</translatableAttribute>
|
||||
<action on="Press">switchToStrucTreePage();</action>
|
||||
</object>
|
||||
|
||||
<!-- Close dialog -->
|
||||
<object
|
||||
type="button"
|
||||
style="StoneButton"
|
||||
size="100%-164 100%-52 100%-24 100%-24"
|
||||
name="close"
|
||||
hotkey="cancel"
|
||||
>
|
||||
<translatableAttribute id="caption">Close</translatableAttribute>
|
||||
<action on="Press">
|
||||
<![CDATA[
|
||||
Engine.PopGuiPage();
|
||||
]]>
|
||||
close();
|
||||
</action>
|
||||
</object>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@ var g_GameSpeeds = getGameSpeedChoices(false);
|
|||
*/
|
||||
const g_CivData = loadCivData(false, false);
|
||||
|
||||
/**
|
||||
* Store civilization code and page (structree or history) opened in civilization info.
|
||||
*/
|
||||
var g_CivInfo = {
|
||||
"code": "",
|
||||
"page": "page_civinfo.xml"
|
||||
};
|
||||
|
||||
/**
|
||||
* Highlight the "random" dropdownlist item.
|
||||
*/
|
||||
|
|
@ -1108,6 +1116,12 @@ function init(attribs)
|
|||
supplementDefaults();
|
||||
|
||||
setTimeout(displayGamestateNotifications, 1000);
|
||||
|
||||
Engine.GetGUIObjectByName("civInfoButton").tooltip = sprintf(
|
||||
translate("%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click."), {
|
||||
"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
|
||||
"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
|
||||
});
|
||||
}
|
||||
|
||||
function initDefaults()
|
||||
|
|
@ -2681,3 +2695,9 @@ function updateAutocompleteEntries()
|
|||
|
||||
g_Autocomplete = Object.keys(autocomplete).sort().reverse().reduce((all, priority) => all.concat(autocomplete[priority]), []);
|
||||
}
|
||||
|
||||
function storeCivInfoPage(data)
|
||||
{
|
||||
g_CivInfo.code = data.civ;
|
||||
g_CivInfo.page = data.page;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,18 @@
|
|||
<script directory="gui/common/"/>
|
||||
<script directory="gui/gamesetup/"/>
|
||||
|
||||
<object hotkey="civinfo">
|
||||
<action on="Press">
|
||||
Engine.PushGuiPage("page_civinfo.xml", { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<object hotkey="structree">
|
||||
<action on="Press">
|
||||
Engine.PushGuiPage("page_structree.xml", { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<!-- Add a translucent black background to fade out the menu page -->
|
||||
<object type="image" style="ModernWindow" size="0 0 100% 100%">
|
||||
|
||||
|
|
@ -61,10 +73,9 @@
|
|||
sprite_over="iconInfoWhite"
|
||||
size="85%-37 0 85%-21 16"
|
||||
>
|
||||
<translatableAttribute id="tooltip">View civilization info</translatableAttribute>
|
||||
<action on="Press"><![CDATA[
|
||||
Engine.PushGuiPage("page_civinfo.xml");
|
||||
]]></action>
|
||||
<action on="Press">
|
||||
Engine.PushGuiPage(g_CivInfo.page, { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<object name="civResetButton"
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ Ctrl + Tab: Toggle summary window.
|
|||
Alt + L: Show the multiplayer lobby in a dialog window.
|
||||
Ctrl + B: Toggle in-game barter/trade page.
|
||||
Ctrl + P: Toggle in-game tutorial panel.
|
||||
Alt + Shift + S: Toggle structure tree.
|
||||
Alt + Shift + H: Toggle civilization info.
|
||||
|
||||
[font="sans-bold-14"]Modify mouse action
|
||||
[font="sans-14"]Ctrl + Right Click on building: Garrison
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ function init(initData, hotloadData)
|
|||
guiObj.sprite = g_BackgroundLayerset[i].sprite;
|
||||
guiObj.z = i;
|
||||
}
|
||||
Engine.GetGUIObjectByName("structreeButton").tooltip = colorizeHotkey(
|
||||
translate("%(hotkey)s: View the structure tree of civilizations featured in 0 A.D."),
|
||||
"structree");
|
||||
Engine.GetGUIObjectByName("civInfoButton").tooltip = colorizeHotkey(
|
||||
translate("%(hotkey)s: Learn about the many civilizations featured in 0 A.D."),
|
||||
"civinfo");
|
||||
Engine.GetGUIObjectByName("lobbyButton").tooltip = colorizeHotkey(
|
||||
translate("%(hotkey)s: Launch the multiplayer lobby."),
|
||||
"lobby");
|
||||
}
|
||||
|
||||
function getHotloadData()
|
||||
|
|
|
|||
|
|
@ -175,9 +175,10 @@
|
|||
type="button"
|
||||
size="0 64 100% 92"
|
||||
tooltip_style="pgToolTip"
|
||||
name="structreeButton"
|
||||
hotkey="structree"
|
||||
>
|
||||
<translatableAttribute id="caption">Structure Tree</translatableAttribute>
|
||||
<translatableAttribute id="tooltip">View the structure tree of civilizations featured in 0 A.D.</translatableAttribute>
|
||||
<action on="Press">
|
||||
closeMenu();
|
||||
Engine.PushGuiPage("page_structree.xml", {});
|
||||
|
|
@ -190,9 +191,10 @@
|
|||
type="button"
|
||||
size="0 96 100% 124"
|
||||
tooltip_style="pgToolTip"
|
||||
name="civInfoButton"
|
||||
hotkey="civinfo"
|
||||
>
|
||||
<translatableAttribute id="caption">History</translatableAttribute>
|
||||
<translatableAttribute id="tooltip">Learn about the many civilizations featured in 0 A.D.</translatableAttribute>
|
||||
<action on="Press">
|
||||
closeMenu();
|
||||
Engine.PushGuiPage("page_civinfo.xml");
|
||||
|
|
@ -310,10 +312,10 @@
|
|||
style="StoneButtonFancy"
|
||||
size="0 64 100% 92"
|
||||
tooltip_style="pgToolTip"
|
||||
name="lobbyButton"
|
||||
hotkey="lobby"
|
||||
>
|
||||
<translatableAttribute id="caption">Game Lobby</translatableAttribute>
|
||||
<translatableAttribute id="tooltip">Launch the multiplayer lobby.</translatableAttribute>
|
||||
<action on="Press">
|
||||
if (!Engine.StartXmppClient)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ var g_BuildList = {};
|
|||
*/
|
||||
var g_TrainList = {};
|
||||
|
||||
/**
|
||||
* Callback function name on closing gui via Engine.PopGuiPage().
|
||||
*/
|
||||
var g_Callback = "";
|
||||
|
||||
/**
|
||||
* Initialize the page
|
||||
*
|
||||
|
|
@ -16,7 +21,7 @@ var g_TrainList = {};
|
|||
function init(data = {})
|
||||
{
|
||||
if (data.callback)
|
||||
g_CallbackSet = true;
|
||||
g_Callback = data.callback;
|
||||
|
||||
let civList = Object.keys(g_CivData).map(civ => ({
|
||||
"name": g_CivData[civ].Name,
|
||||
|
|
@ -40,6 +45,23 @@ function init(data = {})
|
|||
civSelection.list = civList.map(c => c.name);
|
||||
civSelection.list_data = civList.map(c => c.code);
|
||||
civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0;
|
||||
|
||||
Engine.GetGUIObjectByName("civinfo").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to History."), "civinfo");
|
||||
Engine.GetGUIObjectByName("close").tooltip = colorizeHotkey(translate("%(hotkey)s: Close Structure Tree."), "cancel");
|
||||
}
|
||||
|
||||
function switchToCivInfoPage()
|
||||
{
|
||||
Engine.PopGuiPage();
|
||||
Engine.PushGuiPage("page_civinfo.xml", { "civ": g_SelectedCiv, "callback": g_Callback });
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
if (g_Callback)
|
||||
Engine.PopGuiPageCB({ "civ": g_SelectedCiv, "page": "page_structree.xml" });
|
||||
else
|
||||
Engine.PopGuiPage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@
|
|||
<script directory="gui/reference/common/"/>
|
||||
<script directory="gui/reference/structree/"/>
|
||||
|
||||
<object hotkey="structree">
|
||||
<action on="Press">
|
||||
close();
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<!-- Add a translucent black background to fade out the menu page -->
|
||||
<object type="image" z="0" sprite="BackgroundTranslucent"/>
|
||||
|
||||
|
|
@ -109,16 +115,29 @@
|
|||
</object>
|
||||
</object>
|
||||
|
||||
<!-- History page -->
|
||||
<object
|
||||
type="button"
|
||||
style="StoneButton"
|
||||
size="100%-309 100%-44 100%-169 100%-16"
|
||||
name="civinfo"
|
||||
hotkey="civinfo"
|
||||
>
|
||||
<translatableAttribute id="caption">History</translatableAttribute>
|
||||
<action on="Press">switchToCivInfoPage();</action>
|
||||
</object>
|
||||
<!-- Close dialog -->
|
||||
<object
|
||||
type="button"
|
||||
style="StoneButton"
|
||||
size="100%-164 100%-44 100%-16 100%-16"
|
||||
name="close"
|
||||
hotkey="cancel"
|
||||
>
|
||||
<translatableAttribute id="caption">Close</translatableAttribute>
|
||||
<action on="Press">closePage();</action>
|
||||
<action on="Press">
|
||||
close();
|
||||
</action>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
</objects>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,18 @@
|
|||
<action on="Press">openGameSummary();</action>
|
||||
</object>
|
||||
|
||||
<object hotkey="civinfo">
|
||||
<action on="Press">
|
||||
Engine.PushGuiPage("page_civinfo.xml", { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<object hotkey="structree">
|
||||
<action on="Press">
|
||||
Engine.PushGuiPage("page_structree.xml", { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
|
||||
</action>
|
||||
</object>
|
||||
|
||||
<object hotkey="silhouettes">
|
||||
<action on="Press">toggleConfigBool("silhouettes");</action>
|
||||
</object>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@ var STEP = 5;
|
|||
// Shown in the trade dialog.
|
||||
var g_IdleTraderTextColor = "orange";
|
||||
|
||||
/**
|
||||
* Store civilization code and page (structree or history) opened in civilization info.
|
||||
*/
|
||||
var g_CivInfo = {
|
||||
"code": "",
|
||||
"page": "page_structree.xml"
|
||||
};
|
||||
|
||||
/**
|
||||
* The barter constants should match with the simulation
|
||||
* Quantity of goods to sell per click.
|
||||
|
|
@ -1108,12 +1116,20 @@ function openStrucTree()
|
|||
pauseGame();
|
||||
|
||||
// TODO add info about researched techs and unlocked entities
|
||||
Engine.PushGuiPage("page_structree.xml", {
|
||||
"civ": g_Players[g_ViewedPlayer].civ,
|
||||
"callback": "resumeGame",
|
||||
|
||||
Engine.PushGuiPage(g_CivInfo.page, {
|
||||
"civ": g_CivInfo.code || g_Players[g_ViewedPlayer].civ,
|
||||
"callback": "storeCivInfoPage"
|
||||
});
|
||||
}
|
||||
|
||||
function storeCivInfoPage(data)
|
||||
{
|
||||
g_CivInfo.code = data.civ;
|
||||
g_CivInfo.page = data.page;
|
||||
resumeGame();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause or resume the game.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -654,9 +654,13 @@ function updateTopPanel()
|
|||
if (isPlayer)
|
||||
{
|
||||
civIcon.sprite = "stretched:" + g_CivData[g_Players[g_ViewedPlayer].civ].Emblem;
|
||||
Engine.GetGUIObjectByName("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree"), {
|
||||
"civ": g_CivData[g_Players[g_ViewedPlayer].civ].Name
|
||||
});
|
||||
Engine.GetGUIObjectByName("civIconOverlay").tooltip =
|
||||
sprintf(
|
||||
translate("%(civ)s\n%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click."), {
|
||||
"civ": setStringTags(g_CivData[g_Players[g_ViewedPlayer].civ].Name, { "font": "sans-bold-stroke-14" }),
|
||||
"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
|
||||
"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
|
||||
});
|
||||
}
|
||||
|
||||
Engine.GetGUIObjectByName("optionFollowPlayer").hidden = !g_IsObserver || !isPlayer;
|
||||
|
|
|
|||
Loading…
Reference in a new issue