Path: blob/main/Scripts/Menu/MenuControl.txt
1319 views
//----------------Sonic CD Menu Control Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Fade6#alias Object.Value1 : Object.ButtonYOffset7#alias Object.Value2 : Object.DragCurrentSelection8#alias Object.Value3 : Object.CurrentSelection9#alias Object.Value4 : Object.ButtonScroll10#alias Object.Value5 : Object.DragEnabled11#alias Object.Value6 : Object.DragYOffset12#alias Object.Value7 : Object.DragSmooth13#alias Object.Direction : Object.YOffsetCorrection1415// Object[1] is a blank object only used to share values across the menu objects16#alias Object[1].Value0 : Object.DragPos17#alias Object[1].Value1 : Object.RecenterValue18#alias Object[1].Value2 : Object.MaxButtonCount19#alias Object[1].Value3 : Object.DragLimit20#alias Object[1].Value4 : Object.YOffSet1 //in other scripts this is used to check inputs21#alias Object[1].Value5 : Object.YOffSet222#alias Object[1].Value6 : Object.YOffSet32324// Menu Button Aliases25#alias Object[34].State : MenuButton.State2627// States28#alias 0 : MENUCONTROL_SETUP29#alias 1 : MENUCONTROL_BUTTONS_MOVEIN30#alias 2 : MENUCONTROL_CONTROLS31#alias 3 : MENUCONTROL_BLANK32#alias 4 : MENUCONTROL_ENTER_TIMEATTACK33#alias 5 : MENUCONTROL_ENTER_DEMO34#alias 6 : MENUCONTROL_MENUBUTTON_CHECK35#alias 7 : MENUCONTROL_ENTER_TROPHIES36#alias 8 : MENUCONTROL_ENTER_LEADERBOARDS3738// MenuButton States39#alias 2 : MENUBUTTON_CONFIRM_SELECTION4041// Presentation Stages42#alias 2 : STAGE_P_TATTACK43#alias 9 : STAGE_P_THROPIES44#alias 10 : STAGE_P_LEADERBOARDS4546// Regular Stages47#alias 0 : STAGE_R_PPZ1A4849// Global SFX50#alias 23 : SFX_G_MENUBUTTON51#alias 27 : SFX_G_SELECT5253// Soundtrack54#alias 0 : OST_JP5556// Engine & CallBacks57#alias 2 : MESSAGE_LOSTFOCUS5859// Device Type60#alias 0 : RETRO_STANDARD616263sub ObjectMain6465switch Object.State66case MENUCONTROL_SETUP67Object.State = MENUCONTROL_BUTTONS_MOVEIN68Object.Fade = 38469SetScreenFade(0, 0, 0, 255)70PlayMusic(Options.Soundtrack)71if Engine.FrameSkipTimer > -172Engine.FrameSkipTimer = -173end if74break7576case MENUCONTROL_BUTTONS_MOVEIN77if Object.Fade > 078Object.Fade -= 879else80Object.State = MENUCONTROL_MENUBUTTON_CHECK81end if82SetScreenFade(0, 0, 0, Object.Fade)83break8485case MENUCONTROL_CONTROLS8687#platform: Standard88CheckResult = true89#endplatform9091#platform: Mobile92CheckEqual(Options.PhysicalControls, true)93#endplatform9495#platform: Use_Origins96CheckEqual(Options.PhysicalControls, true)97#endplatform9899100// 2011 Steam lacks Options.PhysicalControls, so we force it here first and the other platforms can override it101if CheckResult == true102#platform: Use_Origins103Menu.ExitFlag = true104#endplatform105if KeyPress.Up == true106Object.CurrentSelection--107if Object.CurrentSelection < 1108Object.CurrentSelection = 1109else110PlaySfx(SFX_G_MENUBUTTON, false)111end if112end if113114if KeyPress.Down == true115Object.CurrentSelection++116if Object.CurrentSelection > Object.MaxButtonCount117Object.CurrentSelection = Object.MaxButtonCount118else119PlaySfx(SFX_G_MENUBUTTON, false)120end if121end if122123TempValue0 = Object.CurrentSelection124TempValue0 -= Object.ButtonScroll125if TempValue0 < 1126Object.ButtonScroll--127Object.YOffsetCorrection = 3128end if129130if TempValue0 > 4131Object.ButtonScroll++132Object.YOffsetCorrection = 0133end if134135//Button Movement across the screen136TempValue0 = Object.ButtonYOffset137TempValue0 -= 32138139TempValue1 = Object.ButtonScroll140TempValue1 *= -60141TempValue1 -= TempValue0142TempValue1 += Object.YOffsetCorrection143TempValue1 >>= 2144Object.ButtonYOffset += TempValue1145146#platform: Use_Origins147CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)148if CheckResult > -1149Options.PhysicalControls = false150Object.CurrentSelection = 0151Object.DragCurrentSelection = 0152end if153#endplatform154155#platform: Mobile156CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)157if CheckResult > -1158Options.PhysicalControls = false159Object.CurrentSelection = 0160Object.DragCurrentSelection = 0161end if162#endplatform163164else165if Engine.Message == MESSAGE_LOSTFOCUS166Object.CurrentSelection = 0167Object.DragCurrentSelection = 0168end if169170if Object.DragCurrentSelection > 0171Object.CurrentSelection = Object.DragCurrentSelection172else173Object.CurrentSelection = 0174end if175176if Object.MaxButtonCount > 4177CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)178if CheckResult > -1179ArrayPos0 = CheckResult180if Object.DragEnabled == false181Object.DragEnabled = true182Object.DragPos = Object.ButtonYOffset183Object.DragYOffset = TouchScreen[ArrayPos0].YPos184else185//Dragging of buttons based on input186TempValue0 = TouchScreen[ArrayPos0].YPos187TempValue0 -= Object.DragYOffset188TempValue0 += Object.DragPos189190Object.YOffSet3 = Object.YOffSet2191Object.YOffSet2 = Object.YOffSet1192Object.YOffSet1 = Object.DragSmooth193194Object.DragSmooth = TempValue0195Object.DragSmooth -= Object.ButtonYOffset196Object.ButtonYOffset = TempValue0197end if198199TempValue0 = Object.DragSmooth200TempValue0 >>= 2201if TempValue0 != 0202Object.CurrentSelection = 0203Object.DragCurrentSelection = 0204end if205else206if Object.DragEnabled == true207//Sets the position to where the buttons will go post-drag208Object.DragEnabled = false209Object.DragYOffset = Object.ButtonYOffset210Object.DragYOffset <<= 8211212Object.DragSmooth += Object.YOffSet1213Object.DragSmooth += Object.YOffSet2214Object.DragSmooth += Object.YOffSet3215Object.DragSmooth >>= 2216Object.DragSmooth <<= 7217218if Object.DragSmooth == 0219if Object.CurrentSelection == 0220Object.DragSmooth = 1 //Forces movement221end if222end if223end if224225if Object.DragSmooth != 0226//Centers to whatever button is closer to the center + offset up or down depending of to where did you drag227Object.DragYOffset += Object.DragSmooth228if Object.DragYOffset < Object.DragLimit229Object.DragYOffset = Object.DragLimit230Object.DragSmooth = 0231end if232if Object.DragYOffset > 0x5A00233Object.DragYOffset = 0x5A00234Object.DragSmooth = 0235end if236237if Object.DragSmooth > 0238Object.DragSmooth -= 32239if Object.DragSmooth < 0240Object.DragSmooth = 0241end if242else243Object.DragSmooth += 32244if Object.DragSmooth > 0245Object.DragSmooth = 0246end if247end if248249Object.ButtonYOffset = Object.DragYOffset250Object.ButtonYOffset >>= 8251if Object.DragSmooth == 0252Object.ButtonScroll = Object.ButtonYOffset253Object.ButtonScroll -= 32254Object.ButtonScroll /= -60255if Object.ButtonScroll < 0256Object.ButtonScroll = 0257end if258259TempValue0 = Object.MaxButtonCount260TempValue0 -= 4261if Object.ButtonScroll > TempValue0262Object.ButtonScroll = TempValue0263end if264end if265else266//Drag screen re-centering267TempValue0 = Object.ButtonYOffset268TempValue0 -= 32269Object.RecenterValue = Object.ButtonScroll270Object.RecenterValue *= -60271Object.RecenterValue -= TempValue0272Object.RecenterValue >>= 2273if Object.RecenterValue < -4274Object.RecenterValue = -4275end if276if Object.RecenterValue > 4277Object.RecenterValue = 4278end if279Object.ButtonYOffset += Object.RecenterValue280end if281end if282end if283284#platform: Use_Origins285if KeyPress[0].Up == true286Object.CurrentSelection = Object.MaxButtonCount287Options.PhysicalControls = true288end if289290if KeyPress[0].Down == true291Object.CurrentSelection = 1292Options.PhysicalControls = true293end if294#endplatform295296#platform: Mobile297if KeyPress[0].Up == true298Object.CurrentSelection = Object.MaxButtonCount299Options.PhysicalControls = true300end if301302if KeyPress[0].Down == true303Object.CurrentSelection = 1304Options.PhysicalControls = true305end if306#endplatform307end if308309break310311case MENUCONTROL_BLANK //Used to stop the controls temporarily312break313314case MENUCONTROL_ENTER_TIMEATTACK315if Object.Fade < 320316Object.Fade += 8317else318Stage.ListPos = STAGE_P_TATTACK319LoadStage()320end if321SetScreenFade(0, 0, 0, Object.Fade)322break323324case MENUCONTROL_ENTER_DEMO //Only used in Demo versions of the game325if Object.Fade < 320326Object.Fade += 8327else328LoadVideo("Opening")329330331// if Engine.PlatformID != RETRO_WP7332// if Options.Soundtrack == OST_JP333// LoadVideo("Opening")334// else335// LoadVideo("OpeningUS")336// end if337// end if338339Stage.ActiveList = REGULAR_STAGE340Stage.ListPos = STAGE_R_PPZ1A341LoadStage()342end if343SetScreenFade(0, 0, 0, Object.Fade)344break345346case MENUCONTROL_MENUBUTTON_CHECK347if MenuButton.State == MENUBUTTON_CONFIRM_SELECTION348Object.State = MENUCONTROL_CONTROLS349end if350break351352case MENUCONTROL_ENTER_TROPHIES //Mobile Only353if Object.Fade < 320354Object.Fade += 8355else356Stage.ListPos = STAGE_P_THROPIES357LoadStage()358end if359SetScreenFade(0, 0, 0, Object.Fade)360361break362363case MENUCONTROL_ENTER_LEADERBOARDS //Mobile Only364if Object.Fade < 320365Object.Fade += 8366else367Stage.ListPos = STAGE_P_LEADERBOARDS368LoadStage()369end if370SetScreenFade(0, 0, 0, Object.Fade)371372break373374end switch375end sub376377378sub ObjectStartup379SetMusicTrack("JP/SpecialStage.ogg", 0, 1)380SetMusicTrack("US/SpecialStage.ogg", 1, 270972)381Object[0].Type = TypeName[Menu Control]382Object[0].ButtonYOffset = 32383384#platform: Use_Origins // they have in mind a mobile release or this is for Switch?385if Engine.DeviceType == RETRO_STANDARD386Object[0].CurrentSelection = 1387Options.PhysicalControls = true388else389Options.PhysicalControls = false390endif391#endplatform392393#platform: Use_Standalone394#platform: Standard395Object[0].CurrentSelection = 1396#endplatform397#endplatform398#platform: Use_Standalone399#platform: Mobile400Options.PhysicalControls = false401#endplatform402#endplatform403404Object[0].DragCurrentSelection = 0405end sub406407408// ========================409// Editor Subs410// ========================411412sub RSDKDraw413DrawSprite(0)414end sub415416417sub RSDKLoad418LoadSpriteSheet("Global/Display.gif")419SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon420421SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")422end sub423424425