From 31487c0a32a03f5615f5627dd1787c56345fb145 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Sat, 27 Aug 2022 02:02:29 -0400 Subject: [PATCH] Logic for double cans, partial implementation of cans into 2hot --- source/funkin/Alphabet.hx | 4 ++-- source/funkin/SongLoad.hx | 12 ++++++++---- source/funkin/audiovis/SpectogramSprite.hx | 4 ++-- source/funkin/play/PlayState.hx | 5 ++++- source/funkin/ui/AtlasMenuList.hx | 4 ++-- source/funkin/util/macro/FlxMacro.hx | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/source/funkin/Alphabet.hx b/source/funkin/Alphabet.hx index 018882e0c..cba2025a6 100644 --- a/source/funkin/Alphabet.hx +++ b/source/funkin/Alphabet.hx @@ -1,7 +1,6 @@ package funkin; import flixel.FlxSprite; -import flixel.graphics.frames.FlxAtlasFrames; import flixel.group.FlxSpriteGroup; import flixel.math.FlxMath; import flixel.util.FlxTimer; @@ -11,7 +10,8 @@ using StringTools; /** * Loosley based on FlxTypeText lolol */ -@:deprecated("Use ui.AtlasText instead") +// TODO: Re-eanble this +// @:deprecated("Use ui.AtlasText instead") class Alphabet extends FlxSpriteGroup { public var delay:Float = 0.05; diff --git a/source/funkin/SongLoad.hx b/source/funkin/SongLoad.hx index d4e414ae4..78bfee757 100644 --- a/source/funkin/SongLoad.hx +++ b/source/funkin/SongLoad.hx @@ -3,7 +3,6 @@ package funkin; import funkin.Note.NoteData; import funkin.Section.SwagSection; import haxe.Json; -import haxe.format.JsonParser; import lime.utils.Assets; using StringTools; @@ -105,6 +104,8 @@ class SongLoad public static function checkAndCreateNotemap(diff:String):Void { + if (songData == null || songData.noteMap == null) + return; if (songData.noteMap[diff] == null) songData.noteMap[diff] = []; } @@ -249,14 +250,17 @@ class SongLoad public static function parseJSONshit(rawJson:String):SwagSong { var songParsed:Dynamic; - try { + try + { songParsed = Json.parse(rawJson); - } catch (e) { + } + catch (e) + { FlxG.log.warn("Error parsing JSON: " + e.message); trace("Error parsing JSON: " + e.message); return null; } - + var swagShit:SwagSong = cast songParsed.song; swagShit.difficulties = []; // reset it to default before load swagShit.noteMap = new Map(); diff --git a/source/funkin/audiovis/SpectogramSprite.hx b/source/funkin/audiovis/SpectogramSprite.hx index 8e5b69e48..8a31884e3 100644 --- a/source/funkin/audiovis/SpectogramSprite.hx +++ b/source/funkin/audiovis/SpectogramSprite.hx @@ -111,7 +111,7 @@ class SpectogramSprite extends FlxTypedSpriteGroup prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x; prevLine.y = (i / group.members.length * daHeight) + y; - var line = FlxVector.get(prevLine.x - group.members[i].x, prevLine.y - group.members[i].y); + var line = FlxPoint.get(prevLine.x - group.members[i].x, prevLine.y - group.members[i].y); group.members[i].setGraphicSize(Std.int(Math.max(line.length, 1)), Std.int(1)); group.members[i].angle = line.degrees; @@ -288,7 +288,7 @@ class SpectogramSprite extends FlxTypedSpriteGroup prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x; prevLine.y = (Std.int(remappedSample) / lengthOfShit * daHeight) + y; - var line = FlxVector.get(prevLine.x - group.members[Std.int(remappedSample)].x, prevLine.y - group.members[Std.int(remappedSample)].y); + var line = FlxPoint.get(prevLine.x - group.members[Std.int(remappedSample)].x, prevLine.y - group.members[Std.int(remappedSample)].y); group.members[Std.int(remappedSample)].setGraphicSize(Std.int(Math.max(line.length, 1)), Std.int(1)); group.members[Std.int(remappedSample)].angle = line.degrees; diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a965b04fb..c6d0fcf49 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -37,7 +37,6 @@ import funkin.ui.stageBuildShit.StageOffsetSubstate; import funkin.util.Constants; import funkin.util.SortUtil; import lime.ui.Haptic; -import polymod.hscript.HScriptedClass; using StringTools; @@ -286,6 +285,7 @@ class PlayState extends MusicBeatState lime.app.Application.current.window.alert("There was a critical error while accessing the selected song. Click OK to return to the main menu.", "Error loading PlayState"); FlxG.switchState(new MainMenuState()); + return; } instance = this; @@ -1787,6 +1787,9 @@ class PlayState extends MusicBeatState override function stepHit():Bool { + if (SongLoad.songData == null) + return false; + // super.stepHit() returns false if a module cancelled the event. if (!super.stepHit()) return false; diff --git a/source/funkin/ui/AtlasMenuList.hx b/source/funkin/ui/AtlasMenuList.hx index 922ef9369..053f387a1 100644 --- a/source/funkin/ui/AtlasMenuList.hx +++ b/source/funkin/ui/AtlasMenuList.hx @@ -1,7 +1,7 @@ package funkin.ui; -import funkin.ui.MenuList; import flixel.graphics.frames.FlxAtlasFrames; +import funkin.ui.MenuList; typedef AtlasAsset = flixel.util.typeLimit.OneOfTwo; @@ -16,7 +16,7 @@ class AtlasMenuList extends MenuTypedList { super(navControls, wrapMode); - if (Std.is(atlas, String)) + if (Std.isOfType(atlas, String)) this.atlas = Paths.getSparrowAtlas(cast atlas); else this.atlas = cast atlas; diff --git a/source/funkin/util/macro/FlxMacro.hx b/source/funkin/util/macro/FlxMacro.hx index adbee3319..8e75dc1ec 100644 --- a/source/funkin/util/macro/FlxMacro.hx +++ b/source/funkin/util/macro/FlxMacro.hx @@ -15,7 +15,7 @@ class FlxMacro // The fields of the FlxClass. var fields:Array = haxe.macro.Context.getBuildFields(); - haxe.macro.Context.info('[INFO] ${cls.name}: Adding zIndex attribute...', pos); + // haxe.macro.Context.info('[INFO] ${cls.name}: Adding zIndex attribute...', pos); // Here, we add the zIndex attribute to all FlxBasic objects. // This has no functional code tied to it, but it can be used as a target value