From 67a56f741661bc817a44cdd9daa9a3aa46e86e5a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 6 Apr 2023 01:39:27 -0400 Subject: [PATCH] loaded up teehee --- .haxerc | 4 - source/funkin/FreeplayState.hx | 30 ++++- source/funkin/ui/StickerSubState.hx | 141 ++++++++++++++++++-- source/funkin/ui/debug/DebugMenuSubState.hx | 3 +- 4 files changed, 158 insertions(+), 20 deletions(-) delete mode 100644 .haxerc diff --git a/.haxerc b/.haxerc deleted file mode 100644 index 714054662..000000000 --- a/.haxerc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "4.2.5", - "resolveLibs": "scoped" -} \ No newline at end of file diff --git a/source/funkin/FreeplayState.hx b/source/funkin/FreeplayState.hx index 622625f16..8a635bfda 100644 --- a/source/funkin/FreeplayState.hx +++ b/source/funkin/FreeplayState.hx @@ -1,5 +1,6 @@ package funkin; +import funkin.ui.StickerSubState; import flash.text.TextField; import flixel.FlxCamera; import flixel.FlxGame; @@ -73,10 +74,35 @@ class FreeplayState extends MusicBeatSubstate var typing:FlxInputText; var exitMovers:Map, MoveData> = new Map(); - override function create() + var stickerSubState:StickerSubState; + + public function new(?stickers:StickerSubState = null) { + if (stickers != null) + { + stickerSubState = stickers; + } + + super(); + } + + override function create():Void + { + super.create(); + FlxTransitionableState.skipNextTransIn = true; + if (stickerSubState != null) + { + this.persistentUpdate = true; + this.persistentDraw = true; + + openSubState(stickerSubState); + stickerSubState.degenStickers(); + + // resetSubState(); + } + #if discord_rpc // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); @@ -429,8 +455,6 @@ class FreeplayState extends MusicBeatSubstate forEach(function(bs) { bs.cameras = [funnyCam]; }); - - super.create(); } public function generateSongList(?filterStuff:SongFilter, ?force:Bool = false) diff --git a/source/funkin/ui/StickerSubState.hx b/source/funkin/ui/StickerSubState.hx index e42957508..0b5999f6b 100644 --- a/source/funkin/ui/StickerSubState.hx +++ b/source/funkin/ui/StickerSubState.hx @@ -7,19 +7,72 @@ import lime.utils.Assets; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.util.FlxTimer; import flixel.FlxG; +import flixel.math.FlxMath; import flixel.util.FlxSort; +import flixel.util.FlxSignal; +import flixel.addons.transition.FlxTransitionableState; +import openfl.display.BitmapData; +import openfl.geom.Matrix; +import openfl.display.Sprite; +import openfl.display.Bitmap; class StickerSubState extends MusicBeatSubstate { - var grpStickers:FlxTypedGroup; + public var grpStickers:FlxTypedGroup; - public function new():Void + // yes... a damn OpenFL sprite!!! + public var dipshit:Sprite; + + public function new(?oldStickers:Array):Void { super(); grpStickers = new FlxTypedGroup(); add(grpStickers); + if (oldStickers != null) + { + for (sticker in oldStickers) + { + grpStickers.add(sticker); + trace(sticker); + } + + degenStickers(); + } + else + regenStickers(); + } + + public function degenStickers():Void + { + if (dipshit != null) + { + FlxG.removeChild(dipshit); + dipshit = null; + } + + for (ind => sticker in grpStickers.members) + { + new FlxTimer().start(sticker.timing, _ -> { + sticker.visible = false; + + if (ind == grpStickers.members.length - 1) + { + switchingState = false; + close(); + } + }); + } + } + + function regenStickers():Void + { + if (grpStickers.members.length > 0) + { + grpStickers.clear(); + } + var stickerInfo:StickerInfo = new StickerInfo('stickers-set-1'); for (stickerSets in stickerInfo.getPack("all")) { @@ -32,20 +85,12 @@ class StickerSubState extends MusicBeatSubstate sticky.x -= sticky.width / 2; sticky.y -= sticky.height / 2; sticky.visible = false; + sticky.scrollFactor.set(); sticky.angle = FlxG.random.int(-60, 70); // sticky.flipX = FlxG.random.bool(); grpStickers.add(sticky); - sticky.timing = FlxG.random.float(0, 1.5); - - new FlxTimer().start(sticky.timing, function(_) { - sticky.visible = true; - - new FlxTimer().start((1 / 24) * 2, _ -> { - sticky.scale.x = sticky.scale.y = FlxG.random.float(0.97, 1.02); - // sticky.angle *= FlxG.random.float(0, 0.05); - }); - }); + sticky.timing = FlxG.random.float(0, 0.8); } } } @@ -58,9 +103,81 @@ class StickerSubState extends MusicBeatSubstate sticker.y += Math.floor(ind / 6) * sticker.height; } + FlxG.random.shuffle(grpStickers.members); + + // another damn for loop... apologies!!! + for (ind => sticker in grpStickers.members) + { + sticker.timing = FlxMath.remapToRange(ind, 0, grpStickers.members.length, 0, 0.9); + + new FlxTimer().start(sticker.timing, _ -> { + sticker.visible = true; + + var frameTimer:Int = FlxG.random.int(0, 2); + + // always make the last one POP + if (ind == grpStickers.members.length - 1) frameTimer = 2; + + new FlxTimer().start((1 / 24) * frameTimer, _ -> { + sticker.scale.x = sticker.scale.y = FlxG.random.float(0.97, 1.02); + + if (ind == grpStickers.members.length - 1) + { + switchingState = true; + FlxTransitionableState.skipNextTransIn = true; + FlxTransitionableState.skipNextTransOut = true; + + dipshit = new Sprite(); + var scrn:BitmapData = new BitmapData(FlxG.width, FlxG.height, true, 0x00000000); + var mat:Matrix = new Matrix(); + scrn.draw(FlxG.camera.canvas, mat); + + var bitmap:Bitmap = new Bitmap(scrn); + + dipshit.addChild(bitmap); + FlxG.addChildBelowMouse(dipshit); + + FlxG.switchState(new FreeplayState(this)); + } + + // sticky.angle *= FlxG.random.float(0, 0.05); + }); + }); + } + grpStickers.sort((ord, a, b) -> { return FlxSort.byValues(ord, a.timing, b.timing); }); + + // centers the very last sticker + var lastOne:StickerSprite = grpStickers.members[grpStickers.members.length - 1]; + lastOne.updateHitbox(); + lastOne.angle = 0; + lastOne.screenCenter(); + } + + override public function update(elapsed:Float):Void + { + super.update(elapsed); + + if (FlxG.keys.justPressed.ANY) + { + regenStickers(); + } + } + + var switchingState:Bool = false; + + override public function close():Void + { + if (switchingState) return; + super.close(); + } + + override public function destroy():Void + { + if (switchingState) return; + super.destroy(); } } diff --git a/source/funkin/ui/debug/DebugMenuSubState.hx b/source/funkin/ui/debug/DebugMenuSubState.hx index 7a12eb7fb..5d00c03b8 100644 --- a/source/funkin/ui/debug/DebugMenuSubState.hx +++ b/source/funkin/ui/debug/DebugMenuSubState.hx @@ -15,9 +15,10 @@ class DebugMenuSubState extends MusicBeatSubstate */ var camFocusPoint:FlxObject; - override function create() + override function create():Void { super.create(); + bgColor = 0x00000000; // Create an object for the camera to track. camFocusPoint = new FlxObject(0, 0);