fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
a8034e9
v2.1.6
1local PANEL =class . create ( "Settings" , "BasePanel" ) 2 3local log =require ( "log" ) 4local json =require ( "serializer.json" ) 5local notification =require ( "notification" ) 6local music =require ( "music" ) 7local overlay =require ( "overlay" ) 8local updater =require ( "updater" ) 9 10require ( "extensions.math" ) 11 12SLIPPI_OFF =1 13SLIPPI_NETPLAY =2 14SLIPPI_REPLAY =3 15 16LOOPING_NONE =0 17LOOPING_MENU =1 18LOOPING_STAGE_TIMED =2 19LOOPING_STAGE_ENDLESS =4 20 21DEBUG_INPUT_NONE =0 22DEBUG_INPUT_BUTTONS =1 23DEBUG_INPUT_JOYSTICK =2 24DEBUG_INPUT_C_STICK =4 25DEBUG_INPUT_TRIGGERS =8 26 27function PANEL : OnMouseMoved ( x , y , dx , dy , istouch ) 28local px , py =self . MAIN : GetPos () 29local pw , ph =self . MAIN : GetSize () 30 31if x < px - 8 or x > px + pw + 8 then 32self . MAIN : UnCenter () 33self . MAIN : SetPos ( px , 256 - 24 ) 34else 35self . MAIN : Center () 36end 37end 38 39function PANEL : Settings () 40self : super () -- Initialize our baseclass 41 42self : DockMargin ( 0 , 0 , 0 , 0 ) 43self : SizeToScreen () 44 45self . PORTSELECT =self : Add ( "PortSelect" ) 46self . SKINSELECT =self : Add ( "SkinSelect" ) 47 48self . COLORSELECT =self : Add ( "ColorSelector" ) 49self . COLORSELECT : SetSize ( 296 + 32 , 256 ) 50self . COLORSELECT : Center () 51self . COLORSELECT : SetVisible ( false ) 52 53self . MUSICPROBABILITY =self : Add ( "MusicProbability" ) 54self . MUSICPROBABILITY : SetSize ( 512 , 256 ) 55self . MUSICPROBABILITY : Center () 56self . MUSICPROBABILITY : SetVisible ( false ) 57 58self . DEBUG_INPUTS_CONFIG =self : Add ( "DebugInputs" ) 59self . DEBUG_INPUTS_CONFIG : SetSize ( 156 , 164 ) 60self . DEBUG_INPUTS_CONFIG : Center () 61self . DEBUG_INPUTS_CONFIG : SetVisible ( false ) 62 63self . DEBUG_INPUTS_CONFIG . OnClosed =function ( this ) 64self . MAIN : SetVisible ( true ) 65end 66 67self . MAIN =self : Add ( "TabbedPanel" ) 68self . MAIN : SetSize ( 296 + 32 , 196 ) 69self . MAIN : DockPadding ( 0 , 0 , 0 , 0 ) 70self . MAIN : Center () 71 72self . GENERAL =self . MAIN : AddTab ( "General" , "textures/gui/cog.png" , true ) 73 74self . GENERAL . LEFT =self . GENERAL : Add ( "Panel" ) 75self . GENERAL . LEFT : SetWidth ( 160 ) 76self . GENERAL . LEFT : Dock ( DOCK_LEFT ) 77self . GENERAL . LEFT : SetDrawPanel ( false ) 78 79self . GENERAL . RIGHT =self . GENERAL : Add ( "Panel" ) 80self . GENERAL . RIGHT : SetWidth ( 160 ) 81self . GENERAL . RIGHT : Dock ( DOCK_RIGHT ) 82self . GENERAL . RIGHT : SetDrawPanel ( false ) 83 84self . MELEE =self . MAIN : AddTab ( "Melee" , "textures/gui/melee.png" ) 85 86self . MELEE . LEFT =self . MELEE : Add ( "Panel" ) 87self . MELEE . LEFT : SetWidth ( 160 ) 88self . MELEE . LEFT : Dock ( DOCK_LEFT ) 89self . MELEE . LEFT : SetDrawPanel ( false ) 90 91self . MELEE . RIGHT =self . MELEE : Add ( "Panel" ) 92self . MELEE . RIGHT : SetWidth ( 160 ) 93self . MELEE . RIGHT : Dock ( DOCK_RIGHT ) 94self . MELEE . RIGHT : SetDrawPanel ( false ) 95 96self . SLIPPI =self . MAIN : AddTab ( "Slippi" , "textures/gui/slippi.png" ) 97 98self . SLIPPI . LEFT =self . SLIPPI : Add ( "Panel" ) 99self . SLIPPI . LEFT : SetWidth ( 160 ) 100self . SLIPPI . LEFT : Dock ( DOCK_LEFT ) 101self . SLIPPI . LEFT : SetDrawPanel ( false ) 102 103self . SLIPPI . ICON =self . SLIPPI . LEFT : Add ( "Image" ) 104self . SLIPPI . ICON : SetImage ( "textures/slippi.png" ) 105self . SLIPPI . ICON : SetPos ( 2 , 0 ) 106self . SLIPPI . ICON : SetSize ( 155 , 112 ) 107self . SLIPPI . ICON : CenterVertical () 108 109self . SLIPPI . RIGHT =self . SLIPPI : Add ( "Panel" ) 110self . SLIPPI . RIGHT : SetWidth ( 160 ) 111self . SLIPPI . RIGHT : Dock ( DOCK_RIGHT ) 112self . SLIPPI . RIGHT : SetDrawPanel ( false ) 113 114self . SLIPPI . MODE =self . SLIPPI . RIGHT : Add ( "RadioPanel" ) 115self . SLIPPI . MODE : SetText ( "Slippi mode" ) 116self . SLIPPI . MODE : DockMargin ( 0 , 0 , 0 , 0 ) 117self . SLIPPI . MODE : Dock ( DOCK_FILL ) 118self . SLIPPI . MODE : SetWidth ( 100 ) 119 120local off =self . SLIPPI . MODE : AddOption ( SLIPPI_OFF , "Off: Other games" , true ) 121off : SetTooltipParent ( self . SLIPPI . MODE ) 122off : SetTooltipTitle ( "OFF: OTHER GAMES" ) 123off : SetTooltipBody ( [[Use normal game detection. Supported game list can be found on the github README.]] ) 124local netplay =self . SLIPPI . MODE : AddOption ( SLIPPI_NETPLAY , "Melee: Rollback" ) 125netplay : SetTooltipParent ( self . SLIPPI . MODE ) 126netplay : SetTooltipTitle ( "ROLLBACK" ) 127netplay : SetTooltipBody ( [[Allows the overlay to work properly when playing Slippi online. Will also actively change the overylay to display your current port. 128 129WARNING: This tricks M'Overlay into thinking Melee is being played when an invalid game is detected. When playing other games, it is recommended to set this to OFF.]] ) 130local mirror =self . SLIPPI . MODE : AddOption ( SLIPPI_REPLAY , "Melee: Replay/Mirror" ) 131mirror : SetTooltipParent ( self . SLIPPI . MODE ) 132mirror : SetTooltipTitle ( "REPLAY/MIRROR" ) 133mirror : SetTooltipBody ( [[Allows the overlay to work when viewing replays or mirroring gameplay from a console.]] ) 134 135self . SLIPPI . MODE . OnSelectOption =function ( this , num ) 136self . SLIPPI . ICON : SetImage ( num == SLIPPI_OFF and "textures/slippi.png" or "textures/slippi_filled.png" ) 137end 138 139self . MELEE . MUSIC =self . MELEE . LEFT : Add ( "CheckBox" ) 140self . MELEE . MUSIC : SetText ( "Enable music" ) 141self . MELEE . MUSIC : Dock ( DOCK_TOP ) 142self . MELEE . MUSIC : SetTooltipTitle ( "MELEE MUSIC" ) 143self . MELEE . MUSIC : SetTooltipBody ( [[Enable/Disable custom music for Melee.]] ) 144 145function self . MELEE . MUSIC : OnToggle ( on ) 146if on then 147music . onStateChange () 148else 149music . kill () 150end 151end 152 153self . MELEE . MUSICLOOP =self . MELEE . RIGHT : Add ( "CheckPanel" ) 154self . MELEE . MUSICLOOP : SetText ( "Loop on.." ) 155self . MELEE . MUSICLOOP : DockMargin ( 0 , 0 , 0 , 0 ) 156self . MELEE . MUSICLOOP : Dock ( DOCK_TOP ) 157self . MELEE . MUSICLOOP : SetWidth ( 100 ) 158 159local menu =self . MELEE . MUSICLOOP : AddOption ( LOOPING_MENU , "Menu" ) 160menu : SetTooltipParent ( self . MELEE . MUSICLOOP ) 161menu : SetTooltipTitle ( "LOOP MENU" ) 162menu : SetTooltipBody ( [[When entering the menus, it will select and play one song at random. 163 164When the song ends or reaches a loop point, it will play again.]] ) 165local stage_timed =self . MELEE . MUSICLOOP : AddOption ( LOOPING_STAGE_TIMED , "Stage (timed)" ) 166stage_timed : SetTooltipParent ( self . MELEE . MUSICLOOP ) 167stage_timed : SetTooltipTitle ( "LOOP STAGE (TIMED)" ) 168stage_timed : SetTooltipBody ( [[When entering a stage that has a timer, it will select and play one song at random. 169 170When the song ends or reaches a loop point, it will play again.]] ) 171local stage_endless =self . MELEE . MUSICLOOP : AddOption ( LOOPING_STAGE_ENDLESS , "Stage (endless)" ) 172stage_endless : SetTooltipParent ( self . MELEE . MUSICLOOP ) 173stage_endless : SetTooltipTitle ( "LOOP STAGE (ENDLESS)" ) 174stage_endless : SetTooltipBody ( [[When entering a stage that is endless, such as training mode or endless melee, it will select and play one song at random. 175 176When the song ends or reaches a loop point, it will play again.]] ) 177 178function self . MELEE . MUSICLOOP : OnValueChanged ( flags ) 179music . onLoopChange ( flags ) 180end 181 182self . MELEE . MUSICPROB =self . MELEE . LEFT : Add ( "ButtonIcon" ) 183self . MELEE . MUSICPROB : SetText ( "Music probability" ) 184self . MELEE . MUSICPROB : Dock ( DOCK_BOTTOM ) 185self . MELEE . MUSICPROB : SetImage ( "textures/gui/chart_bar_edit.png" ) 186 187self . MELEE . MUSICPROB . OnClick =function ( this ) 188self . MUSICPROBABILITY : SetVisible ( true ) 189self . MUSICPROBABILITY : BringToFront () 190self . MUSICPROBABILITY : UpdatePlaylist () 191end 192 193self . MELEE . MUSICSKIP =self . MELEE . LEFT : Add ( "GCBinderPanel" ) 194self . MELEE . MUSICSKIP : SetButtonCombo ( 0x0042 ) 195self . MELEE . MUSICSKIP : SetText ( "Skip track combo" ) 196self . MELEE . MUSICSKIP : Dock ( DOCK_TOP ) 197self . MELEE . MUSICSKIP : SetTooltipTitle ( "SKIP TRACK COMBO" ) 198self . MELEE . MUSICSKIP : SetTooltipBody ( [[This button will allow you to a set a button combination on your controller to skip the currently playing music track. 199 200NOTE: This button is only usable when in a supported game.]] ) 201 202self . MELEE . MUSICMUTE =self . MELEE . LEFT : Add ( "GCBinderPanel" ) 203self . MELEE . MUSICMUTE : SetButtonCombo ( 0x0041 ) 204self . MELEE . MUSICMUTE : SetText ( "Mute track combo" ) 205self . MELEE . MUSICMUTE : Dock ( DOCK_TOP ) 206self . MELEE . MUSICMUTE : SetTooltipTitle ( "MUTE TRACK COMBO" ) 207self . MELEE . MUSICMUTE : SetTooltipBody ( [[This button will allow you to a set a button combination on your controller to mute/unmute the music. 208 209NOTE: This button is only usable when in a supported game.]] ) 210 211self . MELEE . VOLUME =self . MELEE . RIGHT : Add ( "SliderPanel" ) 212self . MELEE . VOLUME : DockMargin ( 0 , 0 , 0 , 0 ) 213self . MELEE . VOLUME : SetValue ( 50 ) 214self . MELEE . VOLUME : Dock ( DOCK_BOTTOM ) 215self . MELEE . VOLUME : SetTooltipTitle ( "VOLUME" ) 216self . MELEE . VOLUME : SetTooltipBody ( [[Adjust the volume of the music.]] ) 217self . MELEE . VOLUME : SetTextFormat ( "Volume: %d%%" ) 218 219function self . MELEE . VOLUME : OnValueChanged ( i ) 220music . setVolume ( i ) 221end 222 223self . PORTTITLE =self . GENERAL . LEFT : Add ( "CheckBox" ) 224self . PORTTITLE : SetText ( "Port in title" ) 225self . PORTTITLE : Dock ( DOCK_TOP ) 226self . PORTTITLE : SetTooltipTitle ( "PORT IN TITLE" ) 227self . PORTTITLE : SetTooltipBody ( [[Show the current port number being displayed in the application title.]] ) 228 229function self . PORTTITLE : OnToggle () 230love . updateTitle ( love . getTitleNoPort ()) 231end 232 233self . ALWAYSPORT =self . GENERAL . LEFT : Add ( "CheckBox" ) 234self . ALWAYSPORT : SetText ( "Always show port" ) 235self . ALWAYSPORT : Dock ( DOCK_TOP ) 236self . ALWAYSPORT : SetTooltipTitle ( "ALWAYS SHOW PORT" ) 237self . ALWAYSPORT : SetTooltipBody ( [[Always show the current port in the bottom left of the overlay window.]] ) 238 239self . DPAD =self . GENERAL . RIGHT : Add ( "CheckBox" ) 240self . DPAD : SetText ( "Show D-Pad" ) 241self . DPAD : Dock ( DOCK_TOP ) 242self . DPAD : SetTooltipTitle ( "DIRECTIONAL-PAD" ) 243self . DPAD : SetTooltipBody ( [[Enable/disable the directional pad on the overlay.]] ) 244 245self . START =self . GENERAL . RIGHT : Add ( "CheckBox" ) 246self . START : SetText ( "Show Start" ) 247self . START : Dock ( DOCK_TOP ) 248self . START : SetTooltipTitle ( "START BUTTON" ) 249self . START : SetTooltipBody ( [[Enable/disable the start button on the overlay.]] ) 250 251self . HIGH_CONTRAST =self . GENERAL . RIGHT : Add ( "CheckBox" ) 252self . HIGH_CONTRAST : SetText ( "High-contrast" ) 253self . HIGH_CONTRAST : Dock ( DOCK_TOP ) 254self . HIGH_CONTRAST : SetTooltipTitle ( "HIGH-CONTRAST" ) 255self . HIGH_CONTRAST : SetTooltipBody ( [[All buttons and joystick-gates with be filled with black for better viewing visibility. 256 25720XX theme is unsupported]] ) 258 259self . USE_TRANASPARENCY =self . GENERAL . RIGHT : Add ( "CheckBox" ) 260self . USE_TRANASPARENCY : SetVisible ( love . supportsGameCapture ()) 261self . USE_TRANASPARENCY : SetToggled ( true ) 262self . USE_TRANASPARENCY : SetText ( "Use transparency" ) 263self . USE_TRANASPARENCY : Dock ( DOCK_TOP ) 264self . USE_TRANASPARENCY : SetTooltipTitle ( "USE TRANSPARENCY" ) 265self . USE_TRANASPARENCY : SetTooltipBody ( [[Use a "transparent" background that will allow OBS to capture this panel and mask out the background. 266 267This will only function correctly if you are capturing this window in OBS with a "Game Capture" element with transparency enabled.]] ) 268 269self . USE_TRANASPARENCY . OnToggle =function ( this , on ) 270self . TRANSPARENCY : SetVisible ( on ) 271self . BACKGROUNDCOLOR : SetVisible ( not on ) 272end 273 274self . TRANSPARENCY =self . GENERAL . RIGHT : Add ( "SliderPanel" ) 275self . TRANSPARENCY : SetVisible ( love . supportsGameCapture ()) 276self . TRANSPARENCY : SetValue ( 100 ) 277self . TRANSPARENCY : Dock ( DOCK_BOTTOM ) 278self . TRANSPARENCY : DockMargin ( 0 , 0 , 0 , 0 ) 279self . TRANSPARENCY : SetTooltipTitle ( "TRANSPARENCY" ) 280self . TRANSPARENCY : SetTooltipBody ( [[Adjust how transparent the overlay is. 281 282This will only function correctly if you are capturing this window in OBS with a "Game Capture" element with transparency enabled.]] ) 283self . TRANSPARENCY : SetTextFormat ( "Transparency - %d%%" ) 284 285self . BACKGROUNDCOLOR =self . GENERAL . RIGHT : Add ( "ColorButton" ) 286self . BACKGROUNDCOLOR : SetText ( "Background color" ) 287self . BACKGROUNDCOLOR : Dock ( DOCK_BOTTOM ) 288self . BACKGROUNDCOLOR : SetVisible ( not self . USE_TRANASPARENCY : IsVisible ()) 289self . BACKGROUNDCOLOR : SetColor ( color ( 34 , 34 , 34 )) 290self . BACKGROUNDCOLOR : SetTooltipTitle ( "BACKGROUND COLOR" ) 291self . BACKGROUNDCOLOR : SetTooltipBody ( [[Pick a color to change the background color of the overlay window.]] ) 292 293self . BACKGROUNDCOLOR . OnClick =function ( this ) 294self . COLORSELECT : SetColor ( self . BACKGROUNDCOLOR : GetColor ()) 295self . COLORSELECT : SetVisible ( true ) 296self . COLORSELECT : BringToFront () 297end 298 299self . COLORSELECT : SetColorButton ( self . BACKGROUNDCOLOR ) 300 301self . CONFIGDIR =self . GENERAL . LEFT : Add ( "ButtonIcon" ) 302self . CONFIGDIR : SetText ( "Open config folder" ) 303self . CONFIGDIR : SetImage ( "textures/gui/folder_wrench.png" ) 304self . CONFIGDIR : Dock ( DOCK_BOTTOM ) 305self . CONFIGDIR : SetTooltipTitle ( "CONFIGURATION DIRECTORY" ) 306self . CONFIGDIR : SetTooltipBody ( [[This button will open the file explorer to M'Overlay's config directory. 307 308This is also the same directory you use to place all your music for Melee.]] ) 309 310function self . CONFIGDIR : OnClick () 311love . system . openURL (( "file://%s" ): format ( love . filesystem . getSaveDirectory ())) 312end 313 314if love . supportsAttachableConsole () then 315self . DEBUG =self . GENERAL . LEFT : Add ( "CheckBox" ) 316self . DEBUG : SetText ( "Debug console" ) 317self . DEBUG : Dock ( DOCK_BOTTOM ) 318self . DEBUG : SetTooltipTitle ( "DEBUG CONSOLE" ) 319self . DEBUG : SetTooltipBody ( [[Enable/disable a debug console for developer and debugging purposes.]] ) 320 321function self . DEBUG : OnToggle ( on ) 322love . console ( on ) 323end 324end 325 326self . DEBUG_INPUTS =self . GENERAL . LEFT : Add ( "ButtonIcon" ) 327self . DEBUG_INPUTS : SetText ( "Debug inputs" ) 328self . DEBUG_INPUTS : Dock ( DOCK_BOTTOM ) 329self . DEBUG_INPUTS : SetImage ( "textures/gui/joystick.png" ) 330self . DEBUG_INPUTS : SetTooltipTitle ( "DEBUG INPUTS" ) 331self . DEBUG_INPUTS : SetTooltipBody ( [[Customize a visual display for debugging input values.]] ) 332 333self . DEBUG_INPUTS . OnClick =function ( this ) 334self . MAIN : SetVisible ( false ) 335self . DEBUG_INPUTS_CONFIG : SetVisible ( true ) 336self . DEBUG_INPUTS_CONFIG : BringToFront () 337end 338 339self . ABOUT =self . MAIN : AddTab ( "About" , "textures/icon.png" ) 340 341self . ABOUT . Skin =function ( this ) 342this : super ( "Skin" ) 343this : SetBGColor ( color_purple ) 344end 345 346self . ABOUT . LEFT =self . ABOUT : Add ( "Panel" ) 347self . ABOUT . LEFT : SetDrawPanel ( false ) 348self . ABOUT . LEFT : Dock ( DOCK_LEFT ) 349self . ABOUT . LEFT : SetWidth ( 160 ) 350 351if _LAUNCHER then 352self . ABOUT . LEFT . Paint =function ( this , w , h ) 353updater . draw ( w , h ) 354end 355else 356local ICON =self . ABOUT . LEFT : Add ( "Image" ) 357ICON : Dock ( DOCK_FILL ) 358ICON : DockMargin ( 32 , 32 , 32 , 32 ) 359ICON : SetImage ( "textures/icon.png" ) 360end 361 362self . ABOUT . RIGHT =self . ABOUT : Add ( "Panel" ) 363self . ABOUT . RIGHT : SetDrawPanel ( false ) 364self . ABOUT . RIGHT : Dock ( DOCK_RIGHT ) 365self . ABOUT . RIGHT : SetWidth ( 160 ) 366 367local VERSION =self . ABOUT . RIGHT : Add ( "ButtonIcon" ) 368VERSION : SetImage ( "textures/gui/link.png" ) 369VERSION : SetText ( love . getMOverlayVersion () .. " changelog" ) 370VERSION : Dock ( DOCK_TOP ) 371 372function VERSION : OnClick () 373love . system . openURL (( "https://github.com/bkacjios/m-overlay/releases/tag/v%s" ): format ( love . getMOverlayVersion ())) 374end 375 376if _LAUNCHER then 377local UPDATE =self . ABOUT . RIGHT : Add ( "ButtonIcon" ) 378UPDATE : SetImage ( "textures/gui/wrench.png" ) 379UPDATE : SetText ( "Check for update" ) 380UPDATE : Dock ( DOCK_TOP ) 381 382function UPDATE : OnClick () 383updater . check () 384end 385end 386 387self . ABOUT . SOCIALS =self . ABOUT . RIGHT : Add ( "Panel" ) 388--self.ABOUT.SOCIALS:SetBGColor(color(215, 215, 215)) 389self . ABOUT . SOCIALS : Dock ( DOCK_BOTTOM ) 390 391self . ABOUT . DARK =self . ABOUT . RIGHT : Add ( "CheckBox" ) 392self . ABOUT . DARK : SetToggled ( true ) 393self . ABOUT . DARK : SetText ( "Dark mode" ) 394self . ABOUT . DARK : Dock ( DOCK_BOTTOM ) 395self . ABOUT . DARK : SetTooltipTitle ( "DARK MODE" ) 396self . ABOUT . DARK : SetTooltipBody ( [[Enables a dark mode on the settings UI.]] ) 397 398function self . ABOUT . DARK : OnToggle ( on ) 399gui . setSkin ( on and "dark" or "default" ) 400end 401 402self . ABOUT . AUTHOR =self . ABOUT . SOCIALS : Add ( "Label" ) 403self . ABOUT . AUTHOR : SetText ( "Made by /bkacjios" ) 404self . ABOUT . AUTHOR : SetTextAlignmentX ( "center" ) 405self . ABOUT . AUTHOR : SizeToText () 406self . ABOUT . AUTHOR : Dock ( DOCK_TOP ) 407 408self . ABOUT . SOCIALS : SetHeight ( self . ABOUT . AUTHOR : GetHeight () + 44 ) 409 410local GITHUB =self . ABOUT . SOCIALS : Add ( "Image" ) 411GITHUB : SetFocusable ( true ) 412GITHUB : SetSize ( 32 , 32 ) 413GITHUB : Dock ( DOCK_LEFT ) 414GITHUB : SetImage ( "textures/social/github.png" ) 415GITHUB : SetTooltipTitle ( "GITHUB" ) 416GITHUB : SetTooltipBody ( [[https://github.com/bkacjios]] ) 417 418function GITHUB : OnClick () 419love . system . openURL ( "https://github.com/bkacjios" ) 420end 421 422local self . ABOUT . SOCIALS : Add ( "Image" ) 423: SetFocusable ( true ) 424: SetSize ( 32 , 32 ) 425: Dock ( DOCK_LEFT ) 426: SetImage ( "textures/social/twitter.png" ) 427: SetTooltipTitle ( "TWITTER" ) 428: SetTooltipBody ( [[https://twitter.com/bkacjios]] ) 429 430function : OnClick () 431love . system . openURL ( "https://twitter.com/bkacjios" ) 432end 433 434local TWITCH =self . ABOUT . SOCIALS : Add ( "Image" ) 435TWITCH : SetFocusable ( true ) 436TWITCH : SetSize ( 32 , 32 ) 437TWITCH : Dock ( DOCK_LEFT ) 438TWITCH : SetImage ( "textures/social/twitch.png" ) 439TWITCH : SetTooltipTitle ( "TWITCH" ) 440TWITCH : SetTooltipBody ( [[https://twitch.tv/bkacjios]] ) 441 442function TWITCH : OnClick () 443love . system . openURL ( "https://twitch.tv/bkacjios" ) 444end 445 446local PAYPAL =self . ABOUT . SOCIALS : Add ( "Image" ) 447PAYPAL : SetFocusable ( true ) 448PAYPAL : SetSize ( 32 , 32 ) 449PAYPAL : Dock ( DOCK_LEFT ) 450PAYPAL : SetImage ( "textures/social/paypal.png" ) 451PAYPAL : SetTooltipTitle ( "PAYPAL" ) 452PAYPAL : SetTooltipBody ( [[https://www.paypal.com/paypalme/bkacjios]] ) 453 454function PAYPAL : OnClick () 455love . system . openURL ( "https://www.paypal.com/paypalme/bkacjios" ) 456end 457 458self . m_sFileName ="config.json" 459 460--local test = self:Add("ColorPicker") 461--test:SetSize(256, 256) 462end 463 464function PANEL : UpdateSkins () 465self . SKINSELECT : UpdateSkins () 466end 467 468function PANEL : ChangeSkin ( skin ) 469self . SKINSELECT : ChangeSkin ( skin ) 470end 471 472function PANEL : GetSkin () 473return self . SKINSELECT : GetSkin () 474end 475 476function PANEL : GetPort () 477return self . PORTSELECT : GetPort () 478end 479 480function PANEL : ChangePort ( port ) 481self . PORTSELECT : ChangePort ( port ) 482end 483 484function PANEL : Toggle () 485self : GiveFocus () 486self : SetVisible ( not self : IsVisible ()) 487if not self : IsVisible () then 488gui . hideTooltip () 489self : OnClosed () 490end 491self : Center () 492end 493 494function PANEL : GetSaveTable () 495return { 496[ "config-version" ] =self : GetConfigVersion (), 497[ "port" ] =overlay . getPort (), 498[ "skin" ] =overlay . getSkin (), 499[ "slippi-mode" ] =self : GetSlippiMode (), 500[ "port-in-title" ] =self : IsPortTitleEnabled (), 501[ "always-show-port" ] =self : AlwaysShowPort (), 502[ "high-contrast" ] =self : IsHighContrast (), 503[ "enable-dpad" ] =self : IsDPadEnabled (), 504[ "enable-start" ] =self : IsStartEnabled (), 505[ "debugging" ] =self : IsDebugging (), 506[ "debugging-input-flags" ] =self : GetDebuggingInputFlags (), 507[ "use-transparency" ] =self : UseTransparency (), 508[ "transparency" ] =self : GetTransparency (), 509[ "melee-music" ] =self : PlayStageMusic (), 510[ "melee-music-loop-flags" ] =self : GetMusicLoopMode (), 511[ "melee-music-skip-buttons" ] =self : GetMusicSkipMask (), 512[ "melee-music-mute-buttons" ] =self : GetMusicMuteMask (), 513[ "melee-music-volume" ] =self : GetVolume (), 514[ "background-color" ] =self : GetBackgroundColor (): hexString (), 515[ "dark-mode" ] =self : IsDarkMode (), 516} 517end 518 519function PANEL : GetConfigVersion () 520return "2.0.0" 521end 522 523function PANEL : GetConfigVersionNumbers () 524-- Returns 3 numbers: magor, minor, revision 525return string . match ( self : GetConfigVersion (), "^(%d-)%.(%d-)%.(%d+)$" ) 526end 527 528function PANEL : UseTransparency () 529return self . USE_TRANASPARENCY : IsToggled () 530end 531 532function PANEL : GetBackgroundColor () 533return self . BACKGROUNDCOLOR : GetColor () 534end 535 536function PANEL : IsBinding () 537return self . MELEE . MUSICSKIP : IsBinding () or self . MELEE . MUSICMUTE : IsBinding () 538end 539 540function PANEL : GetMusicSkipMask () 541return self . MELEE . MUSICSKIP : GetButtonCombo () 542end 543 544function PANEL : GetMusicMuteMask () 545return self . MELEE . MUSICMUTE : GetButtonCombo () 546end 547 548function PANEL : PlayStageMusic () 549return self . MELEE . MUSIC : IsToggled () 550end 551 552function PANEL : GetMusicLoopMode () 553return self . MELEE . MUSICLOOP : GetValue () 554end 555 556function PANEL : SetVolume ( volume ) 557return self . MELEE . VOLUME : SetValue ( math . clamp ( volume , 0 , 100 )) 558end 559 560function PANEL : GetVolume () 561return self . MELEE . VOLUME : GetValue () 562end 563 564function PANEL : GetSlippiMode () 565return self . SLIPPI . MODE : GetOption () 566end 567 568function PANEL : IsSlippiNetplay () 569return self . SLIPPI . MODE : GetOption () == SLIPPI_NETPLAY 570end 571 572function PANEL : IsSlippiReplay () 573return self . SLIPPI . MODE : GetOption () == SLIPPI_REPLAY 574end 575 576function PANEL : IsPortTitleEnabled () 577return self . PORTTITLE : IsToggled () 578end 579 580function PANEL : AlwaysShowPort () 581return self . ALWAYSPORT : IsToggled () 582end 583 584function PANEL : IsHighContrast () 585return self . HIGH_CONTRAST : IsToggled () 586end 587 588function PANEL : IsDPadEnabled () 589return self . DPAD : IsToggled () 590end 591 592function PANEL : IsStartEnabled () 593return self . START : IsToggled () 594end 595 596function PANEL : IsDebugging () 597return self . DEBUG and self . DEBUG : IsToggled () or false 598end 599 600function PANEL : GetDebuggingInputFlags () 601return self . DEBUG_INPUTS_CONFIG : GetValue () 602end 603 604function PANEL : IsDebuggingInput ( flag ) 605return bit . band ( self . DEBUG_INPUTS_CONFIG : GetValue (), flag ) == flag 606end 607 608function PANEL : IsDebuggingButtons () 609return self : IsDebuggingInput ( DEBUG_INPUT_BUTTONS ) 610end 611 612function PANEL : IsDebuggingJoystick () 613return self : IsDebuggingInput ( DEBUG_INPUT_JOYSTICK ) 614end 615 616function PANEL : IsDebuggingCStick () 617return self : IsDebuggingInput ( DEBUG_INPUT_C_STICK ) 618end 619 620function PANEL : IsDebuggingTriggers () 621return self : IsDebuggingInput ( DEBUG_INPUT_TRIGGERS ) 622end 623 624function PANEL : GetTransparency () 625return self . TRANSPARENCY and self . TRANSPARENCY : GetValue () or nil 626end 627 628function PANEL : IsDarkMode () 629return self . ABOUT . DARK : IsToggled () 630end 631 632function PANEL : OnClosed () 633if not self : NeedsWrite () then return end -- Stop if we don't need to write any changes 634self : SaveSettings () 635end 636 637function PANEL : NeedsWrite () 638for k , v in pairs ( self : GetSaveTable ()) do 639-- Return true if the last known settings state differs from the current 640if self . m_tSettings [ k ] == nil or self . m_tSettings [ k ] ~= v then 641return true 642end 643end 644return false 645end 646 647function PANEL : SaveSettings () 648local f , err =filesystem . newFile ( self . m_sFileName , "w" ) 649if f then 650log . warn ( "Writing to %s" , self . m_sFileName ) 651notification . warning ( "Writing to %s" , self . m_sFileName ) 652self . m_tSettings =self : GetSaveTable () 653f : write ( json . encode ( self . m_tSettings , true )) 654f : flush () 655f : close () 656else 657log . error ( "Failed writing to %s: %s" , self . m_sFileName , err ) 658notification . error ( "Failed writing to %s: %s" , self . m_sFileName , err ) 659end 660end 661 662local function updatedConfigSetting ( settings , oldkey , oldvalue , newkey , newvalue ) 663settings [ newkey ] =newvalue 664log . debug ( "[CONFIG] Updating setting [%q = %s] to [%q = %s]" , oldkey , oldvalue , newkey , newvalue ) 665end 666 667function PANEL : LoadSettings () 668local settings =self : GetSaveTable () 669 670local f =filesystem . newFile ( self . m_sFileName , "r" ) 671if f then 672local success , decoded =pcall ( json . decode , f : read ()) 673f : close () 674if not success then 675-- If we failed decoding, decoded is an error string. 676-- Get the last bit of text after the file name and line number. 677-- Error format: "filename.lua:1: (OUR ERROR STRING HERE)" 678local err =string . match ( decoded , "^.*:%s*(.*)$" ) or decoded 679log . error ( "[CONFIG] Failed parsing %s: ('%s')" , self . m_sFileName , err ) 680notification . error ( "Failed parsing %s: ('%s')" , self . m_sFileName , err ) 681else 682for k , v in pairs ( decoded ) do 683if settings [ k ] ~= nil then -- We have a valid setting 684settings [ k ] =v -- Update value from config file 685 686-- CONVERT OLD SETTINGS INTO NEW 687elseif k == "hide-dpad" and type ( v ) == "boolean" then 688-- Renamed "hide-dpad" to "enable-dpad" when we added "enable-start" 689updatedConfigSetting ( settings , k , v , "enable-dpad" , not v ) 690elseif k == "slippi-netplay" and v == true then 691-- At one point "slippi-netplay" was a boolean value for on/off 692updatedConfigSetting ( settings , k , v , "slippi-mode" , SLIPPI_NETPLAY ) 693elseif k == "music-volume" then 694-- prefix "melee-" to our old music configs 695updatedConfigSetting ( settings , k , v , "melee-" .. k , v ) 696elseif k == "stage-music" or k == "melee-stage-music" then 697-- we are now called "melee-music" 698updatedConfigSetting ( settings , k , v , "melee-music" , v ) 699elseif k == "melee-stage-music-skip-buttons" then 700updatedConfigSetting ( settings , k , v , "melee-music-skip-buttons" , v ) 701elseif k == "melee-stage-music-loop" or k == "stage-music-loop" then 702if type ( v ) == "boolean" then 703-- Back when we only had a single checkbox for looping a stage 704-- this value was a boolean, convert to new flag. 705updatedConfigSetting ( settings , k , v , "melee-music-loop-flags" , LOOPING_STAGE_TIMED ) 706elseif type ( v ) == "number" then 707-- Convert our old radio options for the new checkbox system 708local translate ={ 709[ 1 ] =LOOPING_NONE , -- OFF 710[ 2 ] =LOOPING_MENU , -- MENU 711[ 3 ] =LOOPING_STAGE_TIMED , -- STAGE 712[ 4 ] =LOOPING_MENU + LOOPING_STAGE_TIMED , -- ALL 713[ 5 ] =LOOPING_STAGE_TIMED , -- ADAPTIVE 714} 715updatedConfigSetting ( settings , k , v , "melee-music-loop-flags" , translate [ v ] or LOOPING_NONE ) 716end 717else 718log . debug ( "[CONFIG] Ignoring unused setting option %q = %s" , k , tostring ( v )) 719end 720end 721end 722end 723 724self . m_tSettings =settings 725 726overlay . setPort ( settings [ "port" ]) 727overlay . setSkin ( settings [ "skin" ]) 728 729self . PORTTITLE : SetToggled ( settings [ "port-in-title" ], true ) 730self . ALWAYSPORT : SetToggled ( settings [ "always-show-port" ], true ) 731self . HIGH_CONTRAST : SetToggled ( settings [ "high-contrast" ], true ) 732self . DPAD : SetToggled ( settings [ "enable-dpad" ], true ) 733self . START : SetToggled ( settings [ "enable-start" ], true ) 734if self . DEBUG then 735self . DEBUG : SetToggled ( love . hasConsole () or settings [ "debugging" ] or false ) 736end 737self . DEBUG_INPUTS_CONFIG : SetValue ( settings [ "debugging-input-flags" ]) 738self . TRANSPARENCY : SetValue ( settings [ "transparency" ]) 739self . SLIPPI . MODE : SetValue ( settings [ "slippi-mode" ]) 740self . MELEE . MUSIC : SetToggled ( settings [ "melee-music" ], true ) 741self . MELEE . MUSICLOOP : SetValue ( settings [ "melee-music-loop-flags" ] or LOOPING_NONE ) 742self . MELEE . MUSICSKIP : SetButtonCombo ( settings [ "melee-music-skip-buttons" ]) 743self . MELEE . MUSICMUTE : SetButtonCombo ( settings [ "melee-music-mute-buttons" ]) 744self . MELEE . VOLUME : SetValue ( settings [ "melee-music-volume" ]) 745if love . supportsGameCapture () then 746self . USE_TRANASPARENCY : SetToggled ( settings [ "use-transparency" ], true ) 747end 748self . BACKGROUNDCOLOR : SetColor ( color ( settings [ "background-color" ])) 749self . ABOUT . DARK : SetToggled ( settings [ "dark-mode" ], true ) 750end