#include "Content\\ShellScripts\\stddefs.h" #include "Content\\ShellScripts\\PilotCommon.h" #include "Content\\ShellScripts\\ScriptStrings.h" #include "Content\\ShellScripts\\buttons.script" #include "Content\\Shellscripts\\editbox.script" #include "Content\\ShellScripts\\listboxes.script" #include "Content\\ShellScripts\\ErrorScreen.script" main { GUI_CREATE { // Total number of difficulties int max_items = TOTAL_NUM_PILOT_DIFFICULTY // use the whole region location = 0, 0, 0 region = 0, 0 to getresx(), getresy() object screen = o_CreatePilotModal } } o_CreatePilotModal { GUI_CREATE { Font3d gHeaderFont3d = szPATH_FONTS localize$(IDS_F_DIALOG_TITLE) Font3d gFont3d = szPATH_FONTS localize$(IDS_F_GEN_DESCRIPTION) pane gFrame = GPATH "dialog_500x300m.tga" // Initialize the OK and Cancel buttons int iloop object mbutton[2] for(iloop = 0; iloop < 2; iloop++) { mbutton[iloop] = s_multistatepane mbutton[iloop].total_states = 3 mbutton[iloop].textsize = 1 mbutton[iloop].file = WPATH "button_reg_138x23m_3state.tga" mbutton[iloop].id = iloop } mbutton[0].text = localize$(IDS_GN_OK) mbutton[0].location = 180, 395, 10 mbutton[1].text = localize$(IDS_GN_CANCEL) mbutton[1].location = 480, 395, 10 for(iloop = 0; iloop < 2; iloop++) { initialize(mbutton[iloop]) } framerate = 30 // Initialize and focus on the Edit Box object mEditBox = s_editbox mEditBox.location = 370, 280, 10 mEditBox.boxWidth = 250 mEditBox.boxHeight = 20 mEditBox.boxFont3D = szPATH_FONTS localize$(IDS_F_GEN_EDITBOX) mEditBox.labelFont3D = szPATH_FONTS localize$(IDS_F_GEN_LABEL) mEditBox.label = localize$(IDS_RS_L_PILOT_NAME_COLON) mEditBox.boxTextOffset = 5, 3 mEditBox.offset = -185, 3 mEditBox.boxTextLimit = PILOT_NAME_TEXT_LIMIT initialize(mEditBox) focus(mEditBox) // Initialize the List Box string difficulty[max_items] difficulty[PILOT_DIFFICULTY_EASY] = localize$(IDS_RS_RECRUIT) difficulty[PILOT_DIFFICULTY_NORMAL] = localize$(IDS_RS_REGULAR) difficulty[PILOT_DIFFICULTY_HARD] = localize$(IDS_RS_VETERAN) difficulty[PILOT_DIFFICULTY_IMPOSSIBLE] = localize$(IDS_RS_ELITE) int max_items = 4 object mListBox = s_droplistbox mListBox.location = 370, 320, 10 mListBox.boxFont3D = szPATH_FONTS localize$(IDS_F_GEN_DROPDOWN) mListBox.labelFont3D = szPATH_FONTS localize$(IDS_F_GEN_LABEL) mListBox.label = localize$(IDS_RS_L_DIFFICULTY_COLON) mListBox.offsetLabel = -185, 3 mListBox.itemWidth = 250 - 16 mListBox.itemHeight = 20 mListBox.list_size = max_items mListBox.max_displayed = 4 mListBox.top_of_list = 0 mListBox.nSelected = 1 int i for (i = 0; i < max_items; i++) { mListBox.list_item[i] = difficulty[i] } initialize(mListBox) sound btnTriggeredSound = SPATH "sfx_button5.wav" // variables for fading in and out int alpha_val = 5 int fadeout = false // Variable for the error screen object errorScreen } GUI_EXECUTE { if fadeout == true { // Fading out(Exiting) if alpha_val > 0 { alpha_val = alpha_val - 5 if alpha_val <= 0 { alpha_val = 0 script_end "CreatePilotModal.script" } } } else { // Fading in(Entering) if alpha_val < 150 { alpha_val += 5 if alpha_val >= 150 { alpha_val = 150 } } } } GUI_DRAW { // fade in or fade out setpencolor(0, 0, 0, alpha_val) drawrect 0, 0 to getresx(), getresy() // Redraw the frame if we are not fading out(exiting) if (fadeout == false) { color (gframe) = packcolor(255, 255, 255, alpha_val) render gframe, 150, 150 // Header print3d_attributes = gHeaderFont3d,0xffffffff,1,0,1,0,0,just_center print3d_margins = 150, 150 to 650, 450 print3d_position = 150, 155 print3d localize$(IDS_RS_CREATE_TITLE) print3d_attributes = gFont3d,0xffffffff,1,1,1,0,0 print3d_margins = 180, 200 to 620, 400 print3d_position = 180, 200 print3d localize$(IDS_RS_S_CREATE) } } GUI_MAILBOX { // Handle edit box finished edit if (sender == mEditBox) { if (getmessage() == 1) { focus(mbutton[0]) } } // Handle the OK Request if (sender == mbutton[0]) { play btnTriggeredSound,1 unfocus // Pass the data to the Pilot Screen script and let it handle the data @PilotEntry@screen.currentPilotName = mEditBox.boxValue @PilotEntry@screen.currentPilotDifficulty = mListBox.nselected mail(1, @PilotEntry@screen) } // Handle the Cancel Request if (sender == mbutton[1]) { play btnTriggeredSound,1 unfocus // Just tell the Pilot Screen script that no changes should be made mail(-1, @PilotEntry@screen) @PilotEntry@screen.onCreatePilot = 0 // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 2; iloop++) { deactivate(mbutton[iloop]) } deactivate(mEditBox) deactivate(mListBox) } if (sender == @PilotEntry@screen) { if (getmessage() == -1) { errorScreen = o_ErrorScreen errorScreen.error_message = localize$(IDS_RS_E_PILOT_CREATE_EMPTY) initialize(errorScreen) activate(errorScreen) return } if (getmessage() == -2) { errorScreen = o_ErrorScreen errorScreen.error_message = localize$(IDS_RS_E_PILOT_CREATE_SPACE) initialize(errorScreen) activate(errorScreen) return } if (getmessage() == -3) { errorScreen = o_ErrorScreen errorScreen.error_message = localize$(IDS_RS_E_PILOT_CREATE_SAME) initialize(errorScreen) activate(errorScreen) return } if (getmessage() == -4) { errorScreen = o_ErrorScreen errorScreen.error_message = localize$(IDS_RS_E_PILOT_CREATE_INVALID) initialize(errorScreen) activate(errorScreen) return } if (getmessage() == 1) { @PilotEntry@screen.onCreatePilot = 0 // Tell this script to fade out and deactivate all its objects fadeout = true for(iloop = 0; iloop < 2; iloop++) { deactivate(mbutton[iloop]) } deactivate(mEditBox) deactivate(mListBox) } } if (sender == errorScreen) { focus(mEditBox) } } }