Skip to content

Commit aed82f3

Browse files
committed
Add prelude and core themes
1 parent 635678e commit aed82f3

15 files changed

+198
-11
lines changed

LICENSE.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ http://creativecommons.org/licenses/by-sa/3.0/
1111
textures/base/pack/refresh.png is under the Apache 2 license
1212
https://www.apache.org/licenses/LICENSE-2.0.html
1313

14-
Textures by Zughy are under CC BY-SA 4.0
14+
Textures by Zughy and v-rob are under CC BY-SA 4.0
1515
https://creativecommons.org/licenses/by-sa/4.0/
1616

1717
Media files by DS are under CC BY-SA 4.0
@@ -82,6 +82,19 @@ SmallJoker:
8282
textures/base/pack/cdb_clear.png
8383
textures/base/pack/server_favorite_delete.png (based on server_favorite.png)
8484

85+
v-rob:
86+
textures/base/pack/ui_button_bg.png
87+
textures/base/pack/ui_button_center_bg.png
88+
textures/base/pack/ui_button_left_bg.png
89+
textures/base/pack/ui_button_right_bg.png
90+
textures/base/pack/ui_check_fg.png
91+
textures/base/pack/ui_check_selected_fg.png
92+
textures/base/pack/ui_radio_fg.png
93+
textures/base/pack/ui_radio_selected_fg.png
94+
textures/base/pack/ui_root_bg.png
95+
textures/base/pack/ui_switch_fg.png
96+
textures/base/pack/ui_switch_selected_fg.png
97+
8598
DS:
8699
games/devtest/mods/soundstuff/textures/soundstuff_bigfoot.png
87100
games/devtest/mods/soundstuff/textures/soundstuff_jukebox.png

builtin/ui/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ dofile(UI_PATH .. "style.lua")
2727
dofile(UI_PATH .. "elem.lua")
2828
dofile(UI_PATH .. "window.lua")
2929
dofile(UI_PATH .. "elem_defs.lua")
30+
dofile(UI_PATH .. "theme.lua")

builtin/ui/style.lua

-10
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,3 @@ function ui._encode_props(props)
218218

219219
return ui._encode("s", ui._encode_flags(fl))
220220
end
221-
222-
local default_theme = ui.Style{}
223-
224-
function ui.get_default_theme()
225-
return default_theme
226-
end
227-
228-
function ui.set_default_theme(theme)
229-
default_theme = theme
230-
end

