Compare commits

..

No commits in common. "f336172dfbbb16046856562b70f8e9699596f2e1" and "5be39f127c484d40b3bb5de58058182a19924848" have entirely different histories.

14 changed files with 19 additions and 128 deletions

View File

@ -1,9 +0,0 @@
# fs_themes
## Credits
The themes Restaurant and Rose were made by the lovely [Tirifto](https://tirifto.xwx.moe), originally for the fediverse server [Mansardo Jamada](https://jam.xwx.moe/users/Tirifto).
## Meta
* License: [GNU LGPLv3+](COPYING.LESSER)
* Author: Jaidyn Ann (jadedctrl AT posteo.net)
* Source: https://hak.xwx.moe/jadedctrl/minetest-fs_themes

View File

@ -15,22 +15,17 @@
fs_themes = {}
fs_themes.themes = {}
fs_themes.modpath = minetest.get_modpath(minetest.get_current_modname())
local storage = minetest.get_mod_storage()
local modpath = minetest.get_modpath(minetest.get_current_modname())
-- Set a players theme by a registered themes name.
-- If dont_save is provided, the players default theme wont change.
function fs_themes.set_theme(player, theme_name, dont_save)
function fs_themes.set_theme(player, theme_name)
if not fs_themes.themes[theme_name] then
minetest.log("warning", string.format("Theme “%s” was not found.", theme_name))
return false
elseif not dont_save then
storage:set_string(player:get_player_name(), theme_name)
return
end
player:set_formspec_prepend(fs_themes.themes[theme_name])
return true
end
@ -39,82 +34,25 @@ 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
return
end
local fs_file_contents = fs_file:read("*all")
fs_themes.themes[name] = fs_file_contents
return true
end
minetest.register_chatcommand(
"themes",
{
description = "Lists available GUI (Formspecs) themes.",
func = function(name, param)
local ret = nil
for name,fs in pairs(fs_themes.themes) do
if ret == nil then
ret = name
else
ret = ret .. ", " .. name
end
end
if ret == nil then
ret = "No themes are installed!"
end
return true, ret
end
}
)
minetest.register_chatcommand(
"set_theme",
{
params = "<theme_name>",
description = "Sets your theme for GUI (Formspecs) windows.",
func = function(name, param)
if fs_themes.set_theme(minetest.get_player_by_name(name), param) then
return true, "Theme set!"
elseif param ~= "" then
return false, string.format("No such theme “%s”.", param)
else
return false
end
end
}
)
-- Whenever a player joins, set their formspecs theme.
-- Whenever a play joins, set their formspecs theme.
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 player_theme = storage:get_string(player_name)
-- 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(
player_name,
string.format("The theme “%s” no longer exists! Resetting preference.", player_theme))
player_theme = ""
storage:set_string(player_name, "")
end
if player_theme == "" then
fs_themes.set_theme(player, default_theme)
end
local default_theme = minetest.settings:get("fs_default_theme") or "restoracio"
fs_themes.set_theme(player, default_theme)
end
)
-- Register all themes in the ./themes/ directory, one by one.
local theme_dir_path = modpath .. "/themes/"
local theme_dir_path = fs_themes.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)

View File

@ -1 +1 @@
fs_default_theme (Default theme for Formspecs) string restaurant
fs_default_theme (Default theme for Formspecs) string restoracio

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

View File

@ -1,24 +0,0 @@
style[*; textcolor=#532b2b]
bgcolor[#fadcbe;true]
background9[
5,5;1,1;restaurant_gui_bg.png;
true;
10
]
tableoptions[background=#fadcbe;highlight=#d7ff87;color=#532b2b]
listcolors[#fadcbe;#d7ff87;#a65200;#ce7f7f;#fff]
style_type[
button,image_button;
bgimg=restaurant_gui_button_bg_inactive.png;
border=false;
bgimg_middle=3,3,-4,-5
]
style_type[
button:pressed,image_button:pressed;
bgimg=restaurant_gui_button_bg_active.png;
border=false;
bgimg_middle=3,3,-3,-4
]

10
themes/restoracio Normal file
View File

@ -0,0 +1,10 @@
style[*;textcolor=#532b2b]
bgcolor[#fadcbe;true]
background9[5,5;1,1;restoracio_gui_bg.png;true;10]
tableoptions[background=#fadcbe;highlight=#d7ff87;color=#532b2b]
listcolors[#fadcbe;#fadcbe;#141318;#30434C;#FFF] ]]
style_type[button,image_button;bgimg=restoracio_gui_button_bg_inactive.png;border=false;bgimg_middle=4,4,-4,-6;content_offset=0,0]
style_type[button:pressed,image_button:pressed;bgimg=restoracio_gui_button_bg_active.png;border=false;bgimg_middle=4,5,-4,-6;content_offset=0,2]

View File

@ -1,24 +0,0 @@
style[*; textcolor=#532b2b]
bgcolor[#ffc7c7;true]
background9[
5,5;1,1;rose_gui_bg.png;
true;
10
]
tableoptions[background=#ffc7c7;highlight=#e0a7a7;color=#532b2b]
listcolors[#ffc7c7;#e0a7a7;#a60808;#d26767;#fff]
style_type[
button,image_button;
bgimg=rose_gui_button_bg_inactive.png;
border=false;
bgimg_middle=4,3,-4,-5
]
style_type[
button:pressed,image_button:pressed;
bgimg=rose_gui_button_bg_active.png;
border=false;
bgimg_middle=4,3,-3,-4
]