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 storage = minetest.get_mod_storage()
|
||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
|
||||||
-- Set a player’s theme by a registered theme’s name.
|
-- Set a player’s theme by a registered theme’s name.
|
||||||
-- If dont_save is provided, the player’s default theme won’t change.
|
-- If dont_save is provided, the player’s default theme won’t change.
|
||||||
function fs_themes.set_theme(player, theme_name, dont_save)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Register a theme, given a name and a formspec-file’s path.
|
-- Register a theme, given a name and a formspec string.
|
||||||
function fs_themes.register_theme(name, formspecs_file_path)
|
function fs_themes.register_theme(name, formspec_str)
|
||||||
local fs_file, open_err = io.open(formspecs_file_path, "r")
|
fs_themes.themes[name] = formspec_str
|
||||||
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
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,11 +55,9 @@ minetest.register_chatcommand(
|
||||||
ret = ret .. ", " .. name
|
ret = ret .. ", " .. name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ret == nil then
|
if ret == nil then
|
||||||
ret = "No themes are installed!"
|
ret = "No themes are installed!"
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, ret
|
return true, ret
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -94,9 +86,14 @@ minetest.register_chatcommand(
|
||||||
minetest.register_on_joinplayer(
|
minetest.register_on_joinplayer(
|
||||||
function(player)
|
function(player)
|
||||||
local player_name = player:get_player_name()
|
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)
|
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 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
|
if player_theme ~= "" and not fs_themes.set_theme(player, player_theme) then
|
||||||
minetest.chat_send_player(
|
minetest.chat_send_player(
|
||||||
|
@ -106,7 +103,7 @@ minetest.register_on_joinplayer(
|
||||||
storage:set_string(player_name, "")
|
storage:set_string(player_name, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
if player_theme == "" then
|
if player_theme == "" and default_theme and default_theme ~= "" then
|
||||||
fs_themes.set_theme(player, default_theme)
|
fs_themes.set_theme(player, default_theme)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -117,5 +114,12 @@ minetest.register_on_joinplayer(
|
||||||
local theme_dir_path = modpath .. "/themes/"
|
local theme_dir_path = modpath .. "/themes/"
|
||||||
local theme_file_paths = minetest.get_dir_list(theme_dir_path, false)
|
local theme_file_paths = minetest.get_dir_list(theme_dir_path, false)
|
||||||
for _, file_name in pairs(theme_file_paths) do
|
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
|
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]
|
style[*; textcolor=#532b2b]
|
||||||
|
|
||||||
bgcolor[#fadcbe;true]
|
bgcolor[#fadcbe]
|
||||||
background9[
|
background9[
|
||||||
5,5;1,1;restaurant_gui_bg.png;
|
5,5;1,1;restaurant_gui_bg.png;
|
||||||
true;
|
true;
|
||||||
|
@ -11,14 +11,25 @@ tableoptions[background=#fadcbe;highlight=#d7ff87;color=#532b2b]
|
||||||
listcolors[#fadcbe;#d7ff87;#a65200;#ce7f7f;#fff]
|
listcolors[#fadcbe;#d7ff87;#a65200;#ce7f7f;#fff]
|
||||||
|
|
||||||
style_type[
|
style_type[
|
||||||
button,image_button;
|
button,image_button,item_image_button;
|
||||||
bgimg=restaurant_gui_button_bg_inactive.png;
|
bgimg=restaurant_gui_button_bg_inactive.png;
|
||||||
border=false;
|
border=false;
|
||||||
bgimg_middle=3,3,-4,-5
|
bgimg_middle=3,3,-4,-5
|
||||||
]
|
]
|
||||||
style_type[
|
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;
|
bgimg=restaurant_gui_button_bg_active.png;
|
||||||
border=false;
|
border=false;
|
||||||
bgimg_middle=3,3,-3,-4
|
bgimg_middle=3,3,-3,-4
|
||||||
]
|
]
|
||||||
|
|
||||||
|
style_type[
|
||||||
|
tabheader;
|
||||||
|
textcolor=white
|
||||||
|
]
|
||||||
|
|
Ŝarĝante…
Reference in New Issue