Advertisement
Viathan

SWBF - StraightToSessionlist

Jun 16th, 2015
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.84 KB | None | 0 0
  1. -- /=============================================================\ --
  2. -- |==== StraightToSessionlist - ifs_main.lua - shell script ====| --
  3. -- \=============================================================/ --
  4. ---------------------------------------------------------------------
  5. -- Changes : Line: 24 [Button] | Line: 366 - 374 [Button function] --
  6. ---------------------------------------------------------------------
  7.  
  8. -- Callback for the "not enough profiles" (QA bug 793) error
  9. function ifs_main_CantEnterSplitOk()
  10.     local this = ifs_main
  11.     IFObj_fnSetVis(this.buttons,1)
  12. end
  13.  
  14. ifsmain_vbutton_layout = {
  15. --  yTop = -70, -- auto-calc'd now
  16.     xWidth = 250, -- Set to 250 NM 8/13/04 to fit the "profile management" spam
  17.     width = 250,
  18.     xSpacing = 6,
  19.     ySpacing = 5,
  20.     font = "gamefont_medium",
  21.     buttonlist = {
  22.         { tag = "sp", string = "ifs.main.sp", },
  23.         { tag = "mp", string = "ifs.main.mp", },
  24.         { tag = "mpsb", string = "SERVER BROWSER", }, --V - add button to menu [17.June.2015] (change name after: string = )
  25.         { tag = "split", string = "ifs.main.split", },
  26.         { tag = "tutorials", string = "ifs.main.tutorials", },
  27.         { tag = "opts", string = "ifs.main.options", },
  28.         { tag = "back2", string = "ifs.main.profiles", },
  29.         { tag = "quit", string = "common.quit2windows", },
  30.     },
  31.     title = "ifs.main.title",
  32. }
  33.  
  34. --
  35. function ifs_main_fnQuitPopupDone(bResult)
  36.     local this = ifs_main
  37.     IFObj_fnSetVis(this.buttons,1)
  38.  
  39.     if(bResult) then
  40.         ScriptCB_QuitToWindows()
  41.     end
  42. end
  43.  
  44. -- Callback from the 'No network adaptor' popup
  45. function ifs_main_fnPostNoNetHW()
  46.     local this = ifs_main
  47.     local fAnimTime = 0.3
  48.     AnimationMgr_AddAnimation(this.buttons,
  49.                                                         { fTotalTime = fAnimTime, fStartAlpha = 0, fEndAlpha = 1,})
  50. end
  51.  
  52. ----------------------------------------------------------------------------------------
  53. -- try to exit backwards.  if the current profile is dirty, warn and prompt a save
  54. ----------------------------------------------------------------------------------------
  55.  
  56. function ifs_main_TryToBackup()
  57. --  print("ifs_main_TryToBackup")
  58.    
  59.     -- is the current profile dirty?
  60.     if(ScriptCB_IsCurProfileDirty()) then
  61. --      print("profile dirty, prompting save")
  62.        
  63.         -- hide this screen
  64.         IFObj_fnSetVis(ifs_main.buttons,nil)
  65.        
  66.         -- set the load/save title text
  67.         IFText_fnSetString(Popup_LoadSave2.title,"ifs.loadsave_ps2.save24")
  68.        
  69.         -- set the button text
  70.         IFText_fnSetString(Popup_LoadSave2.buttons.A.label,"ifs.loadsave_ps2.saveandexit")
  71.         IFText_fnSetString(Popup_LoadSave2.buttons.B.label,"ifs.loadsave_ps2.exitnosave")
  72.         IFText_fnSetString(Popup_LoadSave2.buttons.C.label,"ifs.loadsave_ps2.cancel")
  73.         -- set the button visiblity
  74.         Popup_LoadSave2:fnActivate(1)
  75.         IFObj_fnSetVis(Popup_LoadSave2.buttons.A.label,1)
  76.         IFObj_fnSetVis(Popup_LoadSave2.buttons.B.label,1)
  77.         IFObj_fnSetVis(Popup_LoadSave2.buttons.C.label,1)
  78.         Popup_LoadSave2_ResizeButtons()
  79.         Popup_LoadSave2_SelectButton(1)
  80.         IFObj_fnSetVis(Popup_LoadSave2,1)
  81.         Popup_LoadSave2.fnAccept = ifs_main_SaveDirtyAccept
  82.         return
  83.     end
  84.    
  85.     -- not dirty, backup
  86. --  print("profile not dirty, backing up")
  87.     ScriptCB_Logout()
  88.     ifs_login.EnterDoNothing = nil
  89.     ScriptCB_PopScreen()
  90.    
  91. end
  92.  
  93. function ifs_main_SaveDirtyAccept(fRet)
  94.     Popup_LoadSave2.fnAccept = nil
  95.     Popup_LoadSave2:fnActivate(nil)
  96.  
  97.     -- show this screen
  98.     IFObj_fnSetVis(ifs_main.buttons,1)
  99.  
  100.     if(fRet < 1.5) then
  101. --      print("ifs_main_SaveDirtyAccept(A - Save)")
  102.         ifs_main_SaveAndBackup()
  103.     elseif(fRet < 2.5) then
  104. --      print("ifs_main_SaveDirtyAccept(B - Exit without saving)")
  105.         ScriptCB_Logout()
  106.         ifs_login.EnterDoNothing = nil     
  107.         ScriptCB_PopScreen()
  108.     else
  109. --      print("ifs_main_SaveDirtyAccept(C - Cancel)")
  110.         -- do nothing, just stay in ifs_main
  111.     end
  112. end
  113.  
  114. function ifs_main_SaveAndBackup()
  115. --  print("ifs_main_SaveAndBackup")
  116.    
  117.     ifs_saveop.doOp = "SaveProfile"
  118.     ifs_saveop.OnSuccess = ifs_main_SaveProfileSuccess
  119.     ifs_saveop.OnCancel = ifs_main_SaveProfileCancel
  120.     ifs_saveop.saveName = ScriptCB_GetProfileName(1)
  121.     ifs_saveop.saveProfileNum = 1
  122.     ifs_saveop.NoPromptSave = 1
  123.     ifs_movietrans_PushScreen(ifs_saveop)  
  124.    
  125. end
  126.  
  127. function ifs_main_SaveProfileSuccess()
  128. --  print("ifs_main_SaveProfileSuccess")
  129.    
  130.     ScriptCB_Logout()
  131.     ifs_login.EnterDoNothing = nil
  132.  
  133.     -- pop to login
  134.     ScriptCB_PopScreen("ifs_login")
  135. end
  136.  
  137. function ifs_main_SaveProfileCancel()
  138. --  print("ifs_main_SaveProfileCancel")
  139.    
  140.     -- back to the "its dirty, save?" prompt when we enter
  141.     ifs_main.TryToBackup = 1
  142.     -- pop ifs_saveop, return to ifs_main
  143.     ScriptCB_PopScreen()
  144. end
  145.  
  146. ----------------------------------------------------------------------------------------
  147. ----------------------------------------------------------------------------------------
  148.  
  149.  
  150. --function ifs_main_OnLoginDone()
  151. --  print("ifs_main_OnLoginDone")
  152. --  local this = ifs_main
  153. -- 
  154. --  -- where did we want to go?
  155. --  ifs_movietrans_PushScreen(this.gotoAfterLogin)
  156. --end
  157.  
  158. function ifs_main_GotoLoginScreen(this, afterScreen)
  159. --  -- this is where we go when we're done with the login screen
  160. --  this.gotoAfterLogin = afterScreen
  161. --  -- this is what gets called by the login screen to say its done
  162. --  ifs_login.fnDone = ifs_main_OnLoginDone
  163. --  -- go there
  164. --  ifs_movietrans_PushScreen(ifs_login)
  165.    
  166.     ifs_movietrans_PushScreen(afterScreen)
  167. end
  168.  
  169. -- Helper function, called from several pages. Updates the silent login box
  170. function ifs_XLive_fnUpdateSilentLoginBox(this)
  171.     this.fSilentLoginTimer = 0.5 -- reset timer
  172.  
  173.     local ShowUStr,bSmallFont = ScriptCB_XL_GetSilentLoginState()
  174.     if(bSmallFont) then
  175.         if(ScriptCB_GetLanguage() == "english") then
  176.             IFText_fnSetFont(this.LoginInfoWindow.ShowText,"gamefont_small")
  177.         else
  178.             IFText_fnSetFont(this.LoginInfoWindow.ShowText,"gamefont_tiny")
  179.         end
  180.     else
  181.         IFText_fnSetFont(this.LoginInfoWindow.ShowText,"gamefont_medium")
  182.     end
  183.     IFText_fnSetUString(this.LoginInfoWindow.ShowText,ShowUStr)
  184. end
  185.  
  186.  
  187. ifs_main = NewIFShellScreen {
  188.     bNohelptext_backPC = 1,
  189.  
  190.     buttons = NewIFContainer {
  191.         ScreenRelativeX = 0.5, -- center
  192.         ScreenRelativeY = 0.65, -- top
  193.         y = 30, -- offset slightly down
  194.         x = -30,
  195.         rotY = -30,
  196.         rotX = -20,
  197.         rotZ = 1,
  198.     },
  199.        
  200.     movieIntro      = "ifs_main_intro",
  201.     movieBackground = "ifs_main",
  202.     music           = "shell_soundtrack",
  203.  
  204.     Enter = function(this, bFwd)
  205. --      print("ifs_main.Enter(",bFwd,")")
  206.         gIFShellScreenTemplate_fnEnter(this, bFwd) -- call default enter function
  207.        
  208.         if(gPlatformStr == "PC") then
  209.             this.buttons.tutorials.hidden = 1
  210.         end
  211.         -- if we should attempt to back up, do it
  212.         if(this.TryToBackup) then
  213.             this.TryToBackup = nil
  214.             ifs_main_TryToBackup()
  215.             return
  216.         end
  217.        
  218.         -- if we ever enter going backwards, clear these vars
  219.         if(not bFwd) then
  220.             ScriptCB_SetSplitscreen( nil )
  221.             ScriptCB_SetInNetGame( nil )
  222.         end
  223.        
  224.         --if we're booting from NTGUI, skip forward
  225.         if(ScriptCB_SkipToNTGUI()) then
  226. --          ifs_main_GotoLoginScreen(this, ifs_mpps2_netconfig)
  227.             ifs_main_GotoLoginScreen(this, ifs_mp)
  228.         end
  229.  
  230.         if(not bFwd) then
  231.             ScriptCB_UnbindController(2)
  232.             ScriptCB_UnbindController(3)
  233.             ScriptCB_UnbindController(4)
  234.         end
  235.        
  236.         if(bFwd and ScriptCB_IsSpecialJoinPending()) then
  237.             ifs_main_GotoLoginScreen(this, ifs_mp)
  238.         elseif (bFwd and ScriptCB_IsCmdlineJoinPending()) then
  239.             ifs_mp_lobby_quick.bCmdlineJoinPending = 1
  240.             ifs_main_GotoLoginScreen(this, ifs_mp)
  241.         elseif (bFwd and ScriptCB_InMultiplayer()) then
  242.             --ScriptCB_SndBusFade("music", 0.5, 0.0) -- fade out music
  243.             -- Note: ps2 could go to ifs_mpps2_netconfig here, but I'd
  244.             -- rather assume they want to use the previous netconfig. If they
  245.             -- back all the way out to here, they can select another manually.
  246.             -- Hopefully that'll let us get thru Sony
  247.             ifs_main_GotoLoginScreen(this, ifs_mp)
  248.         elseif(bFwd and ScriptCB_IsMetagameStateSaved()) then
  249.             if(ScriptCB_WasSplitscreen and ScriptCB_WasSplitscreen()) then
  250.                 ScriptCB_SetSplitscreen(1)
  251.             end
  252.             ifs_main_GotoLoginScreen(this, ifs_sp)
  253.         elseif (bFwd and ScriptCB_IsSPStateSaved()) then
  254.             if(ScriptCB_WasSplitscreen and ScriptCB_WasSplitscreen()) then
  255.                 ScriptCB_SetSplitscreen(1)
  256.             end
  257.             ifs_main_GotoLoginScreen(this, ifs_sp)
  258.         else
  259.             -- Staying here... make sure other controllers are unbound,
  260.             -- [Fix for 7005 - NM 7/24/004]
  261.             ScriptCB_UnbindController(2)
  262.             ScriptCB_UnbindController(3)
  263.             ScriptCB_UnbindController(4)
  264.         end
  265.  
  266.         this.buttons.quit.hidden = (gPlatformStr ~= "PC")
  267.         this.buttons.back2.hidden = (gPlatformStr ~= "PC")
  268.         this.buttons.split.hidden = (gPlatformStr == "PC")
  269.         this.buttons.tutorials.hidden = (gPlatformStr == "PC")
  270.  
  271.         ShowHideVerticalButtons(this.buttons,ifsmain_vbutton_layout)
  272.  
  273.         if(gPlatformStr == "XBox") then
  274.             ifs_XLive_fnUpdateSilentLoginBox(this)
  275.         end
  276.  
  277.         IFObj_fnSetVis(this.LoginInfoWindow, (gPlatformStr == "XBox"))
  278.     end,
  279.  
  280.     Exit = function(this, bFwd)
  281.         if (not bFwd) then
  282.             ifelm_shellscreen_fnPlaySound(this.exitSound)
  283.         end
  284.     end,
  285.  
  286.     iNumControllers = 8, -- default value for all platforms, XBox will change this
  287.     fSplitColor = 255,
  288.     fLogTimer = 0.5,
  289.     Update = function(this, fDt)
  290.         -- Call base class functionality
  291.         gIFShellScreenTemplate_fnUpdate(this, fDt)
  292.  
  293.         if(gPlatformStr ~= "PC") then
  294.             local iNumControllers = ScriptCB_GetNumControllers()
  295.             if(this.iNumControllers ~= iNumControllers) then
  296.                 this.iNumControllers = iNumControllers
  297.                 if(this.iNumControllers < 2) then
  298.                     this.fSplitColor = 110
  299.                     -- Move off option if on it.
  300.                     if(this.CurButton == "split") then
  301.                         this:Input_GeneralUp()
  302.                     end
  303.                 else
  304.                     this.fSplitColor = 255
  305.                 end
  306.             end -- # of controllers changed since last frame
  307.  
  308.             ScriptCB_IFFlashyText_SetTextColor(this.buttons.split.label.cpointer, this.fSplitColor , this.fSplitColor , this.fSplitColor)
  309.         end -- XBox-only code
  310.  
  311.         if(gPlatformStr == "XBox") then
  312.             this.fSilentLoginTimer = this.fSilentLoginTimer - fDt
  313.             if(this.fSilentLoginTimer < 0) then
  314.                 ifs_XLive_fnUpdateSilentLoginBox(this)
  315.             end
  316.         end
  317.  
  318.     end,
  319.  
  320.     Input_Back = function(this)
  321.         -- if going backwards (to the login screen), log out
  322.         ifs_main_TryToBackup()
  323.     end,
  324.  
  325.     Input_Accept = function(this)
  326.         -- If base class handled this work, then we're done
  327.         if(gShellScreen_fnDefaultInputAccept(this)) then
  328.             return
  329.         end
  330.  
  331.         if(this.CurButton) then
  332.             ifelm_shellscreen_fnPlaySound(this.acceptSound)
  333.         end
  334.  
  335. --      print("  ***  ifs_main::Input_Accept. Cur = ",this.CurButton)
  336.         if(this.CurButton == "sp") then
  337.             ifs_sp.bForSplitScreen = nil
  338.             ScriptCB_SetSplitscreen( nil )
  339.             ScriptCB_SetInNetGame( nil )
  340.             ifs_main_GotoLoginScreen(this, ifs_sp)
  341.                        
  342.         elseif (this.CurButton == "mp") then
  343.  
  344.             local bPresent = 1
  345.             if(ScriptCB_IsNetHWPresent) then
  346.                 bPresent = ScriptCB_IsNetHWPresent()
  347.             end
  348.             if(not bPresent) then
  349.                 Popup_Ok_Large.fnDone = ifs_main_fnPostNoNetHW
  350.                 IFText_fnSetString(Popup_Ok_Large.title,"ifs.mp.no_net_adaptor")
  351.                 Popup_Ok_Large:fnActivate(1)
  352.                 local fAnimTime = 0.2
  353.                 AnimationMgr_AddAnimation(this.buttons,
  354.                                                                     { fTotalTime = fAnimTime, fStartAlpha = 1, fEndAlpha = 0,})
  355.             else
  356.                 ifs_sp.bForSplitScreen = nil
  357.                 ScriptCB_SetSplitscreen( nil )
  358.                 --ScriptCB_SndBusFade("music", 0.5, 0.0) -- fade out music
  359.                
  360.                 --          if(gPlatformStr == "PS2") then
  361.                 --              ifs_main_GotoLoginScreen(this, ifs_mpps2_netconfig)
  362.                 --          else
  363.                 ifs_main_GotoLoginScreen(this, ifs_mp)
  364.                 --          end
  365.             end -- Has network adaptor
  366. --V - SERVER BROWSER function (17.June.2015) ---------------------------------------------------------------------------------------------
  367.         elseif (this.CurButton == "mpsb") then --V - serverbrowser button
  368.             ifs_sp.bForSplitScreen = nil --V - kill it with fire
  369.             ScriptCB_SetSplitscreen( nil ) --V - kill it with fire #2
  370.         --ifs_main_GotoLoginScreen(this, ifs_mp) --V - We want to jump straight to sessionlist (testing)   
  371.             ScriptCB_SetConnectType("wan") --V - set the ConnectType: not lan nor direct, it's internet!
  372.             ifelm_shellscreen_fnPlaySound(this.acceptSound) --V - play sound because we're cool
  373.             ifs_movietrans_PushScreen(ifs_mp_sessionlist) --V - skip everything and go straight to sessionlist
  374. --V - SERVER BROWSER function end. ---------------------------------------------------------------------------------------------------------
  375.         elseif (this.CurButton == "split") then
  376.             ifs_sp.bForSplitScreen = 1
  377.             ScriptCB_SetSplitscreen( 1 )
  378.             ifs_movietrans_PushScreen(ifs_split_profile)
  379.         elseif (this.CurButton == "tutorials") then
  380.             ifs_movietrans_PushScreen(ifs_tutorials)
  381.         elseif (this.CurButton == "opts") then
  382.             ifs_main_GotoLoginScreen(this, ifs_opt_contmain)
  383.         elseif (this.CurButton == "quit") then
  384.             Popup_YesNo.CurButton = "no" -- default
  385.             Popup_YesNo.fnDone = ifs_main_fnQuitPopupDone
  386.             IFText_fnSetString(Popup_YesNo.title,"ifs.main.askquit")
  387.             IFObj_fnSetVis(this.buttons,nil)
  388.             Popup_YesNo:fnActivate(1)
  389.         elseif (this.CurButton == "back2") then
  390.             -- Why we need another button to go back is beyond me.
  391.             ifs_main_TryToBackup()
  392.         end
  393.     end,
  394.  
  395.     -- Gotta skip over splitscreen option if there's not enough controllers.
  396.     Input_GeneralUp = function(this)
  397.         -- If base class handled this work, then we're done
  398.         if(gShellScreen_fnDefaultInputUp(this)) then
  399.             return
  400.         end
  401.  
  402.         gDefault_Input_GeneralUp(this)
  403.         if((this.CurButton == "split") and (this.iNumControllers < 2)) then
  404.             gDefault_Input_GeneralUp(this) -- move cursor off item
  405.         end
  406.     end,
  407.  
  408.     Input_GeneralDown = function(this)
  409.         -- If base class handled this work, then we're done
  410.         if(gShellScreen_fnDefaultInputDown(this)) then
  411.             return
  412.         end
  413.  
  414.         gDefault_Input_GeneralDown(this)
  415.         if((this.CurButton == "split") and (this.iNumControllers < 2)) then
  416.             gDefault_Input_GeneralDown(this) -- move cursor off item
  417.         end
  418.     end,
  419. }
  420.  
  421. function ifs_main_fnBuildScreen(this)
  422.  
  423.     if(HackBGTextureOnPCOnly) then
  424.         this.bg_texture = HackBGTextureOnPCOnly("main")
  425.     end
  426.  
  427.  
  428.     this.CurButton = AddVerticalButtons(this.buttons,ifsmain_vbutton_layout)
  429.  
  430.     -- Even with the larger window, german needs more space. Too bad it
  431.     -- has to come at the expense of readability. - NM 7/5/04
  432.     if(ScriptCB_GetLanguage() == "german") then
  433.         local k,v
  434.         for k,v in ifsmain_vbutton_layout.buttonlist do
  435.             local Tag = v.tag
  436.             this.buttons[Tag].label.font = "gamefont_small"
  437.         end
  438.     elseif (ScriptCB_GetLanguage() == "italian") then
  439.         this.buttons._titlebar_.font = "gamefont_small"
  440.     end
  441.  
  442.     local InfoWindowW = 270
  443.     local InfoWindowH = 75
  444.  
  445.     this.LoginInfoWindow = NewButtonWindow {
  446.         ScreenRelativeY = 0.0, -- top
  447.         ScreenRelativeX = 1.0, -- right
  448.         x = InfoWindowW * -0.5,
  449.         y = InfoWindowH * 0.5,
  450.         width = InfoWindowW,
  451.         height = InfoWindowH,
  452.         ZPos = 200,
  453.     }
  454.  
  455.     this.LoginInfoWindow.ShowText = NewIFText {
  456.         font = "gamefont_medium",
  457.         textw = InfoWindowW - 24,
  458.         texth = InfoWindowH - 24,
  459.         nocreatebackground = 1,    
  460.         startdelay = random() * 0.5,
  461.         valign = "vcenter",
  462.     }
  463.  
  464.  
  465. end
  466.  
  467. ifs_main_fnBuildScreen(ifs_main)
  468. ifs_main_fnBuildScreen = nil
  469. AddIFScreen(ifs_main,"ifs_main")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement