proper load/deload on freeplay and story

This commit is contained in:
Cameron Taylor 2023-04-10 14:44:32 -04:00
parent 67a56f7416
commit 6fb517059d
3 changed files with 57 additions and 20 deletions

View file

@ -222,20 +222,12 @@ class PauseSubState extends MusicBeatSubstate
item.alpha = 0.6; item.alpha = 0.6;
} }
FlxTween.tween(bg, {alpha: 1}, 0.4,
{
ease: FlxEase.quartInOut,
onComplete: function(_) {
FlxTransitionableState.skipNextTransIn = true; FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true; FlxTransitionableState.skipNextTransOut = true;
FlxG.cameras.list[1].alpha = 0; // bullshit for the UI camera??? if (PlayState.isStoryMode) openSubState(new funkin.ui.StickerSubState(null, STORY));
if (PlayState.isStoryMode) FlxG.switchState(new StoryMenuState());
else else
FlxG.switchState(new FreeplayState()); openSubState(new funkin.ui.StickerSubState());
}
});
} }
} }

View file

@ -15,6 +15,7 @@ import funkin.play.PlayState;
import funkin.play.song.SongData.SongDataParser; import funkin.play.song.SongData.SongDataParser;
import lime.net.curl.CURLCode; import lime.net.curl.CURLCode;
import openfl.Assets; import openfl.Assets;
import funkin.ui.StickerSubState;
#if discord_rpc #if discord_rpc
import Discord.DiscordClient; import Discord.DiscordClient;
#end #end
@ -86,6 +87,18 @@ class StoryMenuState extends MusicBeatState
var yellowBG:FlxSprite; // not actually, yellow, lol! var yellowBG:FlxSprite; // not actually, yellow, lol!
var targetColor:Int = 0xFFF9CF51; var targetColor:Int = 0xFFF9CF51;
var stickerSubState:StickerSubState;
public function new(?stickers:StickerSubState = null)
{
if (stickers != null)
{
stickerSubState = stickers;
}
super();
}
override function create() override function create()
{ {
transIn = FlxTransitionableState.defaultTransIn; transIn = FlxTransitionableState.defaultTransIn;
@ -96,6 +109,17 @@ class StoryMenuState extends MusicBeatState
if (!FlxG.sound.music.playing) FlxG.sound.playMusic(Paths.music('freakyMenu')); if (!FlxG.sound.music.playing) FlxG.sound.playMusic(Paths.music('freakyMenu'));
} }
if (stickerSubState != null)
{
this.persistentUpdate = true;
this.persistentDraw = true;
openSubState(stickerSubState);
stickerSubState.degenStickers();
// resetSubState();
}
persistentUpdate = persistentDraw = true; persistentUpdate = persistentDraw = true;
scoreText = new FlxText(10, 10, 0, "SCORE: 49324858", 36); scoreText = new FlxText(10, 10, 0, "SCORE: 49324858", 36);
@ -293,8 +317,7 @@ class StoryMenuState extends MusicBeatState
difficultySelectors.visible = weekUnlocked[curWeek]; difficultySelectors.visible = weekUnlocked[curWeek];
grpLocks.forEach(function(lock:FlxSprite) grpLocks.forEach(function(lock:FlxSprite) {
{
lock.y = grpWeekText.members[lock.ID].y; lock.y = grpWeekText.members[lock.ID].y;
}); });
@ -380,8 +403,7 @@ class StoryMenuState extends MusicBeatState
}; };
SongLoad.curDiff = PlayState.storyDifficulty_NEW; SongLoad.curDiff = PlayState.storyDifficulty_NEW;
new FlxTimer().start(1, function(tmr:FlxTimer) new FlxTimer().start(1, function(tmr:FlxTimer) {
{
LoadingState.loadAndSwitchState(new PlayState(), true); LoadingState.loadAndSwitchState(new PlayState(), true);
}); });
} }

View file

@ -23,13 +23,20 @@ class StickerSubState extends MusicBeatSubstate
// yes... a damn OpenFL sprite!!! // yes... a damn OpenFL sprite!!!
public var dipshit:Sprite; public var dipshit:Sprite;
public function new(?oldStickers:Array<StickerSprite>):Void var nextState:NEXTSTATE = FREEPLAY;
public function new(?oldStickers:Array<StickerSprite>, ?nextState:NEXTSTATE = FREEPLAY):Void
{ {
super(); super();
this.nextState = nextState;
grpStickers = new FlxTypedGroup<StickerSprite>(); grpStickers = new FlxTypedGroup<StickerSprite>();
add(grpStickers); add(grpStickers);
// makes the stickers on the most recent camera, which is more often than not... a UI camera!!
grpStickers.cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]];
if (oldStickers != null) if (oldStickers != null)
{ {
for (sticker in oldStickers) for (sticker in oldStickers)
@ -46,6 +53,8 @@ class StickerSubState extends MusicBeatSubstate
public function degenStickers():Void public function degenStickers():Void
{ {
grpStickers.cameras = FlxG.cameras.list;
if (dipshit != null) if (dipshit != null)
{ {
FlxG.removeChild(dipshit); FlxG.removeChild(dipshit);
@ -130,14 +139,22 @@ class StickerSubState extends MusicBeatSubstate
dipshit = new Sprite(); dipshit = new Sprite();
var scrn:BitmapData = new BitmapData(FlxG.width, FlxG.height, true, 0x00000000); var scrn:BitmapData = new BitmapData(FlxG.width, FlxG.height, true, 0x00000000);
var mat:Matrix = new Matrix(); var mat:Matrix = new Matrix();
scrn.draw(FlxG.camera.canvas, mat); scrn.draw(grpStickers.cameras[0].canvas, mat);
var bitmap:Bitmap = new Bitmap(scrn); var bitmap:Bitmap = new Bitmap(scrn);
dipshit.addChild(bitmap); dipshit.addChild(bitmap);
FlxG.addChildBelowMouse(dipshit); FlxG.addChildBelowMouse(dipshit);
switch (nextState)
{
case FREEPLAY:
FlxG.switchState(new FreeplayState(this)); FlxG.switchState(new FreeplayState(this));
case STORY:
FlxG.switchState(new StoryMenuState(this));
default:
FlxG.switchState(new FreeplayState(this));
}
} }
// sticky.angle *= FlxG.random.float(0, 0.05); // sticky.angle *= FlxG.random.float(0, 0.05);
@ -277,3 +294,9 @@ typedef StickerShit =
stickers:Map<String, Array<String>>, stickers:Map<String, Array<String>>,
stickerPacks:Map<String, Array<String>> stickerPacks:Map<String, Array<String>>
} }
enum abstract NEXTSTATE(String)
{
var FREEPLAY = 'freeplay';
var STORY = 'story';
}