Skip to content

Commit 7c0a2d6

Browse files
committed
Fix ColorField table formatting and skip SetInvisibleFields in RmlUi
1. Fix ColorField:GenerateRml() string.format error - Color values are tables in Chili: {r, g, b, a} with 0-1 values - Convert to hex string format: #RRGGBB - Handle both table format and string format 2. Skip SetInvisibleFields in RmlUi mode - This is a Chili-specific method for showing/hiding fields - Calls Chili control methods (Show/Hide/SetVisibility) - RmlUi doesn't use Chili controls, so skip entirely - Field visibility in RmlUi handled via CSS/display properties Fixes: - bad argument #4 to 'format' (string expected, got table) at line 152 - attempt to index field 'parent' (a nil value) in object.lua:488
1 parent f4de1e1 commit 7c0a2d6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

scen_edit/view/editor.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ 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
312+
if SB.view and SB.view.useRmlUi then
313+
return
314+
end
315+
311316
if self.stackPanel then self.stackPanel:DisableRealign() end
312317

313318
local fields = {...}

scen_edit/view/rmlui_fields.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,23 @@ function RmlUiColorField:init(opts)
149149
end
150150

151151
function RmlUiColorField:GenerateRml()
152+
-- Convert color to hex string
153+
local colorHex = "#FFFFFF"
154+
if self.value then
155+
if type(self.value) == "table" then
156+
-- Chili format: {r, g, b, a} where values are 0-1
157+
local r = math.floor((self.value[1] or self.value.r or 1) * 255)
158+
local g = math.floor((self.value[2] or self.value.g or 1) * 255)
159+
local b = math.floor((self.value[3] or self.value.b or 1) * 255)
160+
colorHex = string.format("#%02X%02X%02X", r, g, b)
161+
else
162+
colorHex = tostring(self.value)
163+
end
164+
end
165+
152166
return string.format(
153167
'<div class="field-row"><label class="field-label">%s:</label><input type="color" id="field-%s" class="field-input" value="%s"/><button id="btn-pick-%s" class="field-button">Pick</button></div>',
154-
self.title, self.name, self.value or "#FFFFFF", self.name
168+
self.title, self.name, colorHex, self.name
155169
)
156170
end
157171

0 commit comments

Comments
 (0)