Skip to content

Commit 83cf69b

Browse files
authored
UIState Reloading Fix (#469)
* Reloading UIStates does not softlock anymore * fix * Removed all prev changes and use a better method * Switch to tabs
1 parent eada310 commit 83cf69b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/funkin/backend/MusicBeatState.hx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class MusicBeatState extends FlxState implements IBeatReceiver
9393

9494
public var scriptsAllowed:Bool = true;
9595

96+
public static var lastScriptName:String = null;
97+
public static var lastStateName:String = null;
98+
9699
public var scriptName:String = null;
97100

98101
public static var skipTransOut:Bool = false;
@@ -108,7 +111,12 @@ class MusicBeatState extends FlxState implements IBeatReceiver
108111
public function new(scriptsAllowed:Bool = true, ?scriptName:String) {
109112
super();
110113
this.scriptsAllowed = #if SOFTCODED_STATES scriptsAllowed #else false #end;
111-
this.scriptName = scriptName;
114+
115+
if(lastStateName != (lastStateName = Type.getClassName(Type.getClass(this)))) {
116+
lastScriptName = null;
117+
}
118+
this.scriptName = scriptName != null ? scriptName : lastScriptName;
119+
lastScriptName = this.scriptName;
112120
}
113121

114122
function loadScript() {

0 commit comments

Comments
 (0)