From ceac1c6129a48b1bd31212e2cf240f540f38a7a2 Mon Sep 17 00:00:00 2001 From: Lucky56 <55949451+Lucky-56@users.noreply.github.com> Date: Thu, 17 Jun 2021 06:00:18 +0200 Subject: [PATCH] CoolUtil gets used more --- source/CoolUtil.hx | 6 +++--- source/FreeplayState.hx | 10 +--------- source/LoadReplayState.hx | 2 +- source/PauseSubState.hx | 2 +- source/PlayState.hx | 12 ++---------- 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/source/CoolUtil.hx b/source/CoolUtil.hx index 92cc2c0..24dc749 100644 --- a/source/CoolUtil.hx +++ b/source/CoolUtil.hx @@ -6,11 +6,11 @@ using StringTools; class CoolUtil { - public static var difficultyArray:Array = ['EASY', "NORMAL", "HARD"]; + public static var difficultyArray:Array = ['Easy', "Normal", "Hard"]; - public static function difficultyString():String + public static function difficultyFromInt(difficulty:Int):String { - return difficultyArray[PlayState.storyDifficulty]; + return difficultyArray[difficulty]; } public static function coolTextFile(path:String):Array diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 4fcc985..a46f108 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -244,15 +244,7 @@ class FreeplayState extends MusicBeatState intendedScore = Highscore.getScore(songHighscore, curDifficulty); #end - switch (curDifficulty) - { - case 0: - diffText.text = "EASY"; - case 1: - diffText.text = 'NORMAL'; - case 2: - diffText.text = "HARD"; - } + diffText.text = CoolUtil.difficultyFromInt(curDifficulty).toUpperCase(); } function changeSelection(change:Int = 0) diff --git a/source/LoadReplayState.hx b/source/LoadReplayState.hx index afcdfd4..8c3af52 100644 --- a/source/LoadReplayState.hx +++ b/source/LoadReplayState.hx @@ -54,7 +54,7 @@ class LoadReplayState extends MusicBeatState var string:String = controlsStrings[i]; actualNames[i] = string; var rep:Replay = Replay.LoadReplay(string); - controlsStrings[i] = string.split("time")[0] + " " + (rep.replay.songDiff == 2 ? "HARD" : rep.replay.songDiff == 1 ? "EASY" : "NORMAL"); + controlsStrings[i] = string.split("time")[0] + " " + CoolUtil.difficultyFromInt(rep.replay.songDiff).toUpperCase(); } if (controlsStrings.length == 0) diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index ab9b1a2..ee72f18 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -52,7 +52,7 @@ class PauseSubState extends MusicBeatSubstate add(levelInfo); var levelDifficulty:FlxText = new FlxText(20, 15 + 32, 0, "", 32); - levelDifficulty.text += CoolUtil.difficultyString(); + levelDifficulty.text += CoolUtil.difficultyFromInt(PlayState.storyDifficulty).toUpperCase(); levelDifficulty.scrollFactor.set(); levelDifficulty.setFormat(Paths.font('vcr.ttf'), 32); levelDifficulty.updateHitbox(); diff --git a/source/PlayState.hx b/source/PlayState.hx index 2562965..3b500ac 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -255,15 +255,7 @@ class PlayState extends MusicBeatState #if windows // Making difficulty text for Discord Rich Presence. - switch (storyDifficulty) - { - case 0: - storyDifficultyText = "Easy"; - case 1: - storyDifficultyText = "Normal"; - case 2: - storyDifficultyText = "Hard"; - } + storyDifficultyText = CoolUtil.difficultyFromInt(storyDifficulty); iconRPC = SONG.player2; @@ -965,7 +957,7 @@ class PlayState extends MusicBeatState add(healthBar); // Add Kade Engine watermark - kadeEngineWatermark = new FlxText(4,healthBarBG.y + 50,0,SONG.song + " " + (storyDifficulty == 2 ? "Hard" : storyDifficulty == 1 ? "Normal" : "Easy") + (Main.watermarks ? " - KE " + MainMenuState.kadeEngineVer : ""), 16); + kadeEngineWatermark = new FlxText(4,healthBarBG.y + 50,0,SONG.song + " " + CoolUtil.difficultyFromInt(storyDifficulty) + (Main.watermarks ? " - KE " + MainMenuState.kadeEngineVer : ""), 16); kadeEngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); kadeEngineWatermark.scrollFactor.set(); add(kadeEngineWatermark);