Merge remote-tracking branch 'upstream/main' into new-editors-main

# Conflicts:
# commandline/commands/Compiler.hx
# source/funkin/backend/FunkinSprite.hx
# source/funkin/backend/MusicBeatState.hx
# source/funkin/backend/MusicBeatSubstate.hx
# source/funkin/backend/chart/Chart.hx
# source/funkin/backend/chart/EventsData.hx
# source/funkin/backend/scripting/GlobalScript.hx
# source/funkin/backend/system/Controls.hx
# source/funkin/backend/system/MainState.hx
# source/funkin/backend/utils/AudioAnalyzer.hx
# source/funkin/backend/utils/CoolUtil.hx
# source/funkin/editors/character/CharacterInfoScreen.hx
# source/funkin/editors/charter/Charter.hx
# source/funkin/editors/charter/CharterSelection.hx
# source/funkin/editors/charter/CharterStrumline.hx
# source/funkin/editors/charter/CharterStrumlineButton.hx
# source/funkin/editors/charter/SongCreationScreen.hx
# source/funkin/editors/ui/UIDropDown.hx
# source/funkin/editors/ui/UIFileExplorer.hx
# source/funkin/game/Note.hx
# source/funkin/game/PlayState.hx
# source/funkin/game/SplashGroup.hx
# source/funkin/game/Stage.hx
# source/funkin/game/Strum.hx
# source/funkin/menus/FreeplayState.hx
# source/funkin/options/Options.hx
# source/funkin/options/keybinds/KeybindsOptions.hx
This commit is contained in:
Ralty
2025-07-19 00:57:08 +07:00
372 changed files with 3244 additions and 1248 deletions
+27 -15
View File
@@ -4,6 +4,8 @@ import flixel.FlxState;
import funkin.backend.assets.ModsFolder;
import funkin.backend.scripting.events.CancellableEvent;
import funkin.backend.system.Conductor;
import funkin.options.PlayerSettings;
#if GLOBAL_SCRIPT
/**
* Class for THE Global Script, aka script that runs in the background at all times.
@@ -12,6 +14,8 @@ class GlobalScript {
public static var scripts:ScriptPack;
private static var initialized:Bool = false;
private static var reloading:Bool = false;
private static var _lastAllow_Reload:Bool = false;
public static function init() {
if(initialized) return;
@@ -46,19 +50,13 @@ class GlobalScript {
});
FlxG.signals.postUpdate.add(function() {
call("postUpdate", [FlxG.elapsed]);
#if EXPERMENTAL_SCRIPT_RELOADING
if (FlxG.keys.justPressed.F5) {
if (scripts.scripts.length > 0) {
Logs.trace('Reloading global script...', WARNING, YELLOW);
scripts.reload();
Logs.trace('Global script successfully reloaded.', WARNING, GREEN);
} else {
Logs.trace('Loading global script...', WARNING, YELLOW);
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
}
if (reloading) {
reloading = false;
MusicBeatState.ALLOW_DEV_RELOAD = _lastAllow_Reload;
}
#end
if (FlxG.keys.justPressed.F2)
if (PlayerSettings.solo.controls.DEV_CONSOLE)
NativeAPI.allocConsole();
});
FlxG.signals.preDraw.add(function() {
@@ -76,13 +74,26 @@ class GlobalScript {
FlxG.signals.preStateSwitch.add(function() {
call("preStateSwitch", []);
});
FlxG.signals.preUpdate.add(function() {
call("preUpdate", [FlxG.elapsed]);
call("update", [FlxG.elapsed]);
});
// Commented this out, because it might be the cause why global runs twice - Neo
//onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
if (FlxG.keys.pressed.SHIFT) {
// If we want, we could just make reseting GlobalScript it's own keybind, but for now this works.
if (PlayerSettings.solo.controls.DEV_RELOAD) {
reloading = true;
Logs.trace("Reloading Global Scripts...", INFO, YELLOW);
// yeah its a bit messy, sorry. This just prevents actually reloading the actual state.
_lastAllow_Reload = MusicBeatState.ALLOW_DEV_RELOAD;
MusicBeatState.ALLOW_DEV_RELOAD = false;
// Would be better to just re-initalize GlobalScript so there aren't any lose ends.
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
}
}
});
}
public static function event<T:CancellableEvent>(name:String, event:T):T {
@@ -95,6 +106,7 @@ class GlobalScript {
if (scripts != null)
scripts.call(name, args);
}
public static function onModSwitch(newMod:String) {
call("destroy");
scripts = FlxDestroyUtil.destroy(scripts);
@@ -128,6 +128,10 @@ class HScript extends Script {
interp.execute(expr);
call("new", []);
}
#if GLOBAL_SCRIPT
funkin.backend.scripting.GlobalScript.call("onScriptSetup", [this, "hscript"]);
#end
}
public override function reload() {
@@ -83,7 +83,7 @@ class ScriptPack extends Script {
**/
public override function call(func:String, ?parameters:Array<Dynamic>):Dynamic {
for(e in scripts)
if(e.active)
if (e.active)
e.call(func, parameters);
return null;
}
@@ -2,12 +2,12 @@ package funkin.backend.scripting.events.gameplay;
final class RatingUpdateEvent extends CancellableEvent {
/**
New combo
New combo (may be null if no ratings were found)
**/
public var rating:ComboRating;
public var rating:Null<ComboRating>;
/**
Old combo (may be null)
**/
public var oldRating:ComboRating;
public var oldRating:Null<ComboRating>;
}
@@ -1,10 +1,12 @@
package funkin.backend.scripting.events.healthicon;
import flixel.util.typeLimit.OneOfTwo;
final class HealthIconChangeEvent extends CancellableEvent {
/**
* Amount
* Animation State
*/
public var amount:Int;
public var anim:OneOfTwo<String, Int>;
/**
* The health icon
@@ -1,6 +1,6 @@
package funkin.backend.scripting.events.menu.storymenu;
import funkin.menus.StoryMenuState.WeekData;
import funkin.backend.week.WeekData;
final class WeekSelectEvent extends CancellableEvent {
/**
@@ -1,6 +1,7 @@
package funkin.backend.scripting.events.note;
import funkin.game.Character;
import funkin.game.HealthIcon;
import funkin.game.Note;
final class NoteHitEvent extends CancellableEvent {
@@ -113,6 +114,10 @@ final class NoteHitEvent extends CancellableEvent {
* Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one).
*/
public var forceAnim:Null<Bool> = true;
/**
* The attached healthIcon used distinction for icons amongst others
*/
public var healthIcon:HealthIcon;
/**
* Prevents the default sing animation from being played.
@@ -1,5 +1,6 @@
package funkin.backend.scripting.events.splash;
import funkin.game.Splash;
import funkin.game.SplashGroup;
import funkin.game.Strum;
@@ -11,7 +12,7 @@ final class SplashShowEvent extends CancellableEvent {
/**
Splash that is shown
**/
public var splash:FunkinSprite;
public var splash:Splash;
/**
Strum that the splash is shown on
**/