Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into cne-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Nov 27, 2024
2 parents e68d7c9 + 0da2fd2 commit a7d2467
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<git name="hscript-improved" url="https://github.com/FNF-CNE-Devs/hscript-improved" ref="custom-classes" />
<git name="flxanimate" url="https://github.com/FNF-CNE-Devs/flxanimate" />
<git name="hxdiscord_rpc" url="https://github.com/FNF-CNE-Devs/hxdiscord_rpc" />
<lib name="hxvlc" skipDeps="true" />
<lib name="hxvlc" version="1.9.3" skipDeps="true" />

<!-- Documentation and other features -->
<git name="away3d" url="https://github.com/FNF-CNE-Devs/away3d" />
Expand Down
1 change: 0 additions & 1 deletion source/funkin/backend/system/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
75 changes: 75 additions & 0 deletions source/funkin/backend/utils/NativeAPI.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
*/
Expand Down
46 changes: 45 additions & 1 deletion source/funkin/backend/utils/native/Windows.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>, 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<Int>) {}

@:functionCode('
// https://stackoverflow.com/questions/15543571/allocconsole-not-displaying-cout

Expand Down
30 changes: 30 additions & 0 deletions source/funkin/editors/charter/Charter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class Charter extends UIState {
null,
{
label: "↑ Speed 25%",
keybind: [PERIOD],
onSelect: _playback_speed_raise
},
{
Expand All @@ -349,6 +350,7 @@ class Charter extends UIState {
},
{
label: "↓ Speed 25%",
keybind: [COMMA],
onSelect: _playback_speed_lower
},
null,
Expand All @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions source/funkin/editors/ui/UISlider.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a7d2467

Please sign in to comment.