diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index f67ee922..d817f142 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -5,7 +5,7 @@ import flixel.math.FlxMatrix; import flixel.math.FlxPoint; import flixel.math.FlxRect; import flixel.system.FlxAssets.FlxGraphicAsset; -import funkin.backend.scripting.events.PlayAnimEvent.PlayAnimContext; +import funkin.backend.scripting.events.PlayAnimContext; import funkin.backend.system.interfaces.IBeatReceiver; import funkin.backend.system.interfaces.IOffsetCompatible; import funkin.backend.utils.XMLUtil.AnimData; @@ -19,9 +19,9 @@ enum abstract XMLAnimType(Int) var BEAT = 1; var LOOP = 2; - public static function fromString(str:String, def:XMLAnimType = NONE) + public static function fromString(str:String, def:XMLAnimType = XMLAnimType.NONE) { - return switch (str.trim().toLowerCase()) + return switch (StringTools.trim(str).toLowerCase()) { case "none": NONE; case "beat" | "onbeat": BEAT; diff --git a/source/funkin/backend/scripting/events/DirectionAnimEvent.hx b/source/funkin/backend/scripting/events/DirectionAnimEvent.hx index 9592e7d0..a23626f4 100644 --- a/source/funkin/backend/scripting/events/DirectionAnimEvent.hx +++ b/source/funkin/backend/scripting/events/DirectionAnimEvent.hx @@ -1,7 +1,5 @@ package funkin.backend.scripting.events; -import funkin.backend.scripting.events.PlayAnimEvent.PlayAnimContext; - final class DirectionAnimEvent extends CancellableEvent { /** Default animation that will be played diff --git a/source/funkin/backend/scripting/events/PlayAnimContext.hx b/source/funkin/backend/scripting/events/PlayAnimContext.hx new file mode 100644 index 00000000..f3c9e211 --- /dev/null +++ b/source/funkin/backend/scripting/events/PlayAnimContext.hx @@ -0,0 +1,36 @@ +package funkin.backend.scripting.events; + +/** + Contains all contexts possible for `PlayAnimEvent`. +**/ +enum abstract PlayAnimContext(String) { + /** + No context was given for the animation. + The character won't dance until the animation is finished + **/ + var NONE = null; + + /** + Whenever a note is hit and a sing animation will be played. + The character will only dance after their holdTime is reached. + **/ + var SING = "SING"; + + /** + Whenever a dance animation is played. + The character's dancing wont be blocked. + **/ + var DANCE = "DANCE"; + + /** + Whenever a note is missed and a miss animation will be played. + Only for scripting, since it has the same effects as SING. + **/ + var MISS = "MISS"; + + /** + Locks the character's animation. + Prevents the character from dancing, even if the animation ended. + **/ + var LOCK = "LOCK"; +} \ No newline at end of file diff --git a/source/funkin/backend/scripting/events/PlayAnimEvent.hx b/source/funkin/backend/scripting/events/PlayAnimEvent.hx index ca88c408..a555c3ed 100644 --- a/source/funkin/backend/scripting/events/PlayAnimEvent.hx +++ b/source/funkin/backend/scripting/events/PlayAnimEvent.hx @@ -25,39 +25,4 @@ final class PlayAnimEvent extends CancellableEvent { Context of the animation **/ public var context:PlayAnimContext; -} - -/** - Contains all contexts possible for `PlayAnimEvent`. -**/ -enum abstract PlayAnimContext(String) { - /** - No context was given for the animation. - The character won't dance until the animation is finished - **/ - var NONE = null; - - /** - Whenever a note is hit and a sing animation will be played. - The character will only dance after their holdTime is reached. - **/ - var SING = "SING"; - - /** - Whenever a dance animation is played. - The character's dancing wont be blocked. - **/ - var DANCE = "DANCE"; - - /** - Whenever a note is missed and a miss animation will be played. - Only for scripting, since it has the same effects as SING. - **/ - var MISS = "MISS"; - - /** - Locks the character's animation. - Prevents the character from dancing, even if the animation ended. - **/ - var LOCK = "LOCK"; } \ No newline at end of file diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 747f898d..40ddcd74 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -7,8 +7,11 @@ import flixel.util.FlxColor; import funkin.backend.FunkinSprite; import funkin.backend.scripting.DummyScript; import funkin.backend.scripting.Script; -import funkin.backend.scripting.events.*; -import funkin.backend.scripting.events.PlayAnimEvent.PlayAnimContext; +import funkin.backend.scripting.events.DanceEvent; +import funkin.backend.scripting.events.DirectionAnimEvent; +import funkin.backend.scripting.events.PlayAnimContext; +import funkin.backend.scripting.events.PlayAnimEvent; +import funkin.backend.scripting.events.PointEvent; import funkin.backend.system.Conductor; import funkin.backend.system.interfaces.IBeatReceiver; import funkin.backend.system.interfaces.IOffsetCompatible; @@ -65,11 +68,11 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset return new FlxPoint(event.x, event.y); } + var singAnims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"]; + public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, Force:Bool = true, Reversed:Bool = false, Frame:Int = 0) { - var anims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"]; - - var event = EventManager.get(DirectionAnimEvent).recycle(anims[direction] + suffix, direction, suffix, Context, Reversed, Frame, Force); + var event = EventManager.get(DirectionAnimEvent).recycle(singAnims[direction % singAnims.length] + suffix, direction, suffix, Context, Reversed, Frame, Force); script.call("onPlaySingAnim", [event]); if (!event.cancelled) playAnim(event.animName, event.force, event.context, event.reversed, event.frame); diff --git a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx index 47f2a58e..8885f56a 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx @@ -3,7 +3,7 @@ package funkin.game.cutscenes.dialogue; import flixel.addons.text.FlxTypeText; import flixel.sound.FlxSound; import funkin.backend.scripting.Script; -import funkin.backend.scripting.events.PlayAnimEvent.PlayAnimContext; +import funkin.backend.scripting.events.PlayAnimContext; import funkin.backend.scripting.events.PlayAnimEvent; import funkin.backend.scripting.events.dialogue.*; import haxe.xml.Access; diff --git a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx index 502b1a83..9fe4c44e 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx @@ -2,6 +2,7 @@ package funkin.game.cutscenes.dialogue; import flixel.tweens.FlxTween; import funkin.backend.scripting.Script; +import funkin.backend.scripting.events.PlayAnimContext; import funkin.backend.scripting.events.PlayAnimEvent; import funkin.backend.scripting.events.dialogue.*; import haxe.xml.Access; diff --git a/source/hscript/Config.hx b/source/hscript/Config.hx index d12ccb5f..dcfcc10e 100644 --- a/source/hscript/Config.hx +++ b/source/hscript/Config.hx @@ -25,7 +25,6 @@ class Config { ]; public static final DISALLOW_ABSTRACT_AND_ENUM = [ - "funkin.backend.FunkinSprite", // Error: String has no field trim, Due to Func - "funkin.backend.scripting.events.PlayAnimEvent", // Error: expected member name or ';' after declaration specifiers, Due to Func + "funkin.backend.scripting.events.PlayAnimContext", // Error: expected member name or ';' after declaration specifiers, Due to define macro from math.h ]; } \ No newline at end of file