From 4ab261e176d05091b654e5fd190f7c2c23ad7980 Mon Sep 17 00:00:00 2001 From: HackDev <80620538+Hackx2@users.noreply.github.com> Date: Wed, 12 Feb 2025 23:45:56 +0000 Subject: [PATCH] no --- source/flixel/AttachedFlxSprite.hx | 1 - source/flixel/BetterFlxSprite.hx | 14 +++ .../backend/system/initialization/Logs.hx | 3 +- source/funkin/game/objects/CampaignUI.hx | 39 +++---- source/funkin/game/states/FreeplayState.hx | 2 +- source/funkin/game/states/StoryMenuState.hx | 105 ++++++++++-------- 6 files changed, 93 insertions(+), 71 deletions(-) create mode 100644 source/flixel/BetterFlxSprite.hx diff --git a/source/flixel/AttachedFlxSprite.hx b/source/flixel/AttachedFlxSprite.hx index 318f75d..536fec8 100644 --- a/source/flixel/AttachedFlxSprite.hx +++ b/source/flixel/AttachedFlxSprite.hx @@ -1,7 +1,6 @@ package flixel; import funkin.backend.utils.Paths; -import flixel.FlxSprite; class AttachedFlxSprite extends FlxSprite { diff --git a/source/flixel/BetterFlxSprite.hx b/source/flixel/BetterFlxSprite.hx new file mode 100644 index 0000000..01d9a7b --- /dev/null +++ b/source/flixel/BetterFlxSprite.hx @@ -0,0 +1,14 @@ +package flixel; + +/** +* Used to set data inside a flxsprite. +*/ +class BetterFlxSprite extends flixel.FlxSprite +{ + public var data:Map = new Map(); + + public function new(?X:Float = 0, ?Y:Float = 0, ?FlxGraphicAsset:flixel.system.FlxAssets.FlxGraphicAsset):Void + { + super(X, Y, FlxGraphicAsset); + } +} diff --git a/source/funkin/backend/system/initialization/Logs.hx b/source/funkin/backend/system/initialization/Logs.hx index 83ee25b..0eefd13 100644 --- a/source/funkin/backend/system/initialization/Logs.hx +++ b/source/funkin/backend/system/initialization/Logs.hx @@ -23,7 +23,6 @@ class Logs // needs rework ... public static function print(v:Dynamic, ?color:TColor, ?infos:PosInfos) // sorry but, you don't need PosInfo lmao { - trace(infos.className); if (color != null) Terminal.instance.fg(color); trace(v, infos); @@ -57,7 +56,7 @@ class Logs // needs rework ... // for (param in infos.customParams) // extra += ", " + param; - final logThing:String = '[${prefix}]: ${v + (extra == "" ? '' : extra)} : ${infos.fileName + ":" + infos.lineNumber}'; + final logThing:String = '[${prefix}]: ${v + (extra == "" ? '' : extra)} : source/${infos.className.replace('.','/') + ":" + infos.lineNumber}'; #if js if (js.Syntax.typeof(untyped console) != "undefined" && (untyped console).log != null) (untyped console).log(logThing); diff --git a/source/funkin/game/objects/CampaignUI.hx b/source/funkin/game/objects/CampaignUI.hx index 4acb5e2..d75d114 100644 --- a/source/funkin/game/objects/CampaignUI.hx +++ b/source/funkin/game/objects/CampaignUI.hx @@ -3,9 +3,9 @@ package funkin.game.objects; // i'll doc later -orbl private enum abstract DaArrowType(String) to String from String { - final LEFT = "left"; - final RIGHT = "right"; - final LOCK = "lock"; + final LEFT:String = "left"; + final RIGHT:String = "right"; + final LOCK:String = "lock"; } // i hate my life @@ -28,8 +28,8 @@ class CampaignUI extends FlxSprite animation.addByPrefix('press', 'arrow push $TYPE'); } else - animation.addByPrefix('lock', TYPE); - animation.play(animation.getByName('idle') != null ? 'idle' : 'lock'); + animation.addByPrefix('idle', TYPE); + animation.play('idle'); antialiasing = ClientPrefs.data.antialiasing; @@ -39,18 +39,19 @@ class CampaignUI extends FlxSprite } /** - * Bindable event + * Bind a event to a specific map value. */ public function bind(tag:String, func:CampaignUI->Void):Void // enum maybe?? events.set(tag, func); + /** + * Mainly used to GET functions from the map `events`... + */ private function get(tag:String):NullVoid> { - var GET_REQUEST = events.get(tag); - if (GET_REQUEST != null) - return GET_REQUEST; - else - return (void) -> {}; // fail safe, kinda... + final GET_REQUEST:CampaignUI->Void = events.get(tag); + if (GET_REQUEST != null) return GET_REQUEST; + return (void) -> {}; // fail safe, kinda... } override function update(elapsed:Float):Void @@ -60,17 +61,13 @@ class CampaignUI extends FlxSprite if (!shouldReact) return; - if (FlxG.mouse.overlaps(this, camera)) + if ((isSelected = FlxG.mouse.overlaps(this, camera)) && FlxG.mouse.justPressed) { - if (FlxG.mouse.justPressed) - get("clicked")(this); - isSelected = true; - FlxTween.tween(this.scale, {x: _defaultSize.x + .05, y: _defaultSize.y + .05}, .1, {ease: FlxEase.circOut}); - } - else - { - isSelected = false; - FlxTween.tween(this.scale, {x: _defaultSize.x, y: _defaultSize.y}, .1, {ease: FlxEase.circOut}); + FlxTween.tween(this, {"scale.x": this.scale.x * 0.85, "scale.y": this.scale.y * 0.85}, 0.2, {type: BACKWARD, ease: FlxEase.cubeOut}); + //if(animation.getByName('press') != null) animation.play('press'); + get("clicked")(this); + + new FlxTimer().start(.5, (_) -> {scale.set(_defaultSize.x, _defaultSize.y); animation.play('idle');}); } } } diff --git a/source/funkin/game/states/FreeplayState.hx b/source/funkin/game/states/FreeplayState.hx index 3f6c27b..b763591 100644 --- a/source/funkin/game/states/FreeplayState.hx +++ b/source/funkin/game/states/FreeplayState.hx @@ -79,7 +79,7 @@ class FreeplayState extends MusicBeatState //Paths.clearUnusedMemory(); persistentUpdate = true; - PlayState.isStoryMode = false; + PlayState.isStoryMode = FlxG.mouse.visible = false; WeekData.reloadWeekFiles(false); #if DISCORD_ALLOWED diff --git a/source/funkin/game/states/StoryMenuState.hx b/source/funkin/game/states/StoryMenuState.hx index 50ece0c..6bd0329 100644 --- a/source/funkin/game/states/StoryMenuState.hx +++ b/source/funkin/game/states/StoryMenuState.hx @@ -19,6 +19,7 @@ import flixel.util.FlxTimer; import flixel.graphics.FlxGraphic; import funkin.backend.Song; +@:access(funkin.game.objects.CampaignUI) class StoryMenuState extends MusicBeatState { public static var weekCompleted:Map = new Map(); @@ -26,6 +27,7 @@ class StoryMenuState extends MusicBeatState var scoreText:FlxText; private static var lastDifficultyName:String = ''; + var curDifficulty:Int = 1; var txtWeekTitle:FlxText; @@ -61,17 +63,17 @@ class StoryMenuState extends MusicBeatState DiscordClient.changePresence("In the Menus", null); #end - if(WeekData.weeksList.length < 1) + if (WeekData.weeksList.length < 1) { FlxTransitionableState.skipNextTransIn = true; persistentUpdate = false; MusicBeatState.switchState(new ErrorState("NO WEEKS ADDED FOR STORY MODE\n\nPress ACCEPT to go to the Week Editor Menu.\nPress BACK to return to Main Menu.", - function() MusicBeatState.switchState(new WeekEditorState()), - function() MusicBeatState.switchState(new MainMenuState()))); + function() MusicBeatState.switchState(new WeekEditorState()), function() MusicBeatState.switchState(new MainMenuState()))); return; } - if(curWeek >= WeekData.weeksList.length) curWeek = 0; + if (curWeek >= WeekData.weeksList.length) + curWeek = 0; scoreText = new FlxText(10, 10, 0, 'WEEK SCORE: ${lerpScore}', 36); scoreText.setFormat(Paths.font("vcr.ttf"), 32); @@ -101,7 +103,7 @@ class StoryMenuState extends MusicBeatState { var weekFile:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[i]); var isLocked:Bool = weekIsLocked(WeekData.weeksList[i]); - if(!isLocked || !weekFile.hiddenUntilUnlocked) + if (!isLocked || !weekFile.hiddenUntilUnlocked) { loadedWeeks.push(weekFile); WeekData.setDirectoryFromWeek(weekFile); @@ -139,21 +141,20 @@ class StoryMenuState extends MusicBeatState difficultySelectors = new FlxGroup(); add(difficultySelectors); - + leftArrow = new CampaignUI(850, grpWeekText.members[0].y + 10, "left"); - leftArrow.bind('clicked', (obj:CampaignUI)->{ - trace('LOL LEFT'); - }); + leftArrow.bind('clicked', (obj:CampaignUI) -> changeDifficulty(-1)); difficultySelectors.add(leftArrow); rightArrow = new CampaignUI(leftArrow.x + 376, leftArrow.y, "right"); + rightArrow.bind('clicked', (obj:CampaignUI) -> changeDifficulty(1)); difficultySelectors.add(rightArrow); Difficulty.resetList(); - if(lastDifficultyName == '') + if (lastDifficultyName == '') lastDifficultyName = Difficulty.getDefault(); curDifficulty = Math.round(Math.max(0, Difficulty.defaultList.indexOf(lastDifficultyName))); - + sprDifficulty = new FlxSprite(0, leftArrow.y); sprDifficulty.antialiasing = ClientPrefs.data.antialiasing; difficultySelectors.add(sprDifficulty); @@ -164,7 +165,7 @@ class StoryMenuState extends MusicBeatState var tracksSprite:FlxSprite = new FlxSprite(FlxG.width * 0.07 + 100, bgSprite.y + 425).loadGraphic(Paths.image('Menu_Tracks')); tracksSprite.antialiasing = ClientPrefs.data.antialiasing; - tracksSprite.x -= tracksSprite.width/2; + tracksSprite.x -= tracksSprite.width / 2; add(tracksSprite); txtTracklist = new FlxText(FlxG.width * 0.05, tracksSprite.y + 60, 0, "", 32); @@ -181,7 +182,8 @@ class StoryMenuState extends MusicBeatState super.create(); } - override function closeSubState() { + override function closeSubState() + { persistentUpdate = true; changeWeek(); super.closeSubState(); @@ -189,7 +191,7 @@ class StoryMenuState extends MusicBeatState override function update(elapsed:Float) { - if(WeekData.weeksList.length < 1) + if (WeekData.weeksList.length < 1) { if (controls.BACK && !movedBack && !selectedWeek) { @@ -202,11 +204,12 @@ class StoryMenuState extends MusicBeatState } // scoreText.setFormat(Paths.font("vcr.ttf"), 32); - if(intendedScore != lerpScore) + if (intendedScore != lerpScore) { lerpScore = Math.floor(FlxMath.lerp(intendedScore, lerpScore, Math.exp(-elapsed * 30))); - if(Math.abs(intendedScore - lerpScore) < 10) lerpScore = intendedScore; - + if (Math.abs(intendedScore - lerpScore) < 10) + lerpScore = intendedScore; + scoreText.text = 'WEEK SCORE: ${lerpScore}'; } @@ -229,7 +232,7 @@ class StoryMenuState extends MusicBeatState changeDiff = true; } - if(FlxG.mouse.wheel != 0) + if (FlxG.mouse.wheel != 0) { FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); changeWeek(-FlxG.mouse.wheel); @@ -253,16 +256,16 @@ class StoryMenuState extends MusicBeatState else if (changeDiff) changeDifficulty(); - if(FlxG.keys.justPressed.CONTROL) + if (FlxG.keys.justPressed.CONTROL) { persistentUpdate = false; openSubState(new GameplayChangersSubstate()); } - else if(controls.RESET) + else if (controls.RESET) { persistentUpdate = false; openSubState(new ResetScoreSubState('', curDifficulty, '', curWeek)); - //FlxG.sound.play(Paths.sound('scrollMenu')); + // FlxG.sound.play(Paths.sound('scrollMenu')); } else if (controls.ACCEPT) selectWeek(); @@ -276,13 +279,13 @@ class StoryMenuState extends MusicBeatState } super.update(elapsed); - + var offY:Float = grpWeekText.members[curWeek].targetY; for (num => item in grpWeekText.members) item.y = FlxMath.lerp(item.targetY - offY + 480, item.y, Math.exp(-elapsed * 10.2)); for (num => lock in grpLocks.members) - lock.y = grpWeekText.members[lock.ID].y + grpWeekText.members[lock.ID].height/2 - lock.height/2; + lock.y = grpWeekText.members[lock.ID].y + grpWeekText.members[lock.ID].height / 2 - lock.height / 2; } var movedBack:Bool = false; @@ -296,7 +299,8 @@ class StoryMenuState extends MusicBeatState // We can't use Dynamic Array .copy() because that crashes HTML5, here's a workaround. var songArray:Array = []; var leWeek:Array = loadedWeeks[curWeek].songs; - for (i in 0...leWeek.length) { + for (i in 0...leWeek.length) + { songArray.push(leWeek[i][0]); } @@ -306,22 +310,23 @@ class StoryMenuState extends MusicBeatState PlayState.storyPlaylist = songArray; PlayState.isStoryMode = true; selectedWeek = true; - + var diffic = Difficulty.getFilePath(curDifficulty); - if(diffic == null) diffic = ''; - + if (diffic == null) + diffic = ''; + PlayState.storyDifficulty = curDifficulty; - + Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + diffic, PlayState.storyPlaylist[0].toLowerCase()); PlayState.campaignScore = 0; PlayState.campaignMisses = 0; } - catch(e:Dynamic) + catch (e:Dynamic) { trace('ERROR! $e'); return; } - + if (stopspamming == false) { FlxG.sound.play(Paths.sound('confirmMenu')); @@ -340,9 +345,8 @@ class StoryMenuState extends MusicBeatState var directory = StageData.forceNextDirectory; LoadingState.loadNextDirectory(); StageData.forceNextDirectory = directory; - @:privateAccess - if(PlayState._lastLoadedModDirectory != Mods.currentModDirectory) + if (PlayState._lastLoadedModDirectory != Mods.currentModDirectory) { trace('CHANGED MOD DIRECTORY, RELOADING STUFF'); Paths.freeGraphicsFromMemory(); @@ -354,12 +358,13 @@ class StoryMenuState extends MusicBeatState LoadingState.loadAndSwitchState(new PlayState(), true); FreeplayState.destroyFreeplayVocals(); }); - + #if (MODS_ALLOWED && DISCORD_ALLOWED) DiscordClient.loadModRPC(); #end } - else FlxG.sound.play(Paths.sound('cancelMenu')); + else + FlxG.sound.play(Paths.sound('cancelMenu')); } function changeDifficulty(change:Int = 0):Void @@ -367,7 +372,7 @@ class StoryMenuState extends MusicBeatState curDifficulty += change; if (curDifficulty < 0) - curDifficulty = Difficulty.list.length-1; + curDifficulty = Difficulty.list.length - 1; if (curDifficulty >= Difficulty.list.length) curDifficulty = 0; @@ -375,9 +380,9 @@ class StoryMenuState extends MusicBeatState var diff:String = Difficulty.getString(curDifficulty); var newImage:FlxGraphic = Paths.image('menudifficulties/' + Paths.formatToSongPath(diff)); - //trace(Mods.currentModDirectory + ', menudifficulties/' + Paths.formatToSongPath(diff)); + // trace(Mods.currentModDirectory + ', menudifficulties/' + Paths.formatToSongPath(diff)); - if(sprDifficulty.graphic != newImage) + if (sprDifficulty.graphic != newImage) { sprDifficulty.loadGraphic(newImage); sprDifficulty.x = leftArrow.x + 60; @@ -424,9 +429,12 @@ class StoryMenuState extends MusicBeatState bgSprite.visible = true; var assetName:String = leWeek.weekBackground; - if(assetName == null || assetName.length < 1) { + if (assetName == null || assetName.length < 1) + { bgSprite.visible = false; - } else { + } + else + { bgSprite.loadGraphic(Paths.image('menubackgrounds/menu_' + assetName)); } PlayState.storyWeek = curWeek; @@ -434,35 +442,40 @@ class StoryMenuState extends MusicBeatState Difficulty.loadFromWeek(); difficultySelectors.visible = unlocked; - if(Difficulty.list.contains(Difficulty.getDefault())) + if (Difficulty.list.contains(Difficulty.getDefault())) curDifficulty = Math.round(Math.max(0, Difficulty.defaultList.indexOf(Difficulty.getDefault()))); else curDifficulty = 0; var newPos:Int = Difficulty.list.indexOf(lastDifficultyName); - //trace('Pos of ' + lastDifficultyName + ' is ' + newPos); - if(newPos > -1) + // trace('Pos of ' + lastDifficultyName + ' is ' + newPos); + if (newPos > -1) { curDifficulty = newPos; } updateText(); } - function weekIsLocked(name:String):Bool { + function weekIsLocked(name:String):Bool + { var leWeek:WeekData = WeekData.weeksLoaded.get(name); - return (!leWeek.startUnlocked && leWeek.weekBefore.length > 0 && (!weekCompleted.exists(leWeek.weekBefore) || !weekCompleted.get(leWeek.weekBefore))); + return (!leWeek.startUnlocked + && leWeek.weekBefore.length > 0 + && (!weekCompleted.exists(leWeek.weekBefore) || !weekCompleted.get(leWeek.weekBefore))); } function updateText() { var weekArray:Array = loadedWeeks[curWeek].weekCharacters; - for (i in 0...grpWeekCharacters.length) { + for (i in 0...grpWeekCharacters.length) + { grpWeekCharacters.members[i].changeCharacter(weekArray[i]); } var leWeek:WeekData = loadedWeeks[curWeek]; var stringThing:Array = []; - for (i in 0...leWeek.songs.length) { + for (i in 0...leWeek.songs.length) + { stringThing.push(leWeek.songs[i][0]); }