builtin/ui/theme.lua

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
--[[
2+
Minetest
3+
Copyright (C) 2023 v-rob, Vincent Robinson <[email protected]>
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU Lesser General Public License as published by
7+
the Free Software Foundation; either version 2.1 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public License along
16+
with this program; if not, write to the Free Software Foundation, Inc.,
17+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
--]]
19+
20+
local prelude_theme = ui.Style{
21+
ui.Style{
22+
sel = "root",
23+
24+
-- The root window should be centered on the screen, but have no size
25+
-- by default, since the size should be user-set.
26+
rel_pos = {1/2, 1/2},
27+
rel_anchor = {1/2, 1/2},
28+
rel_size = {0, 0},
29+
30+
-- Normally, we don't show the backdrop unless we have user focus.
31+
ui.Style{
32+
sel = "@backdrop",
33+
visible = false,
34+
},
35+
ui.Style{
36+
sel = "@backdrop$focused",
37+
visible = true,
38+
}
39+
},
40+
ui.Style{
41+
sel = "image",
42+
fg_scale = 0,
43+
},
44+
ui.Style{
45+
sel = "check, switch, radio",
46+
fg_halign = "left",
47+
},
48+
}
49+
50+
function ui.get_prelude_theme()
51+
return prelude_theme
52+
end
53+
54+
local core_theme = ui.Style{
55+
-- Like any good theme should, we include the prelude theme first.
56+
prelude_theme,
57+
58+
ui.Style{
59+
sel = "root",
60+
61+
ui.Style{
62+
sel = "!.ui:blank",
63+
64+
padding = {4, 4, 4, 4},
65+
66+
bg_image = "ui_root_bg.png",
67+
bg_middle = {2/16, 2/16, 2/16, 2/16},
68+
bg_middle_scale = 2,
69+
},
70+
ui.Style{
71+
sel = "@backdrop",
72+
73+
bg_fill = "black#5",
74+
},
75+
},
76+
77+
ui.Style{
78+
sel = "button, toggle, option",
79+
80+
padding = {2, 2, 2, 4},
81+
82+
bg_image = "ui_button_bg.png",
83+
bg_source = {0/6, 0, 1/6, 1},
84+
bg_middle = {1/16, 2/16, 1/16, 2/16},
85+
bg_middle_scale = 2,
86+
87+
ui.Style{
88+
sel = "$hovered, $focused",
89+
bg_source = {1/6, 0, 2/6, 1},
90+
},
91+
ui.Style{
92+
sel = "$disabled",
93+
bg_source = {2/6, 0, 3/6, 1},
94+
},
95+
ui.Style{
96+
sel = "$pressed, $selected",
97+
padding = {2, 4, 2, 2},
98+
bg_source = {3/6, 0, 4/6, 1},
99+
},
100+
ui.Style{
101+
sel = "($hovered, $focused)$selected",
102+
bg_source = {4/6, 0, 5/6, 1},
103+
},
104+
ui.Style{
105+
sel = "$disabled$selected",
106+
bg_source = {5/6, 0, 6/6, 1},
107+
},
108+
109+
ui.Style{
110+
sel = ".ui:left",
111+
bg_image = "ui_button_left_bg.png",
112+
},
113+
ui.Style{
114+
sel = ".ui:center",
115+
bg_image = "ui_button_center_bg.png",
116+
},
117+
ui.Style{
118+
sel = ".ui:right",
119+
bg_image = "ui_button_right_bg.png",
120+
},
121+
},
122+
123+
ui.Style{
124+
sel = "check, switch, radio",
125+
126+
fg_source = {0/4, 0, 1/4, 1},
127+
fg_scale = 2,
128+
129+
ui.Style{
130+
sel = "check",
131+
fg_image = "ui_check_fg.png",
132+
},
133+
ui.Style{
134+
sel = "check$selected",
135+
fg_image = "ui_check_selected_fg.png",
136+
},
137+
138+
ui.Style{
139+
sel = "switch",
140+
fg_image = "ui_switch_fg.png",
141+
},
142+
ui.Style{
143+
sel = "switch$selected",
144+
fg_image = "ui_switch_selected_fg.png",
145+
},
146+
147+
ui.Style{
148+
sel = "radio",
149+
fg_image = "ui_radio_fg.png",
150+
},
151+
ui.Style{
152+
sel = "radio$selected",
153+
fg_image = "ui_radio_selected_fg.png",
154+
},
155+
156+
ui.Style{
157+
sel = "$hovered, $focused",
158+
fg_source = {1/4, 0, 2/4, 1},
159+
},
160+
ui.Style{
161+
sel = "$pressed",
162+
fg_source = {2/4, 0, 3/4, 1},
163+
},
164+
ui.Style{
165+
sel = "$disabled",
166+
fg_source = {3/4, 0, 4/4, 1},
167+
},
168+
},
169+
}
170+
171+
function ui.get_core_theme()
172+
return core_theme
173+
end
174+
175+
local default_theme = core_theme
176+
177+
function ui.get_default_theme()
178+
return default_theme
179+
end
180+
181+
function ui.set_default_theme(theme)
182+
default_theme = theme
183+
end

textures/base/pack/ui_button_bg.png

816 Bytes
Loading
797 Bytes
Loading
852 Bytes
Loading
845 Bytes
Loading

textures/base/pack/ui_check_fg.png

764 Bytes
Loading
4.56 KB
Loading

textures/base/pack/ui_radio_fg.png

917 Bytes
Loading
1003 Bytes
Loading

textures/base/pack/ui_root_bg.png

619 Bytes
Loading

textures/base/pack/ui_switch_fg.png

830 Bytes
Loading
841 Bytes
Loading

0 commit comments

Comments
 (0)