1
0

A new batch of MainMenu improvements (#110)

Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
This commit is contained in:
Maksym H 2022-12-07 16:05:14 +02:00 committed by GitHub
parent ebe6a07c9a
commit 13c4b3bd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 281 additions and 235 deletions

View File

@ -6,7 +6,8 @@ core.register_on_death(function()
local formspec = "size[8,5]bgcolor[#320000b4;true]" .. local formspec = "size[8,5]bgcolor[#320000b4;true]" ..
"background9[0,0;0,0;bg_common.png;true;40]" .. "background9[0,0;0,0;bg_common.png;true;40]" ..
"style[you_died;font_size=+4;content_offset=0]" .. "style[you_died;font_size=+4;content_offset=0]" ..
"image_button[0.5,1.5;7,0.8;blank.png;you_died;" .. fgettext("You died") .. ";false;false]" .. "image_button[0.5,1.5;7,0.8;;you_died;" .. fgettext("You died") .. ";false;false]" ..
btn_style("btn_respawn") ..
"button_exit[2,3;4,0.5;btn_respawn;".. fgettext("Respawn") .."]" "button_exit[2,3;4,0.5;btn_respawn;".. fgettext("Respawn") .."]"
core.show_formspec("bultin:death", formspec) core.show_formspec("bultin:death", formspec)
end) end)

View File

@ -8,6 +8,7 @@ dofile(commonpath .. "after.lua")
dofile(commonpath .. "chatcommands.lua") dofile(commonpath .. "chatcommands.lua")
dofile(clientpath .. "chatcommands.lua") dofile(clientpath .. "chatcommands.lua")
dofile(commonpath .. "vector.lua") dofile(commonpath .. "vector.lua")
dofile(commonpath .. "btn_style.lua")
dofile(clientpath .. "death_formspec.lua") dofile(clientpath .. "death_formspec.lua")
dofile(clientpath .. "sscsm.lua") dofile(clientpath .. "sscsm.lua")
dofile(clientpath .. "misc.lua") dofile(clientpath .. "misc.lua")

View File

@ -0,0 +1,37 @@
-- MultiCraft: builtin/common/btn_style.lua
-- luacheck: read_globals PLATFORM
local device_is_tablet = core.settings:get_bool("device_is_tablet", false)
local screen_density = core.get_screen_info().density
function is_high_dpi()
if PLATFORM == "OSX" then
return tonumber(core.settings:get("screen_dpi")) / 72 >= 2
elseif PLATFORM == "iOS" and device_is_tablet then
return screen_density >= 2
else
return screen_density >= 3
end
end
local DIR_DELIM_esc = core.formspec_escape(DIR_DELIM)
local button_path = (INIT == "mainmenu" and defaulttexturedir_esc or "") .. "gui" .. DIR_DELIM_esc
function btn_style(field, color)
local btn_size = is_high_dpi() and ".x2" or ""
color = (color and "_" .. color) or ""
local retval =
"style[" .. field .. ";border=false]" ..
"style[" .. field .. ";bgimg=" .. button_path .. "gui_button" .. color .. btn_size ..
".png;bgimg_middle=" .. (is_high_dpi() and 48 or 32) .. ";padding=" .. (is_high_dpi() and -36 or -24) .. "]"
if color ~= "_gray" then
retval = retval ..
"style[" .. field .. ":hovered;bgimg=" .. button_path .. "gui_button" .. color .. "_hovered" .. btn_size ..
".png]" ..
"style[" .. field .. ":pressed;bgimg=" .. button_path .. "gui_button" .. color .. "_pressed" .. btn_size ..
".png]"
end
return retval
end

View File

@ -60,13 +60,11 @@ local function buttonbar_formspec(self)
end end
if button.cdb then if button.cdb then
local tpath = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc
formspec = formspec .. formspec = formspec ..
"style[" .. btn_name .. ";bgimg=" .. tpath .. btn_style(btn_name) ..
"btn_download.png;bgimg_hovered=" .. tpath .. "btn_download_hover.png]" .. ("image_button[%f,%f;%f,%f;%s;%s;%s;true;%s]tooltip[%s;%s]"):format(
btn_pos.x + 0.1, btn_pos.y + 0.1, self.btn_size - 0.2, self.btn_size - 0.2,
("image_button[%f,%f;%f,%f;;%s;%s;true;%s]tooltip[%s;%s]"):format( defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc .. "btn_download.png",
btn_pos.x, btn_pos.y, self.btn_size, self.btn_size,
btn_name, button.caption, btn_name, button.caption,
borders, btn_name, button.tooltip) borders, btn_name, button.tooltip)
else else

View File

@ -86,7 +86,8 @@ function messagebox(name, message)
function() function()
return ([[ return ([[
set_focus[ok;true] set_focus[ok;true]
textarea[1,1;10,4;;;%s] style[msg;font_size=+1;content_offset=0]
image_button[1,0;10,4;;msg;%s;false;false]
%s %s
button[5,4.5;2,0.8;ok;%s] button[5,4.5;2,0.8;ok;%s]
]]):format(message, btn_style("ok"), fgettext("OK")) ]]):format(message, btn_style("ok"), fgettext("OK"))

View File

