From 803cfe0e9aac7f8910cc1fbb63098ea729108af6 Mon Sep 17 00:00:00 2001 From: Joalor64 Date: Thu, 24 Oct 2024 10:22:05 -0400 Subject: [PATCH] made achievement resetting a bit better --- assets/achievements/full_combo.json | 2 +- source/states/AchievementsState.hx | 44 +++++++++++++++++++++++++++-- source/states/PlayState.hx | 3 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/assets/achievements/full_combo.json b/assets/achievements/full_combo.json index 08947b0..ced1a4e 100644 --- a/assets/achievements/full_combo.json +++ b/assets/achievements/full_combo.json @@ -1,5 +1,5 @@ { "name": "Full Combo", "desc": "Great job!", - "hint": "Complete a song without missing." + "hint": "Complete any song without missing." } \ No newline at end of file diff --git a/source/states/AchievementsState.hx b/source/states/AchievementsState.hx index a5fa5fd..c626c69 100644 --- a/source/states/AchievementsState.hx +++ b/source/states/AchievementsState.hx @@ -9,7 +9,6 @@ class AchievementsState extends ExtendableState { var iconArray:Array = []; var isUnlocked:Array = []; var description:FlxText; - var curSelected:Int = 0; var camFollow:FlxObject; @@ -89,7 +88,7 @@ class AchievementsState extends ExtendableState { for (i in 0...achievementArray.length) { var formattedName:String = StringTools.replace(achievementArray[i].name.toLowerCase(), " ", "_"); Achievements.forget(formattedName); - ExtendableState.resetState(); + regenList(); } }, () -> { FlxG.sound.play(Paths.sound('cancel')); @@ -99,7 +98,7 @@ class AchievementsState extends ExtendableState { FlxG.sound.play(Paths.sound('select')); var formattedName:String = StringTools.replace(achievementArray[curSelected].name.toLowerCase(), " ", "_"); Achievements.forget(formattedName); - ExtendableState.resetState(); + regenList(); }, () -> { FlxG.sound.play(Paths.sound('cancel')); })); @@ -134,6 +133,45 @@ class AchievementsState extends ExtendableState { description.screenCenter(X); } } + + function regenList() { + achievementArray = []; + + achievementGrp.forEach(ach -> { + achievementGrp.remove(ach, true); + ach.destroy(); + }); + achievementGrp.clear(); // clear whatever is left + + iconArray = []; + + for (i in 0...Achievements.achievements.length) { + var coolAchieve:AchievementData = cast Json.parse(File.getContent(Paths.json('achievements/' + Achievements.achievements[i]))); + achievementArray.push(coolAchieve); + + var stringToUse:String = coolAchieve.name; + var unlocked:Bool = true; + + if (!Achievements.achievementsMap.exists(Achievements.achievements[i])) { + stringToUse = "???"; + unlocked = false; + } + + isUnlocked.push(unlocked); + + var text:FlxText = new FlxText(20, 60 + (i * 80), stringToUse, 32); + text.setFormat(Paths.font('vcr.ttf'), 60, FlxColor.WHITE, FlxTextAlign.LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + text.ID = i; + achievementGrp.add(text); + + var icon:AchievementIcon = new AchievementIcon(0, 0, Achievements.achievements[i].trim()); + icon.sprTracker = text; + iconArray.push(icon); + add(icon); + } + + changeSelection(0, false); + } } class AchievementIcon extends GameSprite { diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 114ff5b..9ab3620 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -538,7 +538,8 @@ class PlayState extends ExtendableState { noteDataTimes[Utilities.getNoteIndex(note.dir)] = note.strum; doNotHit[Utilities.getNoteIndex(note.dir)] = true; - strumline.members[Utilities.getNoteIndex(note.dir)].press(); + if (!SaveData.settings.botPlay) + strumline.members[Utilities.getNoteIndex(note.dir)].press(); switch (curRating) { case "perfect" | "perfect-golden":