From b6953ec111523d0f3399bbbd98860ec83012d1f5 Mon Sep 17 00:00:00 2001 From: Lucky56 <55949451+Lucky-56@users.noreply.github.com> Date: Thu, 17 Jun 2021 18:02:20 +0200 Subject: [PATCH] brought back the week locking --- source/KadeEngineData.hx | 5 ++++- source/Options.hx | 22 ++++++++++++++++++++++ source/OptionsMenu.hx | 5 +++++ source/PlayState.hx | 11 +++++++---- source/StoryMenuState.hx | 16 +++++++++++++++- source/TitleState.hx | 14 -------------- 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/source/KadeEngineData.hx b/source/KadeEngineData.hx index 39275f3..e412609 100644 --- a/source/KadeEngineData.hx +++ b/source/KadeEngineData.hx @@ -5,7 +5,10 @@ class KadeEngineData { public static function initSave() { - if (FlxG.save.data.newInput == null) + if (FlxG.save.data.weekUnlocked == null) + FlxG.save.data.weekUnlocked = 6; + + if (FlxG.save.data.newInput == null) FlxG.save.data.newInput = true; if (FlxG.save.data.downscroll == null) diff --git a/source/Options.hx b/source/Options.hx index 770568e..a3210c6 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -634,3 +634,25 @@ class CamZoomOption extends Option return "Camera Zoom " + (!FlxG.save.data.camzoom ? "off" : "on"); } } + +class LockWeeksOption extends Option +{ + public function new(desc:String) + { + super(); + description = desc; + } + public override function press():Bool + { + FlxG.save.data.weekUnlocked = 0; + StoryMenuState.weekUnlocked = [true]; + trace('Weeks Locked'); + display = updateDisplay(); + return true; + } + + private override function updateDisplay():String + { + return "Lock Weeks"; + } +} diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 03cf31c..3a46c25 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -58,6 +58,11 @@ class OptionsMenu extends MusicBeatState new FlashingLightsOption("Toggle flashing lights that can cause epileptic seizures and strain."), new WatermarkOption("Enable and disable all watermarks from the engine."), new BotPlay("Showcase your charts and mods with autoplay.") + ]), + + new OptionCategory("Saved Data", [ + new LockWeeksOption("Lock all weeks. (exept Tutorial of course)") + // TODO reset score ]) ]; diff --git a/source/PlayState.hx b/source/PlayState.hx index 2562965..d32c87e 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2576,16 +2576,19 @@ class PlayState extends MusicBeatState } #end - // if () - StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true; - if (SONG.validScore) { NGio.unlockMedal(60961); Highscore.saveWeekScore(storyWeek, campaignScore, storyDifficulty); } - FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked; + if(storyWeek < StoryMenuState.getWeeks().length - 1 && FlxG.save.data.weekUnlocked == storyWeek) + { + StoryMenuState.weekUnlocked.push(true); + trace('Week ' + storyWeek + ' beat (Week ' + (storyWeek + 1) + ' unlocked)'); + } + + FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked.length - 1; FlxG.save.flush(); } else diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index bf80753..74afeea 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -34,7 +34,7 @@ class StoryMenuState extends MusicBeatState ]; var curDifficulty:Int = 1; - public static var weekUnlocked:Array = [true, true, true, true, true, true, true]; + public static var weekUnlocked:Array = []; var weekCharacters:Array = [ ['', 'bf', 'gf'], @@ -72,8 +72,21 @@ class StoryMenuState extends MusicBeatState var leftArrow:FlxSprite; var rightArrow:FlxSprite; + function unlockWeeks():Array + { + var weeks:Array = [true]; + + for(i in 0...FlxG.save.data.weekUnlocked) + { + weeks.push(true); + } + return weeks; + } + override function create() { + weekUnlocked = unlockWeeks(); + #if windows // Updating Discord Rich Presence DiscordClient.changePresence("In the Story Mode Menu", null); @@ -133,6 +146,7 @@ class StoryMenuState extends MusicBeatState // Needs an offset thingie if (!weekUnlocked[i]) { + trace('locking week ' + i); var lock:FlxSprite = new FlxSprite(weekThing.width + 10 + weekThing.x); lock.frames = ui_tex; lock.animation.addByPrefix('lock', 'lock'); diff --git a/source/TitleState.hx b/source/TitleState.hx index 6b86eca..9873de2 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -94,20 +94,6 @@ class TitleState extends MusicBeatState Highscore.load(); - if (FlxG.save.data.weekUnlocked != null) - { - // FIX LATER!!! - // WEEK UNLOCK PROGRESSION!! - // StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked; - - if (StoryMenuState.weekUnlocked.length < 4) - StoryMenuState.weekUnlocked.insert(0, true); - - // QUICK PATCH OOPS! - if (!StoryMenuState.weekUnlocked[0]) - StoryMenuState.weekUnlocked[0] = true; - } - #if FREEPLAY FlxG.switchState(new FreeplayState()); #elseif CHARTING