Add settings (#85)
* Add settings * Fix luacheck * Fix unupdatable sorting fields values (settings) * Better settings names * Better sort settings behaviour * Rework set_setting() * Rework settings storage * Better get sorting filters (inbox/outbox) * Fix reseting/saving settings
This commit is contained in:
parent
a8632255b3
commit
720029a73e
4
api.lua
4
api.lua
@ -98,7 +98,9 @@ function mail.send(m)
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
if recipients[name] then
|
||||
minetest.chat_send_player(name, mail_alert)
|
||||
if mail.get_setting(name, "chat_notifications") == true then
|
||||
minetest.chat_send_player(name, mail_alert)
|
||||
end
|
||||
local receiver_entry = mail.get_storage_entry(name)
|
||||
local receiver_messages = receiver_entry.inbox
|
||||
mail.hud_update(name, receiver_messages)
|
||||
|
2
hud.lua
2
hud.lua
@ -48,7 +48,7 @@ function mail.hud_update(playername, messages)
|
||||
end
|
||||
end
|
||||
|
||||
if unreadcount == 0 then
|
||||
if unreadcount == 0 or (not mail.get_setting(playername, "hud_notifications")) then
|
||||
player:hud_change(data.imageid, "text", "")
|
||||
player:hud_change(data.textid, "text", "")
|
||||
else
|
||||
|
10
init.lua
10
init.lua
@ -25,7 +25,13 @@ mail = {
|
||||
sortfield = {},
|
||||
sortdirection = {},
|
||||
filter = {},
|
||||
multipleselection = {}
|
||||
multipleselection = {},
|
||||
optionstab = {},
|
||||
chat_notifications = {},
|
||||
onjoin_notifications = {},
|
||||
hud_notifications = {},
|
||||
unreadcolorenable = {},
|
||||
cccolorenable = {}
|
||||
},
|
||||
|
||||
message_drafts = {}
|
||||
@ -59,6 +65,8 @@ dofile(MP .. "/ui/select_contact.lua")
|
||||
dofile(MP .. "/ui/maillists.lua")
|
||||
dofile(MP .. "/ui/edit_maillists.lua")
|
||||
dofile(MP .. "/ui/compose.lua")
|
||||
dofile(MP .. "/ui/options.lua")
|
||||
dofile(MP .. "/ui/settings.lua")
|
||||
dofile(MP .. "/ui/about.lua")
|
||||
|
||||
-- migrate storage
|
||||
|
@ -3,53 +3,65 @@ BCC=BCC
|
||||
Cancel=Abbrechen
|
||||
Save draft=Entwurf Speichern
|
||||
Send=Senden
|
||||
Delete=Löschen
|
||||
New=Neu
|
||||
No drafts=Keine Entwürfe
|
||||
Edit=Bearbeiten
|
||||
Subject=Betreff
|
||||
New=Neu
|
||||
Delete=Löschen
|
||||
No drafts=Keine Entwürfe
|
||||
Player name=Spielername
|
||||
your contacts.=ihre Kontakte.
|
||||
The contact=Der Kontakt
|
||||
Save=Speichern
|
||||
That name=Der Name
|
||||
is already in=ist bereits in
|
||||
name cannot=Name kann nicht
|
||||
be empty.=leer sein.
|
||||
Back=Zurück
|
||||
Note=Notiz
|
||||
Maillist name=Verteilerlistenname
|
||||
Desc=Beschreibung
|
||||
Players=Spieler
|
||||
your maillists.=ihre Verteilerlisten.
|
||||
The maillist=Die Verteilerliste
|
||||
Save=Speichern
|
||||
That name=Der Name
|
||||
is already in=ist bereits in
|
||||
name cannot=Name kann nicht
|
||||
be empty.=leer sein.
|
||||
Mark Read=Als gelesen makieren
|
||||
Mark Unread=Als ungelesen makieren
|
||||
From=Von
|
||||
(No description)=(Keine Beschreibung)
|
||||
No maillist=Keine Verteilerliste
|
||||
CC=CC
|
||||
Read=Lesen
|
||||
Ascending=
|
||||
Descending=
|
||||
Filter=
|
||||
Allow multiple selection=
|
||||
selected=
|
||||
(Un)select all=
|
||||
No mail=Keine Nachrichten
|
||||
(No description)=(Keine Beschreibung)
|
||||
No maillist=Keine Verteilerliste
|
||||
Subject=Betreff
|
||||
Inbox=Posteingang
|
||||
Sent messages=Nachrichten senden
|
||||
Drafts=Entwürfe
|
||||
Contacts=Kontakte
|
||||
Mail lists=Verteilerlisten
|
||||
About=Über
|
||||
Options=
|
||||
Close=Schließen
|
||||
(No subject)=(Kein Betreff)
|
||||
Date=Datum
|
||||
Reply=Antworten
|
||||
Reply all=Allen antworten
|
||||
Forward=Weiter
|
||||
Add=Hinzufügen
|
||||
Remove=Entfernen
|
||||
CC=CC
|
||||
Note=Notiz
|
||||
Back=Zurück
|
||||
Name=Name
|
||||
To=An
|
||||
Notifications=
|
||||
Chat notifications=
|
||||
On join notifications=
|
||||
HUD notifications=
|
||||
Message list=
|
||||
Show unread in different color=
|
||||
Show CC/BCC in different color=
|
||||
Default sorting fields=
|
||||
From/To=
|
||||
Reset=
|
||||
Settings=
|
||||
About=Über
|
||||
Ascending=
|
||||
Descending=
|
||||
Date=Datum
|
||||
|
@ -3,53 +3,65 @@ BCC=Cci
|
||||
Cancel=Annuler
|
||||
Save draft=Enregistrer le brouillon
|
||||
Send=Envoyer
|
||||
Delete=Supprimer
|
||||
New=Nouveau
|
||||
No drafts=Pas de brouillons
|
||||
Edit=Modifier
|
||||
Subject=Objet
|
||||
New=Nouveau
|
||||
Delete=Supprimer
|
||||
No drafts=Pas de brouillons
|
||||
Player name=Nom du joueur
|
||||
your contacts.=vos contacts.
|
||||
The contact=Ce contact
|
||||
Save=Sauvegarder
|
||||
That name=Ce nom
|
||||
is already in=existe déjà
|
||||
name cannot=nom ne peut pas
|
||||
be empty.=être vide.
|
||||
Back=Retour
|
||||
Note=Note
|
||||
Maillist name=Nom de la liste de diffusion
|
||||
Desc=Desc
|
||||
Players=Joueurs
|
||||
your maillists.=vos listes de diffusion.
|
||||
The maillist=Cette liste de diffusion
|
||||
Save=Sauvegarder
|
||||
That name=Ce nom
|
||||
is already in=existe déjà
|
||||
name cannot=nom ne peut pas
|
||||
be empty.=être vide.
|
||||
Mark Read=Marquer comme lu
|
||||
Mark Unread=Marquer non lu
|
||||
From=De
|
||||
(No description)=Sans description
|
||||
No maillist=Aucune liste de diffusion
|
||||
CC=Cc
|
||||
Read=Lire
|
||||
Ascending=Croissant
|
||||
Descending=Décroissant
|
||||
Filter=Filtre
|
||||
Allow multiple selection=Autoriser la sélection multiple
|
||||
selected=sélectionnés
|
||||
(Un)select all=Tout (dé)selectionner
|
||||
No mail=Aucun mail
|
||||
(No description)=Sans description
|
||||
No maillist=Aucune liste de diffusion
|
||||
Subject=Objet
|
||||
Inbox=Boîte de réception
|
||||
Sent messages=Messages envoyés
|
||||
Drafts=Brouillons
|
||||
Contacts=Contacts
|
||||
Mail lists=Listes de diffusion
|
||||
About=À propos
|
||||
Options=Options
|
||||
Close=Fermer
|
||||
(No subject)=(Sans objet)
|
||||
Date=Date
|
||||
Reply=Répondre
|
||||
Reply all=Répondre à tous
|
||||
Forward=Transférer
|
||||
Add=Ajouter
|
||||
Remove=Enlever
|
||||
CC=Cc
|
||||
Note=Note
|
||||
Back=Retour
|
||||
Name=Nom
|
||||
To=À
|
||||
Notifications=Notifications
|
||||
Chat notifications=Notifications dans le tchat
|
||||
On join notifications=Notifications à la connexion
|
||||
HUD notifications=Notifications ATH
|
||||
Message list=Liste de messages
|
||||
Show unread in different color=Coloriser les non lus
|
||||
Show CC/BCC in different color=Coloriser les Cc/Cci
|
||||
Default sorting fields=Champs de tri par défaut
|
||||
From/To=De/À
|
||||
Reset=Réinitialiser
|
||||
Settings=Paramètres
|
||||
About=À propos
|
||||
Ascending=Croissant
|
||||
Descending=Décroissant
|
||||
Date=Date
|
||||
|
@ -3,53 +3,65 @@ BCC=密件副本
|
||||
Cancel=取消
|
||||
Save draft=儲存草稿
|
||||
Send=發送
|
||||
Delete=刪除
|
||||
New=新建
|
||||
No drafts=沒有草稿
|
||||
Edit=編輯
|
||||
Subject=主旨
|
||||
New=新建
|
||||
Delete=刪除
|
||||
No drafts=沒有草稿
|
||||
Player name=玩家名稱
|
||||
your contacts.=
|
||||
The contact=
|
||||
Save=儲存
|
||||
That name=
|
||||
is already in=
|
||||
name cannot=
|
||||
be empty.=
|
||||
Back=返回
|
||||
Note=備註
|
||||
Maillist name=郵件列表名稱
|
||||
Desc=描述
|
||||
Players=玩家
|
||||
your maillists.=
|
||||
The maillist=
|
||||
Save=儲存
|
||||
That name=
|
||||
is already in=
|
||||
name cannot=
|
||||
be empty.=
|
||||
Mark Read=標記已讀
|
||||
Mark Unread=標記未讀
|
||||
From=寄件者
|
||||
(No description)=(沒有描述)
|
||||
No maillist=沒有郵件列表
|
||||
CC=副本
|
||||
Read=閱讀
|
||||
Ascending=
|
||||
Descending=
|
||||
Filter=
|
||||
Allow multiple selection=
|
||||
selected=
|
||||
(Un)select all=
|
||||
No mail=沒有郵件
|
||||
(No description)=(沒有描述)
|
||||
No maillist=沒有郵件列表
|
||||
Subject=主旨
|
||||
Inbox=收件箱
|
||||
Sent messages=寄件備份
|
||||
Drafts=草稿
|
||||
Contacts=聯繫人
|
||||
Mail lists=郵件列表
|
||||
About=關於
|
||||
Options=
|
||||
Close=關閉
|
||||
(No subject)=(沒有主旨)
|
||||
Date=日期
|
||||
Reply=回覆
|
||||
Reply all=回覆所有人
|
||||
Forward=轉寄
|
||||
Add=加入
|
||||
Remove=移除
|
||||
CC=副本
|
||||
Note=備註
|
||||
Back=返回
|
||||
Name=名稱
|
||||
To=收件人
|
||||
Notifications=
|
||||
Chat notifications=
|
||||
On join notifications=
|
||||
HUD notifications=
|
||||
Message list=
|
||||
Show unread in different color=
|
||||
Show CC/BCC in different color=
|
||||
Default sorting fields=
|
||||
From/To=
|
||||
Reset=
|
||||
Settings=
|
||||
About=關於
|
||||
Ascending=
|
||||
Descending=
|
||||
Date=日期
|
||||
|
@ -3,53 +3,65 @@ BCC=
|
||||
Cancel=
|
||||
Save draft=
|
||||
Send=
|
||||
Delete=
|
||||
New=
|
||||
No drafts=
|
||||
Edit=
|
||||
Subject=
|
||||
New=
|
||||
Delete=
|
||||
No drafts=
|
||||
Player name=
|
||||
your contacts.=
|
||||
The contact=
|
||||
Save=
|
||||
That name=
|
||||
is already in=
|
||||
name cannot=
|
||||
be empty.=
|
||||
Back=
|
||||
Note=
|
||||
Maillist name=
|
||||
Desc=
|
||||
Players=
|
||||
your maillists.=
|
||||
The maillist=
|
||||
Save=
|
||||
That name=
|
||||
is already in=
|
||||
name cannot=
|
||||
be empty.=
|
||||
Mark Read=
|
||||
Mark Unread=
|
||||
From=
|
||||
(No description)=
|
||||
No maillist=
|
||||
CC=
|
||||
Read=
|
||||
Ascending=
|
||||
Descending=
|
||||
Filter=
|
||||
Allow multiple selection=
|
||||
selected=
|
||||
(Un)select all=
|
||||
No mail=
|
||||
(No description)=
|
||||
No maillist=
|
||||
Subject=
|
||||
Inbox=
|
||||
Sent messages=
|
||||
Drafts=
|
||||
Contacts=
|
||||
Mail lists=
|
||||
About=
|
||||
Options=
|
||||
Close=
|
||||
(No subject)=
|
||||
Date=
|
||||
Reply=
|
||||
Reply all=
|
||||
Forward=
|
||||
Add=
|
||||
Remove=
|
||||
CC=
|
||||
Note=
|
||||
Back=
|
||||
Name=
|
||||
To=
|
||||
Notifications=
|
||||
Chat notifications=
|
||||
On join notifications=
|
||||
HUD notifications=
|
||||
Message list=
|
||||
Show unread in different color=
|
||||
Show CC/BCC in different color=
|
||||
Default sorting fields=
|
||||
From/To=
|
||||
Reset=
|
||||
Settings=
|
||||
About=
|
||||
Ascending=
|
||||
Descending=
|
||||
Date=
|
||||
|
@ -12,10 +12,9 @@ minetest.register_on_joinplayer(function(player)
|
||||
end
|
||||
end
|
||||
|
||||
if unreadcount > 0 then
|
||||
if unreadcount > 0 and mail.get_setting(name, "onjoin_notifications") then
|
||||
minetest.chat_send_player(name,
|
||||
minetest.colorize("#00f529", "(" .. unreadcount .. ") You have mail! Type /mail to read"))
|
||||
|
||||
end
|
||||
end, player:get_player_name())
|
||||
end)
|
||||
|
36
storage.lua
36
storage.lua
@ -9,6 +9,7 @@ local function populate_entry(e)
|
||||
e.outbox = e.outbox or {}
|
||||
e.drafts = e.drafts or {}
|
||||
e.lists = e.lists or {}
|
||||
e.settings = e.settings or {}
|
||||
return e
|
||||
end
|
||||
|
||||
@ -246,6 +247,41 @@ function mail.extractMaillists(receivers_string, maillists_owner)
|
||||
return receivers
|
||||
end
|
||||
|
||||
function mail.get_setting_default_value(setting_name)
|
||||
local default_values = {
|
||||
chat_notifications = true,
|
||||
onjoin_notifications = true,
|
||||
hud_notifications = true,
|
||||
unreadcolorenable = true,
|
||||
cccolorenable = true,
|
||||
defaultsortfield = 3,
|
||||
defaultsortdirection = 1,
|
||||
}
|
||||
return default_values[setting_name]
|
||||
end
|
||||
|
||||
function mail.get_setting(playername, setting_name)
|
||||
local entry = mail.get_storage_entry(playername)
|
||||
if entry.settings[setting_name] ~= nil then
|
||||
return entry.settings[setting_name]
|
||||
else
|
||||
return mail.get_setting_default_value(setting_name)
|
||||
end
|
||||
end
|
||||
|
||||
-- add or update a setting
|
||||
function mail.set_setting(playername, key, value)
|
||||
local entry = mail.get_storage_entry(playername)
|
||||
entry.settings[key] = value
|
||||
mail.set_storage_entry(playername, entry)
|
||||
end
|
||||
|
||||
function mail.reset_settings(playername)
|
||||
local entry = mail.get_storage_entry(playername)
|
||||
entry.settings = {}
|
||||
mail.set_storage_entry(playername, entry)
|
||||
end
|
||||
|
||||
function mail.pairsByKeys(t, f)
|
||||
-- http://www.lua.org/pil/19.3.html
|
||||
local a = {}
|
||||
|
31
ui/about.lua
31
ui/about.lua
@ -1,17 +1,21 @@
|
||||
-- translation
|
||||
local S = minetest.get_translator("mail")
|
||||
|
||||
local FORMNAME = "mail:about"
|
||||
|
||||
function mail.show_about(name)
|
||||
local formspec = [[
|
||||
size[10,6;]
|
||||
tabheader[0.3,1;optionstab;]] .. S("Settings") .. "," .. S("About") .. [[;2;false;false]
|
||||
button[9.35,0;0.75,0.5;back;X]
|
||||
label[0,0;Mail]
|
||||
label[0,0.4;Provided my mt-mods]
|
||||
label[0,0.8;Version: 1.1.4]
|
||||
label[0,1.4;Licenses:]
|
||||
label[0.2,1.8;Expat (code), WTFPL (textures)]
|
||||
label[0,2.4;https://github.com/mt-mods/mail]
|
||||
label[0,2.8;https://content.minetest.net/packages/mt-mods/mail]
|
||||
textarea[0.5,4.0;4,5.5;;Note;]] ..
|
||||
label[0,0.8;Mail]
|
||||
label[0,1.2;Provided my mt-mods]
|
||||
label[0,1.6;Version: 1.2.0-dev]
|
||||
label[0,2.2;Licenses:]
|
||||
label[0.2,2.6;Expat (code), WTFPL (textures)]
|
||||
label[0,3.2;https://github.com/mt-mods/mail]
|
||||
label[0,3.6;https://content.minetest.net/packages/mt-mods/mail]
|
||||
textarea[0.5,4.8;4,5.5;;Note;]] ..
|
||||
[[NOTE: Communication using this system is NOT guaranteed to be private!]] ..
|
||||
[[ Admins are able to view the messages of any player.]
|
||||
|
||||
@ -42,8 +46,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
local playername = player:get_player_name()
|
||||
|
||||
if fields.back then
|
||||
local playername = player:get_player_name()
|
||||
mail.show_mail_menu(playername)
|
||||
|
||||
elseif fields.optionstab == "1" then
|
||||
mail.selected_idxs.optionstab[playername] = 1
|
||||
mail.show_settings(playername)
|
||||
|
||||
elseif fields.optionstab == "2" then
|
||||
mail.selected_idxs.optionstab[playername] = 2
|
||||
mail.show_about(playername)
|
||||
end
|
||||
end)
|
||||
|
@ -9,7 +9,7 @@ local drafts_formspec = "size[8.5,10;]" .. mail.theme .. [[
|
||||
button[6,1.70;2.5,0.5;delete;]] .. S("Delete") .. [[]
|
||||
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
|
||||
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
|
||||
button[6,8.7;2.5,0.5;about;]] .. S("About") .. [[]
|
||||
button[6,8.7;2.5,0.5;options;]] .. S("Options") .. [[]
|
||||
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
|
||||
|
||||
tablecolumns[color;text;text]
|
||||
|
@ -249,8 +249,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
elseif fields.maillists then
|
||||
mail.show_maillists(name)
|
||||
|
||||
elseif fields.about then
|
||||
mail.show_about(name)
|
||||
elseif fields.options then
|
||||
mail.show_options(name)
|
||||
|
||||
elseif fields.selectall then
|
||||
if formname == "mail:inbox" then
|
||||
|
21
ui/inbox.lua
21
ui/inbox.lua
@ -1,10 +1,11 @@
|
||||
-- translation
|
||||
local S = minetest.get_translator("mail")
|
||||
|
||||
|
||||
function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
|
||||
sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name]) or 3
|
||||
sortdirection = sortdirection or mail.selected_idxs.sortdirection[name] or "1"
|
||||
sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name])
|
||||
or mail.get_setting(name, "defaultsortfield") or 3
|
||||
sortdirection = tostring(sortdirection or mail.selected_idxs.sortdirection[name]
|
||||
or mail.get_setting(name, "defaultsortdirection") or "1")
|
||||
filter = filter or mail.selected_idxs.filter[name] or ""
|
||||
mail.selected_idxs.inbox[name] = mail.selected_idxs.inbox[name] or {}
|
||||
|
||||
@ -21,7 +22,7 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
|
||||
button[6,5.55;2.5,0.5;markunread;]] .. S("Mark Unread") .. [[]
|
||||
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
|
||||
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
|
||||
button[6,8.7;2.5,0.5;about;]] .. S("About") .. [[]
|
||||
button[6,8.7;2.5,0.5;options;]] .. S("Options") .. [[]
|
||||
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
|
||||
|
||||
dropdown[0,8.4;2,0.5;sortfield;]] ..
|
||||
@ -58,28 +59,28 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
|
||||
end
|
||||
end
|
||||
if selected_id > 0 then
|
||||
if not message.read then
|
||||
if not mail.player_in_list(name, message.to) then
|
||||
if not message.read and mail.get_setting(name, "unreadcolorenable") then
|
||||
if not mail.player_in_list(name, message.to) and mail.get_setting(name, "cccolorenable") then
|
||||
formspec[#formspec + 1] = ",#A39E5D"
|
||||
else
|
||||
formspec[#formspec + 1] = ",#A39E19"
|
||||
end
|
||||
else
|
||||
if not mail.player_in_list(name, message.to) then
|
||||
if not mail.player_in_list(name, message.to) and mail.get_setting(name, "cccolorenable") then
|
||||
formspec[#formspec + 1] = ",#899888"
|
||||
else
|
||||
formspec[#formspec + 1] = ",#466432"
|
||||
end
|
||||
end
|
||||
else
|
||||
if not message.read then
|
||||
if not mail.player_in_list(name, message.to) then
|
||||
if not message.read and mail.get_setting(name, "unreadcolorenable") then
|
||||
if not mail.player_in_list(name, message.to) and mail.get_setting(name, "cccolorenable") then
|
||||
formspec[#formspec + 1] = ",#FFD788"
|
||||
else
|
||||
formspec[#formspec + 1] = ",#FFD700"
|
||||
end
|
||||
else
|
||||
if not mail.player_in_list(name, message.to) then
|
||||
if not mail.player_in_list(name, message.to) and mail.get_setting(name, "cccolorenable") then
|
||||
formspec[#formspec + 1] = ",#CCCCDD"
|
||||
else
|
||||
formspec[#formspec + 1] = ","
|
||||
|
13
ui/options.lua
Normal file
13
ui/options.lua
Normal file
@ -0,0 +1,13 @@
|
||||
-- helper function for tabbed options
|
||||
|
||||
function mail.show_options(playername)
|
||||
local index = mail.selected_idxs.optionstab[playername] or 1
|
||||
if not mail.selected_idxs.optionstab[playername] then
|
||||
mail.selected_idxs.optionstab[playername] = 1
|
||||
end
|
||||
if index == 1 then
|
||||
mail.show_settings(playername)
|
||||
elseif index == 2 then
|
||||
mail.show_about(playername)
|
||||
end
|
||||
end
|
@ -1,10 +1,11 @@
|
||||
-- translation
|
||||
local S = minetest.get_translator("mail")
|
||||
|
||||
|
||||
function mail.show_sent(name, sortfieldindex, sortdirection, filter)
|
||||
sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name]) or 3
|
||||
sortdirection = sortdirection or mail.selected_idxs.sortdirection[name] or "1"
|
||||
sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name])
|
||||
or mail.get_setting(name, "defaultsortfield") or 3
|
||||
sortdirection = tostring(sortdirection or mail.selected_idxs.sortdirection[name]
|
||||
or mail.get_setting(name, "defaultsortdirection") or "1")
|
||||
filter = filter or mail.selected_idxs.filter[name] or ""
|
||||
mail.selected_idxs.sent[name] = mail.selected_idxs.sent[name] or {}
|
||||
|
||||
@ -19,7 +20,7 @@ function mail.show_sent(name, sortfieldindex, sortdirection, filter)
|
||||
button[6,3.95;2.5,0.5;delete;]] .. S("Delete") .. [[]
|
||||
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
|
||||
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
|
||||
button[6,8.7;2.5,0.5;about;]] .. S("About") .. [[]
|
||||
button[6,8.7;2.5,0.5;options;]] .. S("Options") .. [[]
|
||||
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
|
||||
|
||||
dropdown[0,8.4;2,0.5;sortfield;]] ..
|
||||
|
98
ui/settings.lua
Normal file
98
ui/settings.lua
Normal file
@ -0,0 +1,98 @@
|
||||
-- translation
|
||||
local S = minetest.get_translator("mail")
|
||||
|
||||
local FORMNAME = "mail:settings"
|
||||
|
||||
function mail.show_settings(name)
|
||||
local formspec = [[
|
||||
size[10,6;]
|
||||
tabheader[0.3,1;optionstab;]] .. S("Settings") .. "," .. S("About") .. [[;1;false;false]
|
||||
button[9.35,0;0.75,0.5;back;X]
|
||||
|
||||
box[0,0.8;3,0.45;#466432]
|
||||
label[0.2,0.8;]] .. S("Notifications") .. [[]
|
||||
checkbox[0,1.2;chat_notifications;]] .. S("Chat notifications") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "chat_notifications")) .. [[]
|
||||
checkbox[0,1.6;onjoin_notifications;]] .. S("On join notifications") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "onjoin_notifications")) .. [[]
|
||||
checkbox[0,2.0;hud_notifications;]] .. S("HUD notifications") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "hud_notifications")) .. [[]
|
||||
|
||||
box[5,0.8;3,0.45;#466432]
|
||||
label[5.2,0.8;]] .. S("Message list") .. [[]
|
||||
checkbox[5,1.2;unreadcolorenable;]] .. S("Show unread in different color") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "unreadcolorenable")) .. [[]
|
||||
checkbox[5,1.6;cccolorenable;]] .. S("Show CC/BCC in different color") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "cccolorenable")) .. [[]
|
||||
|
||||
label[5,2.6;]] .. S("Default sorting fields") .. [[]
|
||||
dropdown[5.5,3.0;2,0.5;defaultsortfield;]] ..
|
||||
S("From/To") .. "," .. S("Subject") .. "," .. S("Date") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "defaultsortfield")) .. [[;true]
|
||||
dropdown[7.5,3.0;2,0.5;defaultsortdirection;]] ..
|
||||
S("Ascending") .. "," .. S("Descending") .. [[;]] ..
|
||||
tostring(mail.get_setting(name, "defaultsortdirection")) .. [[;true]
|
||||
|
||||
button[0,5.5;2.5,0.5;save;]] .. S("Save") .. [[]
|
||||
button[2.7,5.5;2.5,0.5;reset;]] .. S("Reset") .. [[]
|
||||
]] .. mail.theme
|
||||
|
||||
minetest.show_formspec(name, FORMNAME, formspec)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= FORMNAME then
|
||||
return
|
||||
end
|
||||
|
||||
local playername = player:get_player_name()
|
||||
|
||||
if fields.back then
|
||||
mail.show_mail_menu(playername)
|
||||
return
|
||||
|
||||
elseif fields.optionstab == "1" then
|
||||
mail.selected_idxs.optionstab[playername] = 1
|
||||
|
||||
elseif fields.optionstab == "2" then
|
||||
mail.selected_idxs.optionstab[playername] = 2
|
||||
mail.show_about(playername)
|
||||
return
|
||||
|
||||
elseif fields.chat_notifications then
|
||||
mail.selected_idxs.chat_notifications[playername] = fields.chat_notifications == "true"
|
||||
|
||||
elseif fields.onjoin_notifications then
|
||||
mail.selected_idxs.onjoin_notifications[playername] = fields.onjoin_notifications == "true"
|
||||
|
||||
elseif fields.hud_notifications then
|
||||
mail.selected_idxs.hud_notifications[playername] = fields.hud_notifications == "true"
|
||||
|
||||
elseif fields.unreadcolorenable then
|
||||
mail.selected_idxs.unreadcolorenable[playername] = fields.unreadcolorenable == "true"
|
||||
|
||||
elseif fields.cccolorenable then
|
||||
mail.selected_idxs.cccolorenable[playername] = fields.cccolorenable == "true"
|
||||
|
||||
elseif fields.save then
|
||||
-- checkboxes
|
||||
mail.set_setting(playername, "chat_notifications", mail.selected_idxs.chat_notifications[playername])
|
||||
mail.set_setting(playername, "onjoin_notifications", mail.selected_idxs.onjoin_notifications[playername])
|
||||
mail.set_setting(playername, "hud_notifications", mail.selected_idxs.hud_notifications[playername])
|
||||
mail.set_setting(playername, "unreadcolorenable", mail.selected_idxs.unreadcolorenable[playername])
|
||||
mail.set_setting(playername, "cccolorenable", mail.selected_idxs.cccolorenable[playername])
|
||||
-- dropdowns
|
||||
local defaultsortfield = fields.defaultsortfield or mail.get_setting("defaultsortfield")
|
||||
local defaultsortdirection = fields.defaultsortdirection or mail.get_setting("defaultsortdirection")
|
||||
mail.set_setting(playername, "defaultsortfield", tonumber(defaultsortfield))
|
||||
mail.set_setting(playername, "defaultsortdirection", tonumber(defaultsortdirection))
|
||||
-- update visuals
|
||||
mail.hud_update(playername, mail.get_storage_entry(playername).inbox)
|
||||
mail.show_settings(playername)
|
||||
|
||||
elseif fields.reset then
|
||||
mail.reset_settings(playername)
|
||||
mail.show_settings(playername)
|
||||
end
|
||||
return
|
||||
end)
|
Loading…
Reference in New Issue
Block a user