fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
59a1193
v2.1.3
1local SKIN ={} 2 3local grey =color ( 100 , 100 , 100 , 225 ) 4 5local function draw20XXShadow ( x , y , w , h , c ) 6graphics . setColor ( c . r / 4 , c . g / 4 , c . b / 4 , 75 ) 7graphics . rectangle ( "fill" , x , y , w , 8 ) 8graphics . rectangle ( "fill" , x , y + 8 , 12 , h - 8 ) 9end 10 11local function draw20XXBox ( x , y , w , h , c ) 12graphics . setColor ( c . r , c . g , c . b , c . a ) 13graphics . rectangle ( "fill" , x , y , w , h ) 14 15draw20XXShadow ( x , y , w , h , c ) 16end 17 18local function draw20XXButton ( x , y , w , h , c , controller , flag ) 19draw20XXBox ( x , y , w , h , c ) 20if bit . band ( controller . buttons . pressed , flag ) == flag then 21graphics . setColor ( 255 , 255 , 255 , 255 ) 22graphics . rectangle ( "fill" , x , y , w , h ) 23end 24end 25 26local function draw20XXAnalog ( x , y , w , h , c , controller , value , flag , flipped ) 27graphics . setColor ( c . r , c . g , c . b , c . a ) 28graphics . rectangle ( "fill" , x , y , w , h ) 29 30if bit . band ( controller . buttons . pressed , flag ) == flag then 31graphics . setColor ( 255 , 255 , 255 , 255 ) 32graphics . rectangle ( "fill" , x , y , w , h ) 33else 34graphics . setColor ( 200 , 200 , 200 , 255 ) 35if flipped then 36graphics . rectangle ( "fill" , w + x , y , w *- value , h ) 37else 38graphics . rectangle ( "fill" , x , y , w * value , h ) 39end 40draw20XXShadow ( x , y , w , h , c ) 41end 42end 43 44local white =color ( 255 , 255 , 255 , 225 ) 45local red =color ( 200 , 0 , 0 , 225 ) 46local green =color ( 0 , 200 , 0 , 225 ) 47local purple =color ( 125 , 0 , 125 , 225 ) 48local dyellow =color ( 125 , 125 , 0 , 225 ) 49local yellow =color ( 255 , 255 , 0 , 225 ) 50 51local root2 =math . sqrt ( 2 ) 52 53function SKIN : Paint ( controller ) 54draw20XXBox ( 56 , 56 , 96 , 96 , grey ) -- Joystick 55 56local x , y =memory . game . translateJoyStick ( controller . joystick . x , controller . joystick . y ) 57 58-- Map circular coordiantes onto a square 59-- https://stackoverflow.com/a/32391780 60 61local sx =0.5 * math . sqrt ( 2 + x * x - y * y + 2 * x * root2 ) - 0.5 * math . sqrt ( 2 + x * x - y * y - 2 * x * root2 ) 62local sy =0.5 * math . sqrt ( 2 - x * x + y * y + 2 * y * root2 ) - 0.5 * math . sqrt ( 2 - x * x + y * y - 2 * y * root2 ) 63 64draw20XXBox (( 56 + 48 - 8 ) + 40 * sx , ( 56 + 48 - 8 ) + 40 * ( - sy ), 16 , 16 , white ) 65 66draw20XXButton ( 256 , 56 + 32 , 64 , 64 , green , controller , BUTTONS . A ) -- A 67draw20XXButton ( 256 - 40 , 56 + 64 + 16 , 32 , 32 , red , controller , BUTTONS . B ) -- B 68 69if SETTINGS : IsStartEnabled () then 70draw20XXButton ( 256 - 64 , 56 + 32 , 24 , 24 , grey , controller , BUTTONS . START ) -- Start 71end 72 73draw20XXButton ( 256 , 56 , 64 , 24 , grey , controller , BUTTONS . Y ) -- Y 74draw20XXButton ( 256 + 64 + 8 , 56 , 24 , 24 , purple , controller , BUTTONS . Z ) -- Z 75draw20XXButton ( 256 + 64 + 8 , 56 + 32 , 24 , 64 , grey , controller , BUTTONS . X ) -- X 76 77draw20XXBox ( 256 + 64 + 40 , 56 , 96 , 96 , dyellow ) -- C-Stick 78 79if SETTINGS : IsDPadEnabled () then 80draw20XXButton ( 128 , 168 , 24 , 24 , grey , controller , DPAD . DPAD_UP ) 81draw20XXButton ( 128 - 28 , 168 + 28 , 24 , 24 , grey , controller , DPAD . DPAD_LEFT ) 82draw20XXButton ( 128 + 28 , 168 + 28 , 24 , 24 , grey , controller , DPAD . DPAD_RIGHT ) 83draw20XXButton ( 128 , 168 + 56 , 24 , 24 , grey , controller , DPAD . DPAD_DOWN ) 84end 85 86local x , y =memory . game . translateCStick ( controller . cstick . x , controller . cstick . y ) 87 88local sx =0.5 * math . sqrt ( 2 + x * x - y * y + 2 * x * root2 ) - 0.5 * math . sqrt ( 2 + x * x - y * y - 2 * x * root2 ) 89local sy =0.5 * math . sqrt ( 2 - x * x + y * y + 2 * y * root2 ) - 0.5 * math . sqrt ( 2 - x * x + y * y - 2 * y * root2 ) 90 91draw20XXBox (( 256 + 64 + 80 ) + 40 * sx , ( 56 + 48 - 8 ) + 40 * ( - sy ), 16 , 16 , yellow ) 92 93local al , ar =0 , 0 94 95if SETTINGS : IsSlippiReplay () and melee . isInGame () then 96local analog =controller . analog and controller . analog . float or 0 97al =analog 98ar =analog 99else 100al , ar =memory . game . translateTriggers ( controller . analog . l , controller . analog . r ) 101end 102 103draw20XXAnalog ( 56 + 12 , 24 , 84 , 24 , grey , controller , al , BUTTONS . L ) -- L 104draw20XXAnalog ( 256 , 24 , 84 , 24 , grey , controller , ar , BUTTONS . R , true ) -- R 105end 106 107overlay . registerSkin ( "20XX" , SKIN )