Path: blob/main/Scripts/Special/TouchControls.txt
1319 views
//---------------Sonic CD Touch Controls Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias 8: TYPE_TOUCHCONTROLS67#alias Object.Value0 : Object.MainAlpha8#alias Object.Value1 : Object.PauseAlpha9#alias Object.Value2 : Object.PausePos10#alias Object.Value3 : Object.JumpButtonPos11#alias Object.Value4 : Object.DPadPos1213// Not used in this Script, but the Sonic Object uses it to store if the Jump button was held last frame14#alias Object.Value7 : TouchControls.TouchJump1516// The primary alpha for the input display to use17#alias 160: TOUCHCONTROLS_TARGETALPHA1819// Sonic Aliases20#alias Player.ControlMode : SSSonic.ControlMode2122// ControlMode Aliases23#alias -1 : CONTROLMODE_NONE24#alias 0 : CONTROLMODE_NORMAL2526// Ink Effects27#alias 2 : INK_ALPHA2829// Priority30#alias 1 : PRIORITY_ACTIVE313233sub ObjectDraw34#platform: Mobile35if Options.TouchControls == false36TempValue0 = CONTROLMODE_NONE37else38TempValue0 = Player.ControlMode39end if4041if TempValue0 == CONTROLMODE_NORMAL42// The Player's up and ready to control, so let's show their inputs!4344// Wait for the stage to be active too, before doing anything45if Stage.State != STAGE_PAUSED4647// Fade the controls in, if they're not already yet48if Object.MainAlpha < TOUCHCONTROLS_TARGETALPHA49Object.MainAlpha += 45051// Make Pause Alpha double of the Main Alpha52Object.PauseAlpha = Object.MainAlpha53Object.PauseAlpha <<= 154end if5556// For here, we're drawing all the main features - DPad, and the Jump button - so let's pull from the main alpha for now57Object.Alpha = Object.MainAlpha5859// First, draw the base DPad frame60DrawSpriteScreenFX(0, FX_INK, Object.DPadPos, 160)6162// Now, all the directions6364if Player.Left == true65Object.Alpha = TOUCHCONTROLS_TARGETALPHA66DrawSpriteScreenFX(7, FX_INK, Object.DPadPos, 160)67else68Object.Alpha = Object.MainAlpha69DrawSpriteScreenFX(3, FX_INK, Object.DPadPos, 160)70end if7172if Player.Down == true73Object.Alpha = TOUCHCONTROLS_TARGETALPHA74DrawSpriteScreenFX(6, FX_INK, Object.DPadPos, 160)75else76Object.Alpha = Object.MainAlpha77DrawSpriteScreenFX(2, FX_INK, Object.DPadPos, 160)78end if7980if Player.Right == true81Object.Alpha = TOUCHCONTROLS_TARGETALPHA82DrawSpriteScreenFX(8, FX_INK, Object.DPadPos, 160)83else84Object.Alpha = Object.MainAlpha85DrawSpriteScreenFX(4, FX_INK, Object.DPadPos, 160)86end if8788if Player.Up == true89Object.Alpha = TOUCHCONTROLS_TARGETALPHA90DrawSpriteScreenFX(5, FX_INK, Object.DPadPos, 160)91else92Object.Alpha = Object.MainAlpha93DrawSpriteScreenFX(1, FX_INK, Object.DPadPos, 160)94end if9596// After the directions comes the Jump Button, same song and dance here97if Player.JumpHold == true98Object.Alpha = TOUCHCONTROLS_TARGETALPHA99DrawSpriteScreenFX(10, FX_INK, Object.JumpButtonPos, 176)100else101Object.Alpha = Object.MainAlpha102DrawSpriteScreenFX(9, FX_INK, Object.JumpButtonPos, 176)103end if104105else106Object.MainAlpha = 0 // Not yet, hold 'till needed...107end if108109// Draw the Pause Button, enforcing a maximum alpha of 255110// -> Even if the Pause Button is seemingly drawn regardless of the stage's current state,111// do note that its alpha very well could be 0 when the stage is paused, effectively drawing nothing112if Object.PauseAlpha < 256113Object.Alpha = Object.PauseAlpha114DrawSpriteScreenFX(11, FX_INK, Object.PausePos, 8)115else116DrawSpriteScreenXY(11, Object.PausePos, 8)117end if118119else120121// The Player's not able to control anything yet, let's fade out controls122if Object.MainAlpha > 0123Object.MainAlpha -= 4124125// Since Pause Alpha is always double Main Alpha, decrease it by twice as much here too126Object.PauseAlpha -= 8127end if128129// Draw the unpressed versions of everything130Object.Alpha = Object.MainAlpha131if Object.Alpha > 0132DrawSpriteScreenFX(0, FX_INK, Object.DPadPos, 160)133DrawSpriteScreenFX(1, FX_INK, Object.DPadPos, 160)134DrawSpriteScreenFX(4, FX_INK, Object.DPadPos, 160)135DrawSpriteScreenFX(2, FX_INK, Object.DPadPos, 160)136DrawSpriteScreenFX(3, FX_INK, Object.DPadPos, 160)137138DrawSpriteScreenFX(9, FX_INK, Object.JumpButtonPos, 176)139end if140141// Keep a minimum of zero, Alpha shouldn't go into the negatives142if Object.PauseAlpha < 0143Object.Alpha = 0144else145Object.Alpha = Object.PauseAlpha146end if147148// Similarly, keep a maximum alpha of 255, which is full opacity149if Object.PauseAlpha < 256150Object.Alpha = Object.PauseAlpha151DrawSpriteScreenFX(11, FX_INK, Object.PausePos, 8)152else153DrawSpriteScreenXY(11, Object.PausePos, 8)154end if155end if156#endplatform157end sub158159160sub ObjectStartup161#platform: Mobile162if Options.AttractMode == false163// All the Touch Control sprites are (rather lazily) already on the main SS Objects sheet, so let's load that164LoadSpriteSheet("Special/Objects.gif")165166// Place a Touch Controls Object into the scene167Object[25].Type = TypeName[Touch Controls]168169// Make sure it's always active, and give it a high draw order since it should be above everything else170Object[25].Priority = PRIORITY_ACTIVE171Object[25].DrawOrder = 6172173// The Controls are to fade in, so set up use of Alpha174Object[25].InkEffect = INK_ALPHA175Object[25].MainAlpha = 0176Object[25].PauseAlpha = 0177178// The Pause button should be at the top right corner of the screen179Object[25].PausePos = Screen.XSize180Object[25].PausePos -= 68181182// First, fetch the base Jump Button Position, and then handling differs between platforms...183Object[25].JumpButtonPos = Screen.XSize184185// On the Windows Phone, move everything over a bit186if Engine.PlatformID == RETRO_WP7187Object[25].JumpButtonPos -= 69188Object[25].DPadPos = 24189190Options.DPadX = 56191else192Object[25].JumpButtonPos -= 61193Object[25].DPadPos = 16194195Options.DPadX = 48196end if197198// While not used here, Options.DPadX is used for actual understanding of the inputs, over in the Sonic Object199200// So there's this check for being in a Special Stage... but this script is only ever used in Special Stages anyway so it always returns true201// It's worth noting, this check is in the standard TouchControls script too,202// where it's the opposite situation and it always returns false203204if Stage.ActiveList == SPECIAL_STAGE205Object[25].PausePos += 42206end if207208// 0 - Main DPad Frame209SpriteFrame(0, 0, 64, 64, 128, 192)210211// 1 - Up, Unpressed212SpriteFrame(26, 0, 12, 25, 154, 128)213214// 2 - Down, Unpressed215SpriteFrame(26, 38, 12, 26, 154, 166)216217// 3 - Left, Unpressed218SpriteFrame(0, 25, 26, 13, 128, 153)219220// 4 - Right, Unpressed221SpriteFrame(38, 25, 26, 13, 166, 153)222223// 5 - Up, Pressed224SpriteFrame(26, 0, 12, 25, 244, 192)225226// 6- Down, Pressed227SpriteFrame(26, 38, 12, 26, 244, 230)228229// 7 - Left, Pressed230SpriteFrame(0, 25, 26, 13, 217, 229)231232// 8 - Right, Pressed233SpriteFrame(38, 25, 26, 13, 217, 243)234235// 9 - Jump, Unpressed236SpriteFrame(0, 0, 48, 48, 193, 128)237238// 10 - Jump, Pressed239SpriteFrame(0, 0, 48, 48, 193, 177)240241// 11 - Pause Button, offset differently if on the Windows Phone242if Engine.PlatformID == RETRO_WP7243SpriteFrame(-20, 0, 16, 16, 200, 239)244else245SpriteFrame(0, 0, 16, 16, 200, 239)246end if247end if248#endplatform249250// On Standard Platforms, this event is just empty251end sub252253254// ========================255// Editor Subs256// ========================257258sub RSDKDraw259DrawSprite(0)260end sub261262263sub RSDKLoad264LoadSpriteSheet("Global/Display.gif")265SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon266267SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")268end sub269270271