Finished gui

This commit is contained in:
Billy S 2019-04-21 17:53:46 -04:00
parent 047d04f4ce
commit ffbde14977
2 changed files with 31 additions and 4 deletions

View File

@ -295,7 +295,10 @@ ChatCmdBuilder.new("kingdoms", function(cmd)
end)
-- Bring up kingdoms gui
cmd:sub("", function(name)
local fs = kingdoms.get_gui(name)
minetest.show_formspec(name, "kingdoms:gui", fs)
if kingdoms.members[name] == nil then
return false, "You are not in a kingdom"
end
local fs = kingdoms.get_gui(name, "news")
minetest.show_formspec(name, "kingdoms:gui_news", fs)
end)
end)

View File

@ -1,8 +1,9 @@
function kingdoms.get_gui(pname, tab)
local fs = "size[8,9;]button[0,0;2,1;news;News]"
local fs = "size[8,9;]button[0,0;2,1;news;News]button[2,0;2,1;apls;Applications]"
local kingdom = kingdoms.members[pname].kingdom
-- Get news tabs
if tab == nil or tab == "news" then
fs = fs .. "textlist[0,1;7.8,8;news;"
fs = fs .. "textlist[0,1;7.8,8;newslist;Server News:,"
-- Get news and break it into lines
local ntable = kingdoms.get_news(20)
local nidx = 1
@ -21,5 +22,28 @@ function kingdoms.get_gui(pname, tab)
end
fs = fs:sub(1, -2) .. "]"
return fs
elseif tab == "apls" then
fs = fs .. "textlist[0,1;7.8,8;aplslist;Kingdom Applications:,"
for n,k in pairs(kingdoms.pending) do
if k == kingdom then
fs = fs .. n .. ","
end
end
fs = fs:sub(1, -2) .. "]"
return fs
end
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Check if this is one of the correct forms
if formname:find("^kingdoms:gui") == nil then return end
local pname = player:get_player_name()
-- Check if we are moving to a different tab
if fields["news"] then
minetest.show_formspec(pname, "kingdoms:gui_news", kingdoms.get_gui(pname, "news"))
return
elseif fields["apls"] then
minetest.show_formspec(pname, "kingdoms:gui_apls", kingdoms.get_gui(pname, "apls"))
return
end
end)