Rename GUI methods to be consistent
This commit is contained in:
parent
19bc320859
commit
6900ddeea7
@ -1,6 +1,6 @@
|
||||
minetest.register_chatcommand("mail",{
|
||||
description = "Open the mail interface",
|
||||
func = function(name)
|
||||
mail.showinbox(name)
|
||||
mail.show_inbox(name)
|
||||
end
|
||||
})
|
||||
|
46
gui.lua
46
gui.lua
@ -1,5 +1,5 @@
|
||||
|
||||
mail.inboxformspec = [[
|
||||
mail.inbox_formspec = [[
|
||||
size[8,9;]
|
||||
button_exit[7.5,0;0.5,0.5;quit;X]
|
||||
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;
|
||||
]]
|
||||
|
||||
function mail.showabout(name)
|
||||
function mail.show_about(name)
|
||||
local formspec = [[
|
||||
size[4,5;]
|
||||
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)
|
||||
end
|
||||
|
||||
function mail.showinbox(name)
|
||||
local formspec = mail.inboxformspec
|
||||
function mail.show_inbox(name)
|
||||
local formspec = mail.inbox_formspec
|
||||
mail.messages[name] = mail.messages[name] or {}
|
||||
|
||||
if mail.messages[name][1] then
|
||||
@ -62,7 +62,7 @@ function mail.showinbox(name)
|
||||
minetest.show_formspec(name, "mail:inbox", formspec)
|
||||
end
|
||||
|
||||
function mail.showmessage(name, msgnumber)
|
||||
function mail.show_message(name, msgnumber)
|
||||
local message = mail.messages[name][msgnumber]
|
||||
local formspec = [[
|
||||
size[8,6]
|
||||
@ -82,7 +82,7 @@ function mail.showmessage(name, msgnumber)
|
||||
minetest.show_formspec(name,"mail:message",formspec)
|
||||
end
|
||||
|
||||
function mail.showcompose(name, defaulttgt, defaultsubj, defaultbody)
|
||||
function mail.show_compose(name, defaulttgt, defaultsubj, defaultbody)
|
||||
local formspec = [[
|
||||
size[8,8]
|
||||
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
|
||||
minetest.after(0.5, function()
|
||||
mail.showinbox(player:get_player_name())
|
||||
mail.show_inbox(player:get_player_name())
|
||||
end)
|
||||
elseif formname == "mail:inbox" then
|
||||
local name = player:get_player_name()
|
||||
@ -117,68 +117,68 @@ function mail.handle_receivefields(player, formname, fields)
|
||||
mail.highlightedmessages[name] = event.index
|
||||
if event.type == "DCL" and mail.messages[name][mail.highlightedmessages[name]] then
|
||||
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
||||
mail.showmessage(name, mail.highlightedmessages[name])
|
||||
mail.show_message(name, mail.highlightedmessages[name])
|
||||
end
|
||||
end
|
||||
if fields.read then
|
||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
||||
mail.showmessage(name, mail.highlightedmessages[name])
|
||||
mail.show_message(name, mail.highlightedmessages[name])
|
||||
end
|
||||
elseif fields.delete then
|
||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||
table.remove(mail.messages[name], mail.highlightedmessages[name])
|
||||
end
|
||||
|
||||
mail.showinbox(name)
|
||||
mail.show_inbox(name)
|
||||
mail.save()
|
||||
elseif fields.reply and mail.messages[name][mail.highlightedmessages[name]] then
|
||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||
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
|
||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||
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
|
||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||
mail.messages[name][mail.highlightedmessages[name]].unread = false
|
||||
end
|
||||
mail.showinbox(name)
|
||||
mail.show_inbox(name)
|
||||
mail.save()
|
||||
elseif fields.markunread then
|
||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||
mail.messages[name][mail.highlightedmessages[name]].unread = true
|
||||
end
|
||||
mail.showinbox(name)
|
||||
mail.show_inbox(name)
|
||||
mail.save()
|
||||
elseif fields.new then
|
||||
mail.showcompose(name,"","","Type your message here.")
|
||||
mail.show_compose(name,"","","Type your message here.")
|
||||
elseif fields.quit then
|
||||
if minetest.get_modpath("unified_inventory") then
|
||||
unified_inventory.set_inventory_formspec(player, "craft")
|
||||
end
|
||||
elseif fields.about then
|
||||
mail.showabout(name)
|
||||
mail.show_about(name)
|
||||
end
|
||||
return true
|
||||
elseif formname == "mail:message" then
|
||||
local name = player:get_player_name()
|
||||
if fields.back then
|
||||
mail.showinbox(name)
|
||||
mail.show_inbox(name)
|
||||
elseif fields.reply then
|
||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||
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
|
||||
local message = mail.messages[name][mail.highlightedmessages[name]]
|
||||
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
|
||||
if mail.messages[name][mail.highlightedmessages[name]] then
|
||||
table.remove(mail.messages[name],mail.highlightedmessages[name])
|
||||
end
|
||||
mail.showinbox(name)
|
||||
mail.show_inbox(name)
|
||||
mail.save()
|
||||
end
|
||||
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)
|
||||
end
|
||||
minetest.after(0.5, function()
|
||||
mail.showinbox(player:get_player_name())
|
||||
mail.show_inbox(player:get_player_name())
|
||||
end)
|
||||
return true
|
||||
elseif formname == "mail:unreadnag" then
|
||||
if fields.yes then
|
||||
mail.showinbox(player:get_player_name())
|
||||
mail.show_inbox(player:get_player_name())
|
||||
else
|
||||
minetest.chat_send_player(player:get_player_name(), mail.read_later_message)
|
||||
end
|
||||
return true
|
||||
elseif fields.mail then
|
||||
mail.showinbox(player:get_player_name())
|
||||
mail.show_inbox(player:get_player_name())
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user