Загрузить файлы в «/»
This commit is contained in:
parent
cf4028f3da
commit
c5088a7ce7
10
LICENSE
Normal file
10
LICENSE
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
The file textures/mail_button.png was created by bas080 and is licensed under the WTFPL.
|
||||
|
||||
All other files:
|
||||
|
||||
Copyright (c) 2016 Carter Kolwey ("Cheapie Systems")
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or any associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
22
gui.lua
Normal file
22
gui.lua
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
if minetest.get_modpath("unified_inventory") then
|
||||
|
||||
unified_inventory.register_button("mail", {
|
||||
type = "image",
|
||||
image = "mail_button.png",
|
||||
tooltip = "Mail",
|
||||
action = function(player)
|
||||
mail.show_mail_menu(player:get_player_name())
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("sfinv_buttons") then
|
||||
sfinv_buttons.register_button("mail", {
|
||||
title = "Mail",
|
||||
image = "mail_button.png",
|
||||
action = function(player)
|
||||
mail.show_mail_menu(player:get_player_name())
|
||||
end
|
||||
})
|
||||
end
|
59
hud.lua
Normal file
59
hud.lua
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
local huddata = {}
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local data = {}
|
||||
|
||||
data.imageid = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
name = "MailIcon",
|
||||
position = {x=0.52, y=0.52},
|
||||
text="",
|
||||
scale = {x=1,y=1},
|
||||
alignment = {x=0.5, y=0.5},
|
||||
})
|
||||
|
||||
data.textid = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
name = "MailText",
|
||||
position = {x=0.55, y=0.52},
|
||||
text= "",
|
||||
scale = {x=1,y=1},
|
||||
alignment = {x=0.5, y=0.5},
|
||||
})
|
||||
|
||||
|
||||
huddata[name] = data
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
huddata[name] = nil
|
||||
end)
|
||||
|
||||
|
||||
function mail.hud_update(playername, messages)
|
||||
local data = huddata[playername]
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
|
||||
if not data or not player then
|
||||
return
|
||||
end
|
||||
|
||||
local unreadcount = 0
|
||||
for _, message in ipairs(messages) do
|
||||
if not message.read then
|
||||
unreadcount = unreadcount + 1
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
player:hud_change(data.imageid, "text", "email_mail.png")
|
||||
player:hud_change(data.textid, "text", unreadcount .. " /mail")
|
||||
end
|
||||
|
||||
end
|
69
init.lua
Normal file
69
init.lua
Normal file
@ -0,0 +1,69 @@
|
||||
mail = {
|
||||
-- version
|
||||
version = 3,
|
||||
|
||||
-- mod storage
|
||||
storage = minetest.get_mod_storage(),
|
||||
|
||||
-- translation
|
||||
S = minetest.get_translator(minetest.get_current_modname()),
|
||||
|
||||
-- ui theme prepend
|
||||
theme = "",
|
||||
|
||||
-- ui forms
|
||||
ui = {},
|
||||
|
||||
-- per-user ephemeral data
|
||||
selected_idxs = {
|
||||
inbox = {},
|
||||
outbox = {},
|
||||
drafts = {},
|
||||
trash = {},
|
||||
message = {},
|
||||
contacts = {},
|
||||
maillists = {},
|
||||
to = {},
|
||||
cc = {},
|
||||
bcc = {},
|
||||
boxtab = {},
|
||||
sortfield = {},
|
||||
sortdirection = {},
|
||||
filter = {},
|
||||
multipleselection = {},
|
||||
optionstab = {},
|
||||
settings_group = {},
|
||||
contributor_grouping = {},
|
||||
},
|
||||
|
||||
message_drafts = {}
|
||||
}
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
mail.theme = default.gui_bg .. default.gui_bg_img
|
||||
end
|
||||
|
||||
-- sub files
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
dofile(MP .. "/util/init.lua")
|
||||
dofile(MP .. "/chatcommands.lua")
|
||||
dofile(MP .. "/migrate.lua")
|
||||
dofile(MP .. "/hud.lua")
|
||||
dofile(MP .. "/storage.lua")
|
||||
dofile(MP .. "/api.lua")
|
||||
dofile(MP .. "/gui.lua")
|
||||
dofile(MP .. "/onjoin.lua")
|
||||
dofile(MP .. "/player_recipients.lua")
|
||||
-- sub directories
|
||||
dofile(MP .. "/ui/init.lua")
|
||||
|
||||
-- migrate storage
|
||||
mail.migrate()
|
||||
|
||||
if minetest.get_modpath("mtt") then
|
||||
dofile(MP .. "/mtt.lua")
|
||||
dofile(MP .. "/api.spec.lua")
|
||||
dofile(MP .. "/migrate.spec.lua")
|
||||
dofile(MP .. "/util/uuid.spec.lua")
|
||||
dofile(MP .. "/util/normalize.spec.lua")
|
||||
end
|
Loading…
Reference in New Issue
Block a user