Add a window to show long receivers list
This commit is contained in:
parent
8917fd0b39
commit
67cbef88f7
1
init.lua
1
init.lua
@ -75,6 +75,7 @@ dofile(MP .. "/ui/outbox.lua")
|
|||||||
dofile(MP .. "/ui/drafts.lua")
|
dofile(MP .. "/ui/drafts.lua")
|
||||||
dofile(MP .. "/ui/trash.lua")
|
dofile(MP .. "/ui/trash.lua")
|
||||||
dofile(MP .. "/ui/message.lua")
|
dofile(MP .. "/ui/message.lua")
|
||||||
|
dofile(MP .. "/ui/receivers.lua")
|
||||||
dofile(MP .. "/ui/events.lua")
|
dofile(MP .. "/ui/events.lua")
|
||||||
dofile(MP .. "/ui/contacts.lua")
|
dofile(MP .. "/ui/contacts.lua")
|
||||||
dofile(MP .. "/ui/edit_contact.lua")
|
dofile(MP .. "/ui/edit_contact.lua")
|
||||||
|
@ -17,6 +17,7 @@ function mail.show_message(name, id)
|
|||||||
label[0.2,0.5;]] .. S("To") .. [[: %s]
|
label[0.2,0.5;]] .. S("To") .. [[: %s]
|
||||||
label[0.2,0.9;]] .. S("CC") .. [[: %s]
|
label[0.2,0.9;]] .. S("CC") .. [[: %s]
|
||||||
label[0.2,1.3;]] .. S("Date") .. [[: %s]
|
label[0.2,1.3;]] .. S("Date") .. [[: %s]
|
||||||
|
button[5.1,1;2,1;receivers;]] .. S("Receivers") .. [[]
|
||||||
|
|
||||||
label[0,2.1;]] .. S("Subject") .. [[: %s]
|
label[0,2.1;]] .. S("Subject") .. [[: %s]
|
||||||
textarea[0.25,2.6;8,7.0;;;%s]
|
textarea[0.25,2.6;8,7.0;;;%s]
|
||||||
@ -29,7 +30,9 @@ function mail.show_message(name, id)
|
|||||||
|
|
||||||
local from = minetest.formspec_escape(message.from) or ""
|
local from = minetest.formspec_escape(message.from) or ""
|
||||||
local to = minetest.formspec_escape(message.to) or ""
|
local to = minetest.formspec_escape(message.to) or ""
|
||||||
|
if string.len(to) > 70 then to = string.sub(to, 1, 67) .. "..." end
|
||||||
local cc = minetest.formspec_escape(message.cc) or ""
|
local cc = minetest.formspec_escape(message.cc) or ""
|
||||||
|
if string.len(cc) > 50 then cc = string.sub(cc, 1, 47) .. "..." end
|
||||||
local date = type(message.time) == "number"
|
local date = type(message.time) == "number"
|
||||||
and minetest.formspec_escape(os.date("%Y-%m-%d %X", message.time)) or ""
|
and minetest.formspec_escape(os.date("%Y-%m-%d %X", message.time)) or ""
|
||||||
local subject = minetest.formspec_escape(message.subject) or ""
|
local subject = minetest.formspec_escape(message.subject) or ""
|
||||||
@ -134,6 +137,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
mail.delete_mail(name, message.id, true)
|
mail.delete_mail(name, message.id, true)
|
||||||
end
|
end
|
||||||
mail.show_mail_menu(name)
|
mail.show_mail_menu(name)
|
||||||
|
|
||||||
|
elseif fields.receivers then
|
||||||
|
mail.show_receivers(name, message.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
62
ui/receivers.lua
Normal file
62
ui/receivers.lua
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
-- translation
|
||||||
|
local S = minetest.get_translator("mail")
|
||||||
|
|
||||||
|
local FORMNAME = "mail:receivers"
|
||||||
|
|
||||||
|
function mail.show_receivers(name, id)
|
||||||
|
local message = mail.get_message(name, id)
|
||||||
|
|
||||||
|
local formspec = [[
|
||||||
|
size[8,6]
|
||||||
|
|
||||||
|
box[0,0;7,1.1;]] .. mail.colors.highlighted .. [[]
|
||||||
|
|
||||||
|
button[7.25,0.15;0.75,0.5;back;X]
|
||||||
|
|
||||||
|
label[0.2,0.1;]] .. S("From") .. [[: %s]
|
||||||
|
label[0.2,0.5;]] .. S("Date") .. [[: %s]
|
||||||
|
|
||||||
|
tablecolumns[color;text]
|
||||||
|
table[0,1.5;3.8,4.5;to;%s]
|
||||||
|
|
||||||
|
tablecolumns[color;text]
|
||||||
|
table[4,1.5;3.8,4.5;cc;%s]
|
||||||
|
]] .. mail.theme
|
||||||
|
|
||||||
|
local from = minetest.formspec_escape(message.from) or ""
|
||||||
|
local to = mail.parse_player_list(message.to or "")
|
||||||
|
local to_str = mail.colors.header .. "," .. S("To") .. ",,"
|
||||||
|
to_str = to_str .. table.concat(to, ",,")
|
||||||
|
local cc = mail.parse_player_list(message.cc or "")
|
||||||
|
local cc_str = mail.colors.header .. "," .. S("CC") .. ",,"
|
||||||
|
cc_str = cc_str .. table.concat(cc, ",,")
|
||||||
|
local date = type(message.time) == "number"
|
||||||
|
and minetest.formspec_escape(os.date("%Y-%m-%d %X", message.time)) or ""
|
||||||
|
formspec = string.format(formspec, from, date, to_str, cc_str)
|
||||||
|
|
||||||
|
minetest.show_formspec(name, FORMNAME, formspec)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname ~= FORMNAME then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local entry = mail.get_storage_entry(name)
|
||||||
|
|
||||||
|
local message_id = ""
|
||||||
|
if mail.selected_idxs.inbox[name] and mail.selected_idxs.boxtab[name] == 1 then
|
||||||
|
message_id = mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]]
|
||||||
|
elseif mail.selected_idxs.outbox[name] and mail.selected_idxs.boxtab[name] == 2 then
|
||||||
|
message_id = mail.selected_idxs.outbox[name][#mail.selected_idxs.outbox[name]]
|
||||||
|
elseif mail.selected_idxs.trash[name] and mail.selected_idxs.boxtab[name] == 4 then
|
||||||
|
message_id = entry.trash[mail.selected_idxs.trash[name]].id
|
||||||
|
end
|
||||||
|
|
||||||
|
if fields.back then
|
||||||
|
mail.show_message(name, message_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user