Rename GUI methods to be consistent
This commit is contained in:
parent
19bc320859
commit
6900ddeea7
@ -1,6 +1,6 @@
|
|||||||
minetest.register_chatcommand("mail",{
|
minetest.register_chatcommand("mail",{
|
||||||
description = "Open the mail interface",
|
description = "Open the mail interface",
|
||||||
func = function(name)
|
func = function(name)
|
||||||
mail.showinbox(name)
|
mail.show_inbox(name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
46
gui.lua
46
gui.lua
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
mail.inboxformspec = [[
|
mail.inbox_formspec = [[
|
||||||
size[8,9;]
|
size[8,9;]
|
||||||
button_exit[7.5,0;0.5,0.5;quit;X]
|
button_exit[7.5,0;0.5,0.5;quit;X]
|
||||||
button[6.25,1;1.5,0.5;new;New Message]
|
button[6.25,1;1.5,0.5;new;New Message]
|
||||||
@ -13,7 +13,7 @@ mail.inboxformspec = [[
|
|||||||
textlist[0,0.5;6,8.5;message;
|
textlist[0,0.5;6,8.5;message;
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function mail.showabout(name)
|
function mail.show_about(name)
|
||||||
local formspec = [[
|
local formspec = [[
|
||||||
size[4,5;]
|
size[4,5;]
|
||||||
button[3.5,0;0.5,0.5;back;X]
|
button[3.5,0;0.5,0.5;back;X]
|
||||||
@ -30,8 +30,8 @@ function mail.showabout(name)
|
|||||||
minetest.show_formspec(name, "mail:about", formspec)
|
minetest.show_formspec(name, "mail:about", formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mail.showinbox(name)
|
function mail.show_inbox(name)
|
||||||
local formspec = mail.inboxformspec
|
local formspec = mail.inbox_formspec
|
||||||
mail.messages[name] = mail.messages[name] or {}
|
mail.messages[name] = mail.messages[name] or {}
|
||||||
|
|
||||||
if mail.messages[name][1] then
|
if mail.messages[name][1] then
|
||||||
@ -62,7 +62,7 @@ function mail.showinbox(name)
|
|||||||
minetest.show_formspec(name, "mail:inbox", formspec)
|
minetest.show_formspec(name, "mail:inbox", formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mail.showmessage(name, msgnumber)
|
function mail.show_message(name, msgnumber)
|
||||||
local message = mail.messages[name][msgnumber]
|
local message = mail.messages[name][msgnumber]
|
||||||
local formspec = [[
|
local formspec = [[
|
||||||
size[8,6]
|
size[8,6]
|
||||||
@ -82,7 +82,7 @@ function mail.showmessage(name, msgnumber)
|
|||||||
minetest.show_formspec(name,"mail:message",formspec)
|
minetest.show_formspec(name,"mail:message",formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mail.showcompose(name, defaulttgt, defaultsubj, defaultbody)
|
function mail.show_compose(name, defaulttgt, defaultsubj, defaultbody)
|
||||||
local formspec = [[
|
local formspec = [[
|
||||||
size[8,8]
|
size[8,8]
|
||||||
field[0.25,0.5;4,1;to;To:;%s]
|
field[0.25,0.5;4,1;to;To:;%s]
|
||||||
@ -108,7 +108,7 @@ function mail.handle_receivefields(player, formname, fields)
|
|||||||
|
|
||||||
if formname == "mail:about" then
|
if formname == "mail:about" then
|
||||||
minetest.after(0.5, function()
|
minetest.after(0.5, function()
|
||||||
mail.showinbox(player:get_player_name())
|
mail.show_inbox(player:get_player_name())
|
||||||
end)
|
end)
|
||||||
elseif formname == "mail:inbox" then
|
elseif formname == "mail:inbox" then
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
@ -117,68 +117,68 @@ function mail.handle_receivefields(player, formname, fields)
|
|||||||
mail.highlightedmessages[name] = event.index
|
mail.highlightedmessages[name] = event.index
|
||||||
if event.type == "DCL" and mail.messages[name][mail.highlightedmessages[name]] then
|
if event.type == "DCL" and mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
||||||
mail.showmessage(name, mail.highlightedmessages[name])
|
mail.show_message(name, mail.highlightedmessages[name])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fields.read then
|
if fields.read then
|
||||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
||||||
mail.showmessage(name, mail.highlightedmessages[name])
|
mail.show_message(name, mail.highlightedmessages[name])
|
||||||
end
|
end
|
||||||
elseif fields.delete then
|
elseif fields.delete then
|
||||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
table.remove(mail.messages[name], mail.highlightedmessages[name])
|
table.remove(mail.messages[name], mail.highlightedmessages[name])
|
||||||
end
|
end
|
||||||
|
|
||||||
mail.showinbox(name)
|
mail.show_inbox(name)
|
||||||
mail.save()
|
mail.save()
|
||||||
elseif fields.reply and mail.messages[name][mail.highlightedmessages[name]] then
|
elseif fields.reply and mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||||
local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body
|
local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body
|
||||||
mail.showcompose(name, message.sender, "Re: "..message.subject,replyfooter)
|
mail.show_compose(name, message.sender, "Re: "..message.subject,replyfooter)
|
||||||
elseif fields.forward and mail.messages[name][mail.highlightedmessages[name]] then
|
elseif fields.forward and mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||||
local fwfooter = "Type your message here.\n\n--Original message follows--\n" ..message.body
|
local fwfooter = "Type your message here.\n\n--Original message follows--\n" ..message.body
|
||||||
mail.showcompose(name, "", "Fw: "..message.subject, fwfooter)
|
mail.show_compose(name, "", "Fw: "..message.subject, fwfooter)
|
||||||
elseif fields.markread then
|
elseif fields.markread then
|
||||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
||||||
end
|
end
|
||||||
mail.showinbox(name)
|
mail.show_inbox(name)
|
||||||
mail.save()
|
mail.save()
|
||||||
elseif fields.markunread then
|
elseif fields.markunread then
|
||||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
mail.messages[name][mail.highlightedmessages[name]].unread = true
|
mail.messages[name][mail.highlightedmessages[name]].unread = true
|
||||||
end
|
end
|
||||||
mail.showinbox(name)
|
mail.show_inbox(name)
|
||||||
mail.save()
|
mail.save()
|
||||||
elseif fields.new then
|
elseif fields.new then
|
||||||
mail.showcompose(name,"","","Type your message here.")
|
mail.show_compose(name,"","","Type your message here.")
|
||||||
elseif fields.quit then
|
elseif fields.quit then
|
||||||
if minetest.get_modpath("unified_inventory") then
|
if minetest.get_modpath("unified_inventory") then
|
||||||
unified_inventory.set_inventory_formspec(player, "craft")
|
unified_inventory.set_inventory_formspec(player, "craft")
|
||||||
end
|
end
|
||||||
elseif fields.about then
|
elseif fields.about then
|
||||||
mail.showabout(name)
|
mail.show_about(name)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
elseif formname == "mail:message" then
|
elseif formname == "mail:message" then
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if fields.back then
|
if fields.back then
|
||||||
mail.showinbox(name)
|
mail.show_inbox(name)
|
||||||
elseif fields.reply then
|
elseif fields.reply then
|
||||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||||
local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body
|
local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body
|
||||||
mail.showcompose(name, message.sender, "Re: "..message.subject, replyfooter)
|
mail.show_compose(name, message.sender, "Re: "..message.subject, replyfooter)
|
||||||
elseif fields.forward then
|
elseif fields.forward then
|
||||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||||
local fwfooter = "Type your message here.\n\n--Original message follows--\n" ..message.body
|
local fwfooter = "Type your message here.\n\n--Original message follows--\n" ..message.body
|
||||||
mail.showcompose(name, "", "Fw: "..message.subject, fwfooter)
|
mail.show_compose(name, "", "Fw: "..message.subject, fwfooter)
|
||||||
elseif fields.delete then
|
elseif fields.delete then
|
||||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||||
table.remove(mail.messages[name],mail.highlightedmessages[name])
|
table.remove(mail.messages[name],mail.highlightedmessages[name])
|
||||||
end
|
end
|
||||||
mail.showinbox(name)
|
mail.show_inbox(name)
|
||||||
mail.save()
|
mail.save()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -187,18 +187,18 @@ function mail.handle_receivefields(player, formname, fields)
|
|||||||
mail.send(player:get_player_name(), fields.to, fields.subject, fields.body)
|
mail.send(player:get_player_name(), fields.to, fields.subject, fields.body)
|
||||||
end
|
end
|
||||||
minetest.after(0.5, function()
|
minetest.after(0.5, function()
|
||||||
mail.showinbox(player:get_player_name())
|
mail.show_inbox(player:get_player_name())
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
elseif formname == "mail:unreadnag" then
|
elseif formname == "mail:unreadnag" then
|
||||||
if fields.yes then
|
if fields.yes then
|
||||||
mail.showinbox(player:get_player_name())
|
mail.show_inbox(player:get_player_name())
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(player:get_player_name(), mail.read_later_message)
|
minetest.chat_send_player(player:get_player_name(), mail.read_later_message)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
elseif fields.mail then
|
elseif fields.mail then
|
||||||
mail.showinbox(player:get_player_name())
|
mail.show_inbox(player:get_player_name())
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user