Compare commits
2 Enmetoj
f336172dfb
...
b2c53ad032
Author | SHA1 | Date | |
---|---|---|---|
Jaidyn Ann | b2c53ad032 | ||
Jaidyn Ann | 07c7618d3d |
34
init.lua
34
init.lua
|
@ -19,6 +19,7 @@ fs_themes.themes = {}
|
|||
local storage = minetest.get_mod_storage()
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
|
||||
-- Set a player’s theme by a registered theme’s name.
|
||||
-- If dont_save is provided, the player’s default theme won’t change.
|
||||
function fs_themes.set_theme(player, theme_name, dont_save)
|
||||
|
@ -34,16 +35,9 @@ function fs_themes.set_theme(player, theme_name, dont_save)
|
|||
end
|
||||
|
||||
|
||||
-- Register a theme, given a name and a formspec-file’s path.
|
||||
function fs_themes.register_theme(name, formspecs_file_path)
|
||||
local fs_file, open_err = io.open(formspecs_file_path, "r")
|
||||
if fs_file == nil then
|
||||
minetest.log("warning", string.format("Theme “%s” could not be opened: %s", name, open_err))
|
||||
return false
|
||||
end
|
||||
|
||||
local fs_file_contents = fs_file:read("*all")
|
||||
fs_themes.themes[name] = fs_file_contents
|
||||
-- Register a theme, given a name and a formspec string.
|
||||
function fs_themes.register_theme(name, formspec_str)
|
||||
fs_themes.themes[name] = formspec_str
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -61,11 +55,9 @@ minetest.register_chatcommand(
|
|||
ret = ret .. ", " .. name
|
||||
end
|
||||
end
|
||||
|
||||
if ret == nil then
|
||||
ret = "No themes are installed!"
|
||||
end
|
||||
|
||||
return true, ret
|
||||
end
|
||||
}
|
||||
|
@ -94,9 +86,14 @@ minetest.register_chatcommand(
|
|||
minetest.register_on_joinplayer(
|
||||
function(player)
|
||||
local player_name = player:get_player_name()
|
||||
local default_theme = minetest.settings:get("fs_default_theme") or "restaurant"
|
||||
local default_theme = minetest.settings:get("fs_default_theme")
|
||||
local player_theme = storage:get_string(player_name)
|
||||
|
||||
-- Set the “default” theme (inherited from whatever mods load before fs_themes)
|
||||
if not fs_themes.themes["default"] then
|
||||
fs_themes.themes["default"] = player:get_formspec_prepend()
|
||||
end
|
||||
|
||||
-- If a player has a preferred theme we cannot use, complain & use default.
|
||||
if player_theme ~= "" and not fs_themes.set_theme(player, player_theme) then
|
||||
minetest.chat_send_player(
|
||||
|
@ -106,7 +103,7 @@ minetest.register_on_joinplayer(
|
|||
storage:set_string(player_name, "")
|
||||
end
|
||||
|
||||
if player_theme == "" then
|
||||
if player_theme == "" and default_theme and default_theme ~= "" then
|
||||
fs_themes.set_theme(player, default_theme)
|
||||
end
|
||||
end
|
||||
|
@ -117,5 +114,12 @@ minetest.register_on_joinplayer(
|
|||
local theme_dir_path = modpath .. "/themes/"
|
||||
local theme_file_paths = minetest.get_dir_list(theme_dir_path, false)
|
||||
for _, file_name in pairs(theme_file_paths) do
|
||||
fs_themes.register_theme(file_name, theme_dir_path .. file_name)
|
||||
local fs_file, open_err = io.open(theme_dir_path .. file_name, "r")
|
||||
if fs_file == nil then
|
||||
minetest.log("warning", string.format("Theme “%s” could not be opened: %s", name, open_err))
|
||||
return false
|
||||
end
|
||||
|
||||
local fs_file_contents = fs_file:read("*all")
|
||||
fs_themes.register_theme(file_name, fs_file_contents)
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
fs_default_theme (Default theme for Formspecs) string restaurant
|
||||
fs_default_theme (Default theme for Formspecs) string
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 243 B |
|
@ -1,6 +1,6 @@
|
|||
style[*; textcolor=#532b2b]
|
||||
|
||||
bgcolor[#fadcbe;true]
|
||||
bgcolor[#fadcbe]
|
||||
background9[
|
||||
5,5;1,1;restaurant_gui_bg.png;
|
||||
true;
|
||||
|
@ -11,14 +11,25 @@ tableoptions[background=#fadcbe;highlight=#d7ff87;color=#532b2b]
|
|||
listcolors[#fadcbe;#d7ff87;#a65200;#ce7f7f;#fff]
|
||||
|
||||
style_type[
|
||||
button,image_button;
|
||||
button,image_button,item_image_button;
|
||||
bgimg=restaurant_gui_button_bg_inactive.png;
|
||||
border=false;
|
||||
bgimg_middle=3,3,-4,-5
|
||||
]
|
||||
style_type[
|
||||
button:pressed,image_button:pressed;
|
||||
button:hovered,image_button:hovered,item_image_button:hovered;
|
||||
bgimg=restaurant_gui_button_bg_hovered.png;
|
||||
border=false;
|
||||
bgimg_middle=3,3,-4,-5
|
||||
]
|
||||
style_type[
|
||||
button:pressed,image_button:pressed,item_image_button:pressed;
|
||||
bgimg=restaurant_gui_button_bg_active.png;
|
||||
border=false;
|
||||
bgimg_middle=3,3,-3,-4
|
||||
]
|
||||
|
||||
style_type[
|
||||
tabheader;
|
||||
textcolor=white
|
||||
]
|
||||
|
|
Ŝarĝante…
Reference in New Issue