Skip to content

Commit 24c227c

Browse files
committed
Fix RmlUi field generation - add fields to fieldOrder
CRITICAL FIX: RmlUi fields weren't being added to fieldOrder array The problem: - _AddControl() adds to fieldOrder (for Chili fields with components) - _AddField() did NOT add to fieldOrder - RmlUi fields don't have .components, so they only call _AddField() - Result: fieldOrder was empty, _FinalizeRmlUi() generated no HTML The fix: - Modified _AddField() to add field.name to fieldOrder - Checks for duplicates (in case field was already added via _AddControl) - Now RmlUi fields appear in fieldOrder and get rendered Also: - Removed no_serialize skip in InitializeAllEditors() - no_serialize means "don't save state", not "don't initialize" - objectPropertyWindow and collisionView are valid editors that need initialization This fixes: "all editors have 0 fields" - they now generate proper RML
1 parent 682c0e5 commit 24c227c

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎scen_edit/view/editor.lua‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,19 @@ function Editor:_AddField(field)
387387
end
388388
self.fields[field.name] = field
389389
field.ev = self
390+
391+
-- Add to fieldOrder if not already added (via _AddControl)
392+
-- This is needed for RmlUi fields which don't have components
393+
local alreadyInOrder = false
394+
for _, name in ipairs(self.fieldOrder) do
395+
if name == field.name then
396+
alreadyInOrder = true
397+
break
398+
end
399+
end
400+
if not alreadyInOrder then
401+
table.insert(self.fieldOrder, field.name)
402+
end
390403
end
391404

392405
function Editor:AddControl(name, children)

‎scen_edit/view/view.lua‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,13 @@ function View:InitializeAllEditors()
172172
-- Instantiate all editors from editorRegistry
173173
-- This calls their init() which calls Finalize() which generates RML
174174
-- Doing this upfront catches field errors early instead of when users click buttons
175-
-- Skip editors with no_serialize=true (utility windows created on-demand)
176175
Log.Notice("Initializing all editors from editorRegistry...")
177176
local count = 0
178177
for name, editorCfg in pairs(SB.editorRegistry) do
179-
if editorCfg.editor and not editorCfg.no_serialize then
178+
if editorCfg.editor then
180179
Log.Notice(" Creating editor: " .. name)
181180
SB.editors[name] = editorCfg.editor()
182181
count = count + 1
183-
elseif editorCfg.no_serialize then
184-
Log.Notice(" Skipping utility window: " .. name .. " (no_serialize)")
185182
else
186183
Log.Warning(" Editor " .. name .. " has no constructor function")
187184
end

0 commit comments

Comments
 (0)