diff --git a/manifest.json b/manifest.json
index c358726..de4c0d6 100644
--- a/manifest.json
+++ b/manifest.json
@@ -8,27 +8,26 @@
"src/*.cs"
],
"depends": [ "core>=1", "interface>=1" ],
- "subscriptions": [
+ "ui": [
{
+ "id": "cooking_workbench",
+ "kind": "overlay",
"scene": "home_kitchen",
- "template": "default",
- "code": "cooking_panel_init",
- "trigger": "on_enter",
+ "slot": "ModLastPanel",
+ "scene_path": "scenes/cooking_panel.tscn",
+ "once": true,
+ "show_on_start": false,
"priority": 10
},
{
+ "id": "ration_stats",
+ "kind": "overlay",
"scene": "home_kitchen",
- "template": "default",
- "code": "dinner_tools_show",
- "trigger": "on_enter",
+ "slot": "Lastground",
+ "scene_path": "scenes/ration_statistics_panel.tscn",
+ "once": false,
+ "show_on_start": true,
"priority": 20
- },
- {
- "scene": "home_kitchen",
- "template": "default",
- "code": "dinner_tools_hide",
- "trigger": "on_exit",
- "priority": 10
}
]
}
diff --git a/src/ui/workbench/ToggleCookingPanelAction.cs b/src/ui/workbench/ToggleCookingPanelAction.cs
index deb0407..94e2057 100644
--- a/src/ui/workbench/ToggleCookingPanelAction.cs
+++ b/src/ui/workbench/ToggleCookingPanelAction.cs
@@ -1,19 +1,15 @@
-using Cthangover.Core.Scenes;
-using Cthangover.Core.Actions.Atomic;
using Cthangover.Core.Actions;
+using Cthangover.Core.Actions.Atomic;
+using Cthangover.Core.UI;
using Cthangover.Core.Utils;
-using Godot;
namespace Mods.Cooking.Workbench
{
///
- /// Scenario action registered under toggle_cooking_workbench
- /// that toggles the cooking workbench UI panel on the scenario screen.
- /// Called from scenario script directives via the action system.
- /// Locates the ModLastPanel root node in the scene tree,
- /// finds the CookingWorkbenchPanel child (a ),
- /// and calls Switch() to show or hide it. No-op if the root
- /// or panel node is missing.
+ /// Scenario action registered under toggle_cooking_workbench.
+ /// Delegates to , which owns the workbench
+ /// panel instance and its visibility state — the action no longer searches
+ /// the tree or builds the scene itself, so the panel survives scene changes.
///
public class ToggleCookingPanelAction : IScenarioAction
{
@@ -24,41 +20,12 @@ namespace Mods.Cooking.Workbench
public string Name => "toggle_cooking_workbench";
///
- /// Executes the toggle: finds the CookingWorkbenchPanel
- /// under ModLastPanel and calls Switch() to
- /// alternate its visibility state.
+ /// Toggles the cooking_workbench entry through the UI registry.
///
public void Run(IActionContext ctx)
{
- GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: looking for CookingWorkbenchPanel...");
- var root = SceneContextNode.FindNode("ModLastPanel");
- if (root == null)
- {
- GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: ModLastPanel NOT FOUND", LogLevel.Error);
- return;
- }
-
- var panel = root.GetNodeOrNull("CookingWorkbenchPanel");
- if (panel == null)
- {
- GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: creating panel via TscnScenes.LoadAndBuild...");
- var loaded = TscnScenes.LoadAndBuild("scenes/cooking_panel.tscn");
- if (loaded == null)
- {
- GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: LoadAndBuild returned NULL", LogLevel.Error);
- return;
- }
- var control = loaded as Control;
- if (control == null) return;
- control.Name = "CookingWorkbenchPanel";
- control.Visible = false;
- control.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.FullRect);
- root.AddChild(control);
- panel = control as WorkbenchPanel;
- }
-
- GameLogger.Log("COOKING", $"ToggleCookingPanelAction.Run: switching panel (currently Visible={panel?.Visible})");
- panel?.Switch();
+ GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: toggling 'cooking_workbench'");
+ UiRegistry.Toggle("cooking_workbench");
}
}
}
diff --git a/subscriptions/cooking_panel_init.cs b/subscriptions/cooking_panel_init.cs
deleted file mode 100644
index 2a79ffe..0000000
--- a/subscriptions/cooking_panel_init.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-var modPanel = FindNode("ModLastPanel");
-if (modPanel == null)
- return;
-
-if (modPanel.GetNodeOrNull("CookingWorkbenchPanel") != null)
- return;
-
-var panel = Cthangover.Core.Scenes.TscnScenes.LoadAndBuild("scenes/cooking_panel.tscn");
-if (panel is Control control)
-{
- control.Name = "CookingWorkbenchPanel";
- control.Visible = false;
- control.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.FullRect);
- modPanel.AddChild(control);
-}
\ No newline at end of file
diff --git a/subscriptions/dinner_tools_hide.cs b/subscriptions/dinner_tools_hide.cs
deleted file mode 100644
index 0660830..0000000
--- a/subscriptions/dinner_tools_hide.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-var modPanel = FindNode("Lastground");
-if (modPanel == null)
- return;
-
-var dinner = modPanel.GetNodeOrNull("RationStatistics");
-if (dinner != null)
- dinner.QueueFree();
diff --git a/subscriptions/dinner_tools_show.cs b/subscriptions/dinner_tools_show.cs
deleted file mode 100644
index 70f7129..0000000
--- a/subscriptions/dinner_tools_show.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-var modPanel = FindNode("Lastground");
-if (modPanel == null)
- return;
-
-var dinner = modPanel.GetNodeOrNull("RationStatistics");
-if (dinner == null)
-{
- dinner = (Mods.Cooking.Rations.RationStatisticsPanel)Cthangover.Core.Scenes.TscnScenes.LoadAndBuild("scenes/ration_statistics_panel.tscn");
- dinner.Name = "RationStatistics";
- dinner.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.FullRect);
- dinner.CustomMinimumSize = new Vector2(300, 300);
- modPanel.AddChild(dinner);
-
- dinner.Show();
- modPanel.UpdateMinimumSize();
-}