Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Ne_Eo
2024-11-29 22:02:37 +01:00
22 changed files with 214 additions and 38 deletions
+2 -1
View File
@@ -8,5 +8,6 @@ latest/windows/haxe/
.haxelib/
pages/
docs/doc.xml
mods/Baldi's Basics in Funkin'/
mods/*
!mods/readme.txt
dev-libs/
+4 -8
View File
@@ -92,15 +92,11 @@ function update(elapsed) {
if (!canDoShit) return;
var oldSec = curSelected;
if (controls.DOWN_P)
changeSelection(1, false);
if (controls.UP_P)
changeSelection(-1);
if (oldSec != curSelected) {
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
if (oldSec != curSelected)
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText'));
}
if (controls.ACCEPT) {
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
@@ -118,7 +114,7 @@ function update(elapsed) {
}
}
function changeSelection(change) {
function changeSelection(change) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
curSelected += change;
if (curSelected < 0)
+1 -1
View File
@@ -16,7 +16,7 @@
<git name="hscript-improved" url="https://github.com/FNF-CNE-Devs/hscript-improved" ref="codename-dev" />
<git name="flxanimate" url="https://github.com/FNF-CNE-Devs/flxanimate" />
<git name="hxdiscord_rpc" url="https://github.com/FNF-CNE-Devs/hxdiscord_rpc" skipDeps="true" />
<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" />
+3 -1
View File
@@ -79,8 +79,10 @@ class HScript extends Script {
var code = Assets.getText(p);
var expr:Expr = null;
try {
if (code != null && code.trim() != "")
if (code != null && code.trim() != "") {
parser.line = 1; // fun fact: this is all you need to reuse a parser without issues. all the other vars get reset on parse.
expr = parser.parseString(code, cl.join("/") + "." + hxExt);
}
} catch(e:Error) {
_errorHandler(e);
} catch(e) {
+3
View File
@@ -156,6 +156,9 @@ class Main extends Sprite
FlxG.signals.postStateSwitch.add(onStateSwitchPost);
FlxG.mouse.useSystemCursor = true;
#if DARK_MODE_WINDOW
if(funkin.backend.utils.NativeAPI.hasVersion("Windows 10")) funkin.backend.utils.NativeAPI.redrawWindowHeader();
#end
ModsFolder.init();
#if MOD_SUPPORT
+75
View File
@@ -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
*/
+45 -1
View File
@@ -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
@@ -23,6 +23,7 @@ class ChartDataScreen extends UISubstateWindow {
public override function create() {
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
for (strumLine in Charter.instance.strumLines.members) strumLine.vocals.pause();
winTitle = 'Chart Properties';
winWidth = 420; winHeight = 230; // guys look, the funny numbers!
+30
View File
@@ -332,6 +332,7 @@ class Charter extends UIState {
null,
{
label: "↑ Speed 25%",
keybind: [PERIOD],
onSelect: _playback_speed_raise
},
{
@@ -340,6 +341,7 @@ class Charter extends UIState {
},
{
label: "↓ Speed 25%",
keybind: [COMMA],
onSelect: _playback_speed_lower
},
null,
@@ -353,6 +355,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",
@@ -1583,6 +1601,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;
+28 -7
View File
@@ -1,6 +1,7 @@
package funkin.editors.charter;
import flixel.math.FlxPoint;
import flixel.system.FlxAssets.FlxGraphicAsset;
import funkin.backend.chart.ChartData.ChartEvent;
import funkin.editors.charter.Charter.ICharterSelectable;
import funkin.editors.charter.CharterBackdropGroup.EventBackdrop;
@@ -47,14 +48,34 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable {
private static function generateDefaultIcon(name:String) {
var isBase64:Bool = false;
var path:String = Paths.image('editors/charter/event-icons/$name');
if (!Assets.exists(path)) path = Paths.image('editors/charter/event-icons/Unknown');
if (Assets.exists(Paths.pack('events/$name'))) {
var packimg = Assets.getText(Paths.pack('events/$name')).split('________PACKSEP________')[3];
if (isBase64 = (packimg != null))
path = Assets.getText(Paths.pack('events/$name')).split('________PACKSEP________')[3];
var defaultPath = Paths.image('editors/charter/event-icons/Unknown');
if (!Assets.exists(path)) path = defaultPath;
var packPath = Paths.pack('events/$name');
if (Assets.exists(packPath)) {
var packText = Assets.getText(packPath).split('________PACKSEP________');
var packImg = packText[3];
if(packImg != null && packImg.length > 0) {
isBase64 = !packImg.startsWith("assets/");
path = packImg;
}
var spr = new FlxSprite().loadGraphic(isBase64 ? openfl.display.BitmapData.fromBase64(path.trim(), 'UTF8') : path);
return spr;
}
path = path.trim();
var graphic:FlxGraphicAsset = try {
isBase64 ? openfl.display.BitmapData.fromBase64(path, 'UTF8') : path;
} catch(e:Dynamic) {
Logs.trace('Failed to load event icon: ${e.toString()}', ERROR);
isBase64 = false;
defaultPath;
}
if(!isBase64) {
if (!Assets.exists(graphic))
graphic = defaultPath;
}
return new FlxSprite().loadGraphic(graphic);
}
public static function generateEventIcon(event:ChartEvent) {
@@ -43,6 +43,7 @@ class CharterEventScreen extends UISubstateWindow {
FlxG.sound.music.pause(); // prevent the song from continuing
Charter.instance.vocals.pause();
for (strumLine in Charter.instance.strumLines.members) strumLine.vocals.pause();
events = chartEvent.events.copy();
@@ -39,6 +39,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
for (strumLine in Charter.instance.strumLines.members) strumLine.vocals.pause();
function addLabelOn(ui:UISprite, text:String)
add(new UIText(ui.x, ui.y - 24, 0, text));
@@ -13,6 +13,7 @@ class CharterNoteTypesList extends UISubstateWindow {
public override function create() {
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
for (strumLine in Charter.instance.strumLines.members) strumLine.vocals.pause();
winTitle = 'Note Types List Editor';
winWidth = 380; winHeight = 390;
@@ -51,6 +51,7 @@ class CharterStrumlineScreen extends UISubstateWindow {
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
for (strumLine in Charter.instance.strumLines.members) strumLine.vocals.pause();
super.create();
+1
View File
@@ -27,6 +27,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;
+1 -1
View File
@@ -716,7 +716,7 @@ class PlayState extends MusicBeatState
startingPos,
strumLine.strumScale == null ? 1 : strumLine.strumScale,
strumLine.type == 2 || (!coopMode && !((strumLine.type == 1 && !opponentMode) || (strumLine.type == 0 && opponentMode))),
strumLine.type != 1, coopMode ? (strumLine.type == 1 ? controlsP1 : controlsP2) : controls,
strumLine.type != 1, coopMode ? ((strumLine.type == 1) != opponentMode ? controlsP1 : controlsP2) : controls,
strumLine.vocalsSuffix
);
strLine.cameras = [camHUD];
+1 -1
View File
@@ -218,7 +218,7 @@ class FreeplayState extends MusicBeatState
lerpScore = intendedScore;
if (canSelect) {
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
changeDiff((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
changeCoopMode((FlxG.keys.justPressed.TAB ? 1 : 0));
// putting it before so that its actually smooth
+5 -6
View File
@@ -106,11 +106,12 @@ class MainMenuState extends MusicBeatState
*/
}
if (controls.UP_P)
changeItem(-1);
var upP = controls.UP_P;
var downP = controls.DOWN_P;
var scroll = FlxG.mouse.wheel;
if (controls.DOWN_P)
changeItem(1);
if (upP || downP || scroll != 0) // like this we wont break mods that expect a 0 change event when calling sometimes - Nex
changeItem((upP ? -1 : 0) + (downP ? 1 : 0) - scroll);
if (controls.BACK)
FlxG.switchState(new TitleState());
@@ -124,10 +125,8 @@ class MainMenuState extends MusicBeatState
#end
if (controls.ACCEPT)
{
selectItem();
}
}
super.update(elapsed);
+1 -1
View File
@@ -42,7 +42,7 @@ class ModSwitchMenu extends MusicBeatSubstate {
public override function update(elapsed:Float) {
super.update(elapsed);
changeSelection((controls.DOWN_P ? 1 : 0) + (controls.UP_P ? -1 : 0));
changeSelection((controls.DOWN_P ? 1 : 0) + (controls.UP_P ? -1 : 0) - FlxG.mouse.wheel);
if (controls.ACCEPT) {
ModsFolder.switchMod(mods[curSelected]);
+5 -6
View File
@@ -127,13 +127,12 @@ class PauseSubState extends MusicBeatSubstate
var upP = controls.UP_P;
var downP = controls.DOWN_P;
var accepted = controls.ACCEPT;
var scroll = FlxG.mouse.wheel;
if (upP)
changeSelection(-1);
if (downP)
changeSelection(1);
if (accepted)
if (upP || downP || scroll != 0) // like this we wont break mods that expect a 0 change event when calling sometimes - Nex
changeSelection((upP ? -1 : 0) + (downP ? 1 : 0) - scroll);
if (controls.ACCEPT)
selectOption();
}
+1 -1
View File
@@ -149,7 +149,7 @@ class StoryMenuState extends MusicBeatState {
}
changeDifficulty((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
if (controls.ACCEPT)
selectWeek();