diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 6f7388d135..4fcc985c6f 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -202,27 +202,20 @@ class FreeplayState extends MusicBeatState if (accepted) { - // pre lowercasing the song name (update) - var songLowercase = StringTools.replace(songs[curSelected].songName, " ", "-").toLowerCase(); - switch (songLowercase) { - case 'dad-battle': songLowercase = 'dadbattle'; - case 'philly-nice': songLowercase = 'philly'; - } - // adjusting the highscore song name to be compatible (update) - // would read original scores if we didn't change packages - var songHighscore = StringTools.replace(songs[curSelected].songName, " ", "-"); - switch (songHighscore) { - case 'Dad-Battle': songHighscore = 'Dadbattle'; - case 'Philly-Nice': songHighscore = 'Philly'; + // adjusting the song name to be compatible + var songFormat = StringTools.replace(songs[curSelected].songName, " ", "-"); + switch (songFormat) { + case 'Dad-Battle': songFormat = 'Dadbattle'; + case 'Philly-Nice': songFormat = 'Philly'; } - trace(songLowercase); + trace(songs[curSelected].songName); - var poop:String = Highscore.formatSong(songHighscore, curDifficulty); + var poop:String = Highscore.formatSong(songFormat, curDifficulty); trace(poop); - PlayState.SONG = Song.loadFromJson(poop, songLowercase); + PlayState.SONG = Song.loadFromJson(poop, songs[curSelected].songName); PlayState.isStoryMode = false; PlayState.storyDifficulty = curDifficulty; PlayState.storyWeek = songs[curSelected].week; diff --git a/source/LoadReplayState.hx b/source/LoadReplayState.hx index 1be8679e10..afcdfd4900 100644 --- a/source/LoadReplayState.hx +++ b/source/LoadReplayState.hx @@ -80,7 +80,7 @@ class LoadReplayState extends MusicBeatState } - versionShit = new FlxText(5, FlxG.height - 34, 0, "Replay Loader (ESCAPE TO GO BACK)\nNOTICE!!!! Replays are in a beta stage, and they are probably not 100% correct. expect misses and other stuff that isn't there!", 12); + versionShit = new FlxText(5, FlxG.height - 34, 0, "Replay Loader (ESCAPE TO GO BACK)\nNOTICE!!!! Replays are in a beta stage, and they are probably not 100% correct. expect misses and other stuff that isn't there!\n", 12); versionShit.scrollFactor.set(); versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); add(versionShit); @@ -102,7 +102,7 @@ class LoadReplayState extends MusicBeatState for (i in 0...songs.length) { var pog:FreeplayState.SongMetadata = songs[i]; - if (pog.songName.toLowerCase() == songName) + if (pog.songName == songName) week = pog.week; } return week; @@ -148,9 +148,19 @@ class LoadReplayState extends MusicBeatState PlayState.loadRep = true; - var poop:String = Highscore.formatSong(PlayState.rep.replay.songName.toLowerCase(), PlayState.rep.replay.songDiff); + // adjusting the song name to be compatible + var songFormat = StringTools.replace(PlayState.rep.replay.songName, " ", "-"); + switch (songFormat) { + case 'Dad-Battle': songFormat = 'Dadbattle'; + case 'Philly-Nice': songFormat = 'Philly'; + // Replay v1.0 support + case 'dad-battle': songFormat = 'Dadbattle'; + case 'philly-nice': songFormat = 'Philly'; + } - PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName.toLowerCase()); + var poop:String = Highscore.formatSong(songFormat, PlayState.rep.replay.songDiff); + + PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName); PlayState.isStoryMode = false; PlayState.storyDifficulty = PlayState.rep.replay.songDiff; PlayState.storyWeek = getWeekNumbFromSong(PlayState.rep.replay.songName); @@ -177,7 +187,7 @@ class LoadReplayState extends MusicBeatState var rep:Replay = Replay.LoadReplay(actualNames[curSelected]); - poggerDetails.text = "Replay Details - \nDate Created: " + rep.replay.timestamp + "\nSong: " + rep.replay.songName + "\nReplay Version: " + (rep.replay.replayGameVer != Replay.version ? "OUTDATED" : "Latest"); + poggerDetails.text = "Replay Details - \nDate Created: " + rep.replay.timestamp + "\nSong: " + rep.replay.songName + "\nReplay Version: " + rep.replay.replayGameVer + ' (' + (rep.replay.replayGameVer != Replay.version ? "OUTDATED but still usable" : "Latest") + ')\n'; // selector.y = (70 * curSelected) + 30; diff --git a/source/ModchartState.hx b/source/ModchartState.hx index 1203ea52e3..dd00e06845 100644 --- a/source/ModchartState.hx +++ b/source/ModchartState.hx @@ -255,11 +255,18 @@ class ModchartState function makeAnimatedLuaSprite(spritePath:String,names:Array,prefixes:Array,startAnim:String, id:String) { #if sys - var data:BitmapData = BitmapData.fromFile(Sys.getCwd() + "assets/data/" + PlayState.SONG.song.toLowerCase() + '/' + spritePath + ".png"); + // pre lowercasing the song name (makeAnimatedLuaSprite) + var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } + + var data:BitmapData = BitmapData.fromFile(Sys.getCwd() + "assets/data/" + songLowercase + '/' + spritePath + ".png"); var sprite:FlxSprite = new FlxSprite(0,0); - sprite.frames = FlxAtlasFrames.fromSparrow(FlxGraphic.fromBitmapData(data), Sys.getCwd() + "assets/data/" + PlayState.SONG.song.toLowerCase() + "/" + spritePath + ".xml"); + sprite.frames = FlxAtlasFrames.fromSparrow(FlxGraphic.fromBitmapData(data), Sys.getCwd() + "assets/data/" + songLowercase + "/" + spritePath + ".xml"); trace(sprite.frames.frames.length); @@ -282,7 +289,14 @@ class ModchartState function makeLuaSprite(spritePath:String,toBeCalled:String, drawBehind:Bool) { #if sys - var data:BitmapData = BitmapData.fromFile(Sys.getCwd() + "assets/data/" + PlayState.SONG.song.toLowerCase() + '/' + spritePath + ".png"); + // pre lowercasing the song name (makeLuaSprite) + var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } + + var data:BitmapData = BitmapData.fromFile(Sys.getCwd() + "assets/data/" + songLowercase + '/' + spritePath + ".png"); var sprite:FlxSprite = new FlxSprite(0,0); var imgWidth:Float = FlxG.width / data.width; @@ -345,7 +359,14 @@ class ModchartState //shaders = new Array(); - var result = LuaL.dofile(lua, Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart")); // execute le file + // pre lowercasing the song name (new) + var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } + + var result = LuaL.dofile(lua, Paths.lua(songLowercase + "/modchart")); // execute le file if (result != 0) { diff --git a/source/Note.hx b/source/Note.hx index 7e29d7bb42..1eb3977409 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -59,7 +59,14 @@ class Note extends FlxSprite var daStage:String = PlayState.curStage; - switch (PlayState.SONG.noteStyle) + //defaults if no noteStyle was found in chart + var noteTypeCheck:String = 'normal'; + + if (PlayState.SONG.noteStyle == null) { + switch(PlayState.storyWeek) {case 6: noteTypeCheck = 'pixel';} + } else {noteTypeCheck = PlayState.SONG.noteStyle;} + + switch (noteTypeCheck) { case 'pixel': loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels','week6'), true, 17, 17); diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index e59e72b39f..ab9b1a2a12 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -104,7 +104,14 @@ class PauseSubState extends MusicBeatSubstate var rightP = controls.RIGHT_P; var accepted = controls.ACCEPT; var oldOffset:Float = 0; - var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/'; + + // pre lowercasing the song name (update) + var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } + var songPath = 'assets/data/' + songLowercase + '/'; if (upP) { diff --git a/source/PlayState.hx b/source/PlayState.hx index b5107eb2c1..a59c10e2a5 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -238,10 +238,10 @@ class PlayState extends MusicBeatState // pre lowercasing the song name (create) var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); - switch (songLowercase) { - case 'dad-battle': songLowercase = 'dadbattle'; - case 'philly-nice': songLowercase = 'philly'; - } + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } #if windows executeModchart = FileSystem.exists(Paths.lua(songLowercase + "/modchart")); @@ -309,7 +309,7 @@ class PlayState extends MusicBeatState persistentDraw = true; if (SONG == null) - SONG = Song.loadFromJson('tutorial'); + SONG = Song.loadFromJson('tutorial', 'tutorial'); Conductor.mapBPMChanges(SONG); Conductor.changeBPM(SONG.bpm); @@ -344,7 +344,22 @@ class PlayState extends MusicBeatState dialogue = CoolUtil.coolTextFile(Paths.txt('thorns/thornsDialogue')); } - switch(SONG.stage) + //defaults if no stage was found in chart + var stageCheck:String = 'stage'; + + if (SONG.stage == null) { + switch(storyWeek) + { + case 2: stageCheck = 'halloween'; + case 3: stageCheck = 'philly'; + case 4: stageCheck = 'limo'; + case 5: if (songLowercase == 'winter-horrorland') {stageCheck = 'mallEvil';} else {stageCheck = 'mall';} + case 6: if (songLowercase == 'thorns') {stageCheck = 'schoolEvil';} else {stageCheck = 'school';} + //i should check if its stage (but this is when none is found in chart anyway) + } + } else {stageCheck = SONG.stage;} + + switch(stageCheck) { case 'halloween': { @@ -723,21 +738,33 @@ class PlayState extends MusicBeatState add(stageCurtains); } } - var gfVersion:String = 'gf'; - switch (SONG.gfVersion) + //defaults if no gf was found in chart + var gfCheck:String = 'gf'; + + if (SONG.gfVersion == null) { + switch(storyWeek) + { + case 4: gfCheck = 'gf-car'; + case 5: gfCheck = 'gf-christmas'; + case 6: gfCheck = 'gf-pixel'; + } + } else {gfCheck = SONG.gfVersion;} + + var curGf:String = ''; + switch (gfCheck) { case 'gf-car': - gfVersion = 'gf-car'; + curGf = 'gf-car'; case 'gf-christmas': - gfVersion = 'gf-christmas'; + curGf = 'gf-christmas'; case 'gf-pixel': - gfVersion = 'gf-pixel'; + curGf = 'gf-pixel'; default: - gfVersion = 'gf'; + curGf = 'gf'; } - gf = new Character(400, 130, gfVersion); + gf = new Character(400, 130, curGf); gf.scrollFactor.set(0.95, 0.95); dad = new Character(100, 100, SONG.player2); @@ -1078,17 +1105,11 @@ class PlayState extends MusicBeatState senpaiEvil.updateHitbox(); senpaiEvil.screenCenter(); - // pre lowercasing the song name (schoolIntro) - var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); - switch (songLowercase) { - case 'dad-battle': songLowercase = 'dadbattle'; - case 'philly-nice': songLowercase = 'philly'; - } - if (songLowercase == 'roses' || songLowercase == 'thorns') + if (StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase() == 'roses' || StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase() == 'thorns') { remove(black); - if (songLowercase == 'thorns') + if (StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase() == 'thorns') { add(red); } @@ -1108,7 +1129,7 @@ class PlayState extends MusicBeatState { inCutscene = true; - if (songLowercase == 'thorns') + if (StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase() == 'thorns') { add(senpaiEvil); senpaiEvil.alpha = 0; @@ -1169,10 +1190,16 @@ class PlayState extends MusicBeatState #if windows + // pre lowercasing the song name (startCountdown) + var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } if (executeModchart) { luaModchart = ModchartState.createModchartState(); - luaModchart.executeState('start',[PlayState.SONG.song]); + luaModchart.executeState('start',[songLowercase]); } #end @@ -1381,14 +1408,15 @@ class PlayState extends MusicBeatState var playerCounter:Int = 0; - // pre lowercasing the song name (generateSong) - var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); - switch (songLowercase) { - case 'dad-battle': songLowercase = 'dadbattle'; - case 'philly-nice': songLowercase = 'philly'; - } // Per song offset check #if windows + // pre lowercasing the song name (generateSong) + var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); + switch (songLowercase) { + case 'dad-battle': songLowercase = 'dadbattle'; + case 'philly-nice': songLowercase = 'philly'; + } + var songPath = 'assets/data/' + songLowercase + '/'; for(file in sys.FileSystem.readDirectory(songPath)) @@ -1491,7 +1519,14 @@ class PlayState extends MusicBeatState // FlxG.log.add(i); var babyArrow:FlxSprite = new FlxSprite(0, strumLine.y); - switch (SONG.noteStyle) + //defaults if no noteStyle was found in chart + var noteTypeCheck:String = 'normal'; + + if (SONG.noteStyle == null) { + switch(storyWeek) {case 6: noteTypeCheck = 'pixel';} + } else {noteTypeCheck = SONG.noteStyle;} + + switch (noteTypeCheck) { case 'pixel': babyArrow.loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels'), true, 17, 17); @@ -1816,9 +1851,9 @@ class PlayState extends MusicBeatState super.update(elapsed); - scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,maxNPS,accuracy); - if (!FlxG.save.data.accuracyDisplay) - scoreTxt.text = "Score: " + songScore; + scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,maxNPS,accuracy); + if (!FlxG.save.data.accuracyDisplay) + scoreTxt.text = "Score: " + songScore; if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause) { @@ -2517,30 +2552,20 @@ class PlayState extends MusicBeatState } else { - var difficulty:String = ""; - - if (storyDifficulty == 0) - difficulty = '-easy'; + + // adjusting the song name to be compatible + var songFormat = StringTools.replace(PlayState.storyPlaylist[0], " ", "-"); + switch (songFormat) { + case 'Dad-Battle': songFormat = 'Dadbattle'; + case 'Philly-Nice': songFormat = 'Philly'; + } - if (storyDifficulty == 2) - difficulty = '-hard'; + var poop:String = Highscore.formatSong(songFormat, storyDifficulty); trace('LOADING NEXT SONG'); - // pre lowercasing the next story song name - var nextSongLowercase = StringTools.replace(PlayState.storyPlaylist[0], " ", "-").toLowerCase(); - switch (nextSongLowercase) { - case 'dad-battle': nextSongLowercase = 'dadbattle'; - case 'philly-nice': nextSongLowercase = 'philly'; - } - trace(nextSongLowercase + difficulty); + trace(poop); - // pre lowercasing the song name (endSong) - var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); - switch (songLowercase) { - case 'dad-battle': songLowercase = 'dadbattle'; - case 'philly-nice': songLowercase = 'philly'; - } - if (songLowercase == 'eggnog') + if (StringTools.replace(PlayState.storyPlaylist[0], " ", "-").toLowerCase() == 'eggnog') { var blackShit:FlxSprite = new FlxSprite(-FlxG.width * FlxG.camera.zoom, -FlxG.height * FlxG.camera.zoom).makeGraphic(FlxG.width * 3, FlxG.height * 3, FlxColor.BLACK); @@ -2555,7 +2580,8 @@ class PlayState extends MusicBeatState FlxTransitionableState.skipNextTransOut = true; prevCamFollow = camFollow; - PlayState.SONG = Song.loadFromJson(nextSongLowercase + difficulty, PlayState.storyPlaylist[0]); + + PlayState.SONG = Song.loadFromJson(poop, PlayState.storyPlaylist[0]); FlxG.sound.music.stop(); LoadingState.loadAndSwitchState(new PlayState()); diff --git a/source/Replay.hx b/source/Replay.hx index bf43d776ea..c1a89faa81 100644 --- a/source/Replay.hx +++ b/source/Replay.hx @@ -13,79 +13,79 @@ import openfl.utils.Dictionary; typedef ReplayJSON = { - public var replayGameVer:String; - public var timestamp:Date; - public var songName:String; - public var songDiff:Int; - public var songNotes:Array; + public var replayGameVer:String; + public var timestamp:Date; + public var songName:String; + public var songDiff:Int; + public var songNotes:Array; public var noteSpeed:Float; public var isDownscroll:Bool; } class Replay { - public static var version:String = "1.0"; // replay file version + public static var version:String = "1.1"; // replay file version - public var path:String = ""; - public var replay:ReplayJSON; - public function new(path:String) - { - this.path = path; - replay = { - songName: "Tutorial", - songDiff: 1, + public var path:String = ""; + public var replay:ReplayJSON; + public function new(path:String) + { + this.path = path; + replay = { + songName: "No Song Found", + songDiff: 1, noteSpeed: 1.5, isDownscroll: false, songNotes: [], - replayGameVer: version, - timestamp: Date.now() - }; - } + replayGameVer: version, + timestamp: Date.now() + }; + } - public static function LoadReplay(path:String):Replay + public static function LoadReplay(path:String):Replay { - var rep:Replay = new Replay(path); + var rep:Replay = new Replay(path); - rep.LoadFromJSON(); + rep.LoadFromJSON(); - trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nNotes Length: ' + rep.replay.songNotes.length); + trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nNotes Length: ' + rep.replay.songNotes.length); - return rep; - } + return rep; + } - public function SaveReplay(notearray:Array) - { - var json = { - "songName": PlayState.SONG.song.toLowerCase(), - "songDiff": PlayState.storyDifficulty, + public function SaveReplay(notearray:Array) + { + var json = { + "songName": PlayState.SONG.song, + "songDiff": PlayState.storyDifficulty, "noteSpeed": (FlxG.save.data.scrollSpeed > 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed), "isDownscroll": FlxG.save.data.downscroll, "songNotes": notearray, - "timestamp": Date.now(), - "replayGameVer": version - }; + "timestamp": Date.now(), + "replayGameVer": version + }; - var data:String = Json.stringify(json); + var data:String = Json.stringify(json); - #if sys - File.saveContent("assets/replays/replay-" + PlayState.SONG.song + "-time" + Date.now().getTime() + ".kadeReplay", data); - #end - } + #if sys + File.saveContent("assets/replays/replay-" + PlayState.SONG.song + "-time" + Date.now().getTime() + ".kadeReplay", data); + #end + } - public function LoadFromJSON() - { - #if sys - trace('loading ' + Sys.getCwd() + 'assets/replays/' + path + ' replay...'); - try - { - var repl:ReplayJSON = cast Json.parse(File.getContent(Sys.getCwd() + "assets/replays/" + path)); - replay = repl; - } - catch(e) - { - trace('failed!\n' + e.message); - } - #end - } + public function LoadFromJSON() + { + #if sys + trace('loading ' + Sys.getCwd() + 'assets/replays/' + path + ' replay...'); + try + { + var repl:ReplayJSON = cast Json.parse(File.getContent(Sys.getCwd() + "assets/replays/" + path)); + replay = repl; + } + catch(e) + { + trace('failed!\n' + e.message); + } + #end + } } diff --git a/source/Song.hx b/source/Song.hx index 00d8e94138..532907906c 100644 --- a/source/Song.hx +++ b/source/Song.hx @@ -33,9 +33,9 @@ class Song public var player1:String = 'bf'; public var player2:String = 'dad'; - public var gfVersion:String = 'gf'; - public var noteStyle:String = 'normal'; - public var stage:String = 'stage'; + public var gfVersion:String = ''; + public var noteStyle:String = ''; + public var stage:String = ''; public function new(song, notes, bpm) { @@ -47,8 +47,8 @@ class Song public static function loadFromJson(jsonInput:String, ?folder:String):SwagSong { trace(jsonInput); - - // pre lowercasing the song name (update) + + // pre lowercasing the folder name var folderLowercase = StringTools.replace(folder, " ", "-").toLowerCase(); switch (folderLowercase) { case 'dad-battle': folderLowercase = 'dadbattle'; diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index 501cf2badf..bf80753a61 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -285,19 +285,19 @@ class StoryMenuState extends MusicBeatState PlayState.isStoryMode = true; selectedWeek = true; - var diffic = ""; - switch (curDifficulty) - { - case 0: - diffic = '-easy'; - case 2: - diffic = '-hard'; + PlayState.storyDifficulty = curDifficulty; + + // adjusting the song name to be compatible + var songFormat = StringTools.replace(PlayState.storyPlaylist[0], " ", "-"); + switch (songFormat) { + case 'Dad-Battle': songFormat = 'Dadbattle'; + case 'Philly-Nice': songFormat = 'Philly'; } - PlayState.storyDifficulty = curDifficulty; + var poop:String = Highscore.formatSong(songFormat, curDifficulty); - PlayState.SONG = Song.loadFromJson(StringTools.replace(PlayState.storyPlaylist[0]," ", "-").toLowerCase() + diffic, StringTools.replace(PlayState.storyPlaylist[0]," ", "-").toLowerCase()); + PlayState.SONG = Song.loadFromJson(poop, PlayState.storyPlaylist[0]); PlayState.storyWeek = curWeek; PlayState.campaignScore = 0; new FlxTimer().start(1, function(tmr:FlxTimer)