Skip to content

Commit 59eec6e

Browse files
committed
Fix field rendering issues - GroupFields, colons, checkboxes, visibility
1. Remove duplicate GroupField children - Mark children with _isGroupChild flag - Skip rendering them separately in _FinalizeRmlUi - They're only rendered as part of the GroupField 2. Hide auto-generated GroupField names - Don't show "_groupField1", "_groupField2", etc. - Only show title if explicitly provided and not auto-generated 3. Fix double colons in labels (Amount:: → Amount:) - Strip trailing ":" from title before adding it - Applied to all field types 4. Make GroupField children inline - Replace field-row with field-inline for group children - Inline layout with smaller fixed-width inputs (100dp) 5. Add checkbox styling - .field-checkbox class for checkboxes - 20dp x 20dp size 6. Implement SetInvisibleFields for RmlUi - Use SetClass("hidden", true/false) on field parent nodes - Added .hidden { display: none; } CSS rule - Can't just skip it - need proper visibility control 7. Add CSS for inline fields and groups - .field-inline for inline display in groups - .field-inline .field-input: fixed 100dp width - .field-group: increased gap to 10dp Fixes all reported issues: duplicate fields, group names, double colons, small textboxes, missing checkboxes, broken field visibility.
1 parent 7c0a2d6 commit 59eec6e

File tree

3 files changed

+94
-18
lines changed

3 files changed

+94
-18
lines changed

scen_edit/view/editor.lua

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,30 @@ end
308308
--- Sets fields which are to be made invisible.
309309
-- @tparam {string, ...} ... Field names to be set invisible
310310
function Editor:SetInvisibleFields(...)
311-
-- Skip in RmlUi mode - field visibility is handled differently
311+
-- In RmlUi mode, set CSS display classes instead of manipulating Chili controls
312312
if SB.view and SB.view.useRmlUi then
313+
local fieldsToHide = {...}
314+
-- Hide all fields first
315+
for _, fieldName in ipairs(self.fieldOrder) do
316+
if SB.view.mainDocument then
317+
local fieldElement = SB.view.mainDocument:GetElementById("field-" .. fieldName)
318+
if fieldElement and fieldElement.parent_node then
319+
-- Hide the parent row
320+
fieldElement.parent_node:SetClass("hidden", true)
321+
end
322+
end
323+
end
324+
-- Show fields not in the hide list
325+
for _, fieldName in ipairs(self.fieldOrder) do
326+
if not table.ifind(fieldsToHide, fieldName) then
327+
if SB.view.mainDocument then
328+
local fieldElement = SB.view.mainDocument:GetElementById("field-" .. fieldName)
329+
if fieldElement and fieldElement.parent_node then
330+
fieldElement.parent_node:SetClass("hidden", false)
331+
end
332+
end
333+
end
334+
end
313335
return
314336
end
315337

@@ -380,6 +402,8 @@ function Editor:AddField(field)
380402
for _, childField in ipairs(field.fields) do
381403
if childField.name then
382404
self:_AddField(childField)
405+
-- Mark child field as part of a group so it won't be rendered separately
406+
childField._isGroupChild = true
383407
end
384408
end
385409
end
@@ -704,20 +728,23 @@ SB.IncludeDir(Path.Join(SB.DIRS.SRC, 'view/fields'))
704728
function Editor:_FinalizeRmlUi(opts)
705729
-- Generate RML for all fields
706730
local html = ''
707-
731+
708732
for _, fieldName in ipairs(self.fieldOrder) do
709733
local field = self.fields[fieldName]
710-
if field and field.GenerateRml then
711-
html = html .. field:GenerateRml()
712-
elseif field then
713-
-- Fallback for fields without GenerateRml (like separators/controls)
714-
html = html .. '<div class="field-separator"></div>'
734+
-- Skip fields that are children of GroupFields (they're rendered by the group)
735+
if field and not field._isGroupChild then
736+
if field.GenerateRml then
737+
html = html .. field:GenerateRml()
738+
else
739+
-- Fallback for fields without GenerateRml (like separators/controls)
740+
html = html .. '<div class="field-separator"></div>'
741+
end
715742
end
716743
end
717-
744+
718745
-- Store the generated RML for later use
719746
self.generatedRml = html
720-
747+
721748
-- Mark as hidden by default
722749
self.hidden = true
723750
end

scen_edit/view/rcss/springboard.rcss

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,28 @@ body#springboard {
142142
gap: 10dp;
143143
}
144144

