mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Use formspec version 6 in the main menu (#13761)
This commit is contained in:
parent
7b56daa236
commit
0cbf96cc83
@ -22,8 +22,9 @@ local function buttonbar_formspec(self)
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local formspec = string.format("box[%f,%f;%f,%f;%s]",
|
local formspec = "style_type[box;noclip=true]" ..
|
||||||
self.pos.x,self.pos.y ,self.size.x,self.size.y,self.bgcolor)
|
string.format("box[%f,%f;%f,%f;%s]", self.pos.x, self.pos.y, self.size.x, self.size.y, self.bgcolor) ..
|
||||||
|
"style_type[box;noclip=false]"
|
||||||
|
|
||||||
for i=self.startbutton,#self.buttons,1 do
|
for i=self.startbutton,#self.buttons,1 do
|
||||||
local btn_name = self.buttons[i].name
|
local btn_name = self.buttons[i].name
|
||||||
@ -31,18 +32,18 @@ local function buttonbar_formspec(self)
|
|||||||
|
|
||||||
if self.orientation == "horizontal" then
|
if self.orientation == "horizontal" then
|
||||||
btn_pos.x = self.pos.x + --base pos
|
btn_pos.x = self.pos.x + --base pos
|
||||||
(i - self.startbutton) * self.btn_size + --button offset
|
(i - self.startbutton) * self.btn_size * 1.25 + --button offset
|
||||||
self.btn_initial_offset
|
self.btn_initial_offset
|
||||||
else
|
else
|
||||||
btn_pos.x = self.pos.x + (self.btn_size * 0.05)
|
btn_pos.x = self.pos.x + self.size.x / 2 - self.btn_size / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.orientation == "vertical" then
|
if self.orientation == "vertical" then
|
||||||
btn_pos.y = self.pos.y + --base pos
|
btn_pos.y = self.pos.y + --base pos
|
||||||
(i - self.startbutton) * self.btn_size + --button offset
|
(i - self.startbutton) * self.btn_size * 1.25 + --button offset
|
||||||
self.btn_initial_offset
|
self.btn_initial_offset
|
||||||
else
|
else
|
||||||
btn_pos.y = self.pos.y + (self.btn_size * 0.05)
|
btn_pos.y = self.pos.y + self.size.y / 2 - self.btn_size / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.orientation == "vertical" and
|
if (self.orientation == "vertical" and
|
||||||
@ -195,16 +196,17 @@ function buttonbar_create(name, cbf_buttonhandler, pos, orientation, size)
|
|||||||
self.have_move_buttons = false
|
self.have_move_buttons = false
|
||||||
self.hidden = false
|
self.hidden = false
|
||||||
|
|
||||||
if self.orientation == "horizontal" then
|
if self.btn_initial_offset == nil then
|
||||||
self.btn_size = self.size.y
|
self.btn_initial_offset = 0.375
|
||||||
else
|
|
||||||
self.btn_size = self.size.x
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.btn_initial_offset == nil) then
|
if self.orientation == "horizontal" then
|
||||||
self.btn_initial_offset = self.btn_size * 0.05
|
self.btn_size = self.size.y - 2*0.1
|
||||||
|
else
|
||||||
|
self.btn_size = self.size.x - 2*0.1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self.userbuttonhandler = cbf_buttonhandler
|
self.userbuttonhandler = cbf_buttonhandler
|
||||||
self.buttons = {}
|
self.buttons = {}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ local function add_tab(self,tab)
|
|||||||
event_handler = tab.cbf_events,
|
event_handler = tab.cbf_events,
|
||||||
get_formspec = tab.cbf_formspec,
|
get_formspec = tab.cbf_formspec,
|
||||||
tabsize = tab.tabsize,
|
tabsize = tab.tabsize,
|
||||||
formspec_version = tab.formspec_version,
|
formspec_version = tab.formspec_version or 6,
|
||||||
on_change = tab.on_change,
|
on_change = tab.on_change,
|
||||||
tabdata = {},
|
tabdata = {},
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,7 @@ local function init_globals()
|
|||||||
mm_game_theme.init()
|
mm_game_theme.init()
|
||||||
|
|
||||||
-- Create main tabview
|
-- Create main tabview
|
||||||
local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
|
local tv_main = tabview_create("maintab", {x = 15.5, y = 7.1}, {x = 0, y = 0})
|
||||||
-- note: size would be 15.5,7.1 in real coordinates mode
|
|
||||||
|
|
||||||
tv_main:set_autosave_tab(true)
|
tv_main:set_autosave_tab(true)
|
||||||
tv_main:add(tabs.local_game)
|
tv_main:add(tabs.local_game)
|
||||||
|
@ -194,7 +194,7 @@ return {
|
|||||||
fs = fs .. "button[0.5,5.1;4.5,0.8;userdata;" .. fgettext("Open User Data Directory") .. "]"
|
fs = fs .. "button[0.5,5.1;4.5,0.8;userdata;" .. fgettext("Open User Data Directory") .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
return fs, "size[15.5,7.1,false]real_coordinates[true]"
|
return fs
|
||||||
end,
|
end,
|
||||||
cbf_button_handler = function(this, fields, name, tabdata)
|
cbf_button_handler = function(this, fields, name, tabdata)
|
||||||
if fields.homepage then
|
if fields.homepage then
|
||||||
|
@ -148,8 +148,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return table.concat(retval),
|
return table.concat(retval)
|
||||||
"size[15.5,7.1,false]real_coordinates[true]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_doubleclick(pkg)
|
local function handle_doubleclick(pkg)
|
||||||
|
@ -83,7 +83,7 @@ function singleplayer_refresh_gamebar()
|
|||||||
|
|
||||||
local btnbar = buttonbar_create("game_button_bar",
|
local btnbar = buttonbar_create("game_button_bar",
|
||||||
game_buttonbar_button_handler,
|
game_buttonbar_button_handler,
|
||||||
{x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15})
|
{x=0,y=7.475}, "horizontal", {x=15.5,y=1.25})
|
||||||
|
|
||||||
for _, game in ipairs(pkgmgr.games) do
|
for _, game in ipairs(pkgmgr.games) do
|
||||||
local btn_name = "game_btnbar_" .. game.id
|
local btn_name = "game_btnbar_" .. game.id
|
||||||
@ -155,8 +155,8 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
local creative, damage, host = "", "", ""
|
local creative, damage, host = "", "", ""
|
||||||
|
|
||||||
-- Y offsets for game settings checkboxes
|
-- Y offsets for game settings checkboxes
|
||||||
local y = -0.2
|
local y = 0.2
|
||||||
local yo = 0.45
|
local yo = 0.5625
|
||||||
|
|
||||||
if disabled_settings["creative_mode"] == nil then
|
if disabled_settings["creative_mode"] == nil then
|
||||||
creative = "checkbox[0,"..y..";cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
creative = "checkbox[0,"..y..";cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
||||||
@ -175,41 +175,58 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
end
|
end
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[3.9,3.8;2.8,1;world_delete;".. fgettext("Delete") .. "]" ..
|
"container[5.25,4.75]" ..
|
||||||
"button[6.55,3.8;2.8,1;world_configure;".. fgettext("Select Mods") .. "]" ..
|
"button[0,0;3.125,0.85;world_delete;".. fgettext("Delete") .. "]" ..
|
||||||
"button[9.2,3.8;2.8,1;world_create;".. fgettext("New") .. "]" ..
|
"button[3.375,0;3.125,0.85;world_configure;".. fgettext("Select Mods") .. "]" ..
|
||||||
"label[3.9,-0.05;".. fgettext("Select World:") .. "]"..
|
"button[6.75,0;3.125,0.85;world_create;".. fgettext("New") .. "]" ..
|
||||||
|
"container_end[]" ..
|
||||||
|
"container[0.375,0.375]" ..
|
||||||
creative ..
|
creative ..
|
||||||
damage ..
|
damage ..
|
||||||
host ..
|
host ..
|
||||||
"textlist[3.9,0.4;7.9,3.45;sp_worlds;" ..
|
"container_end[]" ..
|
||||||
|
"container[5.25,0.375]" ..
|
||||||
|
"label[0,0.2;".. fgettext("Select World:") .. "]"..
|
||||||
|
"textlist[0,0.5;9.875,3.6;sp_worlds;" ..
|
||||||
menu_render_worldlist() ..
|
menu_render_worldlist() ..
|
||||||
";" .. index .. "]"
|
";" .. index .. "]" ..
|
||||||
|
"container_end[]"
|
||||||
|
|
||||||
if core.settings:get_bool("enable_server") and disabled_settings["enable_server"] == nil then
|
if core.settings:get_bool("enable_server") and disabled_settings["enable_server"] == nil then
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[7.9,4.75;4.1,1;play;".. fgettext("Host Game") .. "]" ..
|
"button[11.025,5.85;4.1,0.85;play;".. fgettext("Host Game") .. "]" ..
|
||||||
|
"container[0.375,0.375]" ..
|
||||||
"checkbox[0,"..y..";cb_server_announce;" .. fgettext("Announce Server") .. ";" ..
|
"checkbox[0,"..y..";cb_server_announce;" .. fgettext("Announce Server") .. ";" ..
|
||||||
dump(core.settings:get_bool("server_announce")) .. "]" ..
|
dump(core.settings:get_bool("server_announce")) .. "]"
|
||||||
"field[0.3,2.85;3.8,0.5;te_playername;" .. fgettext("Name") .. ";" ..
|
|
||||||
core.formspec_escape(current_name) .. "]" ..
|
y = y + yo + 0.35
|
||||||
"pwdfield[0.3,4.05;3.8,0.5;te_passwd;" .. fgettext("Password") .. "]"
|
|
||||||
|
retval = retval .. "field[0," .. y .. ";4.5,0.75;te_playername;" .. fgettext("Name") .. ";" ..
|
||||||
|
core.formspec_escape(current_name) .. "]"
|
||||||
|
|
||||||
|
y = y + 1.15 + 0.25
|
||||||
|
|
||||||
|
retval = retval .. "pwdfield[0," .. y .. ";4.5,0.75;te_passwd;" .. fgettext("Password") .. "]"
|
||||||
|
|
||||||
|
y = y + 1.15 + 0.25
|
||||||
|
|
||||||
local bind_addr = core.settings:get("bind_address")
|
local bind_addr = core.settings:get("bind_address")
|
||||||
if bind_addr ~= nil and bind_addr ~= "" then
|
if bind_addr ~= nil and bind_addr ~= "" then
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"field[0.3,5.25;2.5,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
|
"field[0," .. y .. ";3,0.75;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
|
||||||
core.formspec_escape(core.settings:get("bind_address")) .. "]" ..
|
core.formspec_escape(core.settings:get("bind_address")) .. "]" ..
|
||||||
"field[2.85,5.25;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
|
"field[3.25," .. y .. ";1.25,0.75;te_serverport;" .. fgettext("Port") .. ";" ..
|
||||||
core.formspec_escape(current_port) .. "]"
|
core.formspec_escape(current_port) .. "]"
|
||||||
else
|
else
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"field[0.3,5.25;3.8,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
|
"field[0," .. y .. ";4.5,0.75;te_serverport;" .. fgettext("Server Port") .. ";" ..
|
||||||
core.formspec_escape(current_port) .. "]"
|
core.formspec_escape(current_port) .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
retval = retval .. "container_end[]"
|
||||||
else
|
else
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[7.9,4.75;4.1,1;play;" .. fgettext("Play Game") .. "]"
|
"button[11.025,5.85;4.1,0.85;play;" .. fgettext("Play Game") .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
@ -180,7 +180,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
retval = retval .. ";0]"
|
retval = retval .. ";0]"
|
||||||
end
|
end
|
||||||
|
|
||||||
return retval, "size[15.5,7.1,false]real_coordinates[true]"
|
return retval
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user