Skip to content

Commit b80cc8b

Browse files
committed
Add action buttons bar to RmlUi UI
- Add action-bar div to RML template between tab bar and editor panel - Add CSS styling for action bar and toolbar-action-button - Update layout: action bar at 40dp, editor panel at 90dp, content at 175dp - Implement PopulateActionButtons() to create buttons from SB.actionRegistry - Bind click events to execute actions (Save, Load, Export, etc.) - Fix icon paths to be relative to RML document location Matches Chili mode behavior where action buttons appear between tabs and editor buttons.
1 parent 0b546d7 commit b80cc8b

File tree

3 files changed

+101
-3
lines changed

3 files changed

+101
-3
lines changed

scen_edit/view/rcss/springboard.rcss

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,49 @@ body#springboard {
4646
border-bottom: 2dp #3a7ebf;
4747
}
4848

49+
/* Action bar (Save, Load, etc.) */
50+
.action-bar {
51+
position: absolute;
52+
top: 40dp;
53+
left: 0dp;
54+
right: 0dp;
55+
height: 45dp;
56+
background-color: #222222;
57+
border-bottom: 1dp #555555;
58+
display: flex;
59+
flex-direction: row;
60+
gap: 1dp;
61+
padding: 2dp 5dp;
62+
align-items: center;
63+
}
64+
65+
.toolbar-action-button {
66+
width: 40dp;
67+
height: 40dp;
68+
background-color: #3a3a3a;
69+
border: 1dp #555555;
70+
border-radius: 3dp;
71+
cursor: pointer;
72+
padding: 0dp;
73+
display: flex;
74+
align-items: center;
75+
justify-content: center;
76+
}
77+
78+
.toolbar-action-button:hover {
79+
background-color: #4a4a4a;
80+
border-color: #777777;
81+
}
82+
83+
.toolbar-action-button img {
84+
width: 20dp;
85+
height: 20dp;
86+
}
87+
4988
/* Editor button panel (scrollable horizontal) - matches TOOLBOX_ITEM_HEIGHT (70dp) + padding */
5089
.editor-panel-wrapper {
5190
position: absolute;
52-
top: 40dp;
91+
top: 90dp;
5392
left: 0dp;
5493
right: 0dp;
5594
height: 80dp;
@@ -108,10 +147,10 @@ body#springboard {
108147
color: #00ff00;
109148
}
110149

111-
/* Main content area - starts after editor panel (40 + 80 = 120dp) */
150+
/* Main content area - starts after editor panel (40 tab + 45 action + 80 editor = 165dp + 10 margin) */
112151
.main-content {
113152
position: absolute;
114-
top: 125dp;
153+
top: 175dp;
115154
left: 0dp;
116155
right: 0dp;
117156
bottom: 0dp;

scen_edit/view/rml/springboard_main.rml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
<button id="tab-Misc" class="tab-button">Misc</button>
1414
</div>
1515

16+
<!-- Action buttons bar (Save, Load, etc.) -->
17+
<div id="action-bar" class="action-bar">
18+
<!-- Action buttons populated dynamically -->
19+
</div>
20+
1621
<!-- Editor button panel (scrollable horizontal) -->
1722
<div id="editor-panel-wrapper" class="editor-panel-wrapper">
1823
<div id="editor-button-panel" class="editor-button-panel">

scen_edit/view/view.lua

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function View:InitializeRmlUi()
7676
-- Initialize tab system
7777
self.currentTab = "Objects"
7878
self:BindTabEvents()
79+
self:PopulateActionButtons()
7980
self:PopulateEditorButtons(self.currentTab)
8081

8182
-- Setup event handlers
@@ -299,6 +300,59 @@ function View:SwitchTab(tabName)
299300
end
300301
end
301302

303+
function View:PopulateActionButtons()
304+
if not SB.conf.SHOW_BASIC_CONTROLS then
305+
return
306+
end
307+
308+
local actionBar = self.mainDocument:GetElementById("action-bar")
309+
if not actionBar then return end
310+
311+
-- Filter and sort actions by toolbar_order
312+
local actions = Table.Filter(SB.actionRegistry, function(v)
313+
return v.toolbar_order ~= nil
314+
end)
315+
actions = Table.SortByAttr(actions, "toolbar_order")
316+
317+
-- Create button HTML for each action
318+
local buttonsHTML = ""
319+
for _, actionCfg in ipairs(actions) do
320+
if actionCfg.image and actionCfg.tooltip then
321+
local btnId = "toolbar-action-" .. (actionCfg.name or actionCfg.tooltip:gsub("%s+", "-"):lower())
322+
323+
-- Make image path relative to RML document
324+
local imagePath = actionCfg.image
325+
if imagePath:sub(1, 6) == "LuaUI/" then
326+
imagePath = "../../../" .. imagePath
327+
end
328+
329+
buttonsHTML = buttonsHTML .. string.format([[
330+
<button id="%s" class="toolbar-action-button" title="%s">
331+
<img src="%s"/>
332+
</button>
333+
]], btnId, actionCfg.tooltip, imagePath)
334+
end
335+
end
336+
337+
actionBar.inner_rml = buttonsHTML
338+
339+
-- Bind click events for action buttons
340+
for _, actionCfg in ipairs(actions) do
341+
if actionCfg.image and actionCfg.tooltip then
342+
local btnId = "toolbar-action-" .. (actionCfg.name or actionCfg.tooltip:gsub("%s+", "-"):lower())
343+
local btnElement = self.mainDocument:GetElementById(btnId)
344+
if btnElement then
345+
btnElement:AddEventListener("click", function()
346+
local action = actionCfg.action()
347+
if not action.canExecute or action:canExecute() then
348+
action:execute()
349+
end
350+
end)
351+
end
352+
end
353+
end
354+
end
355+
302356
function View:PopulateEditorButtons(tabName)
303357
local editorPanel = self.mainDocument:GetElementById("editor-button-panel")
304358
if not editorPanel then return end

0 commit comments

Comments
 (0)