MainMenu improvements and cleanup (#141)
Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
@ -26,6 +26,9 @@
|
|||||||
-- element.getFormspec() returns formspec of tabview --
|
-- element.getFormspec() returns formspec of tabview --
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local fmt = string.format
|
||||||
|
local tconcat = table.concat
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function add_tab(self,tab)
|
local function add_tab(self,tab)
|
||||||
assert(tab.size == nil or (type(tab.size) == table and
|
assert(tab.size == nil or (type(tab.size) == table and
|
||||||
@ -78,78 +81,149 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local tpath = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc
|
local tpath = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc
|
||||||
local function get_side_menu(self, selected_tab)
|
local function add_side_menu(self, fs, selected_tab, x, fs_h, darken)
|
||||||
if #self.side_buttons == 0 then return "" end
|
if #self.side_buttons == 0 then return end
|
||||||
|
|
||||||
local side_menu_h = #self.side_buttons * 1.2 + 0.2
|
local side_menu_h = #self.side_buttons * 1.41 + 0.14
|
||||||
local bg_y = 2.35 - side_menu_h / 2
|
local bg_y = fs_h / 2 - side_menu_h / 2
|
||||||
local fs = {
|
fs[#fs + 1] = fmt("image[%s,%s;1.15,%s;%sside_menu.png;30]", x, bg_y, side_menu_h, tpath)
|
||||||
"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
|
for i, btn in ipairs(self.side_buttons) do
|
||||||
local y = bg_y - 1.15 + 1.2 * i
|
local y = bg_y - 1.31 + 1.41 * i
|
||||||
if i > 1 then
|
if i > 1 then
|
||||||
fs[#fs + 1] = "image[12.15," .. y - 0.04 .. ";0.9,0.06;" ..
|
fs[#fs + 1] = fmt("image[%s,%s;0.9,0.06;%sside_menu_divider.png]", x + 0.1, y - 0.06, tpath)
|
||||||
tpath .. "side_menu_divider.png]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local btn_name = self.name .. "_side_" .. i
|
local btn_name = self.name .. "_side_" .. i
|
||||||
fs[#fs + 1] = "style[" .. btn_name .. ";bgimg="
|
fs[#fs + 1] = fmt("style[%s;bgimg=", btn_name)
|
||||||
|
|
||||||
local texture_prefix = btn.texture_prefix or btn.tab_name
|
local tab_name = btn.tab_name or btn.tab_name_selected
|
||||||
if btn.tab_name and btn.tab_name == selected_tab then
|
local texture_prefix = btn.texture_prefix or tab_name
|
||||||
|
if tab_name and tab_name == selected_tab then
|
||||||
fs[#fs + 1] = btn.texture_selected or tpath .. texture_prefix .. "_menu_selected.png"
|
fs[#fs + 1] = btn.texture_selected or tpath .. texture_prefix .. "_menu_selected.png"
|
||||||
else
|
else
|
||||||
fs[#fs + 1] = btn.texture or tpath .. texture_prefix .. "_menu.png"
|
fs[#fs + 1] = btn.texture or tpath .. texture_prefix .. "_menu.png"
|
||||||
fs[#fs + 1] = ";bgimg_hovered="
|
fs[#fs + 1] = ";bgimg_hovered="
|
||||||
fs[#fs + 1] = btn.texture_hover or tpath .. texture_prefix .. "_menu_hover.png]"
|
fs[#fs + 1] = btn.texture_hover or tpath .. texture_prefix .. "_menu_hover.png"
|
||||||
end
|
end
|
||||||
fs[#fs + 1] = "]"
|
fs[#fs + 1] = "]"
|
||||||
|
|
||||||
fs[#fs + 1] = "image_button[12.1," .. y .. ";1,1.3;;" .. btn_name .. ";;true;false]"
|
fs[#fs + 1] = fmt("image_button[%s,%s;1,1.35;;%s;;true;false]", x + 0.09, y, btn_name)
|
||||||
fs[#fs + 1] = "tooltip[" .. btn_name .. ";" .. btn.tooltip .. "]"
|
fs[#fs + 1] = fmt("tooltip[%s;%s]", btn_name, btn.tooltip)
|
||||||
end
|
end
|
||||||
|
|
||||||
return table.concat(fs)
|
if darken then
|
||||||
|
fs[#fs + 1] = fmt("style[cancel;bgimg=%sside_menu_darken.png;bgimg_middle=30]", tpath)
|
||||||
|
fs[#fs + 1] = fmt("image_button[%s,%s;1.15,%s;;cancel;;true;false]", x, bg_y, side_menu_h)
|
||||||
|
|
||||||
|
-- Reset "cancel" button styling
|
||||||
|
fs[#fs + 1] = "style[cancel;bgimg=;bgimg_middle=]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_formspec(self)
|
--------------------------------------------------------------------------------
|
||||||
local formspec = ""
|
local function add_button_header(self, fs, fs_w)
|
||||||
|
local visible_tabs = {}
|
||||||
if not self.hidden and (self.parent == nil or not self.parent.hidden) then
|
for _, tab in ipairs(self.tablist) do
|
||||||
local name = self.tablist[self.last_tab_index].name
|
if not tab.hidden and tab.caption ~= "" then
|
||||||
|
visible_tabs[#visible_tabs + 1] = tab
|
||||||
if self.parent == nil then
|
|
||||||
local tsize = self.tablist[self.last_tab_index].tabsize or
|
|
||||||
{width=self.width, height=self.height}
|
|
||||||
formspec = formspec ..
|
|
||||||
string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1,
|
|
||||||
dump(self.fixed_size)) ..
|
|
||||||
"bgcolor[#0000]" ..
|
|
||||||
"listcolors[#000;#000;#000;#dff6f5;#302c2e]" ..
|
|
||||||
"container[1,1]" ..
|
|
||||||
"background9[-0.2,-1.26;" .. tsize.width + 0.4 .. "," ..
|
|
||||||
tsize.height + 1.75 .. ";" .. defaulttexturedir_esc ..
|
|
||||||
"bg_common.png;false;40]" ..
|
|
||||||
get_side_menu(self, name)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- formspec = formspec .. self:tab_header()
|
|
||||||
formspec = formspec .. self:button_header() ..
|
|
||||||
self.tablist[self.last_tab_index].get_formspec(
|
|
||||||
self,
|
|
||||||
name,
|
|
||||||
self.tablist[self.last_tab_index].tabdata,
|
|
||||||
self.tablist[self.last_tab_index].tabsize
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.parent == nil then
|
|
||||||
formspec = formspec .. "container_end[]"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return formspec
|
|
||||||
|
local x = 1.5
|
||||||
|
local w = (fs_w - 0.53) / #visible_tabs
|
||||||
|
for i = 1, #visible_tabs do
|
||||||
|
local caption = visible_tabs[i].caption
|
||||||
|
local side = i == 1 and "left" or (i < #visible_tabs and "middle" or "right")
|
||||||
|
local btn_name = self.name .. "_" .. i
|
||||||
|
if i == math.abs(self.last_tab_index) then
|
||||||
|
side = side .. "_pressed"
|
||||||
|
end
|
||||||
|
|
||||||
|
fs[#fs + 1] = btn_style(btn_name, side)
|
||||||
|
fs[#fs + 1] = fmt("style[%s;content_offset=0;font_size=+1]", btn_name)
|
||||||
|
fs[#fs + 1] = fmt("image_button[%s,0.25;%s,0.9;;%s;%s;true;false]",
|
||||||
|
x, w + 0.03, btn_name, caption)
|
||||||
|
x = x + w
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local function get_formspec(self, popup_w, popup_h, popup_fs)
|
||||||
|
if (self.hidden or (self.parent and self.parent.hidden)) and not popup_fs then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local fs = {}
|
||||||
|
|
||||||
|
local current_tab = self.tablist[self.last_tab_index]
|
||||||
|
local content, prepend_override = current_tab.get_formspec(self,
|
||||||
|
current_tab.name, current_tab.tabdata, current_tab.size)
|
||||||
|
local real_coords = current_tab.formspec_version and current_tab.formspec_version > 1
|
||||||
|
local w, h
|
||||||
|
if prepend_override then
|
||||||
|
fs[#fs + 1] = prepend_override
|
||||||
|
elseif not self.parent then
|
||||||
|
fs[#fs + 1] = "formspec_version[4]"
|
||||||
|
|
||||||
|
local s = current_tab.tabsize or self
|
||||||
|
w, h = s.width, s.height
|
||||||
|
if not real_coords then
|
||||||
|
w = w * 1.25 + 0.6
|
||||||
|
h = h * 1.15 + 0.9
|
||||||
|
end
|
||||||
|
fs[#fs + 1] = fmt("size[%s,%s]", w + 2.5, h + 1.15)
|
||||||
|
|
||||||
|
-- Background
|
||||||
|
fs[#fs + 1] = "bgcolor[;neither]"
|
||||||
|
fs[#fs + 1] = "listcolors[#000;#000;#000;#dff6f5;#302c2e]"
|
||||||
|
fs[#fs + 1] = fmt("background9[1.25,0;%s,%s;%sbg_common.png;false;32]",
|
||||||
|
w, h + 1.15, defaulttexturedir)
|
||||||
|
|
||||||
|
add_button_header(self, fs, w)
|
||||||
|
|
||||||
|
-- This container isn't ideal for real_coordinates formspecs but
|
||||||
|
-- keeps compatibility with existing code
|
||||||
|
fs[#fs + 1] = "container[1,1]"
|
||||||
|
fs[#fs + 1] = "real_coordinates[false]"
|
||||||
|
end
|
||||||
|
|
||||||
|
fs[#fs + 1] = content
|
||||||
|
|
||||||
|
if not prepend_override and not self.parent then
|
||||||
|
-- Make sure that real_coordinates is enabled
|
||||||
|
fs[#fs + 1] = "real_coordinates[true]"
|
||||||
|
fs[#fs + 1] = "container_end[]"
|
||||||
|
|
||||||
|
-- Darken background
|
||||||
|
if popup_fs then
|
||||||
|
-- This styling gets reset in add_side_menu
|
||||||
|
fs[#fs + 1] = fmt("style[cancel;bgimg=%sbg_darken.png;bgimg_middle=32]", tpath)
|
||||||
|
fs[#fs + 1] = fmt("image_button[1.25,0;%s,%s;;cancel;;false;false]",
|
||||||
|
w, h + 1.15)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add the side menu after the darkened background
|
||||||
|
add_side_menu(self, fs, current_tab.name, w + 1.175, h + 1.15, popup_fs)
|
||||||
|
|
||||||
|
-- Draw the popup
|
||||||
|
if popup_fs then
|
||||||
|
fs[#fs + 1] = fmt("container[%s,%s]", (w + 2.5 - popup_w) / 2,
|
||||||
|
(h + 1.15 - popup_h) / 2)
|
||||||
|
fs[#fs + 1] = fmt("style[popup_bg;bgimg=%sbg_common.png;bgimg_middle=32]",
|
||||||
|
defaulttexturedir)
|
||||||
|
fs[#fs + 1] = fmt("image_button[0,0;%s,%s;;popup_bg;;false;false]",
|
||||||
|
popup_w, popup_h)
|
||||||
|
fs[#fs + 1] = popup_fs
|
||||||
|
fs[#fs + 1] = "container_end[]"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Disable real_coordinates again in case there are other UI elements
|
||||||
|
-- (like the game switcher in buttonbar.lua)
|
||||||
|
fs[#fs + 1] = "real_coordinates[false]"
|
||||||
|
end
|
||||||
|
|
||||||
|
return tconcat(fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
local set_tab_by_name
|
local set_tab_by_name
|
||||||
@ -207,69 +281,6 @@ local function handle_events(self,event)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
--[[local function tab_header(self)
|
|
||||||
|
|
||||||
local captions = {}
|
|
||||||
for i = 1, #self.tablist do
|
|
||||||
captions[i] = self.tablist[i].caption
|
|
||||||
end
|
|
||||||
|
|
||||||
local toadd = table.concat(captions, ",")
|
|
||||||
return string.format("tabheader[%f,%f;%s;%s;%i;true;false]",
|
|
||||||
self.header_x, self.header_y, self.name, toadd,
|
|
||||||
math.max(self.last_tab_index, 1))
|
|
||||||
end]]
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
local function button_header(self)
|
|
||||||
local visible_tabs = {}
|
|
||||||
-- local btn_widths = {}
|
|
||||||
-- local total_width = 0
|
|
||||||
for i, tab in ipairs(self.tablist) do
|
|
||||||
if not tab.hidden and tab.caption ~= "" then
|
|
||||||
visible_tabs[#visible_tabs + 1] = tab
|
|
||||||
|
|
||||||
-- local w = math.max(utf8.len(core.get_translated_string(tab.caption)), 10)
|
|
||||||
-- btn_widths[#visible_tabs] = w
|
|
||||||
-- total_width = total_width + w
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local toadd = ""
|
|
||||||
-- local coords_per_char = 12 / total_width
|
|
||||||
|
|
||||||
-- The formspec is 15.4875 "real" coordinates wide
|
|
||||||
-- local x = (12.39 - total_width) / 2 - 0.3
|
|
||||||
local x = -0.1
|
|
||||||
local w = 12 / #visible_tabs
|
|
||||||
for i = 1, #visible_tabs do
|
|
||||||
local caption = visible_tabs[i].caption
|
|
||||||
-- local w = btn_widths[i] * coords_per_char
|
|
||||||
local side = "middle"
|
|
||||||
if i == 1 then
|
|
||||||
side = "left"
|
|
||||||
elseif i == #visible_tabs then
|
|
||||||
side = "right"
|
|
||||||
end
|
|
||||||
local btn_name = self.name .. "_" .. i
|
|
||||||
if i == math.abs(self.last_tab_index) then
|
|
||||||
side = side .. "_pressed"
|
|
||||||
end
|
|
||||||
|
|
||||||
toadd = toadd ..
|
|
||||||
btn_style(btn_name, side) ..
|
|
||||||
"style[" .. btn_name .. ";content_offset=0]" ..
|
|
||||||
"image_button[" .. x .. ",-1.1;" .. w + 0.22 .. ",0.9;;" ..
|
|
||||||
btn_name .. ";" .. caption .. ";true;false]"
|
|
||||||
x = x + w
|
|
||||||
end
|
|
||||||
|
|
||||||
return toadd
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function switch_to_tab(self, index)
|
local function switch_to_tab(self, index)
|
||||||
--first call on_change for tab to leave
|
--first call on_change for tab to leave
|
||||||
@ -387,8 +398,6 @@ local tabview_metatable = {
|
|||||||
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,
|
add_side_button = add_side_button,
|
||||||
-- tab_header = tab_header,
|
|
||||||
button_header = button_header,
|
|
||||||
handle_tab_buttons = handle_tab_buttons
|
handle_tab_buttons = handle_tab_buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +457,8 @@ local confirm_overwrite = {}
|
|||||||
function confirm_overwrite.get_formspec()
|
function confirm_overwrite.get_formspec()
|
||||||
local package = confirm_overwrite.package
|
local package = confirm_overwrite.package
|
||||||
|
|
||||||
return "size[11.5,4.5]" ..
|
return "size[11.5,4.5]bgcolor[#0000]" ..
|
||||||
|
"background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
|
||||||
"label[2,2;" ..
|
"label[2,2;" ..
|
||||||
fgettext("\"$1\" already exists. Would you like to overwrite it?", package.name) .. "]"..
|
fgettext("\"$1\" already exists. Would you like to overwrite it?", package.name) .. "]"..
|
||||||
btn_style("install", "red") ..
|
btn_style("install", "red") ..
|
||||||
|
@ -47,6 +47,7 @@ local function version_info_formspec(data)
|
|||||||
image[4.9,0;2.5,2.5;%slogo.png]
|
image[4.9,0;2.5,2.5;%slogo.png]
|
||||||
style[msg;content_offset=0]
|
style[msg;content_offset=0]
|
||||||
image_button[1,2;10,0.8;;msg;%s;false;false]
|
image_button[1,2;10,0.8;;msg;%s;false;false]
|
||||||
|
%s
|
||||||
hypertext[1.3,2.6;10,2;;<center>%s</center>]
|
hypertext[1.3,2.6;10,2;;<center>%s</center>]
|
||||||
%s
|
%s
|
||||||
button[2,4.5;4,0.8;version_check_remind;%s]
|
button[2,4.5;4,0.8;version_check_remind;%s]
|
||||||
@ -55,6 +56,7 @@ local function version_info_formspec(data)
|
|||||||
]]):format(
|
]]):format(
|
||||||
defaulttexturedir_esc,
|
defaulttexturedir_esc,
|
||||||
esc(data.title),
|
esc(data.title),
|
||||||
|
scrollbar_style("hypertext", true),
|
||||||
esc(changes),
|
esc(changes),
|
||||||
btn_style("version_check_remind", "yellow"),
|
btn_style("version_check_remind", "yellow"),
|
||||||
fgettext("Cancel"),
|
fgettext("Cancel"),
|
||||||
|
@ -73,7 +73,7 @@ local func = loadfile(basepath .. DIR_DELIM .. "hosting" .. DIR_DELIM .. "init.l
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function main_event_handler(tabview, event)
|
local function main_event_handler(tabview, event)
|
||||||
if event == "MenuQuit" then
|
if event == "MenuQuit" and PLATFORM ~= "iOS" then
|
||||||
core.close()
|
core.close()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -110,6 +110,33 @@ function menudata.init_tabs()
|
|||||||
-- Create main tabview
|
-- Create main tabview
|
||||||
local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0.1, y = 0})
|
local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0.1, y = 0})
|
||||||
|
|
||||||
|
tv_main:add_side_button({
|
||||||
|
tooltip = fgettext("Browse online content"),
|
||||||
|
tab_name_selected = "content",
|
||||||
|
is_open_cdb = true,
|
||||||
|
on_click = function(this)
|
||||||
|
if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then
|
||||||
|
this:set_tab("content")
|
||||||
|
else
|
||||||
|
local dialog = create_store_dlg()
|
||||||
|
dialog:set_parent(this)
|
||||||
|
this:hide()
|
||||||
|
dialog:show()
|
||||||
|
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"
|
||||||
|
})
|
||||||
|
|
||||||
for i = 1, #pkgmgr.games do
|
for i = 1, #pkgmgr.games do
|
||||||
if pkgmgr.games[i].id == "default" then
|
if pkgmgr.games[i].id == "default" then
|
||||||
tv_main:add(tabs.local_default_game)
|
tv_main:add(tabs.local_default_game)
|
||||||
@ -151,17 +178,6 @@ 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()
|
||||||
|
@ -99,10 +99,13 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
desc = info.description
|
desc = info.description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local pkg_name = selected_pkg.name
|
||||||
|
pkg_name = (pkg_name:sub(1, 1)):upper() .. pkg_name:sub(2)
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
|
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
|
||||||
"image[5.5,0;3,2;" .. defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc .. "cdb_img_corners.png;15]" ..
|
"image[5.5,0;3,2;" .. defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc .. "cdb_img_corners.png;15]" ..
|
||||||
"label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" ..
|
"label[8.25,0.6;" .. core.formspec_escape(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
|
||||||
@ -150,8 +153,8 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval .. "textarea[5.85,2.2;6.35,2.9;;" ..
|
retval = retval .. scrollbar_style("textarea", true) ..
|
||||||
fgettext("Information:") .. ";" .. desc .. "]"
|
"textarea[5.83,2.23;6.33,2.89;;" .. fgettext("Information:") .. ";" .. desc .. "]"
|
||||||
|
|
||||||
if core.may_modify_path(selected_pkg.path) then
|
if core.may_modify_path(selected_pkg.path) then
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
|
@ -159,7 +159,9 @@ local function get_formspec(_, _, tab_data)
|
|||||||
btn_style("switch_local_default") ..
|
btn_style("switch_local_default") ..
|
||||||
"style[switch_local_default;fgimg=" .. defaulttexturedir_esc .. "switch_local_default.png;fgimg_hovered=" ..
|
"style[switch_local_default;fgimg=" .. defaulttexturedir_esc .. "switch_local_default.png;fgimg_hovered=" ..
|
||||||
defaulttexturedir_esc .. "switch_local_default_hover.png;padding=" .. (is_high_dpi() and -42 or -30) .. "]" ..
|
defaulttexturedir_esc .. "switch_local_default_hover.png;padding=" .. (is_high_dpi() and -42 or -30) .. "]" ..
|
||||||
"image_button[10.6,-0.1;1.5,1.5;;switch_local_default;;true;false]"
|
"real_coordinates[true]" ..
|
||||||
|
"image_button[13.98,0.31;1.6,1.6;;switch_local_default;;true;false]" ..
|
||||||
|
"real_coordinates[false]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local enable_server = core.settings:get_bool("enable_server")
|
local enable_server = core.settings:get_bool("enable_server")
|
||||||
@ -310,7 +312,7 @@ local function main_button_handler(this, fields, name, tab_data)
|
|||||||
world.name ~= "" then
|
world.name ~= "" then
|
||||||
local index = menudata.worldlist:get_raw_index(selected)
|
local index = menudata.worldlist:get_raw_index(selected)
|
||||||
local game = pkgmgr.find_by_gameid(world.gameid)
|
local game = pkgmgr.find_by_gameid(world.gameid)
|
||||||
local delete_world_dlg = create_delete_world_dlg(world.name, index, game.name)
|
local delete_world_dlg = create_delete_world_dlg(world.name, index, game and game.name or world.gameid)
|
||||||
delete_world_dlg:set_parent(this)
|
delete_world_dlg:set_parent(this)
|
||||||
this:hide()
|
this:hide()
|
||||||
delete_world_dlg:show()
|
delete_world_dlg:show()
|
||||||
|
@ -17,14 +17,6 @@
|
|||||||
|
|
||||||
local small_screen = (PLATFORM == "Android" or PLATFORM == "iOS") and not core.settings:get_bool("device_is_tablet")
|
local small_screen = (PLATFORM == "Android" or PLATFORM == "iOS") and not core.settings:get_bool("device_is_tablet")
|
||||||
|
|
||||||
local default_worlds = {
|
|
||||||
{name = "World 1", mg_name = "v7p", seed = "15823438331521897617"},
|
|
||||||
{name = "World 2", mg_name = "v7p", seed = "1841722166046826822"},
|
|
||||||
{name = "World 3", mg_name = "v7p", seed = "CC"},
|
|
||||||
{name = "World 4", mg_name = "valleys", seed = "8572"},
|
|
||||||
{name = "World 5 Flat", mg_name = "flat", seed = "2"}
|
|
||||||
}
|
|
||||||
|
|
||||||
local function menu_render_worldlist()
|
local function menu_render_worldlist()
|
||||||
local retval = {}
|
local retval = {}
|
||||||
|
|
||||||
@ -48,46 +40,7 @@ local function menu_render_worldlist()
|
|||||||
return table.concat(retval, ",")
|
return table.concat(retval, ",")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function create_default_worlds()
|
|
||||||
if #menudata.worldlist:get_list() > 0 then return end
|
|
||||||
|
|
||||||
local _, gameindex = pkgmgr.find_by_gameid("default")
|
|
||||||
if not gameindex or gameindex == 0 then return end
|
|
||||||
|
|
||||||
-- Preserve the old map seed and mapgen values
|
|
||||||
local old_map_seed = core.settings:get("fixed_map_seed")
|
|
||||||
local old_mapgen = core.settings:get("mg_name")
|
|
||||||
|
|
||||||
-- Create the worlds
|
|
||||||
for _, world in ipairs(default_worlds) do
|
|
||||||
core.settings:set("fixed_map_seed", world.seed)
|
|
||||||
core.settings:set("mg_name", world.mg_name)
|
|
||||||
core.create_world(world.name, gameindex)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Restore the old values
|
|
||||||
if old_map_seed then
|
|
||||||
core.settings:set("fixed_map_seed", old_map_seed)
|
|
||||||
else
|
|
||||||
core.settings:remove("fixed_map_seed")
|
|
||||||
end
|
|
||||||
if old_mapgen then
|
|
||||||
core.settings:set("mg_name", old_mapgen)
|
|
||||||
else
|
|
||||||
core.settings:remove("mg_name")
|
|
||||||
end
|
|
||||||
|
|
||||||
menudata.worldlist:refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
local checked_worlds = false
|
|
||||||
local function get_formspec(this)
|
local function get_formspec(this)
|
||||||
-- Only check the worlds once (on restart)
|
|
||||||
if not checked_worlds then
|
|
||||||
create_default_worlds()
|
|
||||||
end
|
|
||||||
checked_worlds = true
|
|
||||||
|
|
||||||
local index = filterlist.get_current_index(menudata.worldlist,
|
local index = filterlist.get_current_index(menudata.worldlist,
|
||||||
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||||
if not index or index < 1 then
|
if not index or index < 1 then
|
||||||
@ -130,12 +83,7 @@ local function get_formspec(this)
|
|||||||
"tableoptions[background=#0000;border=false]" ..
|
"tableoptions[background=#0000;border=false]" ..
|
||||||
"tablecolumns[" .. image_column(fgettext("Creative mode")) .. ";text]" ..
|
"tablecolumns[" .. image_column(fgettext("Creative mode")) .. ";text]" ..
|
||||||
scrollbar_style("sp_worlds") ..
|
scrollbar_style("sp_worlds") ..
|
||||||
"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 .. "]"
|
||||||
|
|
||||||
btn_style("switch_local") ..
|
|
||||||
"style[switch_local;fgimg=" .. defaulttexturedir_esc .. "switch_local.png;fgimg_hovered=" ..
|
|
||||||
defaulttexturedir_esc .. "switch_local_hover.png;padding=" .. (is_high_dpi() and -42 or -30) .. "]" ..
|
|
||||||
"image_button[10.6,-0.1;1.5,1.5;;switch_local;;true;false]"
|
|
||||||
|
|
||||||
local enable_server = core.settings:get_bool("enable_server")
|
local enable_server = core.settings:get_bool("enable_server")
|
||||||
if enable_server then
|
if enable_server then
|
||||||
|
@ -94,6 +94,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
end
|
end
|
||||||
if selected.description then
|
if selected.description then
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
|
scrollbar_style("textarea", true) ..
|
||||||
"textarea[7.5,2.2;4.8,3;;" .. esc((gamedata.serverdescription or ""), true) .. ";]"
|
"textarea[7.5,2.2;4.8,3;;" .. esc((gamedata.serverdescription or ""), true) .. ";]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1862,7 +1862,7 @@ void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &elemen
|
|||||||
spec.sound = style.get(StyleSpec::Property::SOUND, "");
|
spec.sound = style.get(StyleSpec::Property::SOUND, "");
|
||||||
|
|
||||||
GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment,
|
GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment,
|
||||||
data->current_parent, spec.fid, rect, m_client, m_tsrc);
|
data->current_parent, spec.fid, rect, m_client, m_tsrc, style);
|
||||||
e->drop();
|
e->drop();
|
||||||
|
|
||||||
m_fields.push_back(spec);
|
m_fields.push_back(spec);
|
||||||
|
@ -997,7 +997,7 @@ void TextDrawer::draw(const core::rect<s32> &clip_rect,
|
|||||||
//! constructor
|
//! constructor
|
||||||
GUIHyperText::GUIHyperText(const wchar_t *text, IGUIEnvironment *environment,
|
GUIHyperText::GUIHyperText(const wchar_t *text, IGUIEnvironment *environment,
|
||||||
IGUIElement *parent, s32 id, const core::rect<s32> &rectangle,
|
IGUIElement *parent, s32 id, const core::rect<s32> &rectangle,
|
||||||
Client *client, ISimpleTextureSource *tsrc) :
|
Client *client, ISimpleTextureSource *tsrc, const StyleSpec &style) :
|
||||||
IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle),
|
IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle),
|
||||||
m_client(client), m_vscrollbar(nullptr),
|
m_client(client), m_vscrollbar(nullptr),
|
||||||
m_drawer(text, client, environment, tsrc), m_text_scrollpos(0, 0)
|
m_drawer(text, client, environment, tsrc), m_text_scrollpos(0, 0)
|
||||||
@ -1019,6 +1019,7 @@ GUIHyperText::GUIHyperText(const wchar_t *text, IGUIEnvironment *environment,
|
|||||||
|
|
||||||
m_vscrollbar = new GUIScrollBar(Environment, this, -1, rect, false, true);
|
m_vscrollbar = new GUIScrollBar(Environment, this, -1, rect, false, true);
|
||||||
m_vscrollbar->setVisible(false);
|
m_vscrollbar->setVisible(false);
|
||||||
|
m_vscrollbar->setStyle(style, tsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.h" // for USE_FREETYPE
|
#include "config.h" // for USE_FREETYPE
|
||||||
|
#include "StyleSpec.h"
|
||||||
|
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ public:
|
|||||||
GUIHyperText(const wchar_t *text, gui::IGUIEnvironment *environment,
|
GUIHyperText(const wchar_t *text, gui::IGUIEnvironment *environment,
|
||||||
gui::IGUIElement *parent, s32 id,
|
gui::IGUIElement *parent, s32 id,
|
||||||
const core::rect<s32> &rectangle, Client *client,
|
const core::rect<s32> &rectangle, Client *client,
|
||||||
ISimpleTextureSource *tsrc);
|
ISimpleTextureSource *tsrc, const StyleSpec &style);
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
virtual ~GUIHyperText();
|
virtual ~GUIHyperText();
|
||||||
|
BIN
textures/base/pack/gui/bg_darken.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
textures/base/pack/gui/content_menu.png
Normal file
After Width: | Height: | Size: 822 B |
BIN
textures/base/pack/gui/content_menu_hover.png
Normal file
After Width: | Height: | Size: 812 B |
BIN
textures/base/pack/gui/content_menu_selected.png
Normal file
After Width: | Height: | Size: 812 B |
BIN
textures/base/pack/gui/side_menu_darken.png
Normal file
After Width: | Height: | Size: 152 B |
Before Width: | Height: | Size: 816 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 810 B |