diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index c7394c18..347ba33a 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -70,6 +70,8 @@ final class EventsData { hscriptInterp.variables.set("StrumLine", TStrumLine); hscriptInterp.variables.set("ColorWheel", TColorWheel); hscriptInterp.variables.set("DropDown", Reflect.makeVarArgs((args) -> {return args.length > 0 ? TDropDown([for (arg in args) Std.string(arg)]) : TDropDown(["null"]);})); + hscriptInterp.variables.set("Character", TCharacter); + hscriptInterp.variables.set("Stage", TStage); var hscriptParser:Parser = new Parser(); hscriptParser.allowJSON = hscriptParser.allowMetadata = false; @@ -127,4 +129,6 @@ enum EventParamType { TStrumLine; TColorWheel; TDropDown(?options:Array); + TCharacter; + TStage; } diff --git a/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx b/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx new file mode 100644 index 00000000..a98493ef --- /dev/null +++ b/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx @@ -0,0 +1,13 @@ +package funkin.backend.scripting.events; + +final class HealthIconChangeEvent extends CancellableEvent { + /** + * Amount + */ + public var amount:Int; + + /** + * The health icon + */ + public var healthIcon:funkin.game.HealthIcon; +} \ No newline at end of file diff --git a/source/funkin/backend/system/macros/BuildInfo.hx b/source/funkin/backend/system/macros/BuildInfo.hx index 37925fa5..535f6118 100644 --- a/source/funkin/backend/system/macros/BuildInfo.hx +++ b/source/funkin/backend/system/macros/BuildInfo.hx @@ -5,6 +5,7 @@ using StringTools; #if macro class BuildInfo { public static function printBuildInfo() { + if(haxe.macro.Context.defined("display")) return; var haxeVersion = haxe.macro.Context.definedValue("haxe"); Sys.println('--- BUILD INFO ---'); Sys.println('Haxe Version: ${haxeVersion}'); diff --git a/source/funkin/backend/utils/DiscordUtil.hx b/source/funkin/backend/utils/DiscordUtil.hx index 01871674..50bd229c 100644 --- a/source/funkin/backend/utils/DiscordUtil.hx +++ b/source/funkin/backend/utils/DiscordUtil.hx @@ -107,14 +107,28 @@ final class DiscordUtil public static function loadScript() { + #if DISCORD_RPC if (script != null) { call("destroy"); script = FlxDestroyUtil.destroy(script); } script = Script.create(Paths.script('data/discord')); + script.set("ActivityType", { + Playing: ActivityType.Playing, + PLAYING: ActivityType.Playing, + Streaming: ActivityType.Streaming, + STREAMING: ActivityType.Streaming, + Watching: ActivityType.Watching, + WATCHING: ActivityType.Watching, + Listening: ActivityType.Listening, + LISTENING: ActivityType.Listening, + Competing: ActivityType.Competing, + COMPETING: ActivityType.Competing + }); // script.setParent(DiscordUtil); script.load(); + #end } public static function changePresence(details:String, state:String, ?smallImageKey:String) @@ -218,6 +232,8 @@ final class DiscordUtil Utils.safeSetWrapper(dp.joinSecret, data.joinSecret, fixString); Utils.safeSetWrapper(dp.spectateSecret, data.spectateSecret, fixString); Utils.safeSet(dp.instance, data.instance); + Utils.safeSet(dp.activityType, data.activityType); + Utils.safeSetWrapper(dp.streamUrl, data.streamUrl, fixString); if (data.matchSecret == null && data.joinSecret == null && data.spectateSecret == null) { Utils.safeSetWrapper(dp.button1Label, data.button1Label, fixString); @@ -476,6 +492,8 @@ typedef DPresence = var ?button1Url:String; /* max 512 bytes */ var ?button2Label:String; /* max 32 bytes */ var ?button2Url:String; /* max 512 bytes */ + var ?activityType:ActivityType; + var ?streamUrl:String; /* max 512 bytes */ } typedef DEvents = diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index 18b2db21..77cb4ba2 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -5,6 +5,8 @@ import flixel.util.FlxColor; import funkin.backend.chart.ChartData.ChartEvent; import funkin.backend.chart.EventsData; import funkin.backend.system.Conductor; +import funkin.game.Character; +import funkin.game.Stage; using StringTools; @@ -163,6 +165,20 @@ class CharterEventScreen extends UISubstateWindow { var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, Std.int(Math.abs(options.indexOf(cast value)))); paramsPanel.add(dropdown); paramsFields.push(dropdown); dropdown; + case TCharacter: + addLabel(); + var charFileList = Character.getList(false); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + textBox.suggestItems = charFileList; + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; + case TStage: + addLabel(); + var stageFileList = Stage.getList(false); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + textBox.suggestItems = stageFileList; + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; default: paramsFields.push(null); null; diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index d55bf14b..1c7bb59d 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -24,6 +24,11 @@ class HealthIcon extends FlxSprite */ public var healthSteps:Map = null; + /** + * current animation state + */ + public var curAnimState:Int = -1; + /** * Helper for HScript who can't make maps * @param steps Something like this: `[[0, 1], [20, 0]]` @@ -91,7 +96,14 @@ class HealthIcon extends FlxSprite i = icon; } } - if (i >= 0) animation.curAnim.curFrame = i; + if (i >= 0 && curAnimState != i) { + var event = EventManager.get(funkin.backend.scripting.events.HealthIconChangeEvent).recycle(i, this); + funkin.backend.scripting.GlobalScript.event("onHealthIconAnimChange", event); + if (!event.cancelled) + animation.curAnim.curFrame = event.amount; + + curAnimState = event.amount; + } } } } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index be06c3e6..d6e9d18a 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1425,6 +1425,8 @@ class PlayState extends MusicBeatState FlxG.sound.music.stop(); for (strumLine in strumLines.members) strumLine.vocals.stop(); + deathCounter++; + openSubState(new GameOverSubstate(event.x, event.y, event.deathCharID, event.isPlayer, event.gameOverSong, event.lossSFX, event.retrySFX)); scripts.event("onPostGameOver", event); diff --git a/source/funkin/game/SplashHandler.hx b/source/funkin/game/SplashHandler.hx index dc6f7533..1776bdb8 100644 --- a/source/funkin/game/SplashHandler.hx +++ b/source/funkin/game/SplashHandler.hx @@ -40,7 +40,10 @@ class SplashHandler extends FlxTypedGroup { var __grp:SplashGroup; public function showSplash(name:String, strum:Strum) { __grp = getSplashGroup(name); - add(__grp.showOnStrum(strum)); + var event = funkin.backend.scripting.EventManager.get(funkin.backend.scripting.events.DynamicEvent).recycle(__grp.showOnStrum(strum), strum); + event = PlayState.instance.scripts.event("onSplashShown", event); + if (!event.cancelled) + add(event.value1); // max 8 rendered splashes while(members.length > 8) diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index 0e179f71..5a0299d8 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -14,6 +14,8 @@ class Strum extends FlxSprite { public var cpu = false; // Unused public var lastHit:Float = -5000; + public var strumLine = null; + public var scrollSpeed:Null = null; // custom scroll speed per strum public var noteAngle:Null = null; diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index d743dd79..e00e58f8 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -303,6 +303,7 @@ class StrumLine extends FlxTypedGroup { animPrefix = strumAnimPrefix[i % strumAnimPrefix.length]; var babyArrow:Strum = new Strum(startingPos.x + ((Note.swagWidth * strumScale) * i), startingPos.y); babyArrow.ID = i; + babyArrow.strumLine = this; if(data.scrollSpeed != null) babyArrow.scrollSpeed = data.scrollSpeed;