Skip to content

Commit 5741084

Browse files
committed
Use existing Chili editors with RmlUi field compatibility layer
Removed separate RmlUi editor hierarchy - not needed! The field compatibility layer (rmlui_field_compat.lua) makes: - StringField() → RmlUiStringField when RmlUi active - NumericField() → RmlUiNumericField when RmlUi active - etc. So existing Chili editors (GrassEditor, MetalEditor, LightingEditor, etc.) automatically work with RmlUi without any code changes: 1. Editor:init() adds fields using StringField(), NumericField(), etc. 2. Field compat layer creates RmlUi fields instead of Chili fields 3. Editor:Finalize() detects SB.view.useRmlUi and calls _FinalizeRmlUi() 4. _FinalizeRmlUi() generates HTML by calling field:GenerateRml() Changes: - Removed manual RmlUi editor initialization (RmlUiGrassEditor, etc.) - Removed rmlui_editor_base.lua and rmlui_components.lua includes - InitializeAllEditors() creates editors from editorRegistry - They auto-detect RmlUi mode and generate HTML via field compat layer This is cleaner and avoids duplicating editor definitions.
1 parent 24c227c commit 5741084

File tree

1 file changed

+4
-88
lines changed

1 file changed

+4
-88
lines changed

scen_edit/view/view.lua

Lines changed: 4 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,12 @@ function View:init()
4646
end
4747

4848
function View:InitializeRmlUi()
49-
-- Load RmlUi dialogs
50-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_dialogs/base_dialog.lua'))
51-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_dialogs/file_dialog.lua'))
52-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_dialogs/new_project_dialog.lua'))
53-
54-
-- Load RmlUi editors
55-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_editors/trigger_editor.lua'))
56-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_editors/object_editor.lua'))
57-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_editors/heightmap_editor.lua'))
58-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_editors/texture_editor.lua'))
59-
60-
-- Load RmlUi floating windows
61-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_floating/command_window.lua'))
62-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_floating/status_window.lua'))
63-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_floating/control_buttons.lua'))
64-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_floating/top_left_menu.lua'))
65-
66-
-- Load RmlUi field system (maintains original AddField API - implementation-agnostic!)
49+
-- Load RmlUi field system first (maintains original AddField API - implementation-agnostic!)
50+
-- This makes StringField(), NumericField(), etc. create RmlUi fields instead of Chili
6751
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_component.lua')) -- Base class for components
68-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_editor_base.lua'))
6952
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_fields.lua'))
7053
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_field_compat.lua')) -- Makes StringField() etc work
7154

72-
-- Load all other RmlUi components (general, map, object, trigger)
73-
SB.Include(Path.Join(SB.DIRS.SRC, 'view/rmlui_components.lua'))
74-
7555
-- Load main UI template
7656
local rmlPath = Path.Join(SB.DIRS.SRC, 'view/rml/springboard_main.rml')
7757
self.mainDocument = SB.rmlui:LoadDocument(rmlPath, true)
@@ -85,82 +65,18 @@ function View:InitializeRmlUi()
8565

8666
-- Initialize ALL editors upfront from editorRegistry
8767
-- This generates RML during init so we catch errors early
68+
-- The field compat layer makes existing Chili editors work with RmlUi automatically
8869
self:InitializeAllEditors()
8970

9071
-- Initialize tab system
9172
self.currentTab = "Objects"
9273
self:BindTabEvents()
9374
self:PopulateEditorButtons(self.currentTab)
9475

95-
-- Initialize floating windows (hidden by default)
96-
self.commandWindow = RmlUiCommandWindow()
97-
self.commandWindow:Initialize()
98-
-- self.commandWindow:Show() -- Hidden by default
99-
100-
self.statusWindow = RmlUiStatusWindow()
101-
self.statusWindow:Initialize()
102-
-- self.statusWindow:Show() -- Hidden by default
103-
104-
self.controlButtons = RmlUiControlButtons()
105-
self.controlButtons:Initialize()
106-
-- self.controlButtons:Show() -- Hidden by default
107-
108-
self.topLeftMenu = RmlUiTopLeftMenu()
109-
self.topLeftMenu:Initialize()
110-
-- self.topLeftMenu:Show() -- Hidden by default
111-
112-
-- Initialize editors (create instances but don't show)
113-
self.triggerEditor = RmlUiTriggerEditor()
114-
self.triggerEditor:Initialize()
115-
116-
self.objectEditor = RmlUiObjectEditor()
117-
self.objectEditor:Initialize()
118-
119-
self.heightmapEditor = RmlUiHeightmapEditor()
120-
self.heightmapEditor:Initialize()
121-
122-
self.textureEditor = RmlUiTextureEditor()
123-
self.textureEditor:Initialize()
124-
125-
-- Initialize all additional editors (don't show by default)
126-
self.grassEditor = RmlUiGrassEditor()
127-
self.grassEditor:Initialize()
128-
129-
self.metalEditor = RmlUiMetalEditor()
130-
self.metalEditor:Initialize()
131-
132-
self.waterEditor = RmlUiWaterEditor()
133-
self.waterEditor:Initialize()
134-
135-
self.lightingEditor = RmlUiLightingEditor()
136-
self.lightingEditor:Initialize()
137-
138-
self.skyEditor = RmlUiSkyEditor()
139-
self.skyEditor:Initialize()
140-
141-
self.terrainSettingsEditor = RmlUiTerrainSettingsEditor()
142-
self.terrainSettingsEditor:Initialize()
143-
144-
self.dntsEditor = RmlUiDNTSEditor()
145-
self.dntsEditor:Initialize()
146-
147-
self.materialBrowser = RmlUiMaterialBrowser()
148-
self.materialBrowser:Initialize()
149-
150-
-- Initialize general windows
151-
self.scenarioInfoView = RmlUiScenarioInfoView()
152-
self.scenarioInfoView:Initialize()
153-
154-
self.diplomacyWindow = RmlUiDiplomacyWindow()
155-
self.diplomacyWindow:Initialize()
156-
157-
self.playersWindow = RmlUiPlayersWindow()
158-
self.playersWindow:Initialize()
159-
16076
-- Setup event handlers
16177
self:SetupRmlUiEvents()
16278

163-
Log.Notice("RmlUi UI initialized successfully with all dialogs, editors, and floating windows")
79+
Log.Notice("RmlUi UI initialized successfully - editors use field compatibility layer")
16480
end
16581

16682
function View:InitializeAllEditors()

0 commit comments

Comments
 (0)