fix: Add targetStateFactory to prevent Stickers to be called during an ad.

This commit is contained in:
MoonDroid
2025-06-08 16:50:28 +07:00
parent 6e8494e615
commit 24db9235e1
+44 -3
View File
@@ -1,5 +1,6 @@
package funkin.play;
import funkin.ui.transition.stickers.StickerSubState;
import flixel.addons.display.FlxBackdrop;
import flixel.effects.FlxFlicker;
import flixel.FlxSprite;
@@ -98,6 +99,10 @@ class ResultState extends MusicBeatSubState
var blackTopBar:FlxSprite = new FlxSprite();
var targetStateFactory:Null<Void->StickerSubState> = null;
var busy:Bool = false;
public function new(params:ResultsStateParams)
{
super();
@@ -865,6 +870,7 @@ class ResultState extends MusicBeatSubState
if (controls.PAUSE || controls.ACCEPT #if mobile || TouchUtil.pressAction() #end)
{
if (busy) return;
if (_parentState is funkin.ui.debug.results.ResultsDebugSubState)
{
if (introMusicAudio != null)
@@ -955,7 +961,12 @@ class ResultState extends MusicBeatSubState
// No new characters.
shouldTween = false;
shouldUseSubstate = true;
targetState = new funkin.ui.transition.stickers.StickerSubState(
// targetState = new funkin.ui.transition.stickers.StickerSubState(
// {
// targetState: (sticker) -> new StoryMenuState(sticker),
// stickerPack: stickerPackId
// });
targetStateFactory = () -> new StickerSubState(
{
targetState: (sticker) -> new StoryMenuState(sticker),
stickerPack: stickerPackId
@@ -991,7 +1002,7 @@ class ResultState extends MusicBeatSubState
{
shouldTween = false;
shouldUseSubstate = true;
targetState = new funkin.ui.transition.stickers.StickerSubState(
targetStateFactory = () -> new StickerSubState(
{
targetState: (sticker) -> FreeplayState.build(null, sticker),
stickerPack: stickerPackId
@@ -1009,7 +1020,14 @@ class ResultState extends MusicBeatSubState
#if FEATURE_MOBILE_ADVERTISEMENTS
if (PlayStatePlaylist.isStoryMode || (Constants.GLOBAL_PLAYING_COUNTER > 0 && Constants.GLOBAL_PLAYING_COUNTER % 3 == 0))
{
busy = true;
AdMobUtil.loadInterstitial(function():Void {
if (targetStateFactory != null)
{
targetState = targetStateFactory();
}
busy = false;
if (shouldUseSubstate && targetState is FlxSubState)
{
openSubState(cast targetState);
@@ -1023,7 +1041,10 @@ class ResultState extends MusicBeatSubState
else
{
requestReview();
if (targetStateFactory != null)
{
targetState = targetStateFactory();
}
if (shouldUseSubstate && targetState is FlxSubState)
{
openSubState(cast targetState);
@@ -1036,6 +1057,10 @@ class ResultState extends MusicBeatSubState
#else
requestReview();
if (targetStateFactory != null)
{
targetState = targetStateFactory();
}
if (shouldUseSubstate && targetState is FlxSubState)
{
openSubState(cast targetState);
@@ -1054,10 +1079,16 @@ class ResultState extends MusicBeatSubState
#if FEATURE_MOBILE_ADVERTISEMENTS
if (PlayStatePlaylist.isStoryMode || (Constants.GLOBAL_PLAYING_COUNTER > 0 && Constants.GLOBAL_PLAYING_COUNTER % 3 == 0))
{
busy = true;
AdMobUtil.loadInterstitial(function():Void {
if (targetStateFactory != null)
{
targetState = targetStateFactory();
}
if (shouldUseSubstate && targetState is FlxSubState)
{
openSubState(cast targetState);
busy = false;
}
else
{
@@ -1069,6 +1100,11 @@ class ResultState extends MusicBeatSubState
{
requestReview();
if (targetStateFactory != null)
{
targetState = targetStateFactory();
}
if (shouldUseSubstate && targetState is FlxSubState)
{
openSubState(cast targetState);
@@ -1081,6 +1117,11 @@ class ResultState extends MusicBeatSubState
#else
requestReview();
if (targetStateFactory != null)
{
targetState = targetStateFactory();
}
if (shouldUseSubstate && targetState is FlxSubState)
{
openSubState(cast targetState);