move ui to mods
This commit is contained in:
1 parent
6c5c717e32
commit
4dc53b648b
5 files changed
+22
-94
No files matched your search
+13
-14
@@ -8,27 +8,26 @@
|
|||||||
"src/*.cs"
|
"src/*.cs"
|
||||||
],
|
],
|
||||||
"depends": [ "core>=1", "interface>=1" ],
|
"depends": [ "core>=1", "interface>=1" ],
|
||||||
"subscriptions": [
|
"ui": [
|
||||||
{
|
{
|
||||||
|
"id": "cooking_workbench",
|
||||||
|
"kind": "overlay",
|
||||||
"scene": "home_kitchen",
|
"scene": "home_kitchen",
|
||||||
"template": "default",
|
"slot": "ModLastPanel",
|
||||||
"code": "cooking_panel_init",
|
"scene_path": "scenes/cooking_panel.tscn",
|
||||||
"trigger": "on_enter",
|
"once": true,
|
||||||
|
"show_on_start": false,
|
||||||
"priority": 10
|
"priority": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "ration_stats",
|
||||||
|
"kind": "overlay",
|
||||||
"scene": "home_kitchen",
|
"scene": "home_kitchen",
|
||||||
"template": "default",
|
"slot": "Lastground",
|
||||||
"code": "dinner_tools_show",
|
"scene_path": "scenes/ration_statistics_panel.tscn",
|
||||||
"trigger": "on_enter",
|
"once": false,
|
||||||
|
"show_on_start": true,
|
||||||
"priority": 20
|
"priority": 20
|
||||||
},
|
|
||||||
{
|
|
||||||
"scene": "home_kitchen",
|
|
||||||
"template": "default",
|
|
||||||
"code": "dinner_tools_hide",
|
|
||||||
"trigger": "on_exit",
|
|
||||||
"priority": 10
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
using Cthangover.Core.Scenes;
|
|
||||||
using Cthangover.Core.Actions.Atomic;
|
|
||||||
using Cthangover.Core.Actions;
|
using Cthangover.Core.Actions;
|
||||||
|
using Cthangover.Core.Actions.Atomic;
|
||||||
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Core.Utils;
|
using Cthangover.Core.Utils;
|
||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Mods.Cooking.Workbench
|
namespace Mods.Cooking.Workbench
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scenario action registered under <c>toggle_cooking_workbench</c>
|
/// Scenario action registered under <c>toggle_cooking_workbench</c>.
|
||||||
/// that toggles the cooking workbench UI panel on the scenario screen.
|
/// Delegates to <see cref="UiRegistry.Toggle"/>, which owns the workbench
|
||||||
/// Called from scenario script directives via the action system.
|
/// panel instance and its visibility state — the action no longer searches
|
||||||
/// Locates the <c>ModLastPanel</c> root node in the scene tree,
|
/// the tree or builds the scene itself, so the panel survives scene changes.
|
||||||
/// finds the <c>CookingWorkbenchPanel</c> child (a <see cref="WorkbenchPanel"/>),
|
|
||||||
/// and calls <c>Switch()</c> to show or hide it. No-op if the root
|
|
||||||
/// or panel node is missing.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ToggleCookingPanelAction : IScenarioAction
|
public class ToggleCookingPanelAction : IScenarioAction
|
||||||
{
|
{
|
||||||
@@ -24,41 +20,12 @@ namespace Mods.Cooking.Workbench
|
|||||||
public string Name => "toggle_cooking_workbench";
|
public string Name => "toggle_cooking_workbench";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the toggle: finds the <c>CookingWorkbenchPanel</c>
|
/// Toggles the <c>cooking_workbench</c> entry through the UI registry.
|
||||||
/// under <c>ModLastPanel</c> and calls <c>Switch()</c> to
|
|
||||||
/// alternate its visibility state.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Run(IActionContext ctx)
|
public void Run(IActionContext ctx)
|
||||||
{
|
{
|
||||||
GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: looking for CookingWorkbenchPanel...");
|
GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: toggling 'cooking_workbench'");
|
||||||
var root = SceneContextNode.FindNode<Control>("ModLastPanel");
|
UiRegistry.Toggle("cooking_workbench");
|
||||||
if (root == null)
|
|
||||||
{
|
|
||||||
GameLogger.Log("COOKING", "ToggleCookingPanelAction.Run: ModLastPanel NOT FOUND", LogLevel.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var panel = root.GetNodeOrNull<WorkbenchPanel>("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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
var modPanel = FindNode<Control>("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);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
var modPanel = FindNode<Control>("Lastground");
|
|
||||||
if (modPanel == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var dinner = modPanel.GetNodeOrNull<Mods.Cooking.Rations.RationStatisticsPanel>("RationStatistics");
|
|
||||||
if (dinner != null)
|
|
||||||
dinner.QueueFree();
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
var modPanel = FindNode<Control>("Lastground");
|
|
||||||
if (modPanel == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var dinner = modPanel.GetNodeOrNull<Mods.Cooking.Rations.RationStatisticsPanel>("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();
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user