diff --git a/source/Main.hx b/source/Main.hx index f70ecd88e..0fa9c82be 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -70,7 +70,7 @@ class Main extends Sprite public static var gameVersion:String = '0.2.4.1'; - public static var loadedAssets:Array = []; + public static var loadedAssets:Array = []; var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode. @@ -235,6 +235,9 @@ class Main extends Sprite public static function dumpCache() { + // dump saved frames and shit + loadedAssets = []; + ///* SPECIAL THANKS TO HAYA @:privateAccess for (key in FlxG.bitmap._cache.keys()) diff --git a/source/Paths.hx b/source/Paths.hx index 9eaa77c02..a423cf265 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -166,11 +166,19 @@ class Paths inline static public function getSparrowAtlas(key:String, ?library:String) { - return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library)); + return cast(returnCached(FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library))), FlxAtlasFrames); } inline static public function getPackerAtlas(key:String, ?library:String) { - return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); + return cast(returnCached(FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library))), FlxAtlasFrames); + } + + // cache bullshit + + static public function returnCached(asset:Dynamic) { + if (!Main.loadedAssets.contains(asset)) + Main.loadedAssets.push(asset); + return Main.loadedAssets[Main.loadedAssets.indexOf(asset)]; } } diff --git a/source/gameFolder/gameObjects/Stage.hx b/source/gameFolder/gameObjects/Stage.hx index c12765d9b..42fd60a6c 100644 --- a/source/gameFolder/gameObjects/Stage.hx +++ b/source/gameFolder/gameObjects/Stage.hx @@ -604,7 +604,6 @@ class Stage extends FlxTypedGroup override function add(Object:FlxBasic):FlxBasic { - Main.loadedAssets.insert(Main.loadedAssets.length, Object); if (Init.trueSettings.get('Disable Antialiasing') && Std.isOfType(Object, FlxSprite)) cast(Object, FlxSprite).antialiasing = false; return super.add(Object); diff --git a/source/gameFolder/meta/InfoHud.hx b/source/gameFolder/meta/InfoHud.hx index 1e90c9dbb..9a55094cc 100644 --- a/source/gameFolder/meta/InfoHud.hx +++ b/source/gameFolder/meta/InfoHud.hx @@ -1,6 +1,7 @@ package gameFolder.meta; // import Main; +import flixel.FlxG; import haxe.Timer; import openfl.events.Event; import openfl.system.System; @@ -74,14 +75,14 @@ class InfoHud extends TextField times.shift(); } - // according to google, if this is wrong blame google lmao - - // pretty sure that was to avoid optimisation issues and shit but like I dunno man I'm not writing an if statement that updates all of these at once - // if (currentCount != cacheCount && display) + // u h text = ""; if (displayFps) { - currentFPS = Math.round((times.length + cacheCount) / 2); + if (Math.isNaN(FlxG.updateFramerate)) + currentFPS = Math.round((times.length + cacheCount) / 2); + else + currentFPS = FlxG.updateFramerate; text += "FPS: " + currentFPS + "\n"; cacheCount = times.length; } diff --git a/source/gameFolder/meta/data/dependency/FNFSprite.hx b/source/gameFolder/meta/data/dependency/FNFSprite.hx index 83868ffd7..818efe9e9 100644 --- a/source/gameFolder/meta/data/dependency/FNFSprite.hx +++ b/source/gameFolder/meta/data/dependency/FNFSprite.hx @@ -43,7 +43,7 @@ class FNFSprite extends FlxSprite override public function loadGraphic(Graphic:FlxGraphicAsset, Animated:Bool = false, Width:Int = 0, Height:Int = 0, Unique:Bool = false, ?Key:String):FNFSprite { - var graph:FlxGraphic = FlxG.bitmap.add(Graphic, Unique, Key); + var graph:FlxGraphic = cast(Paths.returnCached(FlxG.bitmap.add(Graphic, Unique, Key)), FlxGraphic); if (graph == null) return this; diff --git a/source/gameFolder/meta/state/CustomTitlescreen.hx b/source/gameFolder/meta/state/CustomTitlescreen.hx index 355d431bd..91768a342 100644 --- a/source/gameFolder/meta/state/CustomTitlescreen.hx +++ b/source/gameFolder/meta/state/CustomTitlescreen.hx @@ -3,6 +3,7 @@ package gameFolder.meta.state; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; +import flixel.addons.display.FlxBackdrop; import flixel.addons.display.FlxGridOverlay; import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; import flixel.addons.transition.FlxTransitionableState; @@ -61,6 +62,7 @@ class CustomTitlescreen extends MusicBeatState var initLogowidth:Float = 0; var newLogoScale:Float = 0; + var backdrop:FlxSprite; function startIntro() { @@ -95,6 +97,12 @@ class CustomTitlescreen extends MusicBeatState // bg.updateHitbox(); add(bg); + // cool bg + backdrop = new FlxSprite().makeGraphic(100, 100, 0xFF84A682); + backdrop.setGraphicSize(Std.int(bg.width), Std.int(bg.height)); + backdrop.screenCenter(); + add(backdrop); + logoBl = new FlxSprite(); logoBl.frames = Paths.getSparrowAtlas('menus/base/title/foreverlogo'); logoBl.animation.addByPrefix('bumpin', 'forever bop', 16, false, false, false); @@ -171,29 +179,15 @@ class CustomTitlescreen extends MusicBeatState logoBl.scale.x = FlxMath.lerp(newLogoScale, logoBl.scale.x, 0.95); logoBl.scale.y = FlxMath.lerp(newLogoScale, logoBl.scale.y, 0.95); - var pressedEnter:Bool = FlxG.keys.justPressed.ENTER; - - #if mobile - for (touch in FlxG.touches.list) - { - if (touch.justPressed) - { - pressedEnter = true; - } - } - #end + FlxTween.color(backdrop, 1, backdrop.color, FlxColor.BLACK); + var pressedEnter:Bool = FlxG.keys.justPressed.ENTER; var gamepad:FlxGamepad = FlxG.gamepads.lastActive; if (gamepad != null) { if (gamepad.justPressed.START) pressedEnter = true; - - #if switch - if (gamepad.justPressed.B) - pressedEnter = true; - #end } if (pressedEnter && !transitioning && skippedIntro) @@ -212,23 +206,10 @@ class CustomTitlescreen extends MusicBeatState { // Check if version is outdated - var version:String = "v" + Application.current.meta.get('version'); - /* - if (version.trim() != NGio.GAME_VER_NUMS.trim() && !OutdatedSubState.leftState) - { - FlxG.switchState(new OutdatedSubState()); - trace('OLD VERSION!'); - trace('old ver'); - trace(version.trim()); - trace('cur ver'); - trace(NGio.GAME_VER_NUMS.trim()); - } - else - { */ + //var version:String = "v" + Application.current.meta.get('version'); Main.switchState(this, new MainMenuState()); // } }); - // FlxG.sound.play(Paths.music('titleShoot'), 0.7); } // hi game, please stop crashing its kinda annoyin, thanks! @@ -273,7 +254,9 @@ class CustomTitlescreen extends MusicBeatState override function beatHit() { super.beatHit(); + logoBl.animation.play('bumpin'); + backdrop.color = 0x84A682; switch (curBeat) { @@ -282,6 +265,31 @@ class CustomTitlescreen extends MusicBeatState } } + override function stepHit() + { + super.stepHit(); + + switch (curStep) + { + case 4: + createCoolText(['Yoshubs']); + case 6: + addMoreText('Neolixn'); + case 8: + addMoreText('Gedehari'); + case 10: + addMoreText('Tsuraran'); + case 12: + addMoreText('FlopDoodle'); + case 16: + addMoreText(''); + addMoreText('PRESENT'); + + case 24: + deleteCoolText(); + } + } + var skippedIntro:Bool = false; function skipIntro():Void diff --git a/source/gameFolder/meta/state/PlayState.hx b/source/gameFolder/meta/state/PlayState.hx index 7f3958718..b643cccf1 100644 --- a/source/gameFolder/meta/state/PlayState.hx +++ b/source/gameFolder/meta/state/PlayState.hx @@ -942,10 +942,10 @@ class PlayState extends MusicBeatState ///* if (daNote.isSustainNote && (((daNote.y + daNote.offset.y <= (strumline.receptors.members[Math.floor(daNote.noteData)].y + Note.swagWidth / 2)) - && !Init.trueSettings.get('Downscroll')) - || (((daNote.y - (daNote.offset.y * daNote.scale.y) + daNote.height) >= (strumline.receptors.members[Math.floor(daNote.noteData)].y - + Note.swagWidth / 2)) - && Init.trueSettings.get('Downscroll'))) + && !Init.trueSettings.get('Downscroll')) + || (((daNote.y - (daNote.offset.y * daNote.scale.y) + daNote.height) + >= (strumline.receptors.members[Math.floor(daNote.noteData)].y + Note.swagWidth / 2)) + && Init.trueSettings.get('Downscroll'))) && (autoplay || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))) { var swagRectY = ((strumline.receptors.members[Math.floor(daNote.noteData)].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y); @@ -955,7 +955,8 @@ class PlayState extends MusicBeatState if (Init.trueSettings.get('Downscroll')) { swagRect.height = swagRectY; - swagRect.y -= swagRect.height - daNote.height; + // I'm literally a dumbass + swagRect.y += swagRect.height - daNote.height; } else { @@ -1728,7 +1729,6 @@ class PlayState extends MusicBeatState override function add(Object:FlxBasic):FlxBasic { - Main.loadedAssets.insert(Main.loadedAssets.length, Object); if (Init.trueSettings.get('Disable Antialiasing') && Std.isOfType(Object, FlxSprite)) cast(Object, FlxSprite).antialiasing = false; return super.add(Object); diff --git a/source/gameFolder/meta/state/charting/ChartingState.hx b/source/gameFolder/meta/state/charting/ChartingState.hx index af1ef16da..8da26932a 100644 --- a/source/gameFolder/meta/state/charting/ChartingState.hx +++ b/source/gameFolder/meta/state/charting/ChartingState.hx @@ -16,6 +16,7 @@ import flixel.addons.ui.FlxUIDropDownMenu; import flixel.addons.ui.FlxUIInputText; import flixel.addons.ui.FlxUINumericStepper; import flixel.addons.ui.FlxUITabMenu; +import flixel.graphics.FlxGraphic; import flixel.group.FlxGroup; import flixel.group.FlxSpriteGroup; import flixel.math.FlxMath; @@ -213,19 +214,25 @@ class ChartingState extends MusicBeatState ForeverTools.killMusic([songMusic, vocals]); Main.switchState(this, new PlayState()); } + } + override public function stepHit() { // call all rendered notes lol - curRenderedNotes.forEach(function(epicNote:Note){ + curRenderedNotes.forEach(function(epicNote:Note) + { if ((epicNote.y < (strumLineCam.y - (FlxG.height / 2) - epicNote.height)) - || (epicNote.y > (strumLineCam.y + (FlxG.height / 2)))) { + || (epicNote.y > (strumLineCam.y + (FlxG.height / 2)))) + { // do epic note calls for strum stuffs - if (Math.floor(Conductor.songPosition / Conductor.stepCrochet) == Math.floor(epicNote.strumTime / Conductor.stepCrochet) - && (!hitSoundsPlayed.contains(epicNote))) { - + if (Math.floor(Conductor.songPosition / Conductor.stepCrochet) == Math.floor(epicNote.strumTime / Conductor.stepCrochet) + && (!hitSoundsPlayed.contains(epicNote))) + { hitSoundsPlayed.push(epicNote); } } }); + + super.stepHit(); } function getStrumTime(yPos:Float):Float @@ -255,6 +262,58 @@ class ChartingState extends MusicBeatState fullGrid.height = (songMusic.length / Conductor.stepCrochet) * gridSize; add(fullGrid); + + } + + public var sectionLineGraphic:FlxGraphic; + public var sectionCameraGraphic:FlxGraphic; + public var sectionStepGraphic:FlxGraphic; + + private function regenerateSection(section:Int, placement:Float) + { + // this will be used to regenerate a box that shows what section the camera is focused on + + // oh and section information lol + var sectionLine:FlxSprite = new FlxSprite(FlxG.width / 2 - (gridSize * (keysTotal / 2)) - (extraSize / 2), placement); + sectionLine.frames = sectionLineGraphic.imageFrame; + sectionLine.alpha = (88 / 255); + + // section camera + var sectionExtend:Float = 0; + if (_song.notes[section].mustHitSection) + sectionExtend = (gridSize * (keysTotal / 2)); + + var sectionCamera:FlxSprite = new FlxSprite(FlxG.width / 2 - (gridSize * (keysTotal / 2)) + (sectionExtend), placement); + sectionCamera.frames = sectionCameraGraphic.imageFrame; + sectionCamera.alpha = (88 / 255); + curRenderedSections.add(sectionCamera); + + // set up section numbers + for (i in 0...2) + { + var sectionNumber:FlxText = new FlxText(0, sectionLine.y - 12, 0, Std.string(section), 20); + // set the x of the section number + sectionNumber.x = sectionLine.x - sectionNumber.width - 5; + if (i == 1) + sectionNumber.x = sectionLine.x + sectionLine.width + 5; + + sectionNumber.setFormat(Paths.font("vcr.ttf"), 24, FlxColor.WHITE); + sectionNumber.antialiasing = false; + sectionNumber.alpha = sectionLine.alpha; + curRenderedSections.add(sectionNumber); + } + + for (i in 1...Std.int(_song.notes[section].lengthInSteps / 4)) + { + // create a smaller section stepper + var sectionStep:FlxSprite = new FlxSprite(FlxG.width / 2 - (gridSize * (keysTotal / 2)) - (extraSize / 2), + placement + (i * (gridSize * 4))); + sectionStep.frames = sectionStepGraphic.imageFrame; + sectionStep.alpha = sectionLine.alpha; + curRenderedSections.add(sectionStep); + } + + curRenderedSections.add(sectionLine); } var sectionsMax = 0; @@ -266,9 +325,11 @@ class ChartingState extends MusicBeatState curRenderedSustains.clear(); //sectionsMax = 1; + generateSection(); for (section in 0..._song.notes.length) { sectionsMax = section; + regenerateSection(section, 16 * gridSize * section); for (i in _song.notes[section].sectionNotes) { // note stuffs @@ -283,6 +344,15 @@ class ChartingState extends MusicBeatState //sectionsMax--; } + var extraSize = 6; + + function generateSection() { + // pregenerate assets so it doesnt destroy your ram later + sectionLineGraphic = FlxG.bitmap.create(gridSize * keysTotal + extraSize, 2, FlxColor.WHITE); + sectionCameraGraphic = FlxG.bitmap.create(Std.int(gridSize * (keysTotal / 2)), 16 * gridSize, FlxColor.fromRGB(43, 116, 219)); + sectionStepGraphic = FlxG.bitmap.create(gridSize * keysTotal + extraSize, 1, FlxColor.WHITE); + } + function loadSong(daSong:String):Void { if (songMusic != null)