Cleanup a lot of interface stuff and standardize formspec page names
This commit is contained in:
parent
c797a15e8b
commit
509827186f
@ -173,10 +173,10 @@ minetest.register_on_placenode(on_place)
|
||||
|
||||
-- Formspecs
|
||||
|
||||
local form = default.ui.get_page("core")
|
||||
local form = default.ui.get_page("default:default")
|
||||
form = form .. "tableoptions[background=#DDDDDD30]"
|
||||
form = form .. "tablecolumns[text,align=left,width=11;text,align=left,width=28;text,align=left,width=5]"
|
||||
default.ui.register_page("core_achievements", form)
|
||||
default.ui.register_page("achievements:achievements", form)
|
||||
|
||||
function achievements.get_formspec(name, row)
|
||||
if not row then row = 1 end
|
||||
@ -211,7 +211,7 @@ function achievements.get_formspec(name, row)
|
||||
achievement_list = achievement_list .. progress
|
||||
end
|
||||
|
||||
local form = default.ui.get_page("core_achievements")
|
||||
local form = default.ui.get_page("achievements:achievements")
|
||||
|
||||
form = form .. "table[0.25,2.5;7.75,5.5;achievement_list;" .. achievement_list .. ";" .. row .. "]"
|
||||
|
||||
@ -242,7 +242,7 @@ end
|
||||
local function receive_fields(player, form_name, fields)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if form_name ~= "core_achievements" then return end
|
||||
if form_name ~= "achievements:achievements" then return end
|
||||
|
||||
if fields.quit then return end
|
||||
|
||||
@ -256,7 +256,7 @@ local function receive_fields(player, form_name, fields)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name, selected))
|
||||
minetest.show_formspec(name, "achievements:achievements", achievements.get_formspec(name, selected))
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(receive_fields)
|
||||
|
@ -6,7 +6,7 @@
|
||||
armor = {}
|
||||
|
||||
armor.player_skin = "character.png"
|
||||
armor.update_time = 1
|
||||
armor.update_time = 3
|
||||
|
||||
armor.materials = {
|
||||
-- material craftitem % description
|
||||
@ -18,8 +18,8 @@ armor.materials = {
|
||||
|
||||
armor.slots = {"helmet", "chestplate", "boots"}
|
||||
|
||||
local form_armor = default.ui.get_page("core_2part")
|
||||
default.ui.register_page("core_armor", form_armor)
|
||||
local form_armor = default.ui.get_page("default:2part")
|
||||
default.ui.register_page("armor:armor", form_armor)
|
||||
|
||||
local enable_drop = minetest.setting_getbool("drop_items_on_die") or false
|
||||
|
||||
@ -264,12 +264,14 @@ end
|
||||
|
||||
minetest.register_on_newplayer(on_newplayer)
|
||||
minetest.register_on_joinplayer(on_joinplayer)
|
||||
|
||||
if enable_drop then
|
||||
minetest.register_on_dieplayer(on_die)
|
||||
end
|
||||
|
||||
minetest.register_globalstep(step)
|
||||
|
||||
local form_armor = default.ui.get_page("core_2part")
|
||||
local form_armor = default.ui.get_page("default:2part")
|
||||
form_armor = form_armor .. "list[current_player;main;0.25,4.75;8,4;]"
|
||||
form_armor = form_armor .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
|
||||
form_armor = form_armor .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
|
||||
@ -290,7 +292,7 @@ form_armor = form_armor .. "list[current_player;armor_helmet;2.25,0.75;1,1;]"
|
||||
form_armor = form_armor .. "listring[current_player;armor_helmet]"
|
||||
form_armor = form_armor .. default.ui.get_itemslot_bg(2.25, 0.75, 1, 1)
|
||||
|
||||
default.ui.register_page("core_armor", form_armor)
|
||||
default.ui.register_page("armor:armor", form_armor)
|
||||
|
||||
-- Achievements
|
||||
|
||||
|
@ -22,7 +22,7 @@ minetest.register_craftitem(
|
||||
title = data.title
|
||||
end
|
||||
|
||||
local form = default.ui.get_page("core_notabs")
|
||||
local form = default.ui.get_page("default:notabs")
|
||||
form = form .. "field[0.5,1.25;8,0;title;Title:;"..minetest.formspec_escape(title).."]"
|
||||
form = form .. "textarea[0.5,1.75;8,6.75;text;Contents:;"..minetest.formspec_escape(text).."]"
|
||||
form = form .. default.ui.button_exit(2.75, 7.75, 3, 1, "write", "Write")
|
||||
|
@ -15,6 +15,7 @@ crafting.default_craftdef = {
|
||||
output = nil,
|
||||
description = "",
|
||||
items = {},
|
||||
groups = {},
|
||||
}
|
||||
|
||||
function crafting.register_craft(output, def)
|
||||
@ -33,7 +34,8 @@ function crafting.register_craft(output, def)
|
||||
local craftdef = {
|
||||
output = itemstack,
|
||||
description = def.description or minetest.registered_items[itemn].description,
|
||||
items = def.items or default.default_craftdef.items,
|
||||
items = def.items or crafting.default_craftdef.items,
|
||||
groups = def.groups or crafting.default_craftdef.groups,
|
||||
}
|
||||
|
||||
if #craftdef.items > 4 then
|
||||
@ -143,6 +145,28 @@ function crafting.craft(output, items)
|
||||
return items
|
||||
end
|
||||
|
||||
local form = default.ui.get_page("default:2part")
|
||||
form = form .. "list[current_player;main;0.25,4.75;8,4;]"
|
||||
form = form .. "listring[current_player;main]"
|
||||
form = form .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
|
||||
form = form .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
|
||||
|
||||
form = form .. "list[current_player;craft;2.25,0.75;3,3;]"
|
||||
form = form .. "listring[current_player;craft]"
|
||||
|
||||
form = form .. "image[5.25,1.75;1,1;ui_arrow_bg.png^[transformR270]"
|
||||
|
||||
form = form .. "list[current_player;craftpreview;6.25,1.75;1,1;]"
|
||||
form = form .. default.ui.get_itemslot_bg(2.25, 0.75, 3, 3)
|
||||
form = form .. default.ui.get_itemslot_bg(6.25, 1.75, 1, 1)
|
||||
default.ui.register_page("crafting:crafting", form)
|
||||
|
||||
function crafting.get_formspec(name)
|
||||
local form = default.ui.get_page("crafting:crafting")
|
||||
|
||||
return form
|
||||
end
|
||||
|
||||
crafting.register_craft(
|
||||
"default:stone 4",
|
||||
{
|
||||
@ -156,14 +180,14 @@ crafting.register_craft(
|
||||
crafting.craft(
|
||||
"default:stone 2",
|
||||
{
|
||||
{name = "default:stick", count = 4}, -- 0 leftover
|
||||
"default:stick 4", -- 0 leftover
|
||||
{name = "default:stick", count = 5}, -- 3 leftover
|
||||
{name = "default:fiber", count = 9}, -- 5 leftover
|
||||
"default:fiber 9", -- 5 leftover
|
||||
{name = "group:stone", count = 4}, -- 0 leftover
|
||||
})
|
||||
|
||||
local function on_player_recieve_fields(player, form_name, fields)
|
||||
if form_name ~= "crafting:crafting" or fields.cancel then return end
|
||||
if form_name ~= "core:crafting" or fields.cancel then return end
|
||||
|
||||
local inv = player:get_inventory()
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
default.ui = {}
|
||||
|
||||
default.ui.core = {}
|
||||
default.ui.default = {}
|
||||
|
||||
default.ui.core.colors = "listcolors[#00000000;#00000010;#00000000;#68B259;#FFF]"
|
||||
default.ui.core.bg = "bgcolor[#00000000;false]"
|
||||
default.ui.default.colors = "listcolors[#00000000;#00000010;#00000000;#68B259;#FFF]"
|
||||
default.ui.default.bg = "bgcolor[#00000000;false]"
|
||||
|
||||
function default.ui.get_itemslot_bg(x, y, w, h)
|
||||
local out = ""
|
||||
@ -166,58 +166,42 @@ function default.ui.register_page(name, form)
|
||||
default.ui.registered_pages[name] = form
|
||||
end
|
||||
|
||||
local form_core = ""
|
||||
form_core = form_core .. "size[8.5,9]"
|
||||
form_core = form_core .. default.ui.core.colors
|
||||
form_core = form_core .. default.ui.core.bg
|
||||
form_core = form_core .. default.ui.tab(-0.9, 0.5, "tab_crafting", "ui_icon_crafting.png", "Crafting")
|
||||
local form_default_default = ""
|
||||
form_default_default = form_default_default .. "size[8.5,9]"
|
||||
form_default_default = form_default_default .. default.ui.default.colors
|
||||
form_default_default = form_default_default .. default.ui.default.bg
|
||||
form_default_default = form_default_default .. default.ui.tab(-0.9, 0.5, "tab_crafting", "ui_icon_crafting.png", "Crafting")
|
||||
if minetest.get_modpath("armor") ~= nil then
|
||||
form_core = form_core .. default.ui.tab(-0.9, 1.28, "tab_armor", "ui_icon_armor.png", "Armor")
|
||||
form_default_default = form_default_default .. default.ui.tab(-0.9, 1.28, "tab_armor", "ui_icon_armor.png", "Armor")
|
||||
end
|
||||
if minetest.get_modpath("achievements") ~= nil then
|
||||
form_core = form_core .. default.ui.tab(-0.9, 2.06, "tab_achievements", "ui_icon_achievements.png", "Achievements")
|
||||
form_default_default = form_default_default .. default.ui.tab(-0.9, 2.06, "tab_achievements", "ui_icon_achievements.png", "Achievements")
|
||||
end
|
||||
if minetest.get_modpath("player_skins") ~= nil then
|
||||
form_core = form_core .. default.ui.tab(-0.9, 2.84, "tab_player_skins", "ui_icon_player_skins.png", "Player Skins")
|
||||
form_default_default = form_default_default .. default.ui.tab(-0.9, 2.84, "tab_player_skins", "ui_icon_player_skins.png", "Player Skins")
|
||||
end
|
||||
form_core = form_core .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
|
||||
default.ui.register_page("core", form_core)
|
||||
default.ui.register_page("core_2part", form_core .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]")
|
||||
form_default_default = form_default_default .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
|
||||
default.ui.register_page("default:default", form_default_default)
|
||||
default.ui.register_page("default:2part", form_default_default .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]")
|
||||
|
||||
local form_core_notabs = ""
|
||||
form_core_notabs = form_core_notabs .. "size[8.5,9]"
|
||||
form_core_notabs = form_core_notabs .. default.ui.core.colors
|
||||
form_core_notabs = form_core_notabs .. default.ui.core.bg
|
||||
form_core_notabs = form_core_notabs .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
|
||||
default.ui.register_page("core_notabs", form_core_notabs)
|
||||
default.ui.register_page("core_notabs_2part", form_core_notabs .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]")
|
||||
local form_default_notabs = ""
|
||||
form_default_notabs = form_default_notabs .. "size[8.5,9]"
|
||||
form_default_notabs = form_default_notabs .. default.ui.default.colors
|
||||
form_default_notabs = form_default_notabs .. default.ui.default.bg
|
||||
form_default_notabs = form_default_notabs .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
|
||||
default.ui.register_page("default:notabs", form_default_notabs)
|
||||
default.ui.register_page("default:notabs_2part", form_default_notabs .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]")
|
||||
|
||||
local form_core_field = ""
|
||||
form_core_field = form_core_field .. "size[8.5,5]"
|
||||
form_core_field = form_core_field .. default.ui.core.colors
|
||||
form_core_field = form_core_field .. default.ui.core.bg
|
||||
form_core_field = form_core_field .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]"
|
||||
form_core_field = form_core_field .. default.ui.button_exit(2.75, 3, 3, 1, "", "Write", false)
|
||||
form_core_field = form_core_field .. "field[1,1.75;7,0;text;;${text}]"
|
||||
default.ui.register_page("core_field", form_core_field)
|
||||
local form_default_field = ""
|
||||
form_default_field = form_default_field .. "size[8.5,5]"
|
||||
form_default_field = form_default_field .. default.ui.default.colors
|
||||
form_default_field = form_default_field .. default.ui.default.bg
|
||||
form_default_field = form_default_field .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]"
|
||||
form_default_field = form_default_field .. default.ui.button_exit(2.75, 3, 3, 1, "", "Write", false)
|
||||
form_default_field = form_default_field .. "field[1,1.75;7,0;text;;${text}]"
|
||||
default.ui.register_page("default:field", form_default_field)
|
||||
|
||||
local form_crafting = default.ui.get_page("core_2part")
|
||||
form_crafting = form_crafting .. "list[current_player;main;0.25,4.75;8,4;]"
|
||||
form_crafting = form_crafting .. "listring[current_player;main]"
|
||||
form_crafting = form_crafting .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
|
||||
form_crafting = form_crafting .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
|
||||
|
||||
form_crafting = form_crafting .. "list[current_player;craft;2.25,0.75;3,3;]"
|
||||
form_crafting = form_crafting .. "listring[current_player;craft]"
|
||||
|
||||
form_crafting = form_crafting .. "image[5.25,1.75;1,1;ui_arrow_bg.png^[transformR270]"
|
||||
|
||||
form_crafting = form_crafting .. "list[current_player;craftpreview;6.25,1.75;1,1;]"
|
||||
form_crafting = form_crafting .. default.ui.get_itemslot_bg(2.25, 0.75, 3, 3)
|
||||
form_crafting = form_crafting .. default.ui.get_itemslot_bg(6.25, 1.75, 1, 1)
|
||||
default.ui.register_page("core_crafting", form_crafting)
|
||||
|
||||
local form_bookshelf = default.ui.get_page("core_2part")
|
||||
local form_bookshelf = default.ui.get_page("default:2part")
|
||||
form_bookshelf = form_bookshelf .. "list[current_player;main;0.25,4.75;8,4;]"
|
||||
form_bookshelf = form_bookshelf .. "listring[current_player;main]"
|
||||
form_bookshelf = form_bookshelf .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
|
||||
@ -226,7 +210,7 @@ form_bookshelf = form_bookshelf .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
|
||||
form_bookshelf = form_bookshelf .. "list[current_name;main;2.25,1.25;4,2;]"
|
||||
form_bookshelf = form_bookshelf .. "listring[current_name;main]"
|
||||
form_bookshelf = form_bookshelf .. default.ui.get_itemslot_bg(2.25, 1.25, 4, 2)
|
||||
default.ui.register_page("core_bookshelf", form_bookshelf)
|
||||
default.ui.register_page("default:bookshelf", form_bookshelf)
|
||||
|
||||
function default.ui.receive_fields(player, form_name, fields)
|
||||
local name = player:get_player_name()
|
||||
@ -234,13 +218,13 @@ function default.ui.receive_fields(player, form_name, fields)
|
||||
-- print("Received formspec fields from '"..name.."': "..dump(fields))
|
||||
|
||||
if fields.tab_crafting then
|
||||
minetest.show_formspec(name, "core_crafting", default.ui.get_page("core_crafting"))
|
||||
minetest.show_formspec(name, "crafting:crafting", crafting.get_formspec(name))
|
||||
elseif minetest.get_modpath("armor") ~= nil and fields.tab_armor then
|
||||
minetest.show_formspec(name, "core_armor", default.ui.get_page("core_armor"))
|
||||
minetest.show_formspec(name, "armor:armor", default.ui.get_page("armor:armor"))
|
||||
elseif minetest.get_modpath("achievements") ~= nil and fields.tab_achievements then
|
||||
minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name))
|
||||
minetest.show_formspec(name, "achievements:achievements", achievements.get_formspec(name))
|
||||
elseif minetest.get_modpath("player_skins") ~= nil and fields.tab_player_skins then
|
||||
minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name))
|
||||
minetest.show_formspec(name, "player_skins:player_skins", player_skins.get_formspec(name))
|
||||
end
|
||||
end
|
||||
|
||||
@ -251,5 +235,5 @@ end)
|
||||
|
||||
minetest.register_on_joinplayer(
|
||||
function(player)
|
||||
player:set_inventory_formspec(default.ui.get_page("core_crafting"))
|
||||
player:set_inventory_formspec(default.ui.get_page("crafting:crafting"))
|
||||
end)
|
||||
|
@ -131,7 +131,7 @@ end
|
||||
|
||||
local form_trading = ""
|
||||
|
||||
form_trading = form_trading .. default.ui.get_page("core_2part")
|
||||
form_trading = form_trading .. default.ui.get_page("default:2part")
|
||||
|
||||
form_trading = form_trading .. "list[current_player;gold_trade_out;3.75,2.25;1,1;]"
|
||||
form_trading = form_trading .. "listring[current_player;gold_trade_out]"
|
||||
|
@ -187,7 +187,7 @@ minetest.register_craft(
|
||||
}
|
||||
})
|
||||
|
||||
local form_bench = default.ui.get_page("core_2part")
|
||||
local form_bench = default.ui.get_page("default:2part")
|
||||
form_bench = form_bench .. "list[current_name;main;2.25,1.75;1,1;]"
|
||||
form_bench = form_bench .. "listring[current_name;main]"
|
||||
form_bench = form_bench .. default.ui.get_itemslot_bg(2.25, 1.75, 1, 1)
|
||||
|
@ -134,7 +134,7 @@ minetest.register_node(
|
||||
end
|
||||
|
||||
local np = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local form = default.ui.get_page("core_2part")
|
||||
local form = default.ui.get_page("default:2part")
|
||||
form = form .. "list[nodemeta:" .. np .. ";main;0.25,0.25;8,4;]"
|
||||
form = form .. "listring[nodemeta:" .. np .. ";main]"
|
||||
form = form .. default.ui.get_itemslot_bg(0.25, 0.25, 8, 4)
|
||||
|
@ -16,7 +16,7 @@ player_skins.skins = {}
|
||||
|
||||
local update_time = 1
|
||||
local timer = 10
|
||||
local skins_file = minetest.get_worldpath() .. "/player_skins"
|
||||
local skins_file = minetest.get_worldpath() .. "/player_skins.dat"
|
||||
|
||||
local function save_skins()
|
||||
local f = io.open(skins_file, "w")
|
||||
@ -115,7 +115,7 @@ local function get_chatparams()
|
||||
end
|
||||
|
||||
function player_skins.get_formspec(playername)
|
||||
local form = default.ui.get_page("core")
|
||||
local form = default.ui.get_page("default:default")
|
||||
|
||||
form = form .. "image[4,0;0.5,10.05;ui_vertical_divider.png]"
|
||||
|
||||
@ -148,7 +148,7 @@ minetest.register_on_player_receive_fields(
|
||||
if skinname ~= nil then
|
||||
player_skins.set_skin(name, skinname)
|
||||
|
||||
minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name))
|
||||
minetest.show_formspec(name, "player_skins:player_skins", player_skins.get_formspec(name))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -20,7 +20,7 @@ function welcome.get_formspec(name)
|
||||
return ""
|
||||
end
|
||||
|
||||
local form = default.ui.get_page("core_notabs")
|
||||
local form = default.ui.get_page("default:notabs")
|
||||
|
||||
local rules = ""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user