Skip to content

Commit 2366aa0

Browse files
committed
Add RmlUi support alongside existing Chili UI (no deletions)
This commit adds RmlUi support as an OPTIONAL UI system that runs alongside the existing Chili UI without deleting anything. Architecture: - View.lua checks if Spring.RmlUi is available - If available: Uses RmlUi-based UI - If not available: Falls back to existing Chili UI - Both code paths are preserved and functional New files added: 1. scen_edit/view/rmlui_manager.lua - RmlUi context/document management 2. scen_edit/view/rmlui_builder.lua - Dynamic RML generation helpers 3. scen_edit/view/rml/springboard_main.rml - Main UI template 4. scen_edit/view/rcss/springboard.rcss - Main UI stylesheet 5. LuaUI/widgets/api_sb_rmlui.lua - RmlUi rendering widget Changes to existing files: - scen_edit/view/view.lua: - Added View:InitializeRmlUi() for RmlUi path - Added View:InitializeChili() for Chili path (original code) - Modified View:SetVisible() to handle both UI systems - Modified View:Update() to handle both UI systems - NO CODE DELETED - all Chili code preserved Benefits: - Works on engines with RmlUi (BAR 105.1.1+) - Works on engines without RmlUi (standard Spring) - Enables incremental conversion - Nothing breaks Current RmlUi UI features: - Basic menu bar (Exit, New, Open, Save buttons) - Team selector dropdown - Main content area (placeholder) - Bottom control bar (Play/Pause) - Fully styled with dark theme TODO: - Convert editors (trigger, object, map) to RmlUi - Implement dynamic form generation for editors - Add dialog system - Port remaining Chili features
1 parent d8cc6f2 commit 2366aa0

File tree

6 files changed

+782
-24
lines changed

6 files changed

+782
-24
lines changed