145+
.field-row.hidden {
146+
display: none;
147+
}
148+
149+
.field-inline {
150+
display: flex;
151+
flex-direction: row;
152+
align-items: center;
153+
gap: 5dp;
154+
}
155+
156+
.field-inline .field-label {
157+
min-width: auto;
158+
margin-right: 5dp;
159+
}
160+
161+
.field-inline .field-input {
162+
flex: 0 0 auto;
163+
min-width: 80dp;
164+
width: 100dp;
165+
}
166+
145167
.field-label {
146168
min-width: 120dp;
147169
color: #cccccc;
@@ -162,6 +184,13 @@ body#springboard {
162184
background-color: #2a2a2a;
163185
}
164186

187+
.field-checkbox {
188+
width: 20dp;
189+
height: 20dp;
190+
background-color: #3a3a3a;
191+
border: 1dp #555555;
192+
}
193+
165194
.field-button {
166195
background-color: #3a7ebf;
167196
color: #ffffff;
@@ -183,6 +212,7 @@ body#springboard {
183212
.field-group {
184213
display: flex;
185214
flex-direction: row;
186-
gap: 5dp;
215+
gap: 10dp;
187216
margin-bottom: 10dp;
217+
align-items: center;
188218
}

scen_edit/view/rmlui_fields.lua

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ function RmlUiStringField:init(opts)
6363
end
6464

6565
function RmlUiStringField:GenerateRml()
66+
-- Remove trailing colon from title if present
67+
local title = self.title:gsub(":$", "")
6668
return string.format(
6769
'<div class="field-row"><label class="field-label">%s:</label><input type="text" id="field-%s" class="field-input" value="%s"/></div>',
68-
self.title, self.name, self.value or ""
70+
title, self.name, self.value or ""
6971
)
7072
end
7173

@@ -85,10 +87,12 @@ function RmlUiNumericField:GenerateRml()
8587
if self.min then attrs = attrs .. ' min="' .. self.min .. '"' end
8688
if self.max then attrs = attrs .. ' max="' .. self.max .. '"' end
8789
if self.step then attrs = attrs .. ' step="' .. self.step .. '"' end
90+
-- Remove trailing colon from title if present
91+
local title = self.title:gsub(":$", "")
8892

8993
return string.format(
9094
'<div class="field-row"><label class="field-label">%s:</label><input type="number" %s/></div>',
91-
self.title, attrs
95+
title, attrs
9296
)
9397
end
9498

@@ -101,9 +105,11 @@ end
101105

102106
function RmlUiBooleanField:GenerateRml()
103107
local checked = self.value and 'checked="checked"' or ''
108+
-- Remove trailing colon from title if present
109+
local title = self.title:gsub(":$", "")
104110
return string.format(
105-
'<div class="field-row"><label class="field-label">%s:</label><input type="checkbox" id="field-%s" %s/></div>',
106-
self.title, self.name, checked
111+
'<div class="field-row"><label class="field-label">%s:</label><input type="checkbox" id="field-%s" class="field-checkbox" %s/></div>',
112+
title, self.name, checked
107113
)
108114
end
109115

@@ -123,10 +129,12 @@ function RmlUiChoiceField:GenerateRml()
123129
local selected = (tostring(item) == tostring(self.value)) and ' selected="selected"' or ''
124130
options = options .. string.format('<option value="%s"%s>%s</option>', tostring(item), selected, caption)
125131
end
132+
-- Remove trailing colon from title if present
133+
local title = self.title:gsub(":$", "")
126134

127135
return string.format(
128136
'<div class="field-row"><label class="field-label">%s:</label><select id="field-%s" class="field-input">%s</select></div>',
129-
self.title, self.name, options
137+
title, self.name, options
130138
)
131139
end
132140

@@ -310,13 +318,24 @@ function RmlUiGroupField:init(opts)
310318
end
311319

312320
function RmlUiGroupField:GenerateRml()
321+
-- Group fields display children inline without showing group name
313322
local html = '<div class="field-group">'
314-
if self.title then
315-
html = html .. '<label class="field-label">' .. self.title .. ':</label>'
323+
324+
-- Only show label if explicitly provided (not auto-generated "_groupField" names)
325+
if self.title and not self.title:match("^_groupField%d+$") then
326+
local title = self.title:gsub(":$", "")
327+
html = html .. '<label class="field-label">' .. title .. ':</label>'
316328
end
317329

318330
for _, field in ipairs(self.fields) do
319-
html = html .. field:GenerateRml()
331+
-- Generate inline field HTML (without the field-row wrapper)
332+
if field.GenerateRml then
333+
-- For group children, generate compact inline version
334+
local fieldHtml = field:GenerateRml()
335+
-- Remove the field-row wrapper for inline display
336+
fieldHtml = fieldHtml:gsub('<div class="field%-row">', '<div class="field-inline">')
337+
html = html .. fieldHtml
338+
end
320339
end
321340

322341
html = html .. '</div>'

0 commit comments

Comments
 (0)