diff --git a/source/funkin/backend/system/CommandLineHandler.hx b/source/funkin/backend/system/CommandLineHandler.hx index e6d74007f..4518d3002 100644 --- a/source/funkin/backend/system/CommandLineHandler.hx +++ b/source/funkin/backend/system/CommandLineHandler.hx @@ -3,6 +3,29 @@ package funkin.backend.system; #if sys import sys.FileSystem; final class CommandLineHandler { + @:noPrivateAccess + private static function __showHelpText():Void { + // Just put it all in a string array =) + + final STRINGS:Array = [ + "--- Codename Engine Command Line Help ---", + "", + "-help | Show this help", + #if MOD_SUPPORT + "-mod [mod name] | Load a specific mod", + "-modfolder [path] | Sets the mod folder path", + "-addonsfolder [path] | Sets the addons folder path", + #end + "-nocolor | Disables colors in the terminal", + "-nogpubitmap | Forces GPU only bitmaps off", + "-nocwdfix | Turns off automatic working directory fix" + ]; + + for (s in STRINGS) { + Sys.println(s); + } + } + public static function parseCommandLine(cmd:Array) { var i:Int = 0; while(i < cmd.length) { @@ -10,16 +33,7 @@ final class CommandLineHandler { case null: break; case "-h" | "-help" | "help": - Sys.println("-- Codename Engine Command Line help --"); - Sys.println("-help | Show this help"); - #if MOD_SUPPORT - Sys.println("-mod [mod name] | Load a specific mod"); - Sys.println("-modfolder [path] | Sets the mod folder path"); - Sys.println("-addonsfolder [path] | Sets the addons folder path"); - #end - Sys.println("-nocolor | Disables colors in the terminal"); - Sys.println("-nogpubitmap | Forces GPU only bitmaps off"); - Sys.println("-nocwdfix | Turns off automatic working directory fix"); + __showHelpText(); Sys.exit(0); #if MOD_SUPPORT case "-m" | "-mod" | "-currentmod": diff --git a/source/funkin/backend/system/updating/AsyncUpdater.hx b/source/funkin/backend/system/updating/AsyncUpdater.hx index 36b79ad40..8ddc34237 100644 --- a/source/funkin/backend/system/updating/AsyncUpdater.hx +++ b/source/funkin/backend/system/updating/AsyncUpdater.hx @@ -25,19 +25,8 @@ class AsyncUpdater { } #end - - #if windows - public static var executableGitHubName:String = "update-windows.exe"; - public static var executableName:String = "CodenameEngine.exe"; - #end - #if linux - public static var executableGitHubName:String = "update-linux"; - public static var executableName:String = "CodenameEngine"; - #end - #if mac - public static var executableGitHubName:String = "update-mac"; - public static var executableName:String = "CodenameEngine"; - #end + public static var executableName:String = UpdateUtil.getNameOfExecutable(); + public static var executableGitHubName:String = UpdateUtil.getNameOfUpdateExecutable(); public var releases:Array; public var progress:UpdaterProgress = new UpdaterProgress(); diff --git a/source/funkin/backend/system/updating/UpdateUtil.hx b/source/funkin/backend/system/updating/UpdateUtil.hx index c3f496540..122dabedd 100644 --- a/source/funkin/backend/system/updating/UpdateUtil.hx +++ b/source/funkin/backend/system/updating/UpdateUtil.hx @@ -31,6 +31,19 @@ class UpdateUtil { Thread.create(checkForUpdates.bind(true, false)); } + public static function getNameOfExecutable():String + { + return #if windows "CodenameEngine.exe" #else "CodenameEngine" #end; + } + + public static function getNameOfUpdateExecutable():String + { + var target:String = #if windows "windows.exe" #end + #if mac "mac" #end + #if linux "linux" #end; + return 'update-${target}'; + } + public static function waitForUpdates(force = false, callback:UpdateCheckCallback->Void, lazy = false) { if (__mutex.tryAcquire()) { __mutex.release(); diff --git a/source/funkin/game/Countdown.hx b/source/funkin/game/Countdown.hx new file mode 100644 index 000000000..c2f1091b6 --- /dev/null +++ b/source/funkin/game/Countdown.hx @@ -0,0 +1,150 @@ +package funkin.game; + +import flixel.tweens.misc.VarTween; +import flixel.tweens.FlxTween; +import flixel.sound.FlxSound; +import funkin.backend.scripting.events.gameplay.CountdownEvent; + +enum CountdownAnimationPreset { + + /** + * The default animation for Codename Engine's countdown. + */ + DEFAULT; + + /** + * The classic animation, similar to Funkin's countdown. + */ + CLASSIC; + + /** + * A more enhanced version of Funkin's countdown animation. + */ + BEATING; + +} + +typedef CountdownParams = { + + /** + * The CountdownEvent to be used. + */ + var event:CountdownEvent; + + /** + * Whether the countdown should be visible or not. + */ + var enabled:Bool; + + /** + * Whether each tick from the countdown should play a sound. + */ + var playSound:Bool; + + /** + * The animation preset to be used for the countdown. + */ + var animationPreset:CountdownAnimationPreset; + + /** + * The duration of the countdown's animation. + */ + var duration:Float; + + /** + * The speed of the countdown's animation. The lower it is, the slower it goes and vice-versa. + */ + var speed:Float; + +} + +class Countdown extends FlxTypedSpriteGroup { + public var event:CountdownEvent; + public var enabled:Bool; + public var playSound:Bool; + public var animationPreset:CountdownAnimationPreset; + public var duration:Float; + public var speed:Float; + + /** + * Create a new Countdown component. + * @param params + */ + public function new(params:CountdownParams) { + super(); + + this.event = params.event; + this.enabled = params.enabled; + this.playSound = params.playSound; + this.animationPreset = params.animationPreset; + this.duration = params.duration; + this.speed = params.speed; + + this.makeSprite(); + } + + public function makeSprite():Void { + if (!this.enabled) { + return; + } + + var sprite:FlxSprite = null; + var sound:FlxSound = null; + var tween:FlxTween = null; + + if (!this.event.cancelled) { + if (this.event.spritePath != null) { + // Add 1.0 to defaultSize if animationPreset is BEATING. + var defaultSize:Float = this.event.scale; + var isBeatingPreset:Bool = (this.animationPreset == BEATING); + var targetSize:Float = defaultSize + ((!isBeatingPreset) ? 0.0 : 0.15); + + var spr = this.event.spritePath; + + if (!Assets.exists(spr)) { + spr = Paths.image('$spr'); + } + + sprite = new FunkinSprite().loadAnimatedGraphic(spr); + sprite.scale.set(targetSize, targetSize); + sprite.scrollFactor.set(); + sprite.antialiasing = this.event.antialiasing; + sprite.updateHitbox(); + sprite.screenCenter(); + add(sprite); + + switch(this.animationPreset) { + case CLASSIC: + tween = makeTween(sprite, {alpha: 0}, FlxEase.cubeInOut); + case BEATING: + tween = makeTween(sprite, {alpha: 0, "scale.x": defaultSize, "scale.y": defaultSize}, FlxEase.expoOut); + default: // DEFAULT + tween = makeTween(sprite, {y: sprite.y + 100, alpha: 0}, FlxEase.cubeInOut); + } + } + + if (this.event.soundPath != null && this.playSound) { + var sfx = this.event.soundPath; + if (!Assets.exists(sfx)) { + sfx = Paths.sound(sfx); + } + sound = FlxG.sound.play(sfx, this.event.volume); + } + + this.event.sprite = sprite; + this.event.sound = sound; + this.event.spriteTween = tween; + this.event.cancelled = false; + } + } + + public function makeTween(sprite:FlxSprite, values:Dynamic, easing:EaseFunction):VarTween { + return FlxTween.tween(sprite, values, (this.duration / this.speed), { + ease: easing, + onComplete: function(twn:FlxTween) { + sprite.destroy(); + remove(sprite, true); + } + }); + } +} diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 04be79819..a2ddb2244 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1003,41 +1003,17 @@ class PlayState extends MusicBeatState introSprites[swagCounter], 0.6, true, null, null, null)); - var sprite:FlxSprite = null; - var sound:FlxSound = null; - var tween:FlxTween = null; + var countdown:Countdown = new Countdown({ + event: event, + enabled: true, + playSound: true, + animationPreset: DEFAULT, + duration: (Conductor.crochet / 1000), + speed: 1.0 + }); + countdown.cameras = [camHUD]; - if (!event.cancelled) { - if (event.spritePath != null) { - var spr = event.spritePath; - if (!Assets.exists(spr)) spr = Paths.image('$spr'); - - sprite = new FunkinSprite().loadAnimatedGraphic(spr); - sprite.scrollFactor.set(); - sprite.scale.set(event.scale, event.scale); - sprite.updateHitbox(); - sprite.screenCenter(); - sprite.antialiasing = event.antialiasing; - add(sprite); - tween = FlxTween.tween(sprite, {y: sprite.y + 100, alpha: 0}, Conductor.crochet / 1000, { - ease: FlxEase.cubeInOut, - onComplete: function(twn:FlxTween) - { - sprite.destroy(); - remove(sprite, true); - } - }); - } - if (event.soundPath != null) { - var sfx = event.soundPath; - if (!Assets.exists(sfx)) sfx = Paths.sound(sfx); - sound = FlxG.sound.play(sfx, event.volume); - } - } - event.sprite = sprite; - event.sound = sound; - event.spriteTween = tween; - event.cancelled = false; + add(countdown); gameAndCharsEvent("onPostCountdown", event); }