#include "Content\\ShellScripts\\ctcl_params.h" #include "Content\\ShellScripts\\stddefs.h" #include "Content\\ShellScripts\\ScriptStrings.h" #include "Content\\ShellScripts\\callsign.h" #include "Content\\ShellScripts\\buttons.script" #include "Content\\ShellScripts\\editbox.script" #include "Content\\ShellScripts\\ErrorScreen.script" #include "Content\\ShellScripts\\ScriptStrings.h" #define REAL_CONNECT 0 #define VIRTUAL_CONNECT 1 #define MAXAPPL 3 main { GUI_CREATE { int nDiffY = 0 // use the whole region location = 0, 0, 0 region = 0, 0 to getresx(), getresy() setresource("ScriptStrings.dll") pane p_background = GPATH "MULTIPlayer.tga" int m_nReturnValue = 0 int wIndex //int nVirtualConnect = VIRTUAL_CONNECT // ½ÇÁ¦ ¿¬°á¾øÀÌ °¡»óÀ¸·Î Cleient Tesla»óŸ¦ °áÁ¤ÇÑ´Ù int nVirtualConnect = REAL_CONNECT // int MAXTESLA = callback($$CTCL_Get$$, _CTCL_GetTeslaCountAll) int MAXTESLA_P = callback($$CTCL_Get$$, _CTCL_GetTeslaCount) if (MAXTESLA < 20) nDiffY = (20 - MAXTESLA) * 25 / 2 object screen = o_TeslaPlayer object o_check_player[MAXTESLA] object o_callsigns = callsigns int bot_number object mEditbox[MAXTESLA] object o_Tesla_name[MAXTESLA] object o_Appl[MAXTESLA] object LoadButton[MAXTESLA] object KillButton[MAXTESLA] int roster_posy[MAXTESLA] object o_GameInfo[MAXTESLA] //------------------------------------------------------------------------------ // Define TeslaState //------------------------------------------------------------------------------ string m_aTeslaName[MAXTESLA] int m_aLauncherConnection[MAXTESLA] // 0: no connection, +1: connection, -1: connecting int m_aConnection2[MAXTESLA] // 0: no connection, +1: connection, -1: connecting int m_aApplType[MAXTESLA] int m_aApplState[MAXTESLA] int m_aGameState[MAXTESLA] int m_aTeslaUsed[MAXTESLA] string m_aPlayerName[MAXTESLA] for (wIndex = 0; wIndex < MAXTESLA; wIndex++) { roster_posy[wIndex] = nDiffY + 40 + (wIndex * 25) m_aTeslaName[wIndex] = " " callback($$CTCL_Get$$, _CTCL_GetTeslaName, wIndex, m_aTeslaName[wIndex]) m_aPlayerName[wIndex] = " " if callback($$CTCL_IsTeslaUsed$$, wIndex, m_aPlayerName[wIndex]) { m_aTeslaUsed[wIndex] = 1 } else { m_aTeslaUsed[wIndex] = 0 } //----------------------------------------------------------------------- // CheckBox //----------------------------------------------------------------------- o_check_player[wIndex] = s_checkbox o_check_player[wIndex].file = WPATH "checkbox_15x15_3state.tga" o_check_player[wIndex].total_states = 3 o_check_player[wIndex].location = 115, roster_posy[wIndex] + 8, 5 o_check_player[wIndex].state = 0 deactivate (o_check_player[wIndex]) initialize(o_check_player[wIndex]) //----------------------------------------------------------------------- // Player Name //----------------------------------------------------------------------- bot_number = random(0, NUM_CALLSIGNS - 1) // Random Player Name mEditbox[wIndex] = s_editbox mEditbox[wIndex].location = 150, roster_posy[wIndex] + 5, 10 mEditbox[wIndex].boxWidth = 150 mEditbox[wIndex].boxHeight = 20 mEditbox[wIndex].boxFont3D = szPATH_FONTS localize$(IDS_F_GEN_EDITBOX) mEditbox[wIndex].labelFont3D = szPATH_FONTS localize$(IDS_F_GEN_LABEL) //mEditbox[wIndex].label = localize$(IDS_MP_BOT_NAME) mEditbox[wIndex].boxTextOffset = 5, 3 mEditbox[wIndex].offset = 0, -15 mEditbox[wIndex].boxtextlimit = 16 mEditbox[wIndex].Auto_Update = false mEditbox[wIndex].disable_forward_slash = true if m_aTeslaUsed[wIndex] { mEditbox[wIndex].boxValue = m_aPlayerName[wIndex] mEditbox[wIndex].bl_noEdit = TRUE // deactivate (mEditbox[wIndex]) if (MAXTESLA_P <= wIndex) { // cameraship... mEditbox[wIndex].noEditColor = packcolor (0, 80, 80, 128) } activate(mEditbox[wIndex]) } else { if (MAXTESLA_P <= wIndex) { // cameraship... mEditbox[wIndex].boxValue = m_aTeslaName[wIndex] mEditbox[wIndex].bl_noEdit = TRUE mEditbox[wIndex].noEditColor = packcolor (0, 80, 80, 128) activate(mEditbox[wIndex]) } else { mEditbox[wIndex].boxValue = "" // o_callsigns.names[bot_number] mEditbox[wIndex].bl_noEdit = FALSE // deactivate(mEditbox[wIndex]) } } initialize(mEditbox[wIndex]) //----------------------------------------------------------------------- // Tesla Name //----------------------------------------------------------------------- o_Tesla_name[wIndex] = s_print_text o_Tesla_name[wIndex].location = 320, roster_posy[wIndex] + 8,10 o_Tesla_name[wIndex].text_font = FPATH localize$(IDS_F_MP_LABEL) o_Tesla_name[wIndex].text_color = packcolor(255,255,255,255) o_Tesla_name[wIndex].text = m_aTeslaName[wIndex] //----------------------------------------------------------------------- // Appl Type //----------------------------------------------------------------------- o_Appl[wIndex] = status_control o_Appl[wIndex].location = 430, roster_posy[wIndex] + 9, 5 o_Appl[wIndex].file = GPATH "multiplayer\\watcom_5state_lobby_status.bmp" o_Appl[wIndex].total_states = MAXAPPL o_Appl[wIndex].id = wIndex o_Appl[wIndex].state = _EAT_None initialize (o_Appl[wIndex]) //----------------------------------------------------------------------- // Load App Button //----------------------------------------------------------------------- LoadButton[wIndex] = s_multistatepane LoadButton[wIndex].file = GPATH "multiplayer\\watcom_load.bmp" LoadButton[wIndex].total_states = 3 LoadButton[wIndex].twidth = 5//100 LoadButton[wIndex].id = wIndex LoadButton[wIndex].text = "" LoadButton[wIndex].location = 480, roster_posy[wIndex] + 7, 5 deactivate (LoadButton[wIndex]) initialize(LoadButton[wIndex]) //----------------------------------------------------------------------- // Kill App Button //----------------------------------------------------------------------- KillButton[wIndex] = s_multistatepane KillButton[wIndex].file = WPATH "x_close.tga"//"button_reg_138x23m_3state.tga" KillButton[wIndex].total_states = 3 KillButton[wIndex].twidth = 5//100 KillButton[wIndex].id = wIndex KillButton[wIndex].text = "" KillButton[wIndex].location = 530, roster_posy[wIndex] + 7, 5 deactivate (KillButton[wIndex]) initialize(KillButton[wIndex]) //----------------------------------------------------------------------- // Var Game Info //----------------------------------------------------------------------- o_GameInfo[wIndex] = s_print_text o_GameInfo[wIndex].text_font = FPATH localize$(IDS_F_MP_LABEL) o_GameInfo[wIndex].location = 580, roster_posy[wIndex] + 7, 5 if m_aTeslaUsed[wIndex] { o_GameInfo[wIndex].text_color = packcolor(0,255,0,255) //???? o_GameInfo[wIndex].text = "Added" } else { o_GameInfo[wIndex].text_color = packcolor(255,255,255,255) //???? o_GameInfo[wIndex].text = "" // "00:00:00" } } object o_ChartName [7] // 0: Add 1:Player Name 2: Tesla Name 3: Status 4: Load 5: Kill 6:Time for (wIndex = 0; wIndex < 7; wIndex++) { o_ChartName[wIndex] = s_print_text o_ChartName[wIndex].text_font = FPATH localize$(IDS_F_MP_LABEL) o_ChartName[wIndex].text_color = packcolor(255,255,255,255) } o_ChartName[0].location = 110, nDiffY + 15 ,10 o_ChartName[0].text = "Add" o_ChartName[1].location = 150, nDiffY + 15 ,10 o_ChartName[1].text = "Player Name" o_ChartName[2].location = 320, nDiffY + 15 ,10 o_ChartName[2].text = "Tesla Name" o_ChartName[3].location = 430, nDiffY + 15 ,10 o_ChartName[3].text = "Game" o_ChartName[4].location = 480, nDiffY + 15 ,10 o_ChartName[4].text = "Load!" o_ChartName[5].location = 530, nDiffY + 15 ,10 o_ChartName[5].text = "Kill!" o_ChartName[6].location = 580, nDiffY + 15 ,10 o_ChartName[6].text = "Information" } GUI_DRAW { render P_background, 0,0 setpencolor (0xffbbbbcc) drawline 100,nDiffY + 37 to 690,nDiffY + 37 } GUI_MAILBOX { if m_nReturnValue != 0 return for (wIndex = 0; wIndex < MAXTESLA; wIndex++) { if (sender == LoadButton[wIndex]) { //&&LoadApp&&// int mLauncherConnection // 0: no connection, +1: connection, -1: connecting int mConnection2 // 0: no connection, +1: connection, -1: connecting int mApplType int mApplState int mGameState int nApplType = _EAT_MW4 mLauncherConnection = callback($$CTCL_Get$$, _CTCL_GetTeslaInfo, wIndex, mConnection2, mApplType, mApplState, mGameState) if (mLauncherConnection == 1) && (mConnection2 != 1) && (mApplType == _EAT_None) // && (mApplState == _EAS_Launched) && (mGameState == _EGS_Idle) callback($$CTCL_Set$$, _CTCL_LaunchAppl, wIndex, nApplType) return } if (sender == KillButton[wIndex]) { //&&KillApp&&// int mLauncherConnection // 0: no connection, +1: connection, -1: connecting int mConnection2 // 0: no connection, +1: connection, -1: connecting int mApplType int mApplState int mGameState mLauncherConnection = callback($$CTCL_Get$$, _CTCL_GetTeslaInfo, wIndex, mConnection2, mApplType, mApplState, mGameState) if (mConnection2 == 1) && (mApplType != _EAT_None) && (mApplState == _EAS_Launched) && (mGameState == _EGS_Idle) callback($$CTCL_Set$$, _CTCL_TerminateAppl, wIndex) return } } } GUI_EXECUTE { //---------------------------------------------------- // Get Tesla Struct Information //---------------------------------------------------- if m_nReturnValue != 0 return for (wIndex = 0; wIndex < MAXTESLA; wIndex++) { m_aLauncherConnection[wIndex] = callback($$CTCL_Get$$, _CTCL_GetTeslaInfo, wIndex, m_aConnection2[wIndex], m_aApplType[wIndex], m_aApplState[wIndex], m_aGameState[wIndex]) if (nVirtualConnect == VIRTUAL_CONNECT) { m_aLauncherConnection[wIndex] = 1 m_aConnection2[wIndex] = 1 m_aApplType[wIndex] = _EAT_MW4 m_aApplState[wIndex] = _EAS_Launched m_aGameState[wIndex] = _EGS_Idle if (wIndex == 2 || wIndex == 3) { m_aGameState[wIndex] = _EGS_Running } if (wIndex == 5 || wIndex == 6) { m_aApplType[wIndex] = _EAT_RP } if (wIndex == 7) { m_aConnection2[wIndex] = 0 m_aApplType[wIndex] = _EAT_None m_aApplState[wIndex] = _EAS_None m_aGameState[wIndex] = _EGS_None } } o_Appl[wIndex].state = m_aApplType[wIndex] //... State Box if (m_aLauncherConnection[wIndex] == 1) && (m_aConnection2[wIndex] == 0) && (m_aApplType[wIndex] == _EAT_None) // && (m_aApplState[wIndex] == _EAS_None) && (m_aGameState[wIndex] == _EGS_None) // (m_aConnection2[wIndex] == 0) activate (LoadButton[wIndex]) else deactivate (LoadButton[wIndex]) if !m_aTeslaUsed[wIndex] { if ((m_aConnection2[wIndex] == 1) && (m_aApplType[wIndex] != _EAT_None) && (m_aApplState[wIndex] == _EAS_Launched) && (m_aGameState[wIndex] == _EGS_Idle)) activate (KillButton[wIndex]) else deactivate (KillButton[wIndex]) if (m_aLauncherConnection[wIndex] == 1) { activate (mEditbox[wIndex]) if ((m_aConnection2[wIndex] == 1) && (m_aApplType[wIndex] == _EAT_MW4) && (m_aApplState[wIndex] == _EAS_Launched) && (m_aGameState[wIndex] == _EGS_Idle)) { activate (o_check_player[wIndex]) if (wIndex < MAXTESLA_P) { mEditbox[wIndex].bl_noEdit = false } } else { o_check_player[wIndex].state = 0 deactivate (o_check_player[wIndex]) mEditbox[wIndex].bl_noEdit = true } if (m_aConnection2[wIndex] == 1) { if ((m_aApplType[wIndex] != _EAT_None) && (m_aGameState[wIndex] == _EGS_Running)) { // ³²Àº½Ã°£ Ç¥½Ã o_GameInfo[wIndex].text = "00:00:00" } else { o_GameInfo[wIndex].text = "..." } } else { if (m_aConnection2[wIndex] == -1) { o_GameInfo[wIndex].text = "MW4 Connecting..." } else { o_GameInfo[wIndex].text = "MW4 !ready" } } } else { o_check_player[wIndex].state = 0 deactivate (o_check_player[wIndex]) deactivate (mEditbox[wIndex]) if (m_aLauncherConnection[wIndex] == -1) { o_GameInfo[wIndex].text = "Connecting..." } else { o_GameInfo[wIndex].text = "!ready" } } } else { // initially (check,kill) deactivated, editbox disabled } } } } o_TeslaPlayer { GUI_CREATE { framerate = 10 Font3d gFont3d = szPATH_FONTS localize$(IDS_F_DIALOG_TITLE) //------------------------------------------------------------------------------ // Initialize the OK and Cancel buttons object mbutton[2] for(wIndex = 0; wIndex < 2; wIndex++) { mbutton[wIndex] = s_multistatepane mbutton[wIndex].file = WPATH "button_reg_138x23m_3state.tga" mbutton[wIndex].total_states = 3 mbutton[wIndex].twidth = 100 mbutton[wIndex].id = wIndex } mbutton[0].text = localize$(IDS_RS_B_OK) mbutton[0].location = 200, 560, 10 mbutton[1].text = localize$(IDS_RS_B_CANCEL) mbutton[1].location = 460, 560, 10 for(wIndex = 0; wIndex < 2; wIndex++) { initialize(mbutton[wIndex]) } ////////////////////////////////////////////////////// sound btnTriggeredSound = SPATH "sfx_button5.wav" // variables for fading in and out int alpha_val = 5 int fadeout = false int nTemp = false object errorScreen } GUI_EXECUTE { // Handle fading in and fading out if fadeout == true { // Fading out(Exiting) if alpha_val > 0 { alpha_val = alpha_val - 200 if alpha_val <= 0 { alpha_val = 0 unfocus if (exists(@NetLobby@)) mail(m_nReturnValue, @NetLobby@) } } } 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, 0) drawrect 0, 0 to getresx(), getresy() } GUI_MAILBOX { if (sender == errorScreen) || (sender == mbutton[0]) { if (sender == mbutton[0]) play btnTriggeredSound, 1 // Tell this script to fade out and deactivate all its objects for (wIndex = 0; wIndex < MAXTESLA; wIndex++) { if !m_aTeslaUsed[wIndex] { if (o_check_player[wIndex].state == 2) { if (equal$(mEditBox[wIndex].boxValue, "")) { if (sender == errorScreen) { focus(mEditBox[wIndex]) } else { errorScreen = o_ErrorScreen errorScreen.error_message = "Player name empty!!!" initialize(errorScreen) activate(errorScreen) } return } } } } if (sender == errorScreen) return fadeout = true m_nReturnValue = 1 } // Handle the Cancel Request if (sender == mbutton[1]) { play btnTriggeredSound,1 // Tell this script to fade out and deactivate all its objects fadeout = true m_nReturnValue = -1 } // fade out & destroy... if (fadeout) { for(wIndex = 0; wIndex < 2; wIndex++) { deactivate(mbutton[wIndex]) } for (wIndex = 0; wIndex < MAXTESLA; wIndex++) { deactivate(o_check_player[wIndex]) deactivate(mEditbox[wIndex]) deactivate(o_Appl[wIndex]) deactivate(KillButton[wIndex]) } } } GUI_DESTROY { unfocus } } status_control { GUI_CREATE { int id = 0 pane p_pane bitmap b_states string file int total_states int state = 0 int buttonsize int toggle int textsize = 1 int textcolor = 0xffffffff int theight = 8 int twidth = 8 string text int dropped_player = FALSE int dropped_bot = FALSE int adding_bot = TRUE int last_selection } GUI_INIT { b_states = file buttonsize = getheight(b_states)/total_states p_pane = getwidth(b_states), buttonsize, true, volatile alphamode (p_pane) = am_alpha_alphainvalpha region = 0,0 to getwidth(b_states),buttonsize } GUI_MAILBOX { } GUI_DRAW { render p_pane, location } GUI_EXECUTE { blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } LBUTTON_UPDATE { } } s_print_text { GUI_CREATE { string text font3d text_font int text_color int limit_the_width = -1 int id } GUI_DRAW { print3d_attributes = text_font,Text_Color,1,0,1,0,0,0,1 lprint3d_position = 0, 0 if limit_the_width == -1 lprint3d_margins = 0,0 to getprint3dwidth(text)+2,getprint3dheight(text)+2 else lprint3d_margins = 0,0 to limit_the_width,getprint3dheight(text)+2 if length$(text) > 0 { print3d text } } }