Skip to content

Commit 808c7ee

Browse files
committed
Add missing RmlUiComponent base class
The picker windows in rmlui_fields.lua were extending RmlUiComponent, but this base class was never defined, causing potential runtime errors. Added rmlui_component.lua with a simple base class for RmlUi components that don't need full dialog functionality (OK/Cancel buttons, etc.). This class provides: - Initialize() for loading RML documents - Show()/Hide()/Close() for visibility control - Simple title element support
1 parent 385864d commit 808c7ee

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

scen_edit/view/rmlui_component.lua

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--- RmlUi Base Component
2+
--- Simpler base class for RmlUi windows/components that aren't full dialogs
3+
--- (pickers, floating windows, etc.)
4+
5+
RmlUiComponent = LCS.class{}
6+
7+
function RmlUiComponent:init(rmlPath, title)
8+
self.rmlPath = rmlPath
9+
self.title = title or "Component"
10+
self.document = nil
11+
self.visible = false
12+
end
13+
14+
function RmlUiComponent:Initialize()
15+
if not SB.rmlui or not SB.rmlui.initialized then
16+
Log.Warning("RmlUi not initialized")
17+
return false
18+
end
19+
20+
-- Load document
21+
self.document = SB.rmlui:LoadDocument(self.rmlPath, false)
22+
if not self.document then
23+
Log.Error("Failed to load component: " .. self.rmlPath)
24+
return false
25+
end
26+
27+
-- Set title if there's a title element
28+
local titleElement = self.document:GetElementById("component-title")
29+
if titleElement then
30+
titleElement.inner_rml = self.title
31+
end
32+
33+
Log.Notice(self.title .. " component initialized")
34+
return true
35+
end
36+
37+
function RmlUiComponent:Show()
38+
if not self.document then
39+
if not self:Initialize() then
40+
return
41+
end
42+
end
43+
44+
self.document:Show()
45+
self.visible = true
46+
end
47+
48+
function RmlUiComponent:Hide()
49+
if self.document then
50+
self.document:Hide()
51+
self.visible = false
52+
end
53+
end
54+
55+
function RmlUiComponent:Close()
56+
if self.document then
57+
self.document:Close()
58+
self.document = nil
59+
self.visible = false
60+
end
61+
end
62+
63+
function RmlUiComponent:IsVisible()
64+
return self.visible
65+
end

scen_edit/view/view.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function View:InitializeRmlUi()
5252
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_floating/top_left_menu.lua'))
5353

5454
-- Load RmlUi field system (maintains original AddField API - implementation-agnostic!)
55+
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_component.lua')) -- Base class for components
5556
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_editor_base.lua'))
5657
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_fields.lua'))
5758
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_field_compat.lua')) -- Makes StringField() etc work

0 commit comments

Comments
 (0)