Update submenu code
This was SVN commit r10107.
This commit is contained in:
parent
8729d1115d
commit
2915e9a85e
@ -1,4 +1,5 @@
|
||||
var userReportEnabledText; // contains the original version with "$status" placeholder
|
||||
var currentSubmenu; // contains placeholdersubmenu
|
||||
|
||||
function init()
|
||||
{
|
||||
@ -7,6 +8,7 @@ function init()
|
||||
global.curr_music.loop();
|
||||
|
||||
userReportEnabledText = getGUIObjectByName("userReportEnabledText").caption;
|
||||
currentSubmenu = "submenuSinglePlayer";
|
||||
}
|
||||
|
||||
var t0 = new Date;
|
||||
@ -99,32 +101,21 @@ function onTick()
|
||||
}
|
||||
|
||||
// Update the submenu
|
||||
var MARGIN = 4;
|
||||
var currentSubmenu;
|
||||
function updateSubmenu(buttonName, newSubmenu, numButtons)
|
||||
function updateSubmenu(newSubmenu, position, buttonHeight, numButtons)
|
||||
{
|
||||
// hide old submenu if possible
|
||||
if (null != currentSubmenu)
|
||||
{
|
||||
getGUIObjectByName(currentSubmenu).hidden = true;
|
||||
}
|
||||
const MARGIN = 4;
|
||||
|
||||
// remove old submenu
|
||||
getGUIObjectByName(currentSubmenu).hidden = true;
|
||||
|
||||
// save new submenu
|
||||
// switch to new submenu
|
||||
currentSubmenu = newSubmenu;
|
||||
|
||||
// unhide new submenu
|
||||
getGUIObjectByName(currentSubmenu).hidden = false;
|
||||
|
||||
// find position of new submenu
|
||||
var sourceButton = getGUIObjectByName(buttonName);
|
||||
var verticalOffset = getGUIObjectByName("mainMenuButtons").size.top;
|
||||
var buttonHeight = sourceButton.size.bottom - sourceButton.size.top;
|
||||
|
||||
var top = verticalOffset + sourceButton.size.top - MARGIN;
|
||||
var bottom = verticalOffset + sourceButton.size.bottom + buttonHeight * (numButtons-1) + MARGIN;
|
||||
|
||||
|
||||
// set position of new submenu
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
var top = position - MARGIN;
|
||||
var bottom = position + (buttonHeight * numButtons) + MARGIN;
|
||||
submenu.size = submenu.size.left + " " + top + " " + submenu.size.right + " " + bottom;
|
||||
submenu.hidden = false;
|
||||
|
||||
|
@ -205,7 +205,7 @@ Status: $status.
|
||||
>
|
||||
Single Player
|
||||
<action on="Press"><![CDATA[
|
||||
updateSubmenu("menuSinglePlayerButton", "submenuSinglePlayer", 3);
|
||||
updateSubmenu("submenuSinglePlayer", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 3);
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
@ -219,7 +219,7 @@ Status: $status.
|
||||
>
|
||||
Multiplayer
|
||||
<action on="Press"><![CDATA[
|
||||
updateSubmenu("menuMultiplayerButton", "submenuMultiplayer", 2);
|
||||
updateSubmenu("submenuMultiplayer", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 2);
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
@ -233,7 +233,7 @@ Status: $status.
|
||||
>
|
||||
Tools <![CDATA[&]]> Options
|
||||
<action on="Press"><![CDATA[
|
||||
updateSubmenu("menuToolsAndOptionsButton", "submenuToolsAndOptions", 2);
|
||||
updateSubmenu("submenuToolsAndOptions", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 2);
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
@ -361,7 +361,7 @@ Get involved at: wildfiregames.com/0ad
|
||||
|
||||
<!--
|
||||
==========================================
|
||||
- MAIN MENU SIDE PANEL
|
||||
- SUBMENU
|
||||
==========================================
|
||||
-->
|
||||
|
||||
@ -370,115 +370,119 @@ Get involved at: wildfiregames.com/0ad
|
||||
type="image"
|
||||
hidden="true"
|
||||
>
|
||||
<!-- hides the submenu when the mouse leaves the mainMenuButtons or submenu -->
|
||||
<action on="MouseEnter">
|
||||
<![CDATA[getGUIObjectByName("submenu").hidden = true;;]]>
|
||||
<![CDATA[getGUIObjectByName("submenu").hidden = true;]]>
|
||||
</action>
|
||||
<object
|
||||
name="submenu"
|
||||
type="image"
|
||||
style="MainMenuPanel"
|
||||
size="298 50%-100 538 50%+100"
|
||||
>
|
||||
<object name="submenuSinglePlayer"
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="The 0 A.D. Game Manual"
|
||||
hidden="true"
|
||||
>
|
||||
<object name="subMenuSinglePlayerButton"
|
||||
type="button"
|
||||
style="StoneButtonFancy"
|
||||
size="0 0 100% 32"
|
||||
|
||||
<!-- submenu -->
|
||||
<object
|
||||
name="submenu"
|
||||
type="image"
|
||||
style="MainMenuPanel"
|
||||
size="298 50%-100 538 50%+100"
|
||||
>
|
||||
<!-- submenuSinglePlayer -->
|
||||
<object name="submenuSinglePlayer"
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Click here to start a new single player game. (A very basic computer opponent is available for testing purposes.)"
|
||||
tooltip="The 0 A.D. Game Manual"
|
||||
hidden="true"
|
||||
>
|
||||
Single Player Matches
|
||||
<action on="Press"><![CDATA[
|
||||
// Open Session Setup window.
|
||||
Engine.PushGuiPage("page_gamesetup.xml", { type: "offline" });
|
||||
]]></action>
|
||||
<object name="subMenuSinglePlayerButton"
|
||||
type="button"
|
||||
style="StoneButtonFancy"
|
||||
size="0 0 100% 32"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Click here to start a new single player game. (A very basic computer opponent is available for testing purposes.)"
|
||||
>
|
||||
Single Player Matches
|
||||
<action on="Press"><![CDATA[
|
||||
// Open Session Setup window.
|
||||
Engine.PushGuiPage("page_gamesetup.xml", { type: "offline" });
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
<object name="subMenuCampaignButton"
|
||||
type="button"
|
||||
style="StoneButtonFancy"
|
||||
size="0 32 100% 64"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Want to play a campaign? Unfortunately you'll have to wait as they're not yet implemented."
|
||||
enabled="false"
|
||||
>
|
||||
Historical Campaigns
|
||||
<action on="Press"><![CDATA[
|
||||
openMainMenuSubWindow ("pgCampaigns");
|
||||
]]></action>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<object name="subMenuCampaignButton"
|
||||
type="button"
|
||||
style="StoneButtonFancy"
|
||||
size="0 32 100% 64"
|
||||
<!-- submenuMultiplayer -->
|
||||
<object name="submenuMultiplayer"
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Want to play a campaign? Unfortunately you'll have to wait as they're not yet implemented."
|
||||
enabled="false"
|
||||
tooltip="The 0 A.D. Game Manual"
|
||||
hidden="true"
|
||||
>
|
||||
Historical Campaigns
|
||||
<action on="Press"><![CDATA[
|
||||
openMainMenuSubWindow ("pgCampaigns");
|
||||
]]></action>
|
||||
<object name="subMenuMultiplayerJoinGameButton"
|
||||
type="button"
|
||||
style="StoneButtonFancy"
|
||||
size="0 0 100% 32"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Tired of playing with yourself? Fight against one or more human players in a multiplayer game."
|
||||
>
|
||||
Multiplayer
|
||||
<action on="Press"><![CDATA[
|
||||
// Open Multiplayer connection window.
|
||||
Engine.PushGuiPage("page_gamesetup_mp.xml");
|
||||
]]></action>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
|
||||
<object name="submenuMultiplayer"
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="The 0 A.D. Game Manual"
|
||||
hidden="true"
|
||||
>
|
||||
<object name="subMenuMultiplayerJoinGameButton"
|
||||
type="button"
|
||||
style="StoneButtonFancy"
|
||||
size="0 0 100% 32"
|
||||
|
||||
<!-- submenuToolsAndOptions -->
|
||||
<object name="submenuToolsAndOptions"
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Tired of playing with yourself? Fight against one or more human players in a multiplayer game."
|
||||
tooltip="The 0 A.D. Game Manual"
|
||||
hidden="true"
|
||||
>
|
||||
Multiplayer
|
||||
<action on="Press"><![CDATA[
|
||||
// Open Multiplayer connection window.
|
||||
Engine.PushGuiPage("page_gamesetup_mp.xml");
|
||||
]]></action>
|
||||
<object name="submenuOptionsButton"
|
||||
style="StoneButtonFancy"
|
||||
type="button"
|
||||
size="0 0 100% 32"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="This will take you to the options menu. It does not work now, but someday it will."
|
||||
enabled="false"
|
||||
>
|
||||
Options
|
||||
<action on="Press"><![CDATA[
|
||||
// Open Options window.
|
||||
openMainMenuSubWindow ("pgOptions");
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
<object name="submenuEditorButton"
|
||||
style="StoneButtonFancy"
|
||||
type="button"
|
||||
size="0 32 100% 64"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Open the Atlas Scenario Editor in a new window. You can run this more reliably by starting the game with the command-line argument "-editor"."
|
||||
>
|
||||
Scenario Editor
|
||||
<action on="Press"><![CDATA[
|
||||
if (Engine.AtlasIsAvailable())
|
||||
Engine.RestartInAtlas();
|
||||
else
|
||||
messageBox(400, 200, "The scenario editor is not available or failed to load.", "Error", 2);
|
||||
]]></action>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<object name="submenuToolsAndOptions"
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="The 0 A.D. Game Manual"
|
||||
hidden="true"
|
||||
>
|
||||
<object name="submenuOptionsButton"
|
||||
style="StoneButtonFancy"
|
||||
type="button"
|
||||
size="4 0 100%-4 32"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="This will take you to the options menu. It does not work now, but someday it will."
|
||||
enabled="false"
|
||||
>
|
||||
Options
|
||||
<action on="Press"><![CDATA[
|
||||
// Open Options window.
|
||||
openMainMenuSubWindow ("pgOptions");
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
<object name="submenuEditorButton"
|
||||
style="StoneButtonFancy"
|
||||
type="button"
|
||||
size="4 32 100%-4 64"
|
||||
tooltip_style="pgToolTip"
|
||||
tooltip="Open the Atlas Scenario Editor in a new window. You can run this more reliably by starting the game with the command-line argument "-editor"."
|
||||
>
|
||||
Scenario Editor
|
||||
<action on="Press"><![CDATA[
|
||||
if (Engine.AtlasIsAvailable())
|
||||
Engine.RestartInAtlas();
|
||||
else
|
||||
messageBox(400, 200, "The scenario editor is not available or failed to load.", "Error", 2);
|
||||
]]></action>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
</object> <!-- end of screen -->
|
||||
</object><!-- end of submenu -->
|
||||
</object><!-- end of submenu screen -->
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user