Skip to content

Commit 36d9a1a

Browse files
committed
Use existing MainWindowPanel for both Chili and RmlUi modes
Instead of creating parallel initialization systems, reuse what exists. Changes: 1. MainWindowPanel:AddElement() now detects RmlUi mode - In RmlUi: skips Chili button creation, uses SB.delay for editors - In Chili: creates buttons and editors as before 2. View:InitializeRmlUi() now creates TabbedWindow (like Chili does) - TabbedWindow creates MainWindowPanels - MainWindowPanel:AddElements() populates from editorRegistry - Editor creation happens via existing SB.delay mechanism 3. Removed custom PreCreateAllEditors() - not needed This unifies the editor initialization path for both UI systems. Both modes now use the same TabbedWindow/MainWindowPanel infrastructure, with MainWindowPanel detecting the mode and adapting behavior.
1 parent e73dbfe commit 36d9a1a

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

scen_edit/view/main_window/main_window_panel.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ function MainWindowPanel:AddElement(tbl)
9494
local name = tbl.name
9595
local editor = tbl.editor
9696

97+
-- In RmlUi mode, skip Chili button creation but still create editors
98+
if SB.view and SB.view.useRmlUi then
99+
SB.delay(function()
100+
if not SB.editors[name] then
101+
SB.editors[name] = editor()
102+
end
103+
end)
104+
self._totalEditors = self._totalEditors + 1
105+
return
106+
end
107+
108+
-- Chili mode: create button and editor
97109
local btn = TabbedPanelButton({
98110
tooltip = tooltip,
99111
children = {

scen_edit/view/view.lua

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,21 @@ function View:InitializeRmlUi()
6868
SB.editors = {}
6969
end
7070

71+
-- Use existing TabbedWindow/MainWindowPanel infrastructure (works in both modes)
72+
-- This handles editor creation via SB.delay automatically
73+
self.tabbedWindow = TabbedWindow()
74+
7175
-- Initialize tab system
7276
self.currentTab = "Objects"
7377
self:BindTabEvents()
7478
self:PopulateEditorButtons(self.currentTab)
7579

76-
-- Pre-create ALL editors using SB.delay (matching Chili's approach)
77-
-- This catches errors early while avoiding SB.view nil issues
78-
self:PreCreateAllEditors()
79-
8080
-- Setup event handlers
8181
self:SetupRmlUiEvents()
8282

8383
Log.Notice("RmlUi UI initialized successfully - editors use field compatibility layer")
8484
end
8585

86-
function View:PreCreateAllEditors()
87-
-- Pre-create all registered editors using SB.delay
88-
-- This matches the original Chili approach in main_window_panel.lua
89-
-- Defers creation until after SB.view is assigned
90-
for name, editorCfg in pairs(SB.editorRegistry) do
91-
SB.delay(function()
92-
if not SB.editors[name] and editorCfg.editor then
93-
Log.Notice("Pre-creating editor: " .. name)
94-
SB.editors[name] = editorCfg.editor()
95-
end
96-
end)
97-
end
98-
end
99-
10086
function View:SetupRmlUiEvents()
10187
if not self.mainDocument then
10288
return
@@ -360,7 +346,7 @@ end
360346
function View:OpenEditor(editorName)
361347
Log.Notice("Opening editor: " .. editorName)
362348

363-
-- Editor should be pre-created by PreCreateAllEditors()
349+
-- Editor should be pre-created by TabbedWindow/MainWindowPanel
364350
local editor = SB.editors[editorName]
365351
if not editor then
366352
Log.Error("Editor not yet created: " .. editorName .. " (still initializing?)")

0 commit comments

Comments
 (0)