fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
a8034e9
v2.1.1a
1love . filesystem . setRequirePath ( "?.lua;?/init.lua;modules/?.lua;modules/?/init.lua" ) 2 3math . randomseed ( love . timer . getTime ()) 4 5local VERSION 6 7if love . filesystem . getInfo ( "version.txt" ) then 8-- Read version file and strip any trailing whitespace 9VERSION =love . filesystem . read ( "version.txt" ): match ( "^(%S+)" ) 10end 11 12function love . getMOverlayVersion () 13return VERSION or "0.0.0" 14end 15 16require ( "console" ) 17require ( "errorhandler" ) 18require ( "extensions.love" ) 19 20local log =require ( "log" ) 21local melee =require ( "melee" ) 22local zce =require ( "zce" ) 23local memory =require ( "memory" ) 24local notification =require ( "notification" ) 25 26local overlay =require ( "overlay" ) 27local music =require ( "music" ) 28 29local color =require ( "util.color" ) 30local gui =require ( "gui" ) 31 32local ease =require ( "ease" ) 33 34local web =require ( "web" ) 35local downloader =require ( "downloader" ) 36 37local graphics =love . graphics 38local newImage =graphics . newImage 39 40local PORT_FONT =graphics . newFont ( "fonts/melee-bold.otf" , 42 ) 41local WAITING_FONT =graphics . newFont ( "fonts/melee-bold.otf" , 24 ) 42local DEBUG_FONT =graphics . newFont ( "fonts/melee-bold.otf" , 12 ) 43 44local GRADIENT =newImage ( "textures/gui/gradient.png" ) 45local DOLPHIN =newImage ( "textures/dolphin.png" ) 46local GAME =newImage ( "textures/game.png" ) 47local MELEE =newImage ( "textures/meleedisk.png" ) 48local MELEELABEL =newImage ( "textures/meleedisklabel.png" ) 49local SHADOW =newImage ( "textures/shadow.png" ) 50local KEY =newImage ( "textures/key.png" ) 51 52local ESCAPE_MENU_HINT =love . timer . getTime () + 5 53local ESCAPE_MENU_HINT_FADE =ESCAPE_MENU_HINT + 1 54 55MAX_PORTS =4 56 57local PORT_DISPLAY_OVERRIDE =nil 58 59local PORT_TEXTURES ={ 60[ 1 ] =newImage ( "textures/player1_color.png" ), 61[ 2 ] =newImage ( "textures/player2_color.png" ), 62[ 3 ] =newImage ( "textures/player3_color.png" ), 63[ 4 ] =newImage ( "textures/player4_color.png" ) 64} 65 66local CODE_ENTERED =false 67 68local CODE_POSITION ={ 69[ 1 ] =1 , 70[ 2 ] =1 , 71[ 3 ] =1 , 72[ 4 ] =1 73} 74 75local CODE ={ -- Konami code 760x0008 , 0x0008 , 770x0004 , 0x0004 , 780x0001 , 0x0002 , 790x0001 , 0x0002 , 800x0200 , 0x0100 , 0x1000 81} 82 83--[[local CODE2 = { -- Konami code using joysticks 840x10000, 0x10000, 850x20000, 0x20000, 860x40000, 0x80000, 870x40000, 0x80000, 880x0200, 0x0100, 0x1000 89}]] 90 91local portless_title ="" 92function love . updateTitle ( str ) 93local title =str 94portless_title =str 95if PANEL_SETTINGS : IsPortTitleEnabled () then 96title =string . format ( "%s (Port %d)" , str , overlay . getPort ()) 97end 98love . window . setTitle ( title ) 99--love.window.setMode(1280, 720, nil) 100end 101 102function love . getTitleNoPort () 103return portless_title 104end 105 106memory . hook ( "romstring.akaneia" , "Load Game Specific Textures" , function ( romname , romvalue ) 107melee . loadRomSpecificTextures () 108end ) 109 110function love . load ( args , unfilteredArg ) 111love . keyboard . setKeyRepeat ( true ) 112 113melee . loadTextures () 114gui . init () 115music . init () 116overlay . init () 117 118if memory . hasPermissions () then 119love . updateTitle ( "M'Overlay - Waiting for Dolphin..." ) 120else 121love . updateTitle ( "M'Overlay - Invalid permissions..." ) 122--notification.error() 123end 124 125-- Loop through all the commandline arguments 126for n , arg in pairs ( args ) do 127-- Check for '--port=N' first.. 128local portn =tonumber ( string . match ( arg , "%-%-port=(%d+)" )) 129 130if arg == "--port" then -- Alternative '--port N' 131portn =tonumber ( args [ n + 1 ]) -- Convert the next argument in the commandline to a number 132elseif arg == "--sublime" then 133-- Running through sublime text 134_SUBLIME_TEXT =true 135log . color =false 136end 137 138if portn then -- A port number was specified.. 139overlay . setPort ( portn ) 140break -- Done 141end 142end 143 144log . debug ( "M'Overlay (%s)" , love . getMOverlayVersion ()) 145log . debug ( string . format ( "Love2D %d.%d.%d - %s" , love . getVersion ())) 146log . debug ( "%s (%s - %s)" , _VERSION , jit . version , jit . arch ) 147log . debug ( "System: %s" , jit . os ) 148 149local renderer , version , vendor , device =love . graphics . getRendererInfo () 150 151log . debug ( "Renderer: %s (%s)" , renderer , version ) 152log . debug ( "Graphics: %s (%s)" , vendor , device ) 153end 154 155memory . hook ( "menu.player_one_port" , "Controller port that is acting as player 1" , function ( port ) 156if melee . isSinglePlayerGame () or ( memory . scene . major == SCENE_VS_ONLINE and PANEL_SETTINGS : IsSlippiNetplay ()) then 157overlay . setPort ( port + 1 ) 158log . debug ( "[AUTOPORT] Player \"one\" port changed %d" , overlay . getPort ()) 159end 160end ) 161 162memory . hook ( "scene.major" , "Slippi Auto Port Switcher" , function ( major ) 163if melee . isSinglePlayerGame () or ( major == SCENE_VS_ONLINE and PANEL_SETTINGS : IsSlippiNetplay ()) then 164-- Switch back to whatever controller is controlling port 1, when not in a match 165overlay . setPort ( memory . menu . player_one_port + 1 ) 166log . debug ( "[AUTOPORT] Forcing port %d in menus" , overlay . getPort ()) 167end 168end ) 169 170memory . hook ( "scene.minor" , "Slippi Auto Port Switcher" , function ( minor ) 171-- SCENE_VS_ONLINE = Slippi online 172if memory . scene . major == SCENE_VS_ONLINE and PANEL_SETTINGS : IsSlippiNetplay () then 173if minor == SCENE_VS_ONLINE_CSS or menu == SCENE_VS_ONLINE_SSS then 174-- Switch back to whatever controller is controlling port 1, when not in a match 175overlay . setPort ( memory . menu . player_one_port + 1 ) 176log . debug ( "[AUTOPORT] Forcing port %d in menus" , overlay . getPort ()) 177if minor == SCENE_VS_ONLINE_CSS then 178-- Display the port info only when swiching back to CSS 179overlay . showPort ( 1.5 ) -- Show the port display number for 1.5 seconds 180end 181elseif minor == SCENE_VS_ONLINE_VERSUS then 182PORT_DISPLAY_OVERRIDE =( memory . slippi . local_player . index % MAX_PORTS ) + 1 183overlay . showPort ( 3 ) -- Show the port display number for 3 seconds 184log . debug ( "[AUTOPORT] Switching display icon to use port %d" , overlay . getPort ()) 185elseif minor == SCENE_VS_ONLINE_INGAME then 186-- Switch to the local player index whenever else 187PORT_DISPLAY_OVERRIDE =nil 188overlay . setPort ( memory . slippi . local_player . index + 1 ) 189log . debug ( "[AUTOPORT] Switching to slippi local player index %d" , overlay . getPort ()) 190end 191end 192end ) 193 194memory . hook ( "player.*.character" , "Show port on character select" , function ( port , character ) 195if memory . scene . minor == SCENE_VS_CSS and port == overlay . getPort () then 196overlay . showPort ( 1.5 ) -- Show the port display number for 1.5 seconds 197end 198end ) 199 200do 201local snd =love . audio . newSource ( "sounds/blip.ogg" , "static" ) 202 203memory . hook ( "controller.*.buttons.pressed" , "Konami code check" , function ( port , pressed ) 204if pressed == 0x0 or port ~= overlay . getPort () then return end 205local pos =CODE_POSITION [ port ] 206if CODE [ pos ] == pressed then 207CODE_POSITION [ port ] =pos + 1 208if pos >= # CODE then 209CODE_ENTERED =not CODE_ENTERED 210snd : setVolume ( 0.25 ) 211snd : setPitch ( CODE_ENTERED and 1 or 0.75 ) 212snd : play () 213log . warn ( "[KONAMI] %s developer stats.." , CODE_ENTERED and "Showing" or "Hiding" ) 214end 215else 216CODE_POSITION [ port ] =1 217end 218end ) 219end 220 221function love . update ( dt ) 222web . update () 223downloader . update () 224music . update () 225memory . update () -- Look for Dolphin.exe 226notification . update ( 8 , 0 ) 227gui . update ( dt ) 228end 229 230function love . resize ( w , h ) 231gui . resize ( w , h ) 232end 233 234function love . joystickpressed ( joy , but ) 235gui . joyPressed ( joy , but ) 236end 237 238function love . joystickreleased ( joy , but ) 239gui . joyReleased ( joy , but ) 240end 241 242function love . keypressed ( key , scancode , isrepeat ) 243if key == "escape" and not isrepeat then 244PANEL_SETTINGS : Toggle () 245ESCAPE_MENU_HINT =nil 246ESCAPE_MENU_HINT_FADE =nil 247end 248 249gui . keyPressed ( key , scancode , isrepeat ) 250 251local num =tonumber ( string . match ( key , "kp(%d)" ) or key ) 252 253if not PANEL_SETTINGS : IsVisible () and num and num >= 1 and num <= 4 then 254overlay . setPort ( num ) 255PORT_DISPLAY_OVERRIDE =nil 256overlay . showPort ( 1.5 ) -- Show the port display number for 1.5 seconds 257end 258end 259 260function love . keyreleased ( key ) 261gui . keyReleased ( key ) 262end 263 264function love . textinput ( text ) 265gui . textInput ( text ) 266end 267 268function love . mousemoved ( x , y , dx , dy , istouch ) 269gui . mouseMoved ( x , y , dx , dy , istouch ) 270end 271 272function love . mousepressed ( x , y , button , istouch , presses ) 273gui . mousePressed ( x , y , button , istouch , presses ) 274end 275 276function love . mousereleased ( x , y , button , istouch , presses ) 277gui . mouseReleased ( x , y , button , istouch , presses ) 278end 279 280function love . wheelmoved ( x , y ) 281if PANEL_SETTINGS : IsVisible () then 282gui . mouseWheeled ( x , y ) 283return 284end 285 286local port =overlay . getPort () 287 288if y > 0 then 289port =port - 1 290elseif y < 0 then 291port =port + 1 292end 293overlay . setPort ( port ) 294overlay . showPort ( 1.5 ) 295PORT_DISPLAY_OVERRIDE =nil 296end 297 298local DEBUG_SORT_KEYS 299 300function love . drawDeveloperInfo () 301local stats =love . graphics . getStats () 302stats . memory =collectgarbage ( "count" ) 303stats . fps =love . timer . getFPS () 304 305if not DEBUG_SORT_KEYS then 306DEBUG_SORT_KEYS =table . keys ( stats ) 307table . sort ( DEBUG_SORT_KEYS ) 308end 309 310graphics . setFont ( DEBUG_FONT ) 311local i =0 312for i , stat in ipairs ( DEBUG_SORT_KEYS ) do 313local val =stats [ stat ] 314 315local str 316 317if stat == "memory" or stat == "texturememory" then 318str =string . format ( "%s: %s" , stat , string . toSize ( val )) 319else 320str =string . format ( "%s: %d" , stat , val ) 321end 322 323graphics . setColor ( 0 , 0 , 0 , 255 ) 324graphics . textOutline ( str , 2 , 8 , 8 + 14 * i ) 325graphics . setColor ( 0 , 255 , 0 , 255 ) 326graphics . ( str , 8 , 8 + 14 * i ) 327 328i =i + 1 329end 330end 331 332local DC_CON =newImage ( "textures/buttons/disconnected.png" ) 333 334function love . drawControllerOverlay () 335local controller 336local port =overlay . getPort () 337 338-- Check if ZCE (dynamic controller address swapping) 339if zce . isZce () then 340if zce . isOot () then 341controller =memory . controller . oot [ port ] 342elseif zce . isMajora () then 343controller =memory . controller . mm [ port ] 344elseif zce . isZ1 () then 345controller =memory . controller . z1 [ port ] 346elseif zce . isZ2 () then 347controller =memory . controller . z2 [ port ] 348else 349controller =memory . controller . menu [ port ] 350end 351else 352controller =memory . controller [ port ] 353end 354 355if PANEL_SETTINGS : IsSlippiReplay () and melee . isInGame () then 356local player =memory . player [ port ] 357 358if not player then return end 359 360local entity 361 362if player . transformed == 256 then 363-- If the player has the "transformed" flag set, assume they are now controlling the "partner" entity 364entity =player . partner 365else 366entity =player . entity 367end 368 369controller =entity . controller 370end 371 372if controller then 373if controller . plugged and controller . plugged ~= ( memory . game . pluggedValue or 0x00 ) then 374local sin =128 + math . sin ( love . timer . getTime () * 2 ) * 128 375graphics . setColor ( 255 , 0 , 0 , sin ) 376graphics . easyDraw ( DC_CON , 512 - 42 - 16 , 256 - 42 - 42 , 0 , 42 , 42 ) 377end 378 379overlay . draw ( controller ) 380 381if PANEL_SETTINGS : GetDebuggingInputFlags () > 0 then 382local x , y =memory . game . translateJoyStick ( controller . joystick . x , controller . joystick . y ) 383local cx , cy =memory . game . translateCStick ( controller . cstick . x , controller . cstick . y ) 384local a =0 385local l , r =0 , 0 386 387local xoff =0 388 389graphics . setFont ( DEBUG_FONT ) 390 391if PANEL_SETTINGS : IsDebuggingTriggers () then 392if PANEL_SETTINGS : IsSlippiReplay () and melee . isInGame () then 393a =controller . analog and controller . analog . float or 0 394 395local stra =( "A: % f" ): format ( a ) 396 397xoff =xoff + DEBUG_FONT : getWidth ( stra ) + 8 398 399graphics . setColor ( 0 , 0 , 0 , 255 ) 400graphics . textOutline ( stra , 2 , 512 - xoff , 256 - 4 - 12 ) 401 402graphics . setColor ( 255 , 255 , 255 , 255 ) 403graphics . ( stra , 512 - xoff , 256 - 4 - 12 ) 404else 405l , r =memory . game . translateTriggers ( controller . analog . l , controller . analog . r ) 406 407local strl =( "L: % f" ): format ( l ) 408local strr =( "R: % f" ): format ( r ) 409 410xoff =xoff + DEBUG_FONT : getWidth ( strl ) + 8 411 412graphics . setColor ( 0 , 0 , 0 , 255 ) 413graphics . textOutline ( strl , 2 , 512 - xoff , 256 - 4 - 24 ) 414graphics . textOutline ( strr , 2 , 512 - xoff , 256 - 4 - 12 ) 415 416graphics . setColor ( 255 , 255 , 255 , 255 ) 417graphics . ( strl , 512 - xoff , 256 - 4 - 24 ) 418graphics . ( strr , 512 - xoff , 256 - 4 - 12 ) 419end 420end 421 422if PANEL_SETTINGS : IsDebuggingCStick () then 423local strcx =( "CX: % .4f" ): format ( cx ) 424local strcy =( "CY: % .4f" ): format ( cy ) 425 426xoff =xoff + DEBUG_FONT : getWidth ( strcx ) + 8 427 428graphics . setColor ( 0 , 0 , 0 , 255 ) 429graphics . textOutline ( strcx , 2 , 512 - xoff , 256 - 4 - 24 ) 430graphics . textOutline ( strcy , 2 , 512 - xoff , 256 - 4 - 12 ) 431 432graphics . setColor ( 255 , 255 , 255 , 255 ) 433graphics . ( strcx , 512 - xoff , 256 - 4 - 24 ) 434graphics . ( strcy , 512 - xoff , 256 - 4 - 12 ) 435end 436 437if PANEL_SETTINGS : IsDebuggingJoystick () then 438local strx =( "X: % .4f" ): format ( x ) 439local stry =( "Y: % .4f" ): format ( y ) 440 441xoff =xoff + DEBUG_FONT : getWidth ( strx ) + 8 442 443graphics . setColor ( 0 , 0 , 0 , 255 ) 444graphics . textOutline ( strx , 2 , 512 - xoff , 256 - 4 - 24 ) 445graphics . textOutline ( stry , 2 , 512 - xoff , 256 - 4 - 12 ) 446 447graphics . setColor ( 255 , 255 , 255 , 255 ) 448graphics . ( strx , 512 - xoff , 256 - 4 - 24 ) 449graphics . ( stry , 512 - xoff , 256 - 4 - 12 ) 450end 451 452if PANEL_SETTINGS : IsDebuggingButtons () then 453local btts =( "B: %X" ): format ( controller . buttons . pressed ) 454 455local yoff =36 456 457if xoff <= 0 then 458yoff =12 459xoff =xoff + DEBUG_FONT : getWidth ( btts ) + 8 460end 461 462graphics . setColor ( 0 , 0 , 0 , 255 ) 463graphics . textOutline ( btts , 2 , 512 - xoff , 256 - 4 - yoff ) 464 465graphics . setColor ( 255 , 255 , 255 , 255 ) 466graphics . ( btts , 512 - xoff , 256 - 4 - yoff ) 467end 468end 469end 470end 471 472do 473local icon_time_start 474local icon_time_show 475local icon_time_next 476 477local icon_rotate =0 478 479local canvas =love . graphics . newCanvas () 480 481function love . drawTrobber ( game ) 482local t =love . timer . getTime () 483local dt =love . timer . getDelta () 484 485local lx =0 486local ly =math . sin ( t * 3 ) * 4 487local rx =icon_rotate 488 489local rotate_speed =0 490 491if not game then 492if not icon_time_start or icon_time_next < t then 493icon_time_start =t 494icon_time_show =t + 1 495icon_time_next =t + 2 496end 497 498local anim =0 499if icon_time_show > t then 500anim =ease . sigmoid ( math . min ( 1 , ( t - icon_time_start ) / 1 )) 501lx =ease . lerp ( 0 , - 160 , anim ) 502ly =ease . lerp ( 0 , 64 , anim ) 503rx =ease . lerp ( 0 , - 90 , anim ) 504else 505anim =ease . outback ( math . min ( 1 , ( t - icon_time_show ) / 1 )) 506lx =ease . lerp ( 160 , 0 , anim ) 507ly =ease . lerp ( 64 , 0 , anim ) 508rx =ease . lerp ( 90 , 0 , anim ) 509end 510else 511rotate_speed =math . sinlerp ( 0 , 360 * 4 * dt / 2 , t / 2 ) 512icon_rotate =( icon_rotate + rotate_speed ) % 360 513end 514 515graphics . setColor ( 255 , 255 , 255 , 255 ) 516 517graphics . setCanvas ( canvas ) 518 519graphics . clear ( 0 , 0 , 0 , 0 ) 520if not game then 521graphics . setBlendMode ( "replace" , "premultiplied" ) 522end 523 524graphics . setScissor ( 256 - 80 - 20 , 0 , 160 + 40 , 256 ) 525 526local slippi =PANEL_SETTINGS : IsSlippiNetplay () or PANEL_SETTINGS : IsSlippiReplay () 527local icon =game and ( slippi and MELEE or GAME ) or DOLPHIN 528 529graphics . setColor ( 255 , 255 , 255 , 255 ) 530graphics . easyDraw ( icon , 256 + lx , 64 + 40 + ly , math . rad ( rx ), 80 , 80 , 0.5 , 0.5 ) 531 532if game then 533local p =rotate_speed / 13 534 535for i =0 , 16 do 536local j =rotate_speed - i 537graphics . setColor ( 255 , 255 , 255 , rotate_speed * 4 ) 538graphics . easyDraw ( slippi and MELEELABEL or icon , 256 + lx , 64 + 40 + ly , math . rad ( rx - ( i * p * 4 )), 80 , 80 , 0.5 , 0.5 ) 539end 540end 541 542graphics . setScissor () 543 544if not game then 545graphics . setBlendMode ( "multiply" , "premultiplied" ) 546 547graphics . easyDraw ( GRADIENT , 256 - 80 - 20 , 0 , 0 , 80 , 256 ) 548graphics . easyDraw ( GRADIENT , 256 + 80 + 20 , 0 , math . rad ( 180 ), 80 , 256 , 0 , 1 ) 549end 550 551graphics . setCanvas () 552 553graphics . setBlendMode ( "alpha" , "alphamultiply" ) 554 555if game then 556local sw =math . sinlerp ( 0.5 , 1 , t * 3 ) 557graphics . setColor ( 125 , 125 , 125 , 150 ) 558graphics . easyDraw ( SHADOW , 256 , 154 , 0 , 64 * sw , 6 * sw , 0.5 , 0.5 ) 559end 560 561graphics . setColor ( 255 , 255 , 255 , 255 ) 562graphics . draw ( canvas ) 563end 564end 565 566do 567local ellipses ={ "." , ".." , "..." } 568 569function love . drawNotificationText ( msg ) 570local t =love . timer . getTime () 571 572local w =WAITING_FONT : getWidth ( msg ) 573local h =WAITING_FONT : getHeight () 574local x =256 - ( w / 2 ) 575local y =128 + 32 576 577local i =math . floor ( t % # ellipses ) + 1 578 579msg =msg .. ellipses [ i ] 580 581graphics . setFont ( WAITING_FONT ) 582graphics . setColor ( 0 , 0 , 0 , 255 ) 583graphics . textOutline ( msg , 3 , x , y ) 584graphics . setColor ( 255 , 255 , 255 , 255 ) 585graphics . ( msg , x , y ) 586end 587end 588 589function love . isWindows () 590return jit . os : lower () == "windows" 591end 592 593function love . supportsGameCapture () 594return love . isWindows () 595end 596 597function love . supportsAttachableConsole () 598return love . isWindows () 599end 600 601--[=[local canvas = love.graphics.newCanvas() 602 603local stenciledCanvas = { 604canvas, 605stencil = true, 606} 607 608local blur = graphics.newShader[[ 609extern number radius; 610extern vec2 imageSize; 611 612vec4 effect(vec4 color, Image tex, vec2 tc, vec2 pc) 613{ 614color = vec4(0); 615vec2 st; 616 617for (float x = -radius; x <= radius; x++) { 618for (float y = -radius; y <= radius; y++) { 619// to texture coordinates 620st.xy = vec2(x,y) / imageSize; 621color += Texel(tex, tc + st); 622} 623} 624return color / ((2.0 * radius + 1.0) * (2.0 * radius + 1.0)); 625} 626]] 627 628blur:send("radius", 6) 629blur:send("imageSize", {canvas:getPixelDimensions()})]=] 630 631function love . draw () 632if not love . supportsGameCapture () or not PANEL_SETTINGS : UseTransparency () then 633graphics . setBackgroundColor ( PANEL_SETTINGS : GetBackgroundColor ()) 634else 635-- Default to completely transparent, makes the overlay completely invisible when not in a game! 636local alpha =0 637 638if ( memory . initialized and memory . game ) or PANEL_SETTINGS : IsVisible () then 639-- Only apply transparency when we are watching a games memory. 640alpha =255 - (( PANEL_SETTINGS : GetTransparency () / 100 ) * 255 ) 641end 642 643-- Transparent background for OBS 644graphics . setBackgroundColor ( 0 , 0 , 0 , alpha ) 645 646-- Show a preview for transparency 647if PANEL_SETTINGS : IsVisible () then 648graphics . setBackgroundColor ( 255 , 255 , 255 , alpha ) 649 650for x =0 , 512 / 32 do 651for y =0 , 256 / 32 do 652graphics . setColor ( 230 , 230 , 230 , 255 ) 653graphics . rectangle ( "fill" , 32 * ( x + ( y % 2 )), 32 * ( y + ( x % 2 )), 32 , 32 ) 654end 655end 656 657graphics . setColor ( 0 , 0 , 0 , alpha ) 658graphics . rectangle ( "fill" , 0 , 0 , 512 , 256 ) 659 660--[[graphics.setColor(0, 0, 0, 100) 661graphics.rectangle("fill", 512 - 20, 0, 20, 256) 662 663local rad = math.rad(90) 664 665graphics.setFont(DEBUG_FONT) 666graphics.setColor(0, 0, 0, 255) 667graphics.print(VERSION, 512 - 5, 5, rad) 668graphics.setColor(255, 255, 255, 255) 669graphics.print(VERSION, 512 - 4, 4, rad)]] 670end 671end 672 673--[[if PANEL_SETTINGS:IsVisible() then 674graphics.setCanvas(stenciledCanvas) 675graphics.clear(0, 0, 0, 0) 676end]] 677 678if memory . initialized and memory . ingame and memory . game and memory . controller then 679love . drawControllerOverlay () 680else 681if memory . hooked then 682love . drawTrobber ( true ) 683local slippi =PANEL_SETTINGS : IsSlippiNetplay () or PANEL_SETTINGS : IsSlippiReplay () 684love . drawNotificationText ( slippi and "Waiting for melee" or "Waiting for game" ) 685else 686love . drawTrobber () 687love . drawNotificationText ( "Waiting for dolphin" ) 688end 689end 690 691-- Draw a temporary number to show that the user changed controller port 692if (( PANEL_SETTINGS : AlwaysShowPort () and memory . isInGame ()) or overlay . isPortShowing ()) then 693local port =overlay . getPort () 694if memory . isMelee () then 695local port =PORT_DISPLAY_OVERRIDE or port 696local portColor 697if melee . isTeams () then 698portColor =melee . getPlayerTeamColor ( port ) 699else 700portColor =melee . getPlayerColor ( port ) 701end 702portColor . a =200 703graphics . setColor ( portColor ) 704melee . drawSeries ( port , 8 , 256 - 72 - 4 , 0 , 72 , 72 ) 705graphics . setColor ( 255 , 255 , 255 , 255 ) 706melee . drawStock ( port , 40 , 256 - 42 , 0 , 24 , 24 ) 707graphics . easyDraw ( PORT_TEXTURES [ port ], 12 , 256 - 42 - 24 , 0 , 33 , 14 ) 708else 709graphics . setFont ( PORT_FONT ) 710graphics . setColor ( 0 , 0 , 0 , 255 ) 711graphics . textOutline ( port , 3 , 16 , 256 - 42 - 16 ) 712graphics . setColor ( 255 , 255 , 255 , 255 ) 713graphics . ( port , 16 , 256 - 42 - 16 ) 714end 715end 716 717--[[if PANEL_SETTINGS:IsVisible() then 718graphics.setCanvas() 719 720graphics.setShader(blur) 721graphics.easyDraw(canvas, 0, 0, 0, 512, 256) 722graphics.setShader() 723end]] 724 725music . draw () 726 727local time =love . timer . getTime () 728 729if ESCAPE_MENU_HINT_FADE and ESCAPE_MENU_HINT_FADE >= time then 730local msg ="Press 'ESC' to access the settings!" 731 732local w =DEBUG_FONT : getWidth ( msg ) + 40 733local h =32 734 735local x =512 / 2 - w / 2 736local y =256 - h - 16 737 738y =y + math . sin ( time * 5 ) * 4 739 740local alpha =255 741 742if ESCAPE_MENU_HINT < time then 743local fadeLen =ESCAPE_MENU_HINT_FADE - ESCAPE_MENU_HINT 744local timeRem =ESCAPE_MENU_HINT_FADE - time 745alpha =timeRem / fadeLen * 255 746end 747 748graphics . setColor ( 255 , 255 , 255 , alpha ) 749graphics . roundRect ( x , y , w , h , 4 ) 750graphics . easyDraw ( KEY , x , y , 0 , 32 , 32 ) 751 752graphics . setFont ( DEBUG_FONT ) 753graphics . setColor ( 0 , 0 , 0 , alpha ) 754graphics . ( msg , x + 36 , y + ( h / 2 ) - 6 ) 755end 756notification . draw () 757gui . render () 758if CODE_ENTERED then 759love . drawDeveloperInfo () 760end 761end 762 763local FPS_LIMIT =59.94 764 765function love . run () 766if love . load then love . load ( love . arg . parseGameArguments ( arg ), arg ) end 767 768-- We don't want the first frame's dt to include time taken by love.load. 769if love . timer then love . timer . step () end 770 771local dt =0 772 773-- Main loop time. 774return function () 775local frame_start =love . timer . getTime () 776 777-- Process events. 778if love . event then 779love . event . pump () 780for name , a , b , c , d , e , f in love . event . poll () do 781if name == "quit" then 782if not love . quit or not love . quit () then 783return a or 0 784end 785end 786love . handlers [ name ]( a , b , c , d , e , f ) 787end 788end 789 790-- Update dt, as we'll be passing it to update 791if love . timer then dt =love . timer . step () end 792 793-- Call update and draw 794if love . update then love . update ( dt ) end -- will pass 0 if love.timer is disabled 795 796if love . graphics and love . graphics . isActive () then 797love . graphics . origin () 798love . graphics . clear ( love . graphics . getBackgroundColor ()) 799 800if love . draw then love . draw () end 801 802love . graphics . present () 803end 804 805if love . timer then 806local frame_time =love . timer . getTime () - frame_start 807love . timer . sleep ( 1 / FPS_LIMIT - frame_time ) 808end 809end 810end 811 812function love . quit () 813PANEL_SETTINGS : OnClosed () 814gui . shutdown () 815web . close () 816downloader . close () 817end