LuaUI/widgets/api_sb_rmlui.lua

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
function widget:GetInfo()
2+
return {
3+
name = "SpringBoard RmlUi Framework",
4+
desc = "RmlUi UI framework integration for SpringBoard",
5+
author = "SpringBoard Team",
6+
date = "2025",
7+
license = "GPL",
8+
layer = -999, -- Draw before other widgets
9+
enabled = true
10+
}
11+
end
12+
13+
-- RmlUi integration for SpringBoard
14+
-- This widget provides RmlUi rendering and input handling
15+
16+
local rmlui
17+
local initialized = false
18+
19+
function widget:Initialize()
20+
-- Check if RmlUi is available
21+
if not Spring.RmlUi then
22+
Spring.Log("SpringBoard RmlUi", LOG.WARNING, "RmlUi not available in this Spring engine version")
23+
Spring.Log("SpringBoard RmlUi", LOG.WARNING, "Falling back to Chili UI (engine needs BAR 105.1.1+ for RmlUi)")
24+
widgetHandler:RemoveWidget(self)
25+
return false
26+
end
27+
28+
rmlui = Spring.RmlUi
29+
initialized = true
30+
31+
Spring.Log("SpringBoard RmlUi", LOG.NOTICE, "RmlUi Framework initialized")
32+
return true
33+
end
34+
35+
function widget:Shutdown()
36+
initialized = false
37+
end
38+
39+
function widget:ViewResize(vsx, vsy)
40+
if not initialized then
41+
return
42+
end
43+
44+
-- Update RmlUi context dimensions
45+
if SB and SB.rmlui then
46+
SB.rmlui:UpdateDimensions()
47+
end
48+
end
49+
50+
function widget:DrawScreen()
51+
if not initialized then
52+
return
53+
end
54+
55+
-- Render RmlUi context
56+
if SB and SB.rmlui then
57+
SB.rmlui:Render()
58+
end
59+
end
60+
61+
function widget:MouseMove(x, y, dx, dy, button)
62+
if not initialized then
63+
return false
64+
end
65+
66+
if SB and SB.rmlui then
67+
return SB.rmlui:MouseMove(x, y, dx, dy)
68+
end
69+
70+
return false
71+
end
72+
73+
function widget:MousePress(x, y, button)
74+
if not initialized then
75+
return false
76+
end
77+
78+
if SB and SB.rmlui then
79+
return SB.rmlui:MouseButton(x, y, button, true)
80+
end
81+
82+
return false
83+
end
84+
85+
function widget:MouseRelease(x, y, button)
86+
if not initialized then
87+
return false
88+
end
89+
90+
if SB and SB.rmlui then
91+
return SB.rmlui:MouseButton(x, y, button, false)
92+
end
93+
94+
return false
95+
end
96+
97+
function widget:MouseWheel(up, value)
98+
if not initialized then
99+
return false
100+
end
101+
102+
-- RmlUi mouse wheel handling would go here
103+
-- Implementation depends on RmlUi API availability
104+
105+
return false
106+
end
107+
108+
function widget:KeyPress(key, mods, isRepeat, label, unicode)
109+
if not initialized then
110+
return false
111+
end
112+
113+
if SB and SB.rmlui then
114+
local handled = SB.rmlui:KeyEvent(key, true, mods)
115+
if handled then
116+
return true
117+
end
118+
119+
-- Handle text input
120+
if unicode and unicode > 0 then
121+
return SB.rmlui:TextInput(unicode)
122+
end
123+
end
124+
125+
return false
126+
end
127+
128+
function widget:KeyRelease(key, mods, label, unicode)
129+
if not initialized then
130+
return false
131+
end
132+
133+
if SB and SB.rmlui then
134+
return SB.rmlui:KeyEvent(key, false, mods)
135+
end
136+
137+
return false
138+
end
139+
140+
-- Expose RmlUi to other widgets
141+
function widget:GetRmlUi()
142+
return rmlui
143+
end
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
body#springboard {
2+
font-family: Liberation Sans;
3+
font-size: 14dp;
4+
color: #cccccc;
5+
width: 100%;
6+
height: 100%;
7+
background-color: #1a1a1a;
8+
}
9+
10+
.menu-bar {
11+
position: absolute;
12+
top: 0;
13+
left: 0;
14+
right: 0;
15+
height: 30dp;
16+
background-color: #2a2a2a;
17+
padding: 5dp;
18+
display: flex;
19+
flex-direction: row;
20+
gap: 5dp;
21+
}
22+
23+
.menu-button {
24+
background-color: #3a3a3a;
25+
color: #cccccc;
26+
border: 1dp #555555;
27+
padding: 5dp 15dp;
28+
border-radius: 3dp;
29+
}
30+
31+
.menu-button:hover {
32+
background-color: #4a4a4a;
33+
}
34+
35+
.menu-button:active {
36+
background-color: #555555;
37+
}
38+
39+
.team-selector {
40+
position: absolute;
41+
top: 40dp;
42+
right: 10dp;
43+
padding: 5dp;
44+
background-color: #2a2a2a;
45+
border: 1dp #555555;
46+
border-radius: 3dp;
47+
display: flex;
48+
flex-direction: row;
49+
gap: 5dp;
50+
align-items: center;
51+
}
52+
53+
.team-selector label {
54+
color: #cccccc;
55+
}
56+
57+
.team-selector select {
58+
background-color: #3a3a3a;
59+
color: #cccccc;
60+
border: 1dp #555555;
61+
padding: 3dp;
62+
}
63+
64+
.main-content {
65+
position: absolute;
66+
top: 80dp;
67+
left: 10dp;
68+
right: 10dp;
69+
bottom: 50dp;
70+
background-color: #222222;
71+
border: 1dp #555555;
72+
border-radius: 3dp;
73+
display: flex;
74+
flex-direction: column;
75+
}
76+
77+
.tab-bar {
78+
height: 30dp;
79+
background-color: #2a2a2a;
80+
border-bottom: 1dp #555555;
81+
display: flex;
82+
flex-direction: row;
83+
}
84+
85+
.tab-content {
86+
flex-grow: 1;
87+
padding: 10dp;
88+
color: #cccccc;
89+
}
90+
91+
.bottom-bar {
92+
position: absolute;
93+
bottom: 0;
94+
left: 0;
95+
right: 0;
96+
height: 40dp;
97+
background-color: #2a2a2a;
98+
border-top: 1dp #555555;
99+
padding: 5dp;
100+
display: flex;
101+
flex-direction: row;
102+
justify-content: space-between;
103+
align-items: center;
104+
}
105+
106+
.bottom-bar span {
107+
color: #cccccc;
108+
padding-left: 10dp;
109+
}
110+
111+
.control-button {
112+
background-color: #3a3a3a;
113+
color: #cccccc;
114+
border: 1dp #555555;
115+
padding: 5dp 20dp;
116+
border-radius: 3dp;
117+
margin-left: 5dp;
118+
}
119+
120+
.control-button:hover {
121+
background-color: #4a4a4a;
122+
}
123+
124+
.control-button:active {
125+
background-color: #555555;
126+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<rml>
2+
<head>
3+
<title>SpringBoard</title>
4+
<link type="text/rcss" href="springboard.rcss"/>
5+
</head>
6+
<body id="springboard">
7+
<!-- Top menu bar -->
8+
<div id="top-menu" class="menu-bar">
9+
<button id="btn-exit" class="menu-button">Exit</button>
10+
<button id="btn-new-project" class="menu-button">New</button>
11+
<button id="btn-open-project" class="menu-button">Open</button>
12+
<button id="btn-save-project" class="menu-button">Save</button>
13+
</div>
14+
15+
<!-- Team selector -->
16+
<div id="team-selector-container" class="team-selector">
17+
<label>Team:</label>
18+
<select id="team-selector">
19+
<option value="0">Team 0</option>
20+
<option value="1">Team 1</option>
21+
</select>
22+
</div>
23+
24+
<!-- Main content area (tabbed window placeholder) -->
25+
<div id="main-content" class="main-content">
26+
<div id="tab-bar" class="tab-bar"></div>
27+
<div id="tab-content" class="tab-content">
28+
<p>SpringBoard RmlUi UI - Ready</p>
29+
</div>
30+
</div>
31+
32+
<!-- Bottom bar -->
33+
<div id="bottom-bar" class="bottom-bar">
34+
<span id="status-text">Ready</span>
35+
<button id="btn-play" class="control-button">Play</button>
36+
<button id="btn-pause" class="control-button">Pause</button>
37+
</div>
38+
</body>
39+
</rml>

0 commit comments

Comments
 (0)