Improved message box (3 buttons/icon support).
This was SVN commit r1336.
This commit is contained in:
parent
b5655265da
commit
93706e81c3
@ -11,9 +11,10 @@
|
||||
-->
|
||||
|
||||
<object type="empty" name="pregame_gui" size="0 0 100% 100%" z="1" hidden="false">
|
||||
<action on="Load"><![CDATA[
|
||||
// Play main 0 A.D. theme when the main menu starts.
|
||||
curr_music = new Sound("audio/music/menu_track.ogg"); curr_music.loop();
|
||||
<action on="Load"><![CDATA[
|
||||
// Play main 0 A.D. theme when the main menu starts.
|
||||
curr_music = new Sound("audio/music/menu_track.ogg");
|
||||
curr_music.loop();
|
||||
]]></action>
|
||||
|
||||
<object type="image" name="pregame-mainmenu-background-image" sprite="pregame-mainmenu-background" size="0 0 100% 100%" z="100" hidden="false" />
|
||||
@ -24,7 +25,7 @@
|
||||
GUIObjectUnhide("session_gui");
|
||||
GUIObjectHide("pregame_gui");
|
||||
FlipGUI(GUIType);
|
||||
curr_music.free(); // Close main theme when starting game session.
|
||||
curr_music.free(); // Close main theme when starting game session.
|
||||
]]></action>
|
||||
<action on="MouseEnter"><![CDATA[
|
||||
tooltipObject = getGUIObjectByName("pregame-mainmenu-tooltip");
|
||||
@ -48,9 +49,9 @@
|
||||
<object type="button" name="pregame-mainmenu-wfg-logo" sprite="pregame-mainmenu-wfg-logo-256x64" size="10 91.666666%-30 25.9765% 100%-30" z="102" hidden="false">
|
||||
<action on="Press"><![CDATA[
|
||||
btCode = new Array("GUIObjectHide('mb_main');");
|
||||
messageBox(400, 330, "0 A.D. - History Is Yours For The Taking\nby Wildfire Games, 2002-2004\n\nVersion 0.1.2 (PASAP II)\n\n" +
|
||||
messageBox(420, 420, "[icon=0ad_icon] A.D. - History Is Yours For The Taking\nby Wildfire Games, 2002-2004\n\nVersion 0.1.2 (PASAP II)\n\n" +
|
||||
"This is a confidental pre-release version of the game!\n\nVisit http://www.wildfiregames.com/0ad/ " +
|
||||
"to learn more about 0 A.D., participate in the community and meet the developers.\n\n", "About 0 A.D.", 2, new Array(), btCode);
|
||||
"to learn more about [icon=0ad_icon] A.D., participate in the community and meet the developers.\n\n", "About [icon=0ad_icon] A.D.", 2, new Array(), btCode);
|
||||
]]></action>
|
||||
<action on="MouseEnter"><![CDATA[
|
||||
tooltipObject = getGUIObjectByName("pregame-mainmenu-tooltip");
|
||||
|
@ -19,7 +19,7 @@
|
||||
<action on="Press"><![CDATA[
|
||||
btCaptions = new Array("Yes, let me out!", "Nooooo!");
|
||||
btCode = new Array("curr_music.free(); exit();", "GUIObjectHide('mb_main');");
|
||||
messageBox(400, 200, "Do you really want to quit 0 A.D.? This will cause a sudden return to reality.", "Confirmation", 0, btCaptions, btCode);
|
||||
messageBox(400, 200, "Do you really want to quit [icon=0ad_icon] A.D.? This will cause a sudden return to reality.", "Confirmation", 0, btCaptions, btCode);
|
||||
]]></action>
|
||||
|
||||
<!-- START temporary code
|
||||
@ -77,26 +77,32 @@
|
||||
<object type="image" name="mb_titlebar-left" size="15% 0 15%+64 32" sprite="message_box-titlebar-left" absolute="false" z="164" />
|
||||
<object type="image" name="mb_titlebar-middle" size="15%+64 0 85%-64 32" sprite="message_box-titlebar-middle" absolute="false" z="164" />
|
||||
<object type="image" name="mb_titlebar-right" size="85%-64 0 85% 32" sprite="message_box-titlebar-right" absolute="false" z="164" />
|
||||
<object type="text" name="mb_titlebar-text" size="15%+54 4 85%-54 32" absolute="false" font="prospero16" z="165">mbTitle</object>
|
||||
<object type="text" name="mb_titlebar-text" size="15%+54 4 85%-54 32" absolute="false" font="prospero18" z="165">mbTitle</object>
|
||||
|
||||
<!-- text -->
|
||||
<object type="text" name="mb_text" size="32 40 100%-32 100%-100" absolute="false" font="prospero16" z="165" ghost="true" text-align="center">
|
||||
<object type="text" name="mb_text" size="32 40 100%-32 100%-100" absolute="false" font="prospero18" z="165" ghost="true" text-align="center">
|
||||
mbMessage
|
||||
</object>
|
||||
|
||||
<!-- buttons -->
|
||||
<object type="button" name="mb_button1" size="40 100%-80 50%-30 100%-50" absolute="false" sprite="message_box-button-normal" sprite-over="message_box-button-over" font="prospero16" z="165" text-align="center" text-valign="center">
|
||||
<object type="button" name="mb_button1" size="40 100%-80 33%-30 100%-50" absolute="false" sprite="message_box-button-normal" sprite-over="message_box-button-over" font="prospero18" z="165" text-align="center" text-valign="center">
|
||||
mbButton1Caption
|
||||
<action on="Press"><![CDATA[
|
||||
eval(getGUIGlobal().mbButton1Code);
|
||||
]]></action>
|
||||
</object>
|
||||
<object type="button" name="mb_button2" size="50%+30 100%-80 100%-40 100%-50" absolute="false" sprite="message_box-button-normal" sprite-over="message_box-button-over" font="prospero16" z="165" text-align="center" text-valign="center">
|
||||
<object type="button" name="mb_button2" size="33%+30 100%-80 66%-40 100%-50" absolute="false" sprite="message_box-button-normal" sprite-over="message_box-button-over" font="prospero18" z="165" text-align="center" text-valign="center">
|
||||
mbButton2Caption
|
||||
<action on="Press"><![CDATA[
|
||||
eval(getGUIGlobal().mbButton2Code);
|
||||
]]></action>
|
||||
</object>
|
||||
<object type="button" name="mb_button3" size="66%+30 100%-80 100%-40 100%-50" absolute="false" sprite="message_box-button-normal" sprite-over="message_box-button-over" font="prospero18" z="165" text-align="center" text-valign="center">
|
||||
mbButton3Caption
|
||||
<action on="Press"><![CDATA[
|
||||
eval(getGUIGlobal().mbButton2Code);
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
|
||||
|
@ -33,6 +33,9 @@
|
||||
// Objects (like the message box) at runtime.
|
||||
// *******************************************
|
||||
|
||||
/*
|
||||
TODO: Make button code work for any number of buttons without extending the code each time! ((arrays | nested variables) & calculating sizes)
|
||||
*/
|
||||
|
||||
function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbButtonsCode) {
|
||||
|
||||
@ -42,6 +45,7 @@ function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCapti
|
||||
|
||||
mbButton1Obj = getGUIObjectByName("mb_button1");
|
||||
mbButton2Obj = getGUIObjectByName("mb_button2");
|
||||
mbButton3Obj = getGUIObjectByName("mb_button3");
|
||||
|
||||
// Calculate size
|
||||
mbLRDiff = mbWidth / 2; // Message box left/right difference from 50% of screen
|
||||
@ -81,6 +85,7 @@ function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCapti
|
||||
mbButton1Obj.size = "30% 100%-80 70% 100%-50";
|
||||
mbButton1Obj.hidden = false;
|
||||
mbButton2Obj.hidden = true;
|
||||
mbButton3Obj.hidden = true;
|
||||
break;
|
||||
case 2:
|
||||
// Two Buttons
|
||||
@ -90,6 +95,19 @@ function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCapti
|
||||
mbButton2Obj.size = "55% 100%-80 90% 100%-50";
|
||||
mbButton1Obj.hidden = false;
|
||||
mbButton2Obj.hidden = false;
|
||||
mbButton3Obj.hidden = true;
|
||||
break;
|
||||
case 3:
|
||||
// Three Buttons
|
||||
mbButton1Obj.caption = mbButtonCaptions[0];
|
||||
mbButton2Obj.caption = mbButtonCaptions[1];
|
||||
mbButton3Obj.caption = mbButtonCaptions[2];
|
||||
mbButton1Obj.size = "10% 100%-80 30% 100%-50";
|
||||
mbButton2Obj.size = "40% 100%-80 60% 100%-50";
|
||||
mbButton3Obj.size = "70% 100%-80 90% 100%-50";
|
||||
mbButton1Obj.hidden = false;
|
||||
mbButton2Obj.hidden = false;
|
||||
mbButton3Obj.hidden = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -99,14 +117,7 @@ function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCapti
|
||||
// Testing
|
||||
getGUIGlobal().mbButton1Code = mbButtonsCode[0];
|
||||
getGUIGlobal().mbButton2Code = mbButtonsCode[1];
|
||||
|
||||
//getGUIGlobal().test = 0;
|
||||
// Wait for return value
|
||||
//do {
|
||||
// delay(100);
|
||||
//} while (getGUIGlobal().test == 0)
|
||||
|
||||
//return getGUIGlobal().test;
|
||||
getGUIGlobal().mbButton3Code = mbButtonsCode[2];
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user