Skip to content

Commit 8595402

Browse files
committed
Update simple editors to use UI abstraction layer
Convert 7 remaining simple editors to use ActionButton/EditorButton abstractions and new Finalize API: - metal_editor.lua: ActionButton for btnSetMetal, EditorButton for controls - grass_editor.lua: ActionButton for btnAddGrass - water_editor.lua: Use fields-only Finalize() - lighting_editor.lua: Use fields-only Finalize() - sky_editor.lua: Use fields-only Finalize() - terrain_settings_editor.lua: Use fields-only Finalize() - scenario_info_view.lua: Use fields-only Finalize() All editors now use new Finalize({actionButtons = {...}}) API and are completely UI-agnostic with no direct Chili component usage.
1 parent 72c4da9 commit 8595402

File tree

7 files changed

+14
-94
lines changed

7 files changed

+14
-94
lines changed

scen_edit/view/general/scenario_info_view.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,9 @@ function ScenarioInfoView:init()
4949
})
5050
)
5151

52-
local children = {
53-
ScrollPanel:New {
54-
x = 0,
55-
y = 0,
56-
bottom = 30,
57-
right = 0,
58-
borderColor = {0,0,0,0},
59-
horizontalScrollbar = false,
60-
children = { self.stackPanel },
61-
},
62-
}
63-
6452
SB.model.scenarioInfo:addListener(ScenarioInfoListenerWidget(self))
6553

66-
self:Finalize(children)
54+
self:Finalize()
6755
end
6856

6957
function ScenarioInfoView:OnStartChange(name)

scen_edit/view/map/grass_editor.lua

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function GrassEditor:init()
3737
SB.model.terrainManager:generateShape(texture)
3838
end
3939
}))
40-
self.btnAddGrass = TabbedPanelButton({
40+
self.btnAddGrass = ActionButton({
4141
x = 0,
4242
y = 0,
4343
tooltip = "Left Click to add grass, Right Click to remove it.",
@@ -83,19 +83,9 @@ function GrassEditor:init()
8383
tooltip = "Rotation of the shape",
8484
}))
8585

86-
local children = {
87-
self.btnAddGrass,
88-
ScrollPanel:New {
89-
x = 0,
90-
y = 70,
91-
bottom = 30,
92-
right = 0,
93-
borderColor = {0,0,0,0},
94-
horizontalScrollbar = false,
95-
children = { self.stackPanel },
96-
},
97-
}
98-
self:Finalize(children)
86+
self:Finalize({
87+
actionButtons = { self.btnAddGrass }
88+
})
9989
end
10090

10191
function GrassEditor:OnFieldChange(name, value)

scen_edit/view/map/lighting_editor.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,9 @@ function LightingEditor:init()
136136

137137
self:UpdateLighting()
138138

139-
local children = {
140-
ScrollPanel:New {
141-
x = 0,
142-
y = 0,
143-
bottom = 30,
144-
right = 0,
145-
borderColor = {0,0,0,0},
146-
horizontalScrollbar = false,
147-
children = { self.stackPanel },
148-
},
149-
}
150-
151139
SB.commandManager:addListener(self)
152140

153-
self:Finalize(children)
141+
self:Finalize()
154142
end
155143

156144
function LightingEditor:UpdateLighting()

scen_edit/view/map/metal_editor.lua

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function MetalEditor:init()
3737
SB.model.terrainManager:generateShape(texture)
3838
end
3939
}))
40-
self.btnSetMetal = TabbedPanelButton({
40+
self.btnSetMetal = ActionButton({
4141
x = 0,
4242
y = 0,
4343
tooltip = "Left Click to set metal. Right click to remove it.",
@@ -56,7 +56,7 @@ function MetalEditor:init()
5656
})
5757

5858
self:AddControl("btn-show-metal", {
59-
Button:New {
59+
EditorButton {
6060
caption = "Show metal map",
6161
width = 200,
6262
height = 40,
@@ -93,19 +93,9 @@ function MetalEditor:init()
9393
tooltip = "Amount of metal",
9494
}))
9595

96-
local children = {
97-
self.btnSetMetal,
98-
ScrollPanel:New {
99-
x = 0,
100-
y = 70,
101-
bottom = 30,
102-
right = 0,
103-
borderColor = {0,0,0,0},
104-
horizontalScrollbar = false,
105-
children = { self.stackPanel },
106-
},
107-
}
108-
self:Finalize(children)
96+
self:Finalize({
97+
actionButtons = { self.btnSetMetal }
98+
})
10999
end
110100

111101
function MetalEditor:IsValidState(state)

scen_edit/view/map/sky_editor.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,9 @@ function SkyEditor:init()
7878
}))
7979
self:UpdateAtmosphere()
8080

81-
local children = {
82-
ScrollPanel:New {
83-
x = 0,
84-
y = 0,
85-
bottom = 30,
86-
right = 0,
87-
borderColor = {0,0,0,0},
88-
horizontalScrollbar = false,
89-
children = { self.stackPanel },
90-
},
91-
}
92-
9381
SB.commandManager:addListener(self)
9482

95-
self:Finalize(children)
83+
self:Finalize()
9684
end
9785

9886
function SkyEditor:UpdateAtmosphere()

scen_edit/view/map/terrain_settings_editor.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,7 @@ function TerrainSettingsEditor:init()
4848
self:_AddMapTextureControls()
4949
-- self:_AddMapCompileControls()
5050

51-
local children = {
52-
ScrollPanel:New {
53-
x = 0,
54-
y = 0,
55-
bottom = 30,
56-
right = 0,
57-
borderColor = {0,0,0,0},
58-
horizontalScrollbar = false,
59-
children = { self.stackPanel },
60-
},
61-
}
62-
63-
self:Finalize(children)
51+
self:Finalize()
6452
end
6553

6654
function TerrainSettingsEditor:_AddMapTextureControls()

scen_edit/view/map/water_editor.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,9 @@ function WaterEditor:init()
269269

270270
self:UpdateWaterRendering()
271271

272-
local children = {
273-
ScrollPanel:New {
274-
x = 0,
275-
y = 0,
276-
bottom = 30,
277-
right = 0,
278-
borderColor = {0,0,0,0},
279-
horizontalScrollbar = false,
280-
children = { self.stackPanel },
281-
},
282-
}
283-
284272
SB.commandManager:addListener(self)
285273

286-
self:Finalize(children)
274+
self:Finalize()
287275
end
288276

289277
function WaterEditor:UpdateWaterRendering()

0 commit comments

Comments
 (0)