Merge branch 'main' into translations-system

This commit is contained in:
Furo
2025-07-21 12:58:53 +02:00
592 changed files with 20908 additions and 4426 deletions
@@ -3,7 +3,7 @@ package funkin.backend.scripting;
import flixel.FlxState;
import funkin.backend.scripting.events.*;
class EventManager {
final class EventManager {
// map doesn't work for that
public static var eventValues:Array<CancellableEvent> = [];
public static var eventKeys:Array<Class<CancellableEvent>> = [];
+27 -13
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,17 +50,13 @@ class GlobalScript {
});
FlxG.signals.postUpdate.add(function() {
call("postUpdate", [FlxG.elapsed]);
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;
}
if (FlxG.keys.justPressed.F2)
if (PlayerSettings.solo.controls.DEV_CONSOLE)
NativeAPI.allocConsole();
});
FlxG.signals.preDraw.add(function() {
@@ -74,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 {
@@ -93,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() {
+1 -1
View File
@@ -300,7 +300,7 @@ class Script extends FlxBasic implements IFlxDestroyable {
if(remappedNames.exists(fileName))
fileName = remappedNames.get(fileName);
Logs.traceColored([
Logs.logText('${fileName}: ', GREEN),
Logs.logText(fileName + ': ', GREEN),
Logs.logText(Std.string(v))
], TRACE);
}
@@ -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
**/