@ -68,20 +68,51 @@ local function add_tab(self,tab)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function make_side_pane_tab(y, tab_name, tooltip, selected) local function add_side_button(self, btn)
local tpath = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc if btn.pos then
local formspec = "style[" .. tab_name .. "_tab;bgimg=" .. table.insert(self.side_buttons, btn.pos, btn)
tpath .. tab_name
if selected then
formspec = formspec .. "_menu_selected.png]"
else else
formspec = formspec .. "_menu.png;bgimg_hovered=" .. self.side_buttons[#self.side_buttons + 1] = btn
tpath .. tab_name .. "_menu_hover.png]" end
end
--------------------------------------------------------------------------------
local tpath = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc
local function get_side_menu(self, selected_tab)
if #self.side_buttons == 0 then return "" end
local side_menu_h = #self.side_buttons * 1.2 + 0.2
local bg_y = 2.35 - side_menu_h / 2
local fs = {
"background9[12.13,", bg_y, ";0.9,", side_menu_h, ";", tpath,
"side_menu.png;false;30]"
}
for i, btn in ipairs(self.side_buttons) do
local y = bg_y - 1.15 + 1.2 * i
if i > 1 then
fs[#fs + 1] = "image[12.15," .. y - 0.04 .. ";0.9,0.06;" ..
tpath .. "side_menu_divider.png]"
end
local btn_name = self.name .. "_side_" .. i
fs[#fs + 1] = "style[" .. btn_name .. ";bgimg="
local texture_prefix = btn.texture_prefix or btn.tab_name
if btn.tab_name and btn.tab_name == selected_tab then
fs[#fs + 1] = btn.texture_selected or tpath .. texture_prefix .. "_menu_selected.png"
else
fs[#fs + 1] = btn.texture or tpath .. texture_prefix .. "_menu.png"
fs[#fs + 1] = ";bgimg_hovered="
fs[#fs + 1] = btn.texture_hover or tpath .. texture_prefix .. "_menu_hover.png]"
end
fs[#fs + 1] = "]"
fs[#fs + 1] = "image_button[12.1," .. y .. ";1,1.3;;" .. btn_name .. ";;true;false]"
fs[#fs + 1] = "tooltip[" .. btn_name .. ";" .. btn.tooltip .. "]"
end end
return formspec .. return table.concat(fs)
"image_button[12.1," .. y .. ";1,1.5;;" .. tab_name .. "_tab;;true;false]" ..
"tooltip[" .. tab_name .. "_tab;" .. tooltip .. "]"
end end
local function get_formspec(self) local function get_formspec(self)
@ -93,7 +124,6 @@ local function get_formspec(self)
if self.parent == nil then if self.parent == nil then
local tsize = self.tablist[self.last_tab_index].tabsize or local tsize = self.tablist[self.last_tab_index].tabsize or
{width=self.width, height=self.height} {width=self.width, height=self.height}
local tpath = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc
formspec = formspec .. formspec = formspec ..
string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1, string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1,
dump(self.fixed_size)) .. dump(self.fixed_size)) ..
@ -103,11 +133,7 @@ local function get_formspec(self)
"background9[-0.2,-1.26;" .. tsize.width + 0.4 .. "," .. "background9[-0.2,-1.26;" .. tsize.width + 0.4 .. "," ..
tsize.height + 1.75 .. ";" .. defaulttexturedir_esc .. tsize.height + 1.75 .. ";" .. defaulttexturedir_esc ..
"bg_common.png;false;40]" .. "bg_common.png;false;40]" ..
get_side_menu(self, name)
"background9[12.13,1.05;0.9,2.6;" .. tpath .. "side_menu.png;false;30]" ..
make_side_pane_tab(0.9, "settings", fgettext("Settings"), name == "settings") ..
"image[12.15,2.26;0.9,0.06;" .. tpath .. "side_menu_divider.png]" ..
make_side_pane_tab(2.3, "authors", fgettext("Credits"), name == "credits")
end end
-- formspec = formspec .. self:tab_header() -- formspec = formspec .. self:tab_header()
@ -143,14 +169,6 @@ local function handle_buttons(self,fields)
return true return true
end end
if fields.authors_tab then
set_tab_by_name(self, "credits")
return true
elseif fields.settings_tab then
set_tab_by_name(self, "settings")
return true
end
if self.tablist[self.last_tab_index].button_handler ~= nil then if self.tablist[self.last_tab_index].button_handler ~= nil then
return return
self.tablist[self.last_tab_index].button_handler( self.tablist[self.last_tab_index].button_handler(
@ -282,7 +300,7 @@ local function switch_to_tab(self, index)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function handle_tab_buttons(self,fields) local function handle_tab_buttons(self, fields)
--save tab selection to config file --save tab selection to config file
--[[if fields[self.name] then --[[if fields[self.name] then
local index = tonumber(fields[self.name]) local index = tonumber(fields[self.name])
@ -294,9 +312,18 @@ local function handle_tab_buttons(self,fields)
local name_prefix_len = #name_prefix local name_prefix_len = #name_prefix
for field in pairs(fields) do for field in pairs(fields) do
if field:sub(1, name_prefix_len) == name_prefix then if field:sub(1, name_prefix_len) == name_prefix then
local index = tonumber(field:sub(name_prefix_len + 1)) if field:sub(name_prefix_len + 1, name_prefix_len + 5) == "side_" then
if math.abs(self.last_tab_index) == index then return false end local btn = self.side_buttons[tonumber(field:sub(name_prefix_len + 6))]
switch_to_tab(self, index) if btn.tab_name then
set_tab_by_name(self, btn.tab_name)
else
btn.on_click(self)
end
else
local index = tonumber(field:sub(name_prefix_len + 1))
if math.abs(self.last_tab_index) == index then return false end
switch_to_tab(self, index)
end
return true return true
end end
end end
@ -364,6 +391,7 @@ local tabview_metatable = {
function(self,handler) self.glb_evt_handler = handler end, function(self,handler) self.glb_evt_handler = handler end,
set_fixed_size = set_fixed_size =
function(self,state) self.fixed_size = state end, function(self,state) self.fixed_size = state end,
add_side_button = add_side_button,
-- tab_header = tab_header, -- tab_header = tab_header,
button_header = button_header, button_header = button_header,
handle_tab_buttons = handle_tab_buttons handle_tab_buttons = handle_tab_buttons
@ -389,6 +417,7 @@ function tabview_create(name, size, tabheaderpos)
self.current_tab = nil self.current_tab = nil
self.last_tab_index = 1 self.last_tab_index = 1
self.tablist = {} self.tablist = {}
self.side_buttons = {}
self.autosave_tab = false self.autosave_tab = false

View File

@ -300,36 +300,3 @@ function get_language_list()
return languages, language_dropdown, lang_idx, language_name_list return languages, language_dropdown, lang_idx, language_name_list
end end
--------------------------------------------------------------------------------
local device_is_tablet = core.settings:get_bool("device_is_tablet", false)
local screen_density = core.get_screen_info().density
function is_high_dpi()
if PLATFORM == "OSX" then
return tonumber(core.settings:get("screen_dpi")) / 72 >= 2
elseif PLATFORM == "iOS" and device_is_tablet then
return screen_density >= 2
else
return screen_density >= 3
end
end
--------------------------------------------------------------------------------
function btn_style(field, color)
local button_path = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc
local btn_size = is_high_dpi() and ".x2" or ""
color = (color and "_" .. color) or ""
local retval =
"style[" .. field .. ";border=false]" ..
"style[" .. field .. ";bgimg=" .. button_path .. "gui_button" .. color .. btn_size ..
".png;bgimg_middle=" .. (is_high_dpi() and 48 or 32) .. ";padding=" .. (is_high_dpi() and -30 or -20) .. "]"
if color ~= "_gray" then
retval = retval ..
"style[" .. field .. ":hovered;bgimg=" .. button_path .. "gui_button" .. color .. "_hovered" .. btn_size ..
".png]" ..
"style[" .. field .. ":pressed;bgimg=" .. button_path .. "gui_button" .. color .. "_pressed" .. btn_size ..
".png]"
end
return retval
end

View File

@ -712,13 +712,11 @@ function store.get_formspec(dlgdata)
"container[0.375,0.375]", "container[0.375,0.375]",
"image[0,0;7.25,0.8;", defaulttexturedir_esc, "field_bg.png;32]", "image[0,0;7.25,0.8;", defaulttexturedir_esc, "field_bg.png;32]",
"style[search_string;border=false;bgcolor=transparent]", "style[Dsearch_string;border=false;bgcolor=transparent]",
"field[0.1,0;7.15,0.8;search_string;;", esc(search_string), "]", "field[0.1,0;7.15,0.8;Dsearch_string;;", esc(search_string), "]",
"field_close_on_enter[search_string;false]", "set_focus[Dsearch_string;true]",
"set_focus[search_string;true]", btn_style("clear"),
btn_style("search"), "image_button[7.4,0;0.8,0.8;", defaulttexturedir_esc, "clear.png;clear;;true;false]",
"image_button[7.4,0;0.8,0.8;", defaulttexturedir_esc, "search.png;search;;true;false]",
-- "image_button[8.125,0;0.8,0.8;", defaulttexturedir_esc, "clear.png;clear;;true;false]",
"dropdown[8.35,0;3.5,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]", "dropdown[8.35,0;3.5,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]",
"container_end[]", "container_end[]",
@ -878,13 +876,6 @@ function store.get_formspec(dlgdata)
end end
function store.handle_submit(this, fields) function store.handle_submit(this, fields)
if fields.search or fields.key_enter_field == "search_string" then
search_string = fields.search_string:trim()
cur_page = 1
store.filter_packages(search_string)
return true
end
if fields.clear then if fields.clear then
search_string = "" search_string = ""
cur_page = 1 cur_page = 1
@ -1004,6 +995,14 @@ function store.handle_submit(this, fields)
end end
end end
-- Should be last
if fields.Dsearch_string then
search_string = fields.Dsearch_string:trim()
cur_page = 1
store.filter_packages(search_string)
return true
end
return false return false
end end

View File

@ -340,18 +340,26 @@ local function create_world_formspec(dialogdata)
-- Left side -- Left side
"container[0,0]".. "container[0,0]"..
"field[0.3,0.6;6,0.5;te_world_name;" ..
"real_coordinates[true]" ..
"formspec_version[3]" ..
"image[0.37,0.6;7.28,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_world_name;border=false;bgcolor=transparent]" ..
"field[0.42,0.6;7.18,0.8;te_world_name;" ..
fgettext("World name") .. fgettext("World name") ..
":;" .. core.formspec_escape(worldname) .. "]" .. ":;" .. core.formspec_escape(worldname) .. "]" ..
"field[0.3,1.7;6,0.5;te_seed;" .. "image[0.37,1.9;7.28,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_seed;border=false;bgcolor=transparent]" ..
"field[0.42,1.9;7.18,0.8;te_seed;" ..
fgettext("Seed") .. fgettext("Seed") ..
":;".. current_seed .. "]" .. ":;".. current_seed .. "]" ..
"real_coordinates[false]" ..
"label[0,2;" .. fgettext("Mapgen") .. ":]".. "label[0,2.1;" .. fgettext("Mapgen") .. ":]"..
"dropdown[0,2.5;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" .. "dropdown[0,2.5;6.27;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
"label[0,3.35;" .. fgettext("Game") .. ":]".. "label[0,3.45;" .. fgettext("Game") .. ":]"..
"textlist[0,3.85;5.8,"..gamelist_height..";games;" .. "textlist[0,3.85;5.8,"..gamelist_height..";games;" ..
pkgmgr.gamelist() .. ";" .. _gameidx .. ";false]" .. pkgmgr.gamelist() .. ";" .. _gameidx .. ";false]" ..
"container[0,4.5]" .. "container[0,4.5]" ..

View File

@ -15,59 +15,28 @@
--with this program; if not, write to the Free Software Foundation, Inc., --with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local function create_world_formspec() local mapgens = {"v7p", "valleys", "flat", "superflat"}
local mapgens = core.get_mapgen_names() local mapgen_names = {"Default", "Valleys", "Flat", "Superflat"}
local function create_world_formspec()
local current_seed = core.settings:get("fixed_map_seed") or "" local current_seed = core.settings:get("fixed_map_seed") or ""
local current_mg = core.settings:get("mg_name") local current_mg = core.settings:get("mg_name")
local gameid = core.settings:get("menu_last_game")
local gameidx = 0 local selindex = math.max(table.indexof(mapgens, current_mg), 1)
if gameid ~= nil then local mglist = table.concat(mapgen_names, ",")
local _
_, gameidx = pkgmgr.find_by_gameid(gameid)
if gameidx == nil then return "real_coordinates[true]formspec_version[3]" ..
gameidx = 0
end
end
local game_by_gameidx = core.get_game(gameidx)
if game_by_gameidx ~= nil then
local allowed_mapgens = {"v7p", "flat", "valleys"}
for i = #mapgens, 1, -1 do
if table.indexof(allowed_mapgens, mapgens[i]) == -1 then
table.remove(mapgens, i)
end
end
mapgens[#mapgens + 1] = "superflat"
end
local mglist = ""
local selindex = 1
local i = 1
for _, v in pairs(mapgens) do
if current_mg == v then
selindex = i
end
i = i + 1
mglist = mglist .. v .. ","
end
mglist = mglist:sub(1, -2)
return "real_coordinates[true]" .. "formspec_version[3]" ..
"image[3.5,1.1;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" .. "image[3.5,1.1;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_world_name;border=false;bgcolor=transparent]" .. "style[te_world_name;border=false;bgcolor=transparent]" ..
"field[3.55,1.1;8.4,0.8;te_world_name;" .. fgettext("World name") .. ":" .. ";]" .. "field[3.55,1.1;8.4,0.8;te_world_name;" .. fgettext("World name") .. ":;]" ..
"image[3.5,2.5;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" .. "image[3.5,2.5;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_seed;border=false;bgcolor=transparent]" .. "style[te_seed;border=false;bgcolor=transparent]" ..
"field[3.55,2.5;8.4,0.8;te_seed;" .. fgettext("Seed") .. ":" .. ";".. current_seed .. "]" .. "field[3.55,2.5;8.4,0.8;te_seed;" .. fgettext("Seed") .. ":;".. current_seed .. "]" ..
"label[3.5,3.7;" .. fgettext("Mapgen") .. ":" .. "]".. "label[3.5,3.7;" .. fgettext("Mapgen") .. ":]"..
"dropdown[3.5,3.9;8.5,0.8;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" .. "dropdown[3.5,3.9;8.5,0.8;dd_mapgen;" .. mglist .. ";" .. selindex .. ";true]" ..
btn_style("world_create_confirm", "green") .. btn_style("world_create_confirm", "green") ..
"button[4.1,5.3;3.5,0.8;world_create_confirm;" .. fgettext("Create") .. "]" .. "button[4.1,5.3;3.5,0.8;world_create_confirm;" .. fgettext("Create") .. "]" ..
@ -114,17 +83,18 @@ local function create_world_buttonhandler(this, fields)
local message local message
if not menudata.worldlist:uid_exists_raw(worldname) then if not menudata.worldlist:uid_exists_raw(worldname) then
local old_mg_flags local old_mg_flags
if fields["dd_mapgen"] == "superflat" then local mapgen = mapgens[tonumber(fields["dd_mapgen"])]
if mapgen == "superflat" then
core.settings:set("mg_name", "flat") core.settings:set("mg_name", "flat")
old_mg_flags = core.settings:get("mg_flags") old_mg_flags = core.settings:get("mg_flags")
core.settings:set("mg_flags", "nocaves,nodungeons,nodecorations") core.settings:set("mg_flags", "nocaves,nodungeons,nodecorations")
else else
core.settings:set("mg_name", fields["dd_mapgen"]) core.settings:set("mg_name", mapgen)
end end
message = core.create_world(worldname,gameindex) message = core.create_world(worldname,gameindex)
-- Restore the old mg_flags setting if creating a superflat world -- Restore the old mg_flags setting if creating a superflat world
if fields["dd_mapgen"] == "superflat" then if mapgen == "superflat" then
core.settings:set("mg_name", "superflat") core.settings:set("mg_name", "superflat")
if old_mg_flags then if old_mg_flags then
core.settings:set("mg_flags", old_mg_flags) core.settings:set("mg_flags", old_mg_flags)
@ -141,7 +111,6 @@ local function create_world_buttonhandler(this, fields)
else else
if this.data.update_worldlist_filter then if this.data.update_worldlist_filter then
menudata.worldlist:set_filtercriteria(pkgmgr.games[gameindex].id) menudata.worldlist:set_filtercriteria(pkgmgr.games[gameindex].id)
mm_texture.update("singleplayer", pkgmgr.games[gameindex].id)
end end
menudata.worldlist:refresh() menudata.worldlist:refresh()
core.settings:set("mainmenu_last_selected_world", core.settings:set("mainmenu_last_selected_world",

View File

@ -30,6 +30,7 @@ defaulttexturedir_esc = core.formspec_escape(defaulttexturedir)
DIR_DELIM_esc = core.formspec_escape(DIR_DELIM) -- for use in formspecs only DIR_DELIM_esc = core.formspec_escape(DIR_DELIM) -- for use in formspecs only
dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua") dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua")
dofile(basepath .. "common" .. DIR_DELIM .. "btn_style.lua")
dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua") dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
dofile(basepath .. "fstk" .. DIR_DELIM .. "dialog.lua") dofile(basepath .. "fstk" .. DIR_DELIM .. "dialog.lua")
dofile(basepath .. "fstk" .. DIR_DELIM .. "tabview.lua") dofile(basepath .. "fstk" .. DIR_DELIM .. "tabview.lua")
@ -151,6 +152,17 @@ function menudata.init_tabs()
end end
end end
tv_main:add_side_button({
tooltip = fgettext("Settings"),
tab_name = "settings",
})
tv_main:add_side_button({
tooltip = fgettext("Credits"),
tab_name = "credits",
texture_prefix = "authors"
})
ui.set_default("maintab") ui.set_default("maintab")
check_new_version() check_new_version()

View File

@ -60,7 +60,7 @@ local function get_formspec(tabview, name, tabdata)
local retval = local retval =
"label[-0.05,-0.25;".. fgettext("Installed Packages:") .. "]" .. "label[-0.05,-0.25;".. fgettext("Installed Packages:") .. "]" ..
"background9[0,0.23;5.3,4.46;" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" .. "background9[0,0.23;5.3,4.46;" .. defaulttexturedir_esc .. "worldlist_bg.png;false;40]" ..
"tablecolumns[color;tree;text]" .. "tablecolumns[color;tree;text]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"table[0,0.25;5.1,4.3;pkglist;" .. "table[0,0.25;5.1,4.3;pkglist;" ..
@ -99,7 +99,7 @@ local function get_formspec(tabview, name, tabdata)
retval = retval .. retval = retval ..
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" .. "image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
"label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" .. "label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" ..
"background9[5.6,2.3;6.2,2.4;" .. defaulttexturedir_esc .. "desc_bg.png" .. ";false;32]" "background9[5.6,2.3;6.2,2.4;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]"
if selected_pkg.type == "mod" then if selected_pkg.type == "mod" then
if selected_pkg.is_modpack then if selected_pkg.is_modpack then
@ -138,7 +138,7 @@ local function get_formspec(tabview, name, tabdata)
fgettext("Disable Texture Pack") .. ";true;false]" fgettext("Disable Texture Pack") .. ";true;false]"
else else
retval = retval .. retval = retval ..
btn_style("btn_mod_mgr_use_txp") .. btn_style("btn_mod_mgr_use_txp", "green") ..
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_use_txp;" .. "image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_use_txp;" ..
fgettext("Use Texture Pack") .. ";true;false]" fgettext("Use Texture Pack") .. ";true;false]"
end end
@ -150,7 +150,7 @@ local function get_formspec(tabview, name, tabdata)
if core.may_modify_path(selected_pkg.path) then if core.may_modify_path(selected_pkg.path) then
retval = retval .. retval = retval ..
btn_style("btn_mod_mgr_delete_mod") .. btn_style("btn_mod_mgr_delete_mod", "red") ..
"image_button[5.5,4.8;3.25,0.9;;btn_mod_mgr_delete_mod;" .. "image_button[5.5,4.8;3.25,0.9;;btn_mod_mgr_delete_mod;" ..
fgettext("Uninstall Package") .. ";true;false]" fgettext("Uninstall Package") .. ";true;false]"
end end

View File

@ -131,13 +131,13 @@ return {
"image_button[9.5,0.6;2.6,0.85;;privacy;Privacy Policy;true;false]" .. "image_button[9.5,0.6;2.6,0.85;;privacy;Privacy Policy;true;false]" ..
"background9[0,1.5;12,4.2;" .. defaulttexturedir_esc .. "background9[0,1.5;12,4.2;" .. defaulttexturedir_esc ..
"worldlist_bg.png" .. ";false;40]" .. "worldlist_bg.png;false;40]" ..
"tablecolumns[color;text]" .. "tablecolumns[color;text]" ..
"tableoptions[background=#0000;highlight=#00000000;border=false]" .. "tableoptions[background=#0000;highlight=#00000000;border=false]" ..
"table[0,1.5;11.75,4.05;list_credits;" .. "table[0,1.5;11.75,4.05;list_credits;" ..
"#FFFF00," .. fgettext("Core Developers") .. " (MultiCraft)" .. ",," .. "#FFFF00," .. fgettext("Core Developers") .. " (MultiCraft),," ..
buildCreditList(multicraft_developers) .. ",,," .. buildCreditList(multicraft_developers) .. ",,," ..
"#FFFF00," .. fgettext("Core Developers") .. " (Minetest Engine)" .. ",," .. "#FFFF00," .. fgettext("Core Developers") .. " (Minetest Engine),," ..
buildCreditList(core_developers) .. ",,," .. buildCreditList(core_developers) .. ",,," ..
"#FFFF00," .. fgettext("Active Contributors") .. ",," .. "#FFFF00," .. fgettext("Active Contributors") .. ",," ..
buildCreditList(active_contributors) .. ",,," .. buildCreditList(active_contributors) .. ",,," ..

View File

@ -151,7 +151,7 @@ local function get_formspec(_, _, tab_data)
"image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_checkbox .. "image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_checkbox ..
";cb_creative_mode;;true;false]" .. ";cb_creative_mode;;true;false]" ..
"background9[0,0;6.5,4.8;" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" .. "background9[0,0;6.5,4.8;" .. defaulttexturedir_esc .. "worldlist_bg.png;false;40]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" "table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]"
@ -306,7 +306,8 @@ local function main_button_handler(this, fields, name, tab_data)
world.name ~= nil and world.name ~= nil and
world.name ~= "" then world.name ~= "" then
local index = menudata.worldlist:get_raw_index(selected) local index = menudata.worldlist:get_raw_index(selected)
local delete_world_dlg = create_delete_world_dlg(world.name, index, world.gameid) local game = pkgmgr.find_by_gameid(world.gameid)
local delete_world_dlg = create_delete_world_dlg(world.name, index, game.name)
delete_world_dlg:set_parent(this) delete_world_dlg:set_parent(this)
this:hide() this:hide()
delete_world_dlg:show() delete_world_dlg:show()
@ -379,6 +380,8 @@ local function on_change(type, old_tab, new_tab)
if game and game.id ~= "default" then if game and game.id ~= "default" then
menudata.worldlist:set_filtercriteria(game.id) menudata.worldlist:set_filtercriteria(game.id)
mm_texture.update("singleplayer",game) mm_texture.update("singleplayer",game)
else
mm_texture.reset()
end end
core.set_topleft_text("Powered by Minetest Engine") core.set_topleft_text("Powered by Minetest Engine")

View File

@ -111,7 +111,7 @@ local function get_formspec(this)
"image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_checkbox .. "image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_checkbox ..
";cb_creative_mode;;true;false]" .. ";cb_creative_mode;;true;false]" ..
"background9[0,0;6.5,4.8;" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" .. "background9[0,0;6.5,4.8;" .. defaulttexturedir_esc .. "worldlist_bg.png;false;40]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" .. "table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" ..

View File

@ -46,36 +46,36 @@ local function get_formspec(tabview, name, tabdata)
local retval = local retval =
-- Search -- Search
"formspec_version[3]" .. "formspec_version[3]" ..
"image[-0.1,4.93;7,0.81;" .. defaulttexturedir_esc .. "field_bg.png;32]" .. "image[-0.11,4.93;7.02,0.81;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[Dte_search;border=false;bgcolor=transparent]" .. "style[Dte_search;border=false;bgcolor=transparent]" ..
"field[0.25,5.25;5.7,0.83;Dte_search;;" .. esc(tabdata.search_for) .. "]" .. "field[0.25,5.25;5.7,0.83;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
btn_style("btn_mp_search") .. btn_style("btn_mp_clear") ..
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir_esc .. "image_button[5.62,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"search.png;btn_mp_search;;true;false]" .. "clear.png;btn_mp_clear;;true;false]" ..
btn_style("btn_mp_refresh") .. btn_style("btn_mp_refresh") ..
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir_esc .. "image_button[6.37,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"refresh.png;btn_mp_refresh;;true;false]" .. "refresh.png;btn_mp_refresh;;true;false]" ..
-- Address / Port -- Address / Port
"image[7.1,0.09;6,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" .. "image[7.1,0.09;6,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_address;border=false;bgcolor=transparent]" .. "style[te_address;border=false;bgcolor=transparent]" ..
"field[7.45,0.55;4.9,0.5;te_address;" .. fgettext("Address / Port") .. ":" .. ";" .. "field[7.45,0.55;4.9,0.5;te_address;" .. fgettext("Address / Port") .. ":;" ..
esc(address) .. "]" .. esc(address) .. "]" ..
-- Name -- Name
"image[7.1,1.25;2.95,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" .. "image[7.1,1.25;2.95,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_name;border=false;bgcolor=transparent]" .. "style[te_name;border=false;bgcolor=transparent]" ..
"field[7.45,1.7;2.45,0.5;te_name;" .. fgettext("Name") .. ":" .. ";" .. "field[7.45,1.7;2.45,0.5;te_name;" .. fgettext("Name") .. ":;" ..
esc(core.settings:get("name")) .. "]" .. esc(core.settings:get("name")) .. "]" ..
-- Password -- Password
"image[9.55,1.25;2.95,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" .. "image[9.55,1.25;2.95,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_pwd;border=false;bgcolor=transparent]" .. "style[te_pwd;border=false;bgcolor=transparent]" ..
"pwdfield[9.9,1.7;2.45,0.5;te_pwd;" .. fgettext("Password") .. ":" .. ";" .. "pwdfield[9.9,1.7;2.45,0.5;te_pwd;" .. fgettext("Password") .. ":;" ..
esc(password_tmp) .. "]" .. esc(password_tmp) .. "]" ..
-- Description Background -- Description Background
"background9[7.2,2.2;4.8,2.65;" .. defaulttexturedir_esc .. "desc_bg.png" .. ";false;32]" .. "background9[7.2,2.2;4.8,2.65;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
-- Connect -- Connect
btn_style("btn_mp_connect") .. btn_style("btn_mp_connect") ..
@ -102,7 +102,7 @@ local function get_formspec(tabview, name, tabdata)
--favorites --favorites
retval = retval .. retval = retval ..
"background9[0,-0.1;7.1,5;" .. "background9[0,-0.1;7.1,5;" ..
defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" .. defaulttexturedir_esc .. "worldlist_bg.png;false;40]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"tablecolumns[" .. "tablecolumns[" ..
image_column(fgettext("Favorite")) .. ",align=center;" .. image_column(fgettext("Favorite")) .. ",align=center;" ..
@ -289,12 +289,18 @@ local function main_button_handler(tabview, fields, name, tabdata)
return true return true
end end
if fields.btn_mp_clear then
tabdata.search_for = ""
menudata.search_result = nil
return true
end
if fields.btn_mp_refresh then if fields.btn_mp_refresh then
serverlistmgr.sync() serverlistmgr.sync()
return true return true
end end
if (fields.Dte_search or fields.btn_mp_search) and not if fields.Dte_search and not
(fields.btn_mp_connect or fields.key_enter) then (fields.btn_mp_connect or fields.key_enter) then
tabdata.selected = 1 tabdata.selected = 1
local input = lower(fields.Dte_search or "") local input = lower(fields.Dte_search or "")

View File

@ -124,7 +124,7 @@ end
local function formspec(tabview, name, tabdata) local function formspec(tabview, name, tabdata)
local tab_string = local tab_string =
"box[0,0;3.75,4.5;#999999]" .. "background9[0.1,0.1;3.75,4.5;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";" "checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
.. dump(core.settings:get_bool("smooth_lighting")) .. "]" .. .. dump(core.settings:get_bool("smooth_lighting")) .. "]" ..
"checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";" "checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";"
@ -139,7 +139,7 @@ local function formspec(tabview, name, tabdata)
.. getSettingIndex.NodeHighlighting() .. "]" .. .. getSettingIndex.NodeHighlighting() .. "]" ..
"dropdown[0.25,3.6;3.5;dd_leaves_style;" .. dd_options.leaves[1] .. ";" "dropdown[0.25,3.6;3.5;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
.. getSettingIndex.Leaves() .. "]" .. .. getSettingIndex.Leaves() .. "]" ..
"box[4,0;3.75,4.5;#999999]" .. "background9[4.1,0.1;3.75,4.5;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"label[4.25,0.1;" .. fgettext("Texturing:") .. "]" .. "label[4.25,0.1;" .. fgettext("Texturing:") .. "]" ..
"dropdown[4.25,0.55;3.5;dd_filters;" .. dd_options.filters[1] .. ";" "dropdown[4.25,0.55;3.5;dd_filters;" .. dd_options.filters[1] .. ";"
.. getSettingIndex.Filter() .. "]" .. .. getSettingIndex.Filter() .. "]" ..
@ -151,7 +151,7 @@ local function formspec(tabview, name, tabdata)
"label[4.25,3.45;" .. fgettext("Screen:") .. "]" .. "label[4.25,3.45;" .. fgettext("Screen:") .. "]" ..
"checkbox[4.25,3.6;cb_autosave_screensize;" .. fgettext("Autosave Screen Size") .. ";" "checkbox[4.25,3.6;cb_autosave_screensize;" .. fgettext("Autosave Screen Size") .. ";"
.. dump(core.settings:get_bool("autosave_screensize")) .. "]" .. .. dump(core.settings:get_bool("autosave_screensize")) .. "]" ..
"box[8,0;3.75,4.5;#999999]" "background9[8.1,0.1;3.75,4.5;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]"
local video_driver = core.settings:get("video_driver") local video_driver = core.settings:get("video_driver")
local shaders_enabled = core.settings:get_bool("enable_shaders") local shaders_enabled = core.settings:get_bool("enable_shaders")

View File

@ -90,67 +90,67 @@ local languages, language_dropdown, lang_idx = get_language_list()
local function formspec(tabview, name, tabdata) local function formspec(tabview, name, tabdata)
local fps = tonumber(core.settings:get("fps_max")) local fps = tonumber(core.settings:get("fps_max"))
local range = tonumber(core.settings:get("viewing_range")) local range = tonumber(core.settings:get("viewing_range"))
local sensitivity = tonumber(core.settings:get("touch_sensitivity")) * 2000 local sensitivity = tonumber(core.settings:get("touch_sensitivity") or 0) * 2000
local touchtarget = core.settings:get_bool("touchtarget") or false local touchtarget = core.settings:get_bool("touchtarget", false)
local fancy_leaves = core.settings:get("leaves_style") == "fancy" local fancy_leaves = core.settings:get("leaves_style") == "fancy"
local arm_inertia = core.settings:get_bool("arm_inertia") or false local arm_inertia = core.settings:get_bool("arm_inertia", false)
local sound = tonumber(core.settings:get("sound_volume")) ~= 0 and true or false local sound = tonumber(core.settings:get("sound_volume")) ~= 0 and true or false
local tab_string = local tab_string =
"box[-0.1,0;3.85,5.5;#999999]" .. "background9[0,0.05;3.85,5.5;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"checkbox[0.15,-0.05;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";" "checkbox[0.15,-0.1;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
.. dump(core.settings:get_bool("smooth_lighting")) .. "]" .. .. dump(core.settings:get_bool("smooth_lighting")) .. "]" ..
"checkbox[0.15,0.5;cb_particles;" .. fgettext("Particles") .. ";" "checkbox[0.15,0.45;cb_particles;" .. fgettext("Particles") .. ";"
.. dump(core.settings:get_bool("enable_particles")) .. "]" .. .. dump(core.settings:get_bool("enable_particles")) .. "]" ..
"checkbox[0.15,1.1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";" "checkbox[0.15,1.05;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";"
.. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" .. .. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" ..
--[["checkbox[0.15,1.7;cb_opaque_water;" .. fgettext("Opaque Water") .. ";" --[["checkbox[0.15,1.65;cb_opaque_water;" .. fgettext("Opaque Water") .. ";"
.. dump(core.settings:get_bool("opaque_water")) .. "]" .. .. dump(core.settings:get_bool("opaque_water")) .. "]" ..
"checkbox[0.15,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";" "checkbox[0.15,1.95;cb_connected_glass;" .. fgettext("Connected Glass") .. ";"
.. dump(core.settings:get_bool("connected_glass")) .. "]" ..]] .. dump(core.settings:get_bool("connected_glass")) .. "]" ..]]
"checkbox[0.15,1.7;cb_fog;" .. fgettext("Fog") .. ";" "checkbox[0.15,1.65;cb_fog;" .. fgettext("Fog") .. ";"
.. dump(core.settings:get_bool("enable_fog")) .. "]" .. .. dump(core.settings:get_bool("enable_fog")) .. "]" ..
"checkbox[0.15,2.3;cb_inventory_items_animations;" .. fgettext("Inv. animations") .. ";" "checkbox[0.15,2.25;cb_inventory_items_animations;" .. fgettext("Inv. animations") .. ";"
.. dump(core.settings:get_bool("inventory_items_animations")) .. "]" .. .. dump(core.settings:get_bool("inventory_items_animations")) .. "]" ..
"checkbox[0.15,2.9;cb_fancy_leaves;" .. fgettext("Fancy Leaves") .. ";" "checkbox[0.15,2.85;cb_fancy_leaves;" .. fgettext("Fancy Leaves") .. ";"
.. dump(fancy_leaves) .. "]" .. .. dump(fancy_leaves) .. "]" ..
"checkbox[0.15,3.5;cb_touchtarget;" .. fgettext("Touchtarget") .. ";" "checkbox[0.15,3.45;cb_crosshair;" .. fgettext("Crosshair") .. ";"
.. dump(touchtarget) .. "]" .. .. dump(not touchtarget) .. "]" ..
"checkbox[0.15,4.1;cb_arm_inertia;" .. fgettext("Arm inertia") .. ";" "checkbox[0.15,4.05;cb_arm_inertia;" .. fgettext("Arm inertia") .. ";"
.. dump(arm_inertia) .. "]" .. .. dump(arm_inertia) .. "]" ..
"checkbox[0.15,4.7;cb_sound;" .. fgettext("Sound") .. ";" "checkbox[0.15,4.65;cb_sound;" .. fgettext("Sound") .. ";"
.. dump(sound) .. "]" .. .. dump(sound) .. "]" ..
"box[4,0;3.75,5.5;#999999]" .. "background9[4.1,0.05;3.75,5.5;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"label[4.25,0.15;" .. fgettext("Maximum FPS") .. ":]" .. "label[4.25,0.1;" .. fgettext("Maximum FPS") .. ":]" ..
"dropdown[4.25,0.6;3.5;dd_fps_max;30,35,45,60;" .. "dropdown[4.25,0.55;3.5;dd_fps_max;30,35,45,60,90;" ..
tonumber(fps <= 30 and 1 or fps == 35 and 2 or fps == 45 and 3 or 4) .. "]" .. (fps <= 30 and 1 or fps == 35 and 2 or fps == 45 and 3 or fps == 60 and 4 or 5) .. "]" ..
"label[4.25,1.5;" .. fgettext("Viewing range") .. ":]" .. "label[4.25,1.5;" .. fgettext("Viewing range") .. ":]" ..
"dropdown[4.25,1.95;3.5;dd_viewing_range;30,40,60,80,100,125,150,175,200;" .. "dropdown[4.25,1.95;3.5;dd_viewing_range;30,40,60,80,100,125,150,175,200;" ..
tonumber(range <= 30 and 1 or range == 40 and 2 or range == 60 and 3 or (range <= 30 and 1 or range == 40 and 2 or range == 60 and 3 or
range == 80 and 4 or range == 100 and 5 or range == 125 and 6 or range == 80 and 4 or range == 100 and 5 or range == 125 and 6 or
range == 150 and 7 or range == 175 and 8 or 9) .. "]" .. range == 150 and 7 or range == 175 and 8 or 9) .. "]" ..
"label[4.25,2.85;" .. fgettext("Node highlighting") .. ":]" .. "label[4.25,2.9;" .. fgettext("Node highlighting") .. ":]" ..
"dropdown[4.25,3.3;3.5;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";" "dropdown[4.25,3.35;3.5;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
.. getSettingIndex.NodeHighlighting() .. "]" .. .. getSettingIndex.NodeHighlighting() .. "]" ..
"label[4.25,4.2;" .. fgettext("Mouse sensitivity") .. ":]" .. "label[4.25,4.3;" .. fgettext("Mouse sensitivity") .. ":]" ..
"scrollbar[4.25,4.65;3.23,0.5;horizontal;sb_sensitivity;" .. sensitivity .. "]" .. "scrollbar[4.25,4.75;3.23,0.5;horizontal;sb_sensitivity;" .. sensitivity .. "]" ..
"box[8,0;3.85,3.25;#999999]" "background9[8.1,0.05;3.85,3.15;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]"
local video_driver = core.settings:get("video_driver") local video_driver = core.settings:get("video_driver")
local shaders_enabled = video_driver == "opengl" or video_driver == "ogles2" local shaders_enabled = video_driver == "opengl" or video_driver == "ogles2"
core.settings:set_bool("enable_shaders", shaders_enabled) core.settings:set_bool("enable_shaders", shaders_enabled)
if shaders_enabled then if shaders_enabled then
tab_string = tab_string .. tab_string = tab_string ..
"label[8.25,0.15;" .. fgettext("Shaders") .. "]" "label[8.25,0.1;" .. fgettext("Shaders") .. "]"
else else
tab_string = tab_string .. tab_string = tab_string ..
"label[8.25,0.15;" .. core.colorize("#888888", "label[8.25,0.1;" .. core.colorize("#888888",
fgettext("Shaders (unavailable)")) .. "]" fgettext("Shaders (unavailable)")) .. "]"
end end
@ -166,32 +166,33 @@ local function formspec(tabview, name, tabdata)
if shaders_enabled then if shaders_enabled then
tab_string = tab_string .. tab_string = tab_string ..
"checkbox[8.25,0.55;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";" "checkbox[8.25,0.45;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
.. dump(core.settings:get_bool("tone_mapping")) .. "]" .. .. dump(core.settings:get_bool("tone_mapping")) .. "]" ..
"checkbox[8.25,1.15;cb_waving_water;" .. fgettext("Waving liquids") .. ";" "checkbox[8.25,1.05;cb_waving_water;" .. fgettext("Waving liquids") .. ";"
.. dump(core.settings:get_bool("enable_waving_water")) .. "]" .. .. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
"checkbox[8.25,1.75;cb_waving_leaves;" .. fgettext("Waving leaves") .. ";" "checkbox[8.25,1.65;cb_waving_leaves;" .. fgettext("Waving leaves") .. ";"
.. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" .. .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
"checkbox[8.25,2.35;cb_waving_plants;" .. fgettext("Waving plants") .. ";" "checkbox[8.25,2.25;cb_waving_plants;" .. fgettext("Waving plants") .. ";"
.. dump(core.settings:get_bool("enable_waving_plants")) .. "]" .. dump(core.settings:get_bool("enable_waving_plants")) .. "]"
else else
tab_string = tab_string .. tab_string = tab_string ..
"label[8.38,0.75;" .. core.colorize("#888888", "label[8.38,0.65;" .. core.colorize("#888888",
fgettext("Tone Mapping")) .. "]" .. fgettext("Tone Mapping")) .. "]" ..
"label[8.38,1.35;" .. core.colorize("#888888", "label[8.38,1.25;" .. core.colorize("#888888",
fgettext("Waving Liquids")) .. "]" .. fgettext("Waving Liquids")) .. "]" ..
"label[8.38,1.95;" .. core.colorize("#888888", "label[8.38,1.85;" .. core.colorize("#888888",
fgettext("Waving Leaves")) .. "]" .. fgettext("Waving Leaves")) .. "]" ..
"label[8.38,2.55;" .. core.colorize("#888888", "label[8.38,2.45;" .. core.colorize("#888888",
fgettext("Waving Plants")) .. "]" fgettext("Waving Plants")) .. "]"
end end
tab_string = tab_string .. tab_string = tab_string ..
"label[8.25,3.35;" .. fgettext("Language") .. ":]" .. "background9[8.1,3.35;3.85,2.2;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"dropdown[8.25,3.8;3.58;dd_language;" .. language_dropdown .. ";" .. "label[8.25,3.3;" .. fgettext("Language") .. ":]" ..
"dropdown[8.25,3.75;3.58;dd_language;" .. language_dropdown .. ";" ..
lang_idx .. ";true]" .. lang_idx .. ";true]" ..
btn_style("btn_reset") .. btn_style("btn_reset") ..
"button[8.25,4.81;3.5,0.8;btn_reset;" .. fgettext("Reset all settings") .. "]" "button[8.25,4.6;3.5,0.8;btn_reset;" .. fgettext("Reset all settings") .. "]"
return tab_string return tab_string
end end
@ -234,11 +235,11 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
return true return true
end end
if fields["cb_fancy_leaves"] then if fields["cb_fancy_leaves"] then
core.settings:set("leaves_style", fields["cb_fancy_leaves"] and "fancy" or "opaque") core.settings:set("leaves_style", (minetest.is_yes(fields["cb_fancy_leaves"]) and "fancy" or "opaque"))
return true return true
end end
if fields["cb_touchtarget"] then if fields["cb_crosshair"] then
core.settings:set("touchtarget", fields["cb_touchtarget"]) core.settings:set_bool("touchtarget", not minetest.is_yes(fields["cb_crosshair"]))
return true return true
end end
if fields["cb_arm_inertia"] then if fields["cb_arm_inertia"] then
@ -249,10 +250,6 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
core.settings:set("sound_volume", (minetest.is_yes(fields["cb_sound"]) and "1.0") or "0.0") core.settings:set("sound_volume", (minetest.is_yes(fields["cb_sound"]) and "1.0") or "0.0")
return true return true
end end
if fields["cb_shaders"] then
core.settings:set("enable_shaders", fields["cb_shaders"])
return true
end
if fields["cb_tonemapping"] then if fields["cb_tonemapping"] then
core.settings:set("tone_mapping", fields["cb_tonemapping"]) core.settings:set("tone_mapping", fields["cb_tonemapping"])
return true return true

View File

@ -891,34 +891,6 @@ int ModApiMainMenu::l_gettext(lua_State *L)
return 1; return 1;
} }
/******************************************************************************/
int ModApiMainMenu::l_get_screen_info(lua_State *L)
{
lua_newtable(L);
int top = lua_gettop(L);
lua_pushstring(L,"density");
lua_pushnumber(L,RenderingEngine::getDisplayDensity());
lua_settable(L, top);
lua_pushstring(L,"display_width");
lua_pushnumber(L,RenderingEngine::getDisplaySize().X);
lua_settable(L, top);
lua_pushstring(L,"display_height");
lua_pushnumber(L,RenderingEngine::getDisplaySize().Y);
lua_settable(L, top);
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
lua_pushstring(L,"window_width");
lua_pushnumber(L, window_size.X);
lua_settable(L, top);
lua_pushstring(L,"window_height");
lua_pushnumber(L, window_size.Y);
lua_settable(L, top);
return 1;
}
/******************************************************************************/ /******************************************************************************/
int ModApiMainMenu::l_get_min_supp_proto(lua_State *L) int ModApiMainMenu::l_get_min_supp_proto(lua_State *L)
{ {
@ -1035,7 +1007,6 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(gettext); API_FCT(gettext);
API_FCT(get_video_drivers); API_FCT(get_video_drivers);
API_FCT(get_video_modes); API_FCT(get_video_modes);
API_FCT(get_screen_info);
API_FCT(get_min_supp_proto); API_FCT(get_min_supp_proto);
API_FCT(get_max_supp_proto); API_FCT(get_max_supp_proto);
API_FCT(open_url); API_FCT(open_url);

View File

@ -102,8 +102,6 @@ private:
static int l_set_formspec_prepend(lua_State *L); static int l_set_formspec_prepend(lua_State *L);
static int l_get_screen_info(lua_State *L);
//filesystem //filesystem
static int l_get_mainmenu_path(lua_State *L); static int l_get_mainmenu_path(lua_State *L);

View File

@ -41,6 +41,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/sha1.h" #include "util/sha1.h"
#include <algorithm> #include <algorithm>
#ifndef SERVER
#include "client/renderingengine.h"
#endif
// log([level,] text) // log([level,] text)
// Writes a line to the logger. // Writes a line to the logger.
@ -486,6 +490,7 @@ int ModApiUtil::l_sha1(lua_State *L)
return 1; return 1;
} }
#ifndef SERVER
int ModApiUtil::l_upgrade(lua_State *L) int ModApiUtil::l_upgrade(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
@ -516,6 +521,35 @@ int ModApiUtil::l_get_secret_key(lua_State *L)
return 1; return 1;
} }
int ModApiUtil::l_get_screen_info(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
lua_newtable(L);
int top = lua_gettop(L);
lua_pushstring(L,"density");
lua_pushnumber(L,RenderingEngine::getDisplayDensity());
lua_settable(L, top);
lua_pushstring(L,"display_width");
lua_pushnumber(L,RenderingEngine::getDisplaySize().X);
lua_settable(L, top);
lua_pushstring(L,"display_height");
lua_pushnumber(L,RenderingEngine::getDisplaySize().Y);
lua_settable(L, top);
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
lua_pushstring(L,"window_width");
lua_pushnumber(L, window_size.X);
lua_settable(L, top);
lua_pushstring(L,"window_height");
lua_pushnumber(L, window_size.Y);
lua_settable(L, top);
return 1;
}
#endif
void ModApiUtil::Initialize(lua_State *L, int top) void ModApiUtil::Initialize(lua_State *L, int top)
{ {
API_FCT(log); API_FCT(log);
@ -557,6 +591,7 @@ void ModApiUtil::Initialize(lua_State *L, int top)
void ModApiUtil::InitializeClient(lua_State *L, int top) void ModApiUtil::InitializeClient(lua_State *L, int top)
{ {
#ifndef SERVER
API_FCT(log); API_FCT(log);
API_FCT(get_us_time); API_FCT(get_us_time);
@ -575,8 +610,13 @@ void ModApiUtil::InitializeClient(lua_State *L, int top)
API_FCT(get_version); API_FCT(get_version);
API_FCT(sha1); API_FCT(sha1);
API_FCT(get_screen_info);
LuaSettings::create(L, g_settings, g_settings_path); LuaSettings::create(L, g_settings, g_settings_path);
lua_setfield(L, top, "settings"); lua_setfield(L, top, "settings");
#else
FATAL_ERROR("InitializeClient called from server");
#endif
} }
void ModApiUtil::InitializeAsync(lua_State *L, int top) void ModApiUtil::InitializeAsync(lua_State *L, int top)
@ -611,6 +651,11 @@ void ModApiUtil::InitializeAsync(lua_State *L, int top)
void ModApiUtil::InitializeMainMenu(lua_State *L, int top) { void ModApiUtil::InitializeMainMenu(lua_State *L, int top) {
Initialize(L, top); Initialize(L, top);
#ifndef SERVER
API_FCT(upgrade); API_FCT(upgrade);
API_FCT(get_secret_key); API_FCT(get_secret_key);
API_FCT(get_screen_info);
#else
FATAL_ERROR("InitializeMainMenu called from server");
#endif
} }

View File

@ -101,12 +101,16 @@ private:
// sha1(string, raw) // sha1(string, raw)
static int l_sha1(lua_State *L); static int l_sha1(lua_State *L);
#ifndef SERVER
// upgrade(string) // upgrade(string)
static int l_upgrade(lua_State *L); static int l_upgrade(lua_State *L);
// get_secret_key(string) // get_secret_key(string)
static int l_get_secret_key(lua_State *L); static int l_get_secret_key(lua_State *L);
static int l_get_screen_info(lua_State *L);
#endif
public: public:
static void Initialize(lua_State *L, int top); static void Initialize(lua_State *L, int top);
static void InitializeAsync(lua_State *L, int top); static void InitializeAsync(lua_State *L, int top);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 248 B