diff --git a/libs.xml b/libs.xml index 4218feeb1..103442fa1 100644 --- a/libs.xml +++ b/libs.xml @@ -12,7 +12,7 @@ - + diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index 5f57e49fe..72e218b47 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -169,7 +169,6 @@ class Main extends Sprite FlxG.signals.postStateSwitch.add(onStateSwitchPost); FlxG.mouse.useSystemCursor = !Controls.instance.touchC; - #if DARK_MODE_WINDOW if(funkin.backend.utils.NativeAPI.hasVersion("Windows 10")) funkin.backend.utils.NativeAPI.redrawWindowHeader(); #end diff --git a/source/funkin/backend/utils/NativeAPI.hx b/source/funkin/backend/utils/NativeAPI.hx index 42cf23993..ff804f033 100644 --- a/source/funkin/backend/utils/NativeAPI.hx +++ b/source/funkin/backend/utils/NativeAPI.hx @@ -3,6 +3,7 @@ package funkin.backend.utils; import funkin.backend.utils.native.*; import flixel.util.typeLimit.OneOfTwo; import flixel.util.typeLimit.OneOfThree; +import flixel.util.FlxColor; /** * Class for functions that talk to a lower level than haxe, such as message boxes, and more. @@ -84,12 +85,86 @@ class NativeAPI { #end } + /** + * WINDOW COLOR MODE FUNCTIONS. + */ + + /** + * Switch the window's color mode to dark or light mode. + */ public static function setDarkMode(title:String, enable:Bool) { #if windows + if(title == null) title = lime.app.Application.current.window.title; Windows.setDarkMode(title, enable); #end } + /** + * Switch the window's color to any color. + * + * WARNING: This is exclusive to windows 11 users, unfortunately. + * + * NOTE: Setting the color to 0x00000000 (FlxColor.TRANSPARENT) will set the border (must have setBorder on) invisible. + */ + public static function setWindowBorderColor(title:String, color:FlxColor, setHeader:Bool = true, setBorder:Bool = true) { + #if windows + if(title == null) title = lime.app.Application.current.window.title; + Windows.setWindowBorderColor(title, [color.red, color.green, color.blue, color.alpha], setHeader, setBorder); + #end + } + + /** + * Resets the window's border color to the default one. + * + * WARNING: This is exclusive to windows 11 users, unfortunately. + **/ + public static function resetWindowBorderColor(title:String, setHeader:Bool = true, setBorder:Bool = true) { + #if windows + if(title == null) title = lime.app.Application.current.window.title; + Windows.setWindowBorderColor(title, [-1, -1, -1, -1], setHeader, setBorder); + #end + } + + /** + * Switch the window's title text to any color. + * + * WARNING: This is exclusive to windows 11 users, unfortunately. + */ + public static function setWindowTitleColor(title:String, color:FlxColor) { + #if windows + if(title == null) title = lime.app.Application.current.window.title; + Windows.setWindowTitleColor(title, [color.red, color.green, color.blue, color.alpha]); + #end + } + + /** + * Resets the window's title color to the default one. + * + * WARNING: This is exclusive to windows 11 users, unfortunately. + **/ + public static function resetWindowTitleColor(title:String) { + #if windows + if(title == null) title = lime.app.Application.current.window.title; + Windows.setWindowTitleColor(title, [-1, -1, -1, -1]); + #end + } + + /** + * Forces the window header to redraw, causes a small visual jitter so use it sparingly. + */ + public static function redrawWindowHeader() { + #if windows + flixel.FlxG.stage.window.borderless = true; + flixel.FlxG.stage.window.borderless = false; + #end + } + + /** + * Can be used to check if your using a specific version of an OS (or if your using a certain OS). + */ + public static function hasVersion(vers:String) + return lime.system.System.platformLabel.toLowerCase().indexOf(vers.toLowerCase()) != -1; + /** * Shows a message box */ diff --git a/source/funkin/backend/utils/native/Windows.hx b/source/funkin/backend/utils/native/Windows.hx index a536c75f8..8653d2e8c 100644 --- a/source/funkin/backend/utils/native/Windows.hx +++ b/source/funkin/backend/utils/native/Windows.hx @@ -134,13 +134,57 @@ class Windows { HWND window = FindWindowA(NULL, title.c_str()); // Look for child windows if top level aint found if (window == NULL) window = FindWindowExA(GetActiveWindow(), NULL, NULL, title.c_str()); + // If still not found, try to get the active window + if (window == NULL) window = GetActiveWindow(); + if (window == NULL) return; - if (window != NULL && S_OK != DwmSetWindowAttribute(window, 19, &darkMode, sizeof(darkMode))) { + if (S_OK != DwmSetWindowAttribute(window, 19, &darkMode, sizeof(darkMode))) { DwmSetWindowAttribute(window, 20, &darkMode, sizeof(darkMode)); } + UpdateWindow(window); ') public static function setDarkMode(title:String, enable:Bool) {} + @:functionCode(' + HWND window = FindWindowA(NULL, title.c_str()); + if (window == NULL) window = FindWindowExA(GetActiveWindow(), NULL, NULL, title.c_str()); + if (window == NULL) window = GetActiveWindow(); + if (window == NULL) return; + + COLORREF finalColor; + if(color[0] == -1 && color[1] == -1 && color[2] == -1 && color[3] == -1) { // bad fix, I know :sob: + finalColor = 0xFFFFFFFF; // Default border + } else if(color[3] == 0) { + finalColor = 0xFFFFFFFE; // No border (must have setBorder as true) + } else { + finalColor = RGB(color[0], color[1], color[2]); // Use your custom color + } + + if(setHeader) DwmSetWindowAttribute(window, 35, &finalColor, sizeof(COLORREF)); + if(setBorder) DwmSetWindowAttribute(window, 34, &finalColor, sizeof(COLORREF)); + + UpdateWindow(window); + ') + public static function setWindowBorderColor(title:String, color:Array, setHeader:Bool = true, setBorder:Bool = true) {} + + @:functionCode(' + HWND window = FindWindowA(NULL, title.c_str()); + if (window == NULL) window = FindWindowExA(GetActiveWindow(), NULL, NULL, title.c_str()); + if (window == NULL) window = GetActiveWindow(); + if (window == NULL) return; + + COLORREF finalColor; + if(color[0] == -1 && color[1] == -1 && color[2] == -1 && color[3] == -1) { // bad fix, I know :sob: + finalColor = 0xFFFFFFFF; // Default border + } else { + finalColor = RGB(color[0], color[1], color[2]); // Use your custom color + } + + DwmSetWindowAttribute(window, 36, &finalColor, sizeof(COLORREF)); + UpdateWindow(window); + ') + public static function setWindowTitleColor(title:String, color:Array) {} + @:functionCode(' // https://stackoverflow.com/questions/15543571/allocconsole-not-displaying-cout diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 99f6f6909..cf13c0c23 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -341,6 +341,7 @@ class Charter extends UIState { null, { label: "↑ Speed 25%", + keybind: [PERIOD], onSelect: _playback_speed_raise }, { @@ -349,6 +350,7 @@ class Charter extends UIState { }, { label: "↓ Speed 25%", + keybind: [COMMA], onSelect: _playback_speed_lower }, null, @@ -362,6 +364,22 @@ class Charter extends UIState { keybind: [D], onSelect: _playback_forward }, + { + label: "Go to start of section", + keybind: [SHIFT, S], + onSelect: _playback_section_start + }, + null, + { + label: "Go back a step", + keybind: [W], + onSelect: _playback_back_step + }, + { + label: "Go forward a step", + keybind: [S], + onSelect: _playback_forward_step + }, null, { label: "Metronome", @@ -1579,6 +1597,18 @@ class Charter extends UIState { if (FlxG.sound.music.playing) return; Conductor.songPosition += (Conductor.beatsPerMeasure * __crochet); } + function _playback_section_start(_) { + if(FlxG.sound.music.playing) return; + Conductor.songPosition = (Conductor.beatsPerMeasure * (60000 / Conductor.bpm)) * curMeasure; + } + function _playback_back_step(_) { + if (FlxG.sound.music.playing) return; + Conductor.songPosition -= Conductor.stepCrochet; + } + function _playback_forward_step(_) { + if (FlxG.sound.music.playing) return; + Conductor.songPosition += Conductor.stepCrochet; + } function _song_start(_) { if (FlxG.sound.music.playing) return; Conductor.songPosition = 0; diff --git a/source/funkin/editors/ui/UISlider.hx b/source/funkin/editors/ui/UISlider.hx index 277c7b95d..091886c1c 100644 --- a/source/funkin/editors/ui/UISlider.hx +++ b/source/funkin/editors/ui/UISlider.hx @@ -26,6 +26,7 @@ class UISlider extends UISprite { public var value(default, set):Float = 0; public function set_value(newVal:Float):Float { + newVal = FlxMath.bound(newVal, segments[0].start, segments[segments.length-1].end); __barProgress = __calcProgress(newVal); if (onChange != null) onChange(newVal); if (valueStepper != null) valueStepper.value = newVal; return value = newVal;