#include "Content\\ShellScripts\\stddefs.h" #include "Content\\ShellScripts\\ShellFunctionHeaders.hpp" #include "Content\\ShellScripts\\PilotCommon.h" #include "Content\\ShellScripts\\ScriptStrings.h" #include "Content\\ShellScripts\\common_shell.script" #include "Content\\ShellScripts\\buttons.script" #include "Content\\ShellScripts\\mc_listboxes.script" #include "Content\\ShellScripts\\ErrorScreen.script" #include "Content\\ShellScripts\\c_MoviePlayer.script" #include "Content\\ShellScripts\\c_text.script" #include "Content\\ShellScripts\\c_rollover.script" main { GUI_CREATE { // columns - pilot name, difficulty // JACKYC - Add more columns as necessary int max_mccb_columns = 1 // XXX JACKYC - Need to determine the maximum number of items int max_mccb_items = 8 object oRollover = s_HelpRegion oRollover.nFontID = IDS_F_ROLLOVER_INFO oRollover.cTextColor= 0xFFff7200 oRollover.location = 37,514,60 oRollover.nWidth = 522 oRollover.nHeight = 67 initialize(oRollover) activate(oRollover) object screen = o_PilotScreen initialize(screen) } } o_PilotScreen { GUI_CREATE { // variables for its child scripts int onCreatePilot = 0 int onEditPilot = 0 int onRemovePilot = 0 // Variable for communication between the current script and the child scripts string currentPilotName = "" int currentPilotDifficulty = PILOT_DIFFICULTY_NORMAL // Variable for the error screen object errorScreen // Background movie object o_burnmech = s_bkgmovie object o_interlace = interlace o_interlace.location = 0, 0, 10 o_interlace.lace_color = packcolor (100, 150, 255, 175) object o_logo = panedisplay o_logo.filename = GPATH "mw4_logo.tga" o_logo.location = 393, 60, 15 o_logo.alpha_val = 0 initialize(o_logo) // frame image object o_frame = frame o_frame.type = 1 o_frame.location = 0, 0, 50 o_frame.screen_name = localize$(IDS_MM_ROSTER) initialize(o_frame) // initialize the 4 buttons int iloop object mbutton[4] for(iloop = 0; iloop < 4; iloop++) { mbutton[iloop] = s_multistatepane mbutton[iloop].total_states = 3 mbutton[iloop].textsize = 1 mbutton[iloop].id = iloop } mbutton[0].text = localize$(IDS_RS_B_CREATE) mbutton[0].file = WPATH "button_reg_180x23m_3state.tga" mbutton[0].location = 485, 407, 10 mbutton[0].nRollover = 1 mbutton[0].nHelpID = IDS_RS_H_CREATE_PILOT mbutton[1].text = localize$(IDS_RS_B_EDIT) mbutton[1].file = WPATH "button_reg_180x23m_3state.tga" mbutton[1].location = 390, 440, 10 mbutton[1].nRollover = 1 mbutton[1].nHelpID = IDS_RS_H_EDIT_PILOT mbutton[2].text = localize$(IDS_RS_B_REMOVE) mbutton[2].file = WPATH "button_reg_180x23m_3state.tga" mbutton[2].location = 580, 440, 10 mbutton[2].nRollover = 1 mbutton[2].nHelpID = IDS_RS_H_REMOVE_PILOT mbutton[3].text = localize$(IDS_RS_B_ENTER) mbutton[3].file = WPATH "button_main_196x41m_3state.tga" mbutton[3].location = 580, 510, o_frame.location.z + 1 mbutton[3].nRollover = 1 mbutton[3].nHelpID = IDS_RS_H_ENTER for(iloop = 0; iloop < 4; iloop++) { initialize(mbutton[iloop]) } framerate =10 // array of pilot entry string pPilotName[max_mccb_items] // load the number of pilot entries stored int obj_size = 0 callback($$Shell_CallbackHandler$$, ShellGetPilotList, pPilotName[], obj_size) // Initialize the mc list box for pilot entry listing object o_players_mclistbox = s_mc_listbox o_players_mclistbox.location = 392, 173, 10 o_players_mclistbox.boxFont3d = FPATH localize$(IDS_F_GEN_MCLIST_ITEM) //MUST BE INITIALIZED o_players_mclistbox.labelFont3d = FPATH localize$(IDS_F_GEN_LABEL) o_players_mclistbox.itemWidth = 352 o_players_mclistbox.itemHeight = 5 o_players_mclistbox.itemHeight_padding = 1 o_players_mclistbox.list_size = obj_size o_players_mclistbox.column_header_height = 20 o_players_mclistbox.max_displayed = 60 o_players_mclistbox.uniform_item_height = 0 o_players_mclistbox.arrowHeight = 20 o_players_mclistbox.top_of_list = 0 o_players_mclistbox.label = "" o_players_mclistbox.offsetLabel = 0,-18 o_players_mclistbox.buttonwidth = 16 o_players_mclistbox.first_delay = 10 o_players_mclistbox.second_delay = 3 o_players_mclistbox.boxhighlightColor = packcolor(0, 0, 0, 0) o_players_mclistbox.nRollover = 1 o_players_mclistbox.nHelpID = IDS_RS_H_PILOT_LIST // Specify number of columns o_players_mclistbox.num_of_columns = 1 o_players_mclistbox.column[0].location.x = 5 o_players_mclistbox.column[0].fontcolor = packcolor(255,255,255,255) o_players_mclistbox.column[0].fontAlignment = just_left // Now store the pilot entries in the list box int i for (i = 0; i < obj_size; i++) { o_players_mclistbox.column[0].list_item[i] = pPilotName[i] o_players_mclistbox.list_order[i] = i } initialize(o_players_mclistbox) // get the selected pilot callback($$Shell_CallbackHandler$$, ShellGetPilotName, currentPilotName) for (i = 0; i < obj_size; i++) { if (equal$(currentPilotName, pPilotName[i])) { o_players_mclistbox.nselected = i break } } // Specify column headers o_players_mclistbox.column[0].o_header.s_text = localize$(IDS_RS_L_PILOT_NAME) sound btnTriggeredSound = SPATH "sfx_button5.wav" deactivate(o_players_mclistbox) activate(o_players_mclistbox) int disabled_button_num = 2 object disabled_button[disabled_button_num] int d for d = 0; d < disabled_button_num; d++ { disabled_button[d] = panedisplay disabled_button[d].filename = WPATH "button_reg_180x23_disabled.tga" } disabled_button[0].location = mbutton[1].location.x, mbutton[1].location.y, mbutton[1].location.z - 1 disabled_button[1].location = mbutton[2].location.x, mbutton[2].location.y, mbutton[2].location.z - 1 for d = 0; d < disabled_button_num; d++ { initialize(disabled_button[d]) } activate(this) } GUI_INIT { if obj_size == 0 { if (obj_size == max_mccb_items) { errorScreen = o_ErrorScreen errorScreen.error_message = localize$(IDS_RS_E_PILOT_LIMIT) initialize(errorScreen) activate(errorScreen) return } OnCreatePilot = 1 unfocus script_run "Content\\ShellScripts\\CreatePilotModal.script", 0x1400 } } GUI_ACTIVATE { // Activate all buttons if there are entries in the entry array. // Activate only Create and Exit buttons if there are no entries in the entry array if (obj_size > 0) { activate(mbutton[0]) activate(mbutton[1]) activate(mbutton[2]) activate(mbutton[3]) } else { deactivate(mbutton[1]) deactivate(mbutton[2]) deactivate(mbutton[3]) } } GUI_DRAW { setpencolor(0xff000000) drawrect 0, 0 to getresx(), 36 } GUI_MAILBOX { // Handle list box and error screen message. If so, focus on the Enter button if (obj_size > 0) { if (sender == o_players_mclistbox) || (sender == errorScreen) focus(mbutton[3]) } // Handle the Enter button if (sender == mbutton[3]) { play btnTriggeredSound,1 // First search the pilot entry in the entry array int nselected = o_players_mclistbox.nselected int i for (i = 0; i < obj_size; i++) { if (equal$(o_players_mclistbox.column[0].list_item[nselected], pPilotName[i])) { break } } callback($$Shell_CallbackHandler$$, ShellSelectPilot, pPilotName[i]) int nMusicTmp callback($$Shell_CallbackHandler$$,ShellOptionsGetSliderValue,MWO_MUSICVOLUME,nMusicTmp) setvolume (0,nMusicTmp) unfocus @SHELL@lastScreenDepth = 0 @SHELL@currentScreen = MAINMENU } // Do the Create Script if (sender == mbutton[0]) { play btnTriggeredSound,1 if (obj_size == max_mccb_items) { errorScreen = o_ErrorScreen errorScreen.error_message = localize$(IDS_RS_E_PILOT_LIMIT) initialize(errorScreen) activate(errorScreen) return } OnCreatePilot = 1 unfocus script_run "Content\\ShellScripts\\CreatePilotModal.script", 0x1400 } // Do the Edit Script if there are entries in the entry array if (sender == mbutton[1]) { if (obj_size > 0) { play btnTriggeredSound,1 OnEditPilot = 1 unfocus script_run "Content\\ShellScripts\\EditPilotModal.script", 0x1400 } } // Do the Remove script if there are entries in the entry array if (sender == mbutton[2]) { if (obj_size > 0) { play btnTriggeredSound,1 OnRemovePilot = 1 unfocus script_run "Content\\ShellScripts\\RemovePilotModal.script", 0x1400 } } // Handle requests from the Create dialog if (onCreatePilot) { if (sender == @CreatePilotModal@screen) { // We cancelled the operation. Just focus on the enter button if (getmessage() == -1) { if (obj_size > 0) focus(mbutton[3]) return } // trivial rejection - if the input name is NULL then give an error if (equal$(currentPilotName, "")) { mail(-1, @CreatePilotModal@screen) return } // trivial rejection - if beginning or end is a space if ((equal$(left$(currentPilotName, 1), " ")) || (equal$(right$(currentPilotName, 1), " "))) { mail(-2, @CreatePilotModal@screen) return } // Search if there is an existing entry with the same name // if so don't create this pilot for (i = 0; i < obj_size; i++) { if (equal$(currentPilotName, pPilotName[i])) { mail(-3, @CreatePilotModal@screen) return } } // Create a new pilot entry if (callback($$Shell_CallbackHandler$$, ShellCreateNewPilot, currentPilotName, currentPilotDifficulty) == -1) { mail(-4, @CreatePilotModal@screen) return } pPilotName[obj_size] = currentPilotName obj_size++ activate(this) // tell the script that we are done mail(1, @CreatePilotModal@screen) // Update the list box o_players_mclistbox.list_size = obj_size o_players_mclistbox.column[0].list_item[obj_size - 1] = currentPilotName o_players_mclistbox.list_order[obj_size - 1] = obj_size - 1 o_players_mclistbox.nselected = obj_size - 1 initialize(o_players_mclistbox) // move the pointer to the very end for (i = 0; i < obj_size; i++) mail(-3, o_players_mclistbox) o_players_mclistbox.column[0].o_header.s_text = localize$(IDS_RS_L_PILOT_NAME) focus(mbutton[3]) } } // Handle requests from the Remove dialog if (onRemovePilot) { if (sender == @RemovePilotModal@screen) { // We cancelled the operation. Just focus on the enter button if (getmessage() == -1) { if (obj_size > 0) focus(mbutton[3]) return } // First search the pilot entry in the entry array int nselected = o_players_mclistbox.nselected int i for (i = 0; i < obj_size; i++) { if (equal$(o_players_mclistbox.column[0].list_item[nselected], pPilotName[i])) { break } } // Now replace this entry with the last enetry in the entry array callback($$Shell_CallbackHandler$$, ShellDeletePilot, pPilotName[i]) pPilotName[i] = pPilotName[obj_size - 1] obj_size-- activate(this) // now remove the pilot from the mc_list box int j for (j = nselected; j < obj_size; j++) { o_players_mclistbox.column[0].list_item[j] = o_players_mclistbox.column[0].list_item[j + 1] } o_players_mclistbox.column[0].list_item[obj_size] = "" o_players_mclistbox.list_size = obj_size // regroup the list order for (j = 0; j < obj_size; j++) { o_players_mclistbox.list_order[j] = j } o_players_mclistbox.top_of_list = 0 o_players_mclistbox.start_of_list = 0 o_players_mclistbox.nselected = 0 // kill the button and reinit the list box kill o_players_mclistbox.list_button[obj_size] initialize(o_players_mclistbox) o_players_mclistbox.column[0].o_header.s_text = localize$(IDS_RS_L_PILOT_NAME) if (obj_size > 0) focus(mbutton[3]) } } // Handle requests from the Edit dialog if (OnEditPilot) { if (sender == @EditPilotModal@screen) { // We cancelled the operation. Just focus on the enter button if (getmessage() == -1) { if (obj_size > 0) focus(mbutton[3]) return } // trivial rejection - if the input name is NULL then give an error if (equal$(currentPilotName, "")) { mail(-1, @EditPilotModal@screen) return } // trivial rejection - if beginning or end is a space if ((equal$(left$(currentPilotName, 1), " ")) || (equal$(right$(currentPilotName, 1), " "))) { mail(-2, @EditPilotModal@screen) return } // Then search the pilot entry in the entry array int nselected = o_players_mclistbox.nselected int i for (i = 0; i < obj_size; i++) { if (equal$(o_players_mclistbox.column[0].list_item[nselected], pPilotName[i])) { break } } // After that search the current name in the entry array int j for (j = 0; j < obj_size; j++) { if (equal$(currentPilotName, pPilotName[j])) { break } } // reject if the new name is a duplicate if ((j < obj_size) && (i != j)) { mail(-3, @EditPilotModal@screen) return } // Update the selected Pilot if (callback($$Shell_CallbackHandler$$, ShellRenamePilot, pPilotName[i], currentPilotName) == -1) { mail(-4, @EditPilotModal@screen) return } pPilotName[i] = currentPilotName // tell the script that we are done mail(1, @EditPilotModal@screen) // update the list box o_players_mclistbox.column[0].list_item[nselected] = currentPilotName o_players_mclistbox.column[0].o_header.s_text = localize$(IDS_RS_L_PILOT_NAME) focus(mbutton[3]) } } } GUI_DESTROY { unfocus @SHELL@lastScreenDepth = 0 } } panedisplay { GUI_CREATE { pane p_pane string filename int panecolor = packcolor(255, 255, 255, 255) int scalex = 100 int scaley = 100 int alphatype int alpha_val = 255 int alpha_switch = 0 framerate = 15 } GUI_INIT { p_pane = filename color(p_pane) = packcolor(255, 255, 255, alpha_val) scale(p_pane) = scalex, scaley if alphatype == 0 { alphamode(p_pane) = am_alpha_alphainvalpha } else { alphamode(p_pane) = am_alpha_oneone } } GUI_EXECUTE { if alpha_switch == 0 { int random_num_top = random(240, 255) if alpha_val < random_num_top { alpha_val += 10 } if alpha_val >= random_num_top { alpha_switch = 1 } } if alpha_switch == 1 { int random_num_bottom = random(200, 220) if alpha_val > random_num_bottom { alpha_val -= 10 } if alpha_val <= random_num_bottom { alpha_switch = 0 } } color(p_pane) = packcolor(255, 255, 255, alpha_val) } GUI_DRAW { render p_pane, location } } s_bkgmovie { GUI_CREATE { location = 0, 36, 0 movie mymovie = szPATH_MOVIES "Burnloop_lr_15.avi" scale(mymovie) = 167, 167 loop mymovie } GUI_DRAW { render mymovie, location } }