//----------------Sonic CD Menu Control Script----------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
// Aliases
#alias Object.Value0 : [Link]
#alias Object.Value1 : [Link]
#alias Object.Value2 : [Link]
#alias Object.Value3 : [Link]
#alias Object.Value4 : [Link]
#alias Object.Value5 : [Link]
#alias Object.Value6 : [Link]
#alias Object.Value7 : [Link]
#alias [Link] : [Link]
// Object[1] is a blank object only used to share values across the menu objects
#alias Object[1].Value0 : [Link]
#alias Object[1].Value1 : [Link]
#alias Object[1].Value2 : [Link]
#alias Object[1].Value3 : [Link]
#alias Object[1].Value4 : Object.YOffSet1 //in other scripts this is used to
check inputs
#alias Object[1].Value5 : Object.YOffSet2
#alias Object[1].Value6 : Object.YOffSet3
// Menu Button Aliases
#alias Object[34].State : [Link]
// States
#alias 0 : MENUCONTROL_SETUP
#alias 1 : MENUCONTROL_BUTTONS_MOVEIN
#alias 2 : MENUCONTROL_CONTROLS
#alias 3 : MENUCONTROL_BLANK
#alias 4 : MENUCONTROL_ENTER_TIMEATTACK
#alias 5 : MENUCONTROL_ENTER_DEMO
#alias 6 : MENUCONTROL_MENUBUTTON_CHECK
#alias 7 : MENUCONTROL_ENTER_TROPHIES
#alias 8 : MENUCONTROL_ENTER_LEADERBOARDS
// MenuButton States
#alias 2 : MENUBUTTON_CONFIRM_SELECTION
// Presentation Stages
#alias 2 : STAGE_P_TATTACK
#alias 9 : STAGE_P_THROPIES
#alias 10 : STAGE_P_LEADERBOARDS
// Regular Stages
#alias 0 : STAGE_R_PPZ1A
// Global SFX
#alias 23 : SFX_G_MENUBUTTON
#alias 27 : SFX_G_SELECT
// Soundtrack
#alias 0 : OST_JP
// Engine & CallBacks
#alias 2 : MESSAGE_LOSTFOCUS
// Device Type
#alias 0 : RETRO_STANDARD
sub ObjectMain
switch [Link]
case MENUCONTROL_SETUP
[Link] = MENUCONTROL_BUTTONS_MOVEIN
[Link] = 384
SetScreenFade(0, 0, 0, 255)
PlayMusic([Link])
if [Link] > -1
[Link] = -1
end if
break
case MENUCONTROL_BUTTONS_MOVEIN
if [Link] > 0
[Link] -= 8
else
[Link] = MENUCONTROL_MENUBUTTON_CHECK
end if
SetScreenFade(0, 0, 0, [Link])
break
case MENUCONTROL_CONTROLS
#platform: Standard
CheckResult = true
#endplatform
#platform: Mobile
CheckEqual([Link], true)
#endplatform
#platform: Use_Origins
CheckEqual([Link], true)
#endplatform
// 2011 Steam lacks [Link], so we force it here first
and the other platforms can override it
if CheckResult == true
#platform: Use_Origins
[Link] = true
#endplatform
if [Link] == true
[Link]--
if [Link] < 1
[Link] = 1
else
PlaySfx(SFX_G_MENUBUTTON, false)
end if
end if
if [Link] == true
[Link]++
if [Link] > [Link]
[Link] = [Link]
else
PlaySfx(SFX_G_MENUBUTTON, false)
end if
end if
TempValue0 = [Link]
TempValue0 -= [Link]
if TempValue0 < 1
[Link]--
[Link] = 3
end if
if TempValue0 > 4
[Link]++
[Link] = 0
end if
//Button Movement across the screen
TempValue0 = [Link]
TempValue0 -= 32
TempValue1 = [Link]
TempValue1 *= -60
TempValue1 -= TempValue0
TempValue1 += [Link]
TempValue1 >>= 2
[Link] += TempValue1
#platform: Use_Origins
CheckTouchRect(0, 0, [Link], [Link])
if CheckResult > -1
[Link] = false
[Link] = 0
[Link] = 0
end if
#endplatform
#platform: Mobile
CheckTouchRect(0, 0, [Link], [Link])
if CheckResult > -1
[Link] = false
[Link] = 0
[Link] = 0
end if
#endplatform
else
if [Link] == MESSAGE_LOSTFOCUS
[Link] = 0
[Link] = 0
end if
if [Link] > 0
[Link] = [Link]
else
[Link] = 0
end if
if [Link] > 4
CheckTouchRect(0, 0, [Link], [Link])
if CheckResult > -1
ArrayPos0 = CheckResult
if [Link] == false
[Link] = true
[Link] = [Link]
[Link] =
TouchScreen[ArrayPos0].YPos
else
//Dragging of buttons based on input
TempValue0 = TouchScreen[ArrayPos0].YPos
TempValue0 -= [Link]
TempValue0 += [Link]
Object.YOffSet3 = Object.YOffSet2
Object.YOffSet2 = Object.YOffSet1
Object.YOffSet1 = [Link]
[Link] = TempValue0
[Link] -= [Link]
[Link] = TempValue0
end if
TempValue0 = [Link]
TempValue0 >>= 2
if TempValue0 != 0
[Link] = 0
[Link] = 0
end if
else
if [Link] == true
//Sets the position to where the buttons will
go post-drag
[Link] = false
[Link] = [Link]
[Link] <<= 8
[Link] += Object.YOffSet1
[Link] += Object.YOffSet2
[Link] += Object.YOffSet3
[Link] >>= 2
[Link] <<= 7
if [Link] == 0
if [Link] == 0
[Link] = 1
//Forces movement
end if
end if
end if
if [Link] != 0
//Centers to whatever button is closer to the
center + offset up or down depending of to where did you drag
[Link] += [Link]
if [Link] < [Link]
[Link] = [Link]
[Link] = 0
end if
if [Link] > 0x5A00
[Link] = 0x5A00
[Link] = 0
end if
if [Link] > 0
[Link] -= 32
if [Link] < 0
[Link] = 0
end if
else
[Link] += 32
if [Link] > 0
[Link] = 0
end if
end if
[Link] = [Link]
[Link] >>= 8
if [Link] == 0
[Link] =
[Link]
[Link] -= 32
[Link] /= -60
if [Link] < 0
[Link] = 0
end if
TempValue0 = [Link]
TempValue0 -= 4
if [Link] > TempValue0
[Link] = TempValue0
end if
end if
else
//Drag screen re-centering
TempValue0 = [Link]
TempValue0 -= 32
[Link] = [Link]
[Link] *= -60
[Link] -= TempValue0
[Link] >>= 2
if [Link] < -4
[Link] = -4
end if
if [Link] > 4
[Link] = 4
end if
[Link] += [Link]
end if
end if
end if
#platform: Use_Origins
if KeyPress[0].Up == true
[Link] = [Link]
[Link] = true
end if
if KeyPress[0].Down == true
[Link] = 1
[Link] = true
end if
#endplatform
#platform: Mobile
if KeyPress[0].Up == true
[Link] = [Link]
[Link] = true
end if
if KeyPress[0].Down == true
[Link] = 1
[Link] = true
end if
#endplatform
end if
break
case MENUCONTROL_BLANK //Used to stop the controls temporarily
break
case MENUCONTROL_ENTER_TIMEATTACK
if [Link] < 320
[Link] += 8
else
[Link] = STAGE_P_TATTACK
LoadStage()
end if
SetScreenFade(0, 0, 0, [Link])
break
case MENUCONTROL_ENTER_DEMO //Only used in Demo versions of the game
if [Link] < 320
[Link] += 8
else
LoadVideo("Opening")
// if [Link] != RETRO_WP7
// if [Link] == OST_JP
// LoadVideo("Opening")
// else
// LoadVideo("OpeningUS")
// end if
// end if
[Link] = REGULAR_STAGE
[Link] = STAGE_R_PPZ1A
LoadStage()
end if
SetScreenFade(0, 0, 0, [Link])
break
case MENUCONTROL_MENUBUTTON_CHECK
if [Link] == MENUBUTTON_CONFIRM_SELECTION
[Link] = MENUCONTROL_CONTROLS
end if
break
case MENUCONTROL_ENTER_TROPHIES //Mobile Only
if [Link] < 320
[Link] += 8
else
[Link] = STAGE_P_THROPIES
LoadStage()
end if
SetScreenFade(0, 0, 0, [Link])
break
case MENUCONTROL_ENTER_LEADERBOARDS //Mobile Only
if [Link] < 320
[Link] += 8
else
[Link] = STAGE_P_LEADERBOARDS
LoadStage()
end if
SetScreenFade(0, 0, 0, [Link])
break
end switch
end sub
sub ObjectStartup
SetMusicTrack("JP/[Link]", 0, 1)
SetMusicTrack("US/[Link]", 1, 270972)
Object[0].Type = TypeName[Menu Control]
Object[0].ButtonYOffset = 32
#platform: Use_Origins // they have in mind a mobile release or this is for
Switch?
if [Link] == RETRO_STANDARD
Object[0].CurrentSelection = 1
[Link] = true
else
[Link] = false
endif
#endplatform
#platform: Use_Standalone
#platform: Standard
Object[0].CurrentSelection = 1
#endplatform
#endplatform
#platform: Use_Standalone
#platform: Mobile
[Link] = false
#endplatform
#endplatform
Object[0].DragCurrentSelection = 0
end sub
// ========================
// Editor Subs
// ========================
sub RSDKDraw
DrawSprite(0)
end sub
sub RSDKLoad
LoadSpriteSheet("Global/[Link]")
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub