#include "Content\\ShellScripts\\stddefs.h" #include "Content\\ShellScripts\\ScriptStrings.h" #include "Content\\ShellScripts\\buttons.script" #include "Content\\ShellScripts\\ErrorScreen.script" main { GUI_CREATE { //Makes the connection to the string table .dll //Requires the #include "Content\\ShellScripts\\ScriptStrings.h" in every script with localizable text setresource("ScriptStrings.dll") // use the whole region location = 0, 0, 0 region = 0, 0 to getresx(), getresy() object screen = o_PauseModalScreen initialize(screen) object pointer = o_MousePointer pointer.showMousePointer = 1 focus(screen) } } o_PauseModalScreen { GUI_CREATE { // Initialize all 6 buttons int iloop object mbutton[6] for(iloop = 0; iloop < 6; iloop++) { mbutton[iloop] = s_textbutton mbutton[iloop].textcolor = 0xffffffff mbutton[iloop].textsize = 1 mbutton[iloop].id = iloop } mbutton[0].text = localize$(IDS_PS_B_RESUME) mbutton[1].text = localize$(IDS_PS_B_LOAD) mbutton[2].text = localize$(IDS_PS_B_OPTIONS) mbutton[3].text = localize$(IDS_PS_B_EXIT_MISSION) mbutton[4].text = localize$(IDS_PS_B_MAIN_MENU) mbutton[5].text = localize$(IDS_PS_B_QUIT) for (iloop = 0; iloop < 6; iloop++) { initialize(mbutton[iloop]) } framerate = 30 sound btnTriggeredSound = SPATH "sfx_button5.wav" // variables for fading in and out int alpha_val = 5 int fadeout = false object exitScreen object mainMenuScreen } GUI_INIT { mbutton[0].location = (getresx() / 2) - (getprint3dwidth(localize$(IDS_PS_B_RESUME)) / 2), getresy() / 2 - 150, 5 mbutton[1].location = (getresx() / 2) - (getprint3dwidth(localize$(IDS_PS_B_LOAD)) / 2), getresy() / 2 - 100, 5 mbutton[2].location = (getresx() / 2) - (getprint3dwidth(localize$(IDS_PS_B_OPTIONS)) / 2), getresy() / 2 - 50, 5 mbutton[3].location = (getresx() / 2) - (getprint3dwidth(localize$(IDS_PS_B_EXIT_MISSION)) / 2), getresy() / 2, 5 mbutton[4].location = (getresx() / 2) - (getprint3dwidth(localize$(IDS_PS_B_MAIN_MENU)) / 2), getresy() / 2 + 50, 5 mbutton[5].location = (getresx() / 2) - (getprint3dwidth(localize$(IDS_PS_B_QUIT)) / 2), getresy() / 2 + 130, 5 int i for i = 0; i < 6; i++ { initialize(mbutton[i]) } } GUI_ACTIVATE { for(iloop = 0; iloop < 6; iloop++) { activate(mbutton[iloop]) } focus(this) } GUI_DEACTIVATE { for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } } GUI_EXECUTE { if fadeout == true { // Fading out(Exiting) if alpha_val > 0 { alpha_val = alpha_val - 5 if alpha_val <= 0 { alpha_val = 0 unfocus script_end "PauseModalCampaign.script" } } } else { // Fading in(Entering) if alpha_val < 150 { alpha_val += 3 if alpha_val >= 150 { alpha_val = 150 } } } } GUI_DRAW { setpencolor(0, 0, 100, alpha_val) drawrect 0, 0 to getresx(), getresy() } GUI_MAILBOX { // Handle the Resume Request if (sender == mbutton[0]) { play btnTriggeredSound,1 callback($$SetShellCommand$$, ResumeMissionCommand) // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } } // Handle Load Request if (sender == mbutton[1]) { play btnTriggeredSound,1 for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } // Start the load screen script_run "Content\\ShellScripts\\LoadScreen.script", 0x2000 } // Handle Options Request if (sender == mbutton[2]) { play btnTriggeredSound,1 callback($$SetShellCommand$$, SetPauseOptionResCommand) // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 5; iloop++) { deactivate(mbutton[iloop]) } } // Handle Exit Mission Request if (sender == mbutton[3]) { exitScreen = o_ErrorScreen exitScreen.error_header = localize$(IDS_PS_B_EXIT_MISSION) exitScreen.error_message = localize$(IDS_PS_Q_EXIT_MISSION) exitScreen.button_mode = TWO_BUTTON_MODE exitScreen.buttonText[0] = localize$(IDS_GN_YES) exitScreen.buttonText[1] = localize$(IDS_GN_NO) initialize(exitScreen) activate(exitScreen) return } if (sender == exitScreen) { if (getmessage() == 0) { play btnTriggeredSound,1 callback($$SetShellCommand$$, ExitMissionCommand) // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } } else { focus(this) } } // Handle Main Menu Request if (sender == mbutton[4]) { mainMenuScreen = o_ErrorScreen mainMenuScreen.error_header = localize$(IDS_PS_B_MAIN_MENU) mainMenuScreen.error_message = localize$(IDS_PS_Q_MAIN_MENU) mainMenuScreen.button_mode = TWO_BUTTON_MODE mainMenuScreen.buttonText[0] = localize$(IDS_GN_YES) mainMenuScreen.buttonText[1] = localize$(IDS_GN_NO) initialize(mainMenuScreen) activate(mainMenuScreen) return } if (sender == mainMenuScreen) { if (getmessage() == 0) { play btnTriggeredSound,1 callback($$SetShellCommand$$, ExitToMainMenuCommand) // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } } else { focus(this) } } // Handle Exit to Windows Request if (sender == mbutton[5]) { play btnTriggeredSound,1 terminate // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } } // Handle Load Screen if (exists(@loadscreen@)) { if (sender == @loadscreen@screen)) { if (getmessage() == 1) { callback($$SetShellCommand$$, ExitMissionCommand) fadeout = true } else { activate(this) } } } } GUI_CHAR { // Check for the Escape key to resume mission int ch = getchar() if (ch == 27) { callback($$SetShellCommand$$, ResumeMissionCommand) // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 6; iloop++) { deactivate(mbutton[iloop]) } } } GUI_DESTROY { unfocus } } // A utility class for showing the mouse pointer when the pause menu is active o_MousePointer { GUI_CREATE { int showMousePointer = 1 pane p_pointer = GPATH "mouse_pointer.tga" alphamode(p_pointer) = am_alpha_alphainvalpha origin(p_pointer) = 0, 0 location.z = 900 } GUI_DRAW { if (showMousePointer != 0) { render p_pointer, mouse.x, mouse.y } } }