From 0af39387df33e17432164f0540a6fa61a34485cb Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sun, 26 Mar 2023 20:22:16 +0200 Subject: [PATCH] Added support for multiple arguments on trace Added quick skip for title state Small Fixes --- source/funkin/menus/TitleState.hx | 32 ++++--- source/funkin/system/FunkinSprite.hx | 18 ++-- source/funkin/system/Logs.hx | 21 +++-- source/funkin/system/MusicBeatSubstate.hx | 102 +++++++++++----------- source/funkin/system/Paths.hx | 10 +-- 5 files changed, 97 insertions(+), 86 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index e81c81dd..f4f26fae 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -156,6 +156,11 @@ class TitleState extends MusicBeatState #end } + if (pressedEnter && transitioning && skippedIntro) { + FlxG.camera.stopFX();// FlxG.camera.visible = false; + goToMainMenu(); + } + if (pressedEnter && !transitioning && skippedIntro) { pressEnter(); @@ -176,21 +181,22 @@ class TitleState extends MusicBeatState transitioning = true; // FlxG.sound.music.stop(); - new FlxTimer().start(2, function(tmr:FlxTimer) - { - #if UPDATE_CHECKING - var report = hasCheckedUpdates ? null : funkin.updating.UpdateUtil.checkForUpdates(); - hasCheckedUpdates = true; + new FlxTimer().start(2, (_) -> goToMainMenu()); + } - if (report != null && report.newUpdate) { - FlxG.switchState(new funkin.updating.UpdateAvailableScreen(report)); - } else { - FlxG.switchState(new MainMenuState()); - } - #else + function goToMainMenu() { + #if UPDATE_CHECKING + var report = hasCheckedUpdates ? null : funkin.updating.UpdateUtil.checkForUpdates(); + hasCheckedUpdates = true; + + if (report != null && report.newUpdate) { + FlxG.switchState(new funkin.updating.UpdateAvailableScreen(report)); + } else { FlxG.switchState(new MainMenuState()); - #end - }); + } + #else + FlxG.switchState(new MainMenuState()); + #end } public function createCoolText(textArray:Array) diff --git a/source/funkin/system/FunkinSprite.hx b/source/funkin/system/FunkinSprite.hx index 4d44231e..40d416b4 100644 --- a/source/funkin/system/FunkinSprite.hx +++ b/source/funkin/system/FunkinSprite.hx @@ -18,7 +18,7 @@ abstract XMLAnimType(Int) { public static function fromString(str:String, def:XMLAnimType = NONE) { return switch(str.trim().toLowerCase()) { case "none": NONE; - case "beat" | "onbeat": BEAT; + case "beat" | "onbeat": BEAT; case "loop": LOOP; default: def; } @@ -61,12 +61,10 @@ class FunkinSprite extends FlxSprite implements IBeatReceiver implements IOffset public function loadSprite(path:String, Unique:Bool = false, Key:String = null) { var noExt = Path.withoutExtension(path); - if (Assets.exists('$noExt/Animation.json') - && Assets.exists('$noExt/spritemap1.json') - && Assets.exists('$noExt/spritemap1.png')) { - atlasPath = noExt; - animateAtlas = new FlxAnimate(x, y, noExt); - } + if (Assets.exists('$noExt/Animation.json')) { + atlasPath = noExt; + animateAtlas = new FlxAnimate(x, y, noExt); + } else { frames = CoolUtil.loadFrames(path, Unique, Key, true); } @@ -152,8 +150,8 @@ class FunkinSprite extends FlxSprite implements IBeatReceiver implements IOffset } public override function destroy() { - animateAtlas = FlxDestroyUtil.destroy(animateAtlas); - super.destroy(); + animateAtlas = FlxDestroyUtil.destroy(animateAtlas); + super.destroy(); } #end @@ -214,10 +212,10 @@ class FunkinSprite extends FlxSprite implements IBeatReceiver implements IOffset if (!animation.exists(AnimName)) return; animation.play(AnimName, Force, Reversed, Frame); } - var daOffset = getAnimOffset(AnimName); rotOffset.set(daOffset.x, daOffset.y); + daOffset.putWeak(); lastAnimContext = Context; } diff --git a/source/funkin/system/Logs.hx b/source/funkin/system/Logs.hx index a7a8ec10..b04c824e 100644 --- a/source/funkin/system/Logs.hx +++ b/source/funkin/system/Logs.hx @@ -13,20 +13,29 @@ class Logs { public static function init() { Log.trace = function(v : Dynamic, ?infos : Null) { - __showInConsole(prepareColoredTrace([ + var data = [ logText('${infos.fileName}:${infos.lineNumber}: ', CYAN), logText(Std.string(v)) - ], TRACE)); + ]; + + if (infos.customParams != null) { + for (i in infos.customParams) { + data.push( + logText("," + Std.string(i)) + ); + } + } + __showInConsole(prepareColoredTrace(data, TRACE)); }; LogFrontEnd.onLogs = function(Data, Style, FireOnce) { var prefix = "[FLIXEL]"; var color:ConsoleColor = LIGHTGRAY; var level:Level = INFO; - if (Style == LogStyle.CONSOLE) {prefix = "> "; color = WHITE; level = INFO; } - if (Style == LogStyle.ERROR) {prefix = "[FLIXEL]"; color = RED; level = ERROR; } - if (Style == LogStyle.NORMAL) {prefix = "[FLIXEL]"; color = WHITE; level = INFO; } - if (Style == LogStyle.NOTICE) {prefix = "[FLIXEL]"; color = GREEN; level = WARNING;} + if (Style == LogStyle.CONSOLE) {prefix = "> "; color = WHITE; level = INFO; } else + if (Style == LogStyle.ERROR) {prefix = "[FLIXEL]"; color = RED; level = ERROR; } else + if (Style == LogStyle.NORMAL) {prefix = "[FLIXEL]"; color = WHITE; level = INFO; } else + if (Style == LogStyle.NOTICE) {prefix = "[FLIXEL]"; color = GREEN; level = WARNING;} else if (Style == LogStyle.WARNING) {prefix = "[FLIXEL]"; color = YELLOW; level = WARNING;} var d:Dynamic = Data; diff --git a/source/funkin/system/MusicBeatSubstate.hx b/source/funkin/system/MusicBeatSubstate.hx index 2299fd4f..ad0786ef 100644 --- a/source/funkin/system/MusicBeatSubstate.hx +++ b/source/funkin/system/MusicBeatSubstate.hx @@ -15,51 +15,49 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver private var lastBeat:Float = 0; private var lastStep:Float = 0; - /** * Current step */ - public var curStep(get, never):Int; - /** - * Current beat - */ - public var curBeat(get, never):Int; - /** - * Current beat - */ - public var curMeasure(get, never):Int; - /** - * Current step, as a `Float` (ex: 4.94, instead of 4) - */ - public var curStepFloat(get, never):Float; - /** - * Current beat, as a `Float` (ex: 1.24, instead of 1) - */ - public var curBeatFloat(get, never):Float; - /** - * Current beat, as a `Float` (ex: 1.24, instead of 1) - */ - public var curMeasureFloat(get, never):Float; - /** - * Current song position (in milliseconds). - */ - public var songPos(get, never):Float; - - inline function get_curStep():Int - return Conductor.curStep; - inline function get_curBeat():Int - return Conductor.curBeat; - inline function get_curMeasure():Int - return Conductor.curMeasure; - inline function get_curStepFloat():Float - return Conductor.curStepFloat; - inline function get_curBeatFloat():Float - return Conductor.curBeatFloat; - inline function get_curMeasureFloat():Float - return Conductor.curMeasureFloat; - inline function get_songPos():Float - return Conductor.songPosition; + public var curStep(get, never):Int; + /** + * Current beat + */ + public var curBeat(get, never):Int; + /** + * Current beat + */ + public var curMeasure(get, never):Int; + /** + * Current step, as a `Float` (ex: 4.94, instead of 4) + */ + public var curStepFloat(get, never):Float; + /** + * Current beat, as a `Float` (ex: 1.24, instead of 1) + */ + public var curBeatFloat(get, never):Float; + /** + * Current beat, as a `Float` (ex: 1.24, instead of 1) + */ + public var curMeasureFloat(get, never):Float; + /** + * Current song position (in milliseconds). + */ + public var songPos(get, never):Float; + inline function get_curStep():Int + return Conductor.curStep; + inline function get_curBeat():Int + return Conductor.curBeat; + inline function get_curMeasure():Int + return Conductor.curMeasure; + inline function get_curStepFloat():Float + return Conductor.curStepFloat; + inline function get_curBeatFloat():Float + return Conductor.curBeatFloat; + inline function get_curMeasureFloat():Float + return Conductor.curMeasureFloat; + inline function get_songPos():Float + return Conductor.songPosition; /** * Current injected script attached to the state. To add one, create a file at path "data/states/stateName" (ex: "data/states/PauseMenuSubstate.hx") @@ -73,17 +71,17 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver /** * Game Controls. (All players / Solo) */ - public var controls(get, never):Controls; + public var controls(get, never):Controls; - /** - * Game Controls (Player 1 only) - */ - public var controlsP1(get, never):Controls; - - /** - * Game Controls (Player 2 only) - */ - public var controlsP2(get, never):Controls; + /** + * Game Controls (Player 1 only) + */ + public var controlsP1(get, never):Controls; + + /** + * Game Controls (Player 2 only) + */ + public var controlsP2(get, never):Controls; inline function get_controls():Controls return PlayerSettings.solo.controls; @@ -247,7 +245,7 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver public var parent:FlxState; public function onSubstateOpen() { - + } public override function resetSubState() { diff --git a/source/funkin/system/Paths.hx b/source/funkin/system/Paths.hx index 28fd8b22..f9c9de58 100644 --- a/source/funkin/system/Paths.hx +++ b/source/funkin/system/Paths.hx @@ -59,7 +59,7 @@ class Paths { return 'assets/$file'; } - + inline static public function file(file:String, type:AssetType = TEXT, ?library:String) { return getPath(file, type, library); @@ -96,9 +96,9 @@ class Paths } inline static public function ps1(key:String, ?library:String) - { - return getPath('data/$key.ps1', TEXT, library); - } + { + return getPath('data/$key.ps1', TEXT, library); + } static public function sound(key:String, ?library:String) { @@ -153,7 +153,7 @@ class Paths difficulty = difficulty.toLowerCase(); song = song.toLowerCase(); - var difficultyEnd = (difficulty == "normal") ? "" : '-$difficulty'; + //var difficultyEnd = (difficulty == "normal") ? "" : '-$difficulty'; // songs/your-song/charts/hard.json var p = getPath('songs/$song/charts/$difficulty.json', TEXT, null);