Add sound notification

This commit is contained in:
Athozus 2023-05-06 17:35:38 +02:00
parent a79ebd94b8
commit 27875f26b4
No known key found for this signature in database
GPG key ID: B50895022E8484BF
7 changed files with 14 additions and 1 deletions

View file

@ -62,6 +62,7 @@ See the "LICENSE" file
* imre84 (UI fixes)
* Chache (Spanish translation)
* APercy (Brazilian Portuguese translation)
* bennstir (mail_notif.ogg - https://freesound.org/people/bennstir/sounds/81072/)
# Contribute

View file

@ -106,6 +106,9 @@ function mail.send(m)
minetest.chat_send_player(name, unified_inventory_alert)
end
end
if mail.get_setting(name, "sound_notifications") == true then
minetest.sound_play("mail_notif", {to_player=name})
end
local receiver_entry = mail.get_storage_entry(name)
local receiver_messages = receiver_entry.inbox
mail.hud_update(name, receiver_messages)

View file

@ -30,6 +30,7 @@ mail = {
chat_notifications = {},
onjoin_notifications = {},
hud_notifications = {},
sound_notifications = {},
unreadcolorenable = {},
cccolorenable = {}
},

BIN
sounds/mail_notif.ogg Normal file

Binary file not shown.

View file

@ -263,6 +263,7 @@ function mail.get_setting_default_value(setting_name)
chat_notifications = true,
onjoin_notifications = true,
hud_notifications = true,
sound_notifications = true,
unreadcolorenable = true,
cccolorenable = true,
defaultsortfield = 3,

View file

@ -37,7 +37,8 @@ function mail.show_about(name)
[[#FFF,NatureFreshMilk,Maintenance,]] ..
[[#FFF,imre84,UI fixes,]] ..
[[#FFF,Chache,Spanish translation,]] ..
[[#FFF,APercy,Brazilian Portuguese trans.]
[[#FFF,APercy,Brazilian Portuguese trans.,]] ..
[[#FFF,bennstir,mail_notif.ogg]
]] .. mail.theme
minetest.show_formspec(name, FORMNAME, formspec)

View file

@ -17,6 +17,8 @@ function mail.show_settings(name)
tostring(mail.get_setting(name, "onjoin_notifications")) .. [[]
checkbox[0,2.0;hud_notifications;]] .. S("HUD notifications") .. [[;]] ..
tostring(mail.get_setting(name, "hud_notifications")) .. [[]
checkbox[0,2.4;sound_notifications;]] .. S("Sound notifications") .. [[;]] ..
tostring(mail.get_setting(name, "sound_notifications")) .. [[]
box[5,0.8;3,0.45;#466432]
label[5.2,0.8;]] .. S("Message list") .. [[]
@ -68,6 +70,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.hud_notifications then
mail.selected_idxs.hud_notifications[playername] = fields.hud_notifications == "true"
elseif fields.sound_notifications then
mail.selected_idxs.sound_notifications[playername] = fields.sound_notifications == "true"
elseif fields.unreadcolorenable then
mail.selected_idxs.unreadcolorenable[playername] = fields.unreadcolorenable == "true"
@ -79,6 +84,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
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, "sound_notifications", mail.selected_idxs.sound_notifications[playername])
mail.set_setting(playername, "unreadcolorenable", mail.selected_idxs.unreadcolorenable[playername])
mail.set_setting(playername, "cccolorenable", mail.selected_idxs.cccolorenable[playername])
-- dropdowns