Skip to content

Commit b6560b6

Browse files
hopefully fix imgui autopause issues
1 parent 0831f69 commit b6560b6

1 file changed

Lines changed: 19 additions & 21 deletions

File tree

  • source/funkin/backend/system

source/funkin/backend/system/Main.hx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -205,31 +205,10 @@ class Main extends Sprite
205205
private static function onStateSwitch() {
206206
scaleMode.resetSize();
207207
}
208-
209-
#if IMGUI_ENABLED
210-
private static var imGuiActiveLastFrame:Bool = true;
211-
#end
212208
public static function onUpdate() {
213209
#if !IMGUI_ENABLED
214210
if (PlayerSettings.solo.controls.DEV_CONSOLE)
215211
NativeAPI.allocConsole();
216-
#else
217-
if ((ImGuiIO.configFlags & ImGuiConfigFlags.ViewportsEnable) != 0) //TODO: fix this because its not working 100% of the time
218-
{
219-
if (ImGuiIO.navActive || ImGuiIO.wantCaptureMouse || ImGuiIO.wantCaptureKeyboard) {
220-
if (!imGuiActiveLastFrame) {
221-
imGuiActiveLastFrame = true;
222-
FlxG.autoPause = false;
223-
FlxG.game.focusLostFramerate = FlxG.drawFramerate;
224-
}
225-
} else {
226-
if (imGuiActiveLastFrame) {
227-
imGuiActiveLastFrame = false;
228-
FlxG.autoPause = Options.autoPause;
229-
FlxG.game.focusLostFramerate = 10;
230-
}
231-
}
232-
}
233212
#end
234213

235214
if (PlayerSettings.solo.controls.FPS_COUNTER)
@@ -261,6 +240,9 @@ class Main extends Sprite
261240
return (FlxG.game.ticks - _tickFocused) / 1000;
262241
}
263242

243+
#if IMGUI_ENABLED
244+
private static var imGuiActiveLastFrame:Bool = true;
245+
#end
264246
private static function initImGui() {
265247
#if IMGUI_ENABLED
266248
//codename styled
@@ -308,6 +290,22 @@ class Main extends Sprite
308290
style.setColor(ImGuiCol.DockingPreview, new ImVec4(0.56, 0.11, 0.71, 1.00));
309291

310292
ImGuiHandler.instance.addCallback(function() {
293+
if ((ImGuiIO.configFlags & ImGuiConfigFlags.ViewportsEnable) != 0)
294+
{
295+
if (ImGuiIO.metricsRenderWindows > 2) { //debug window + dockspace
296+
if (!imGuiActiveLastFrame) {
297+
imGuiActiveLastFrame = true;
298+
FlxG.autoPause = false;
299+
FlxG.game.focusLostFramerate = FlxG.drawFramerate;
300+
}
301+
} else {
302+
if (imGuiActiveLastFrame) {
303+
imGuiActiveLastFrame = false;
304+
FlxG.autoPause = Options.autoPause;
305+
//FlxG.game.focusLostFramerate = 30; //just keep as draw fps, some timing issues with window focusing that keep it from working correctly
306+
}
307+
}
308+
}
311309
ImGui.dockSpaceOverViewport(0, null, ImGuiDockNodeFlags.PassthruCentralNode);
312310
});
313311
#end

0 commit comments

Comments
 (0)