@@ -9,18 +9,19 @@ namespace GodotModules
99 public class GM : Node
1010 {
1111 [ Export ] public readonly NodePath NodePathGameConsole ;
12+
1213 public static ModLoader ModLoader { get ; set ; }
13- public static UIGameConsole GameConsole { get ; set ; }
14- private static GodotCommands GodotCommands { get ; set ; }
15- private static Logger Logger { get ; set ; }
16-
1714 public static string GameName = "Godot Modules" ;
1815 public static OptionsData Options { get ; set ; }
19- public static SceneTree GameTree { get ; set ; }
16+ public static SceneTree PersistentTree { get ; set ; }
17+
18+ private static UIGameConsole GameConsole { get ; set ; }
19+ private static GodotCommands GodotCommands { get ; set ; }
20+ private static Logger Logger { get ; set ; }
2021
2122 public override void _Ready ( )
2223 {
23- GameTree = GetTree ( ) ;
24+ PersistentTree = GetTree ( ) ;
2425 GameConsole = GetNode < UIGameConsole > ( NodePathGameConsole ) ;
2526 GodotCommands = new GodotCommands ( ) ;
2627 Logger = new Logger ( ) ;
@@ -49,7 +50,7 @@ public override void _Input(InputEvent @event)
4950 public static void SpawnPopupMessage ( string message )
5051 {
5152 var popupMessage = Prefabs . PopupMessage . Instance < UIPopupMessage > ( ) ;
52- GameTree . CurrentScene . AddChild ( popupMessage ) ;
53+ PersistentTree . CurrentScene . AddChild ( popupMessage ) ;
5354 popupMessage . Init ( message ) ;
5455 popupMessage . PopupCentered ( ) ;
5556 }
@@ -58,11 +59,15 @@ public static void SpawnPopupError(Exception e)
5859 {
5960 ErrorNotifier . IncrementErrorCount ( ) ;
6061 var popupError = Prefabs . PopupError . Instance < UIPopupError > ( ) ;
61- GameTree . CurrentScene . AddChild ( popupError ) ;
62+ PersistentTree . CurrentScene . AddChild ( popupError ) ;
6263 popupError . Init ( e . Message , e . StackTrace ) ;
6364 popupError . PopupCentered ( ) ;
6465 }
6566
67+ public static void LogConsoleMessage ( string message ) => GameConsole . AddMessage ( message ) ;
68+ public static void ToggleConsoleVisibility ( ) => GameConsole . ToggleVisibility ( ) ;
69+ public static bool GameConsoleVisible => GameConsole . Visible ;
70+
6671 public static void EnqueueGodotCmd ( GodotOpcode opcode , object data = null ) => GodotCommands . Enqueue ( opcode , data ) ;
6772
6873 public static void Log ( object v , ConsoleColor color = ConsoleColor . Gray ) => Logger . Log ( v , color ) ;
@@ -72,10 +77,6 @@ public static void SpawnPopupError(Exception e)
7277 public static void LogTODO ( object v , ConsoleColor color = ConsoleColor . White ) => Logger . LogTODO ( v , color ) ;
7378 public static void LogMs ( Action code ) => Logger . LogMs ( code ) ;
7479
75- /// <summary>
76- /// This should be used instead of GetTree().Quit() has it will handle cleanup and saving options
77- /// Note that if the console is closed directly then the cleanup will never happen, this should be avoided.
78- /// </summary>
79- public static void Exit ( ) => GameTree . Notification ( MainLoop . NotificationWmQuitRequest ) ;
80+ public static void Exit ( ) => PersistentTree . Notification ( MainLoop . NotificationWmQuitRequest ) ;
8081 }
8182}
0 commit comments