Skip to content

Commit 330afc3

Browse files
committed
Fix checkbox visual state and texture editor Chili control crashes
- Add :checked pseudo-class styling for checkboxes - Checked checkboxes now show blue background (#3a7ebf) - Visual feedback when checkboxes are clicked - Guard all Chili control calls in texture_editor.lua - Wrap GetControl():Hide/Show() calls with RmlUi mode checks - Prevent crashes when savedBrushes controls don't exist - Skip brush UI logic in RmlUi mode (not yet implemented) - Conditionally create Chili children array Fixes: - Checkboxes now visually respond to clicks - Texture editor no longer crashes on init in RmlUi mode
1 parent fd9da88 commit 330afc3

File tree

2 files changed

+115
-57
lines changed

2 files changed

+115
-57
lines changed

scen_edit/view/map/texture_editor.lua

Lines changed: 110 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,16 @@ function TextureEditor:init()
148148
OnClick = {
149149
function()
150150
self:_EnterState("paint")
151-
self.savedBrushes:GetControl():Show()
152-
self.savedDNTSBrushes:GetControl():Hide()
151+
if not (SB.view and SB.view.useRmlUi) then
152+
if self.savedBrushes and self.savedBrushes.GetControl then
153+
local ctrl = self.savedBrushes:GetControl()
154+
if ctrl then ctrl:Show() end
155+
end
156+
if self.savedDNTSBrushes and self.savedDNTSBrushes.GetControl then
157+
local ctrl = self.savedDNTSBrushes:GetControl()
158+
if ctrl then ctrl:Hide() end
159+
end
160+
end
153161
self:SetInvisibleFields("kernelMode", "splatTexScale", "splatTexMult", "splat-sep", "exclusive", "value")
154162
end
155163
},
@@ -165,8 +173,16 @@ function TextureEditor:init()
165173
OnClick = {
166174
function()
167175
self:_EnterState("blur")
168-
self.savedBrushes:GetControl():Hide()
169-
self.savedDNTSBrushes:GetControl():Hide()
176+
if not (SB.view and SB.view.useRmlUi) then
177+
if self.savedBrushes and self.savedBrushes.GetControl then
178+
local ctrl = self.savedBrushes:GetControl()
179+
if ctrl then ctrl:Hide() end
180+
end
181+
if self.savedDNTSBrushes and self.savedDNTSBrushes.GetControl then
182+
local ctrl = self.savedDNTSBrushes:GetControl()
183+
if ctrl then ctrl:Hide() end
184+
end
185+
end
170186
self:SetInvisibleFields("texScale", "texOffsetX", "texOffsetY", "featureFactor", "diffuseColor",
171187
"mode", "texRotation", "splatTexScale", "splatTexMult", "offset-sep",
172188
"splat-sep", "exclusive", "value", "tex-sep",
@@ -195,12 +211,22 @@ function TextureEditor:init()
195211
-- if SB.dntsEditor.window.hidden then
196212
-- SB.view:SetMainPanel(SB.dntsEditor.window)
197213
-- end
198-
if #self.savedDNTSBrushes.brushManager:GetBrushIDs() == 0 then
199-
return
214+
if self.savedDNTSBrushes and self.savedDNTSBrushes.brushManager then
215+
if #self.savedDNTSBrushes.brushManager:GetBrushIDs() == 0 then
216+
return
217+
end
200218
end
201219
self:_EnterState("dnts")
202-
self.savedBrushes:GetControl():Hide()
203-
self.savedDNTSBrushes:GetControl():Show()
220+
if not (SB.view and SB.view.useRmlUi) then
221+
if self.savedBrushes and self.savedBrushes.GetControl then
222+
local ctrl = self.savedBrushes:GetControl()
223+
if ctrl then ctrl:Hide() end
224+
end
225+
if self.savedDNTSBrushes and self.savedDNTSBrushes.GetControl then
226+
local ctrl = self.savedDNTSBrushes:GetControl()
227+
if ctrl then ctrl:Show() end
228+
end
229+
end
204230
self:SetInvisibleFields("kernelMode", "texScale", "texOffsetX", "texOffsetY",
205231
"featureFactor", "diffuseColor", "mode", "texRotation",
206232
"falloffFactor", "offset-sep", "voidFactor", "tex-sep",
@@ -219,8 +245,16 @@ function TextureEditor:init()
219245
OnClick = {
220246
function()
221247
self:_EnterState("void")
222-
self.savedBrushes:GetControl():Hide()
223-
self.savedDNTSBrushes:GetControl():Hide()
248+
if not (SB.view and SB.view.useRmlUi) then
249+
if self.savedBrushes and self.savedBrushes.GetControl then
250+
local ctrl = self.savedBrushes:GetControl()
251+
if ctrl then ctrl:Hide() end
252+
end
253+
if self.savedDNTSBrushes and self.savedDNTSBrushes.GetControl then
254+
local ctrl = self.savedDNTSBrushes:GetControl()
255+
if ctrl then ctrl:Hide() end
256+
end
257+
end
224258
self:SetInvisibleFields("texScale", "texOffsetX", "texOffsetY", "strength", "featureFactor",
225259
"diffuseColor", "mode", "texRotation", "kernelMode", "splatTexScale",
226260
"splatTexMult", "offset-sep", "splat-sep", "exclusive", "value",
@@ -507,28 +541,32 @@ function TextureEditor:init()
507541
format = 'rgb',
508542
}))
509543

510-
local children = {
511-
self.btnPaint,
512-
self.btnFilter,
513-
self.btnDNTS,
514-
self.btnVoid,
515-
-- self.btnHeight,
516-
--self.patternTextureImages:GetControl(),
517-
self.savedBrushes:GetControl(),
518-
self.savedDNTSBrushes:GetControl(),
519-
ScrollPanel:New {
520-
x = 0,
521-
--y = "55%",
522-
y = "35%",
523-
bottom = 30,
524-
right = 0,
525-
borderColor = {0,0,0,0},
526-
horizontalScrollbar = false,
527-
children = {
528-
self.stackPanel
544+
local children = {}
545+
-- Only add Chili UI components in non-RmlUi mode
546+
if not (SB.view and SB.view.useRmlUi) then
547+
children = {
548+
self.btnPaint,
549+
self.btnFilter,
550+
self.btnDNTS,
551+
self.btnVoid,
552+
-- self.btnHeight,
553+
--self.patternTextureImages:GetControl(),
554+
self.savedBrushes and self.savedBrushes:GetControl() or nil,
555+
self.savedDNTSBrushes and self.savedDNTSBrushes:GetControl() or nil,
556+
ScrollPanel:New {
557+
x = 0,
558+
--y = "55%",
559+
y = "35%",
560+
bottom = 30,
561+
right = 0,
562+
borderColor = {0,0,0,0},
563+
horizontalScrollbar = false,
564+
children = {
565+
self.stackPanel
566+
},
529567
},
530-
},
531-
}
568+
}
569+
end
532570
SB.delay(function()
533571
for i = 0, 3 do
534572
local texturePath = SB.model.textureManager.shadingTextures["splat_normals" ..
@@ -546,7 +584,13 @@ function TextureEditor:init()
546584

547585
self:Finalize(children)
548586

549-
self.savedDNTSBrushes:GetControl():Hide()
587+
-- Only manipulate Chili controls in non-RmlUi mode
588+
if not (SB.view and SB.view.useRmlUi) and self.savedDNTSBrushes and self.savedDNTSBrushes.GetControl then
589+
local ctrl = self.savedDNTSBrushes:GetControl()
590+
if ctrl then
591+
ctrl:Hide()
592+
end
593+
end
550594
end
551595

552596
function TextureEditor:__AddEngineDNTSTexture(dntsIndex)
@@ -585,39 +629,48 @@ function TextureEditor:OnEndChange(name)
585629
end
586630

587631
function TextureEditor:OnFieldChange(name, value)
588-
if self.savedBrushes:GetControl().visible then
589-
local brush = self.savedBrushes:GetSelectedBrush()
590-
if brush then
591-
self.savedBrushes:UpdateBrush(brush.brushID, name, value)
592-
if name == "brushTexture" or name == "texOffsetX" or name == "texOffsetY"
593-
or name == "diffuseColor" or name == "texRotation" or name == "texScale" then
632+
-- Skip brush UI logic in RmlUi mode
633+
if not (SB.view and SB.view.useRmlUi) then
634+
local savedBrushesCtrl = self.savedBrushes and self.savedBrushes:GetControl()
635+
local savedDNTSBrushesCtrl = self.savedDNTSBrushes and self.savedDNTSBrushes:GetControl()
636+
637+
if savedBrushesCtrl and savedBrushesCtrl.visible then
638+
local brush = self.savedBrushes:GetSelectedBrush()
639+
if brush then
640+
self.savedBrushes:UpdateBrush(brush.brushID, name, value)
641+
if name == "brushTexture" or name == "texOffsetX" or name == "texOffsetY"
642+
or name == "diffuseColor" or name == "texRotation" or name == "texScale" then
643+
if name == "brushTexture" then
644+
SB.commandManager:execute(CacheTextureCommand(value))
645+
end
646+
647+
self.savedBrushes:RefreshBrushImage(brush.brushID)
648+
end
649+
end
650+
elseif savedDNTSBrushesCtrl and savedDNTSBrushesCtrl.visible then
651+
local brush = self.savedDNTSBrushes:GetSelectedBrush()
652+
if brush then
653+
self.savedDNTSBrushes:UpdateBrush(brush.brushID, name, value)
594654
if name == "brushTexture" then
595-
SB.commandManager:execute(CacheTextureCommand(value))
655+
--SB.commandManager:execute(CacheTextureCommand(value))
656+
self.savedDNTSBrushes:RefreshBrushImage(brush.brushID)
596657
end
597-
598-
self.savedBrushes:RefreshBrushImage(brush.brushID)
599658
end
600659
end
601-
elseif self.savedDNTSBrushes:GetControl().visible then
602-
local brush = self.savedDNTSBrushes:GetSelectedBrush()
603-
if brush then
604-
self.savedDNTSBrushes:UpdateBrush(brush.brushID, name, value)
605-
if name == "brushTexture" then
606-
--SB.commandManager:execute(CacheTextureCommand(value))
607-
self.savedDNTSBrushes:RefreshBrushImage(brush.brushID)
660+
661+
if name == "brushTexture" and savedDNTSBrushesCtrl and savedDNTSBrushesCtrl.visible then
662+
local dntsIndex = self:_GetDNTSIndex()
663+
local material = self.fields["brushTexture"].value
664+
if dntsIndex and material.normal then
665+
SB.delayGL(function()
666+
SB.model.textureManager:SetDNTS(dntsIndex, material)
667+
end)
608668
end
609669
end
610670
end
611671

612-
if name == "brushTexture" and self.savedDNTSBrushes:GetControl().visible then
613-
local dntsIndex = self:_GetDNTSIndex()
614-
local material = self.fields["brushTexture"].value
615-
if dntsIndex and material.normal then
616-
SB.delayGL(function()
617-
SB.model.textureManager:SetDNTS(dntsIndex, material)
618-
end)
619-
end
620-
elseif name == "splatTexScale" or name == "splatTexMult" then
672+
-- Handle DNTS-related field changes (works in both modes)
673+
if name == "splatTexScale" or name == "splatTexMult" then
621674
local index = self:_GetDNTSIndex()
622675
local tbl = {gl.GetMapRendering(name .. "s")}
623676
tbl[index+1] = value

scen_edit/view/rcss/springboard.rcss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ body#springboard {
191191
border: 1dp #555555;
192192
}
193193

194+
.field-checkbox:checked {
195+
background-color: #3a7ebf;
196+
border-color: #2a5f8f;
197+
}
198+
194199
.field-button {
195200
background-color: #3a7ebf;
196201
color: #ffffff;

0 commit comments

Comments
 (0)