Merge branch 'fix_player_check_in_mail_app' into Grizzly-Adam-theming
This commit is contained in:
commit
2c85a57a26
@ -10,24 +10,23 @@ laptop.register_app("mail", {
|
||||
mtos:set_app("mail:nonet")
|
||||
return false
|
||||
end
|
||||
|
||||
if not mtos.sysram.last_player then
|
||||
if not mtos.sysram.current_player then
|
||||
mtos:set_app() -- no player. Back to launcher
|
||||
return false
|
||||
end
|
||||
|
||||
if not cloud[mtos.sysram.last_player] then
|
||||
if not cloud[mtos.sysram.current_player] then
|
||||
mtos:set_app("mail:newplayer")
|
||||
return false
|
||||
end
|
||||
local account = cloud[mtos.sysram.last_player]
|
||||
local account = cloud[mtos.sysram.current_player]
|
||||
account.selected_box = account.selected_box or "inbox"
|
||||
account.selected_index = nil -- will be new determinated by selectedmessage
|
||||
local box = account[account.selected_box] -- inbox or outbox
|
||||
|
||||
app.app_info = app.app_info.." - Welcome "..mtos.sysram.last_player
|
||||
local formspec = mtos.theme:get_tableoptions()..
|
||||
"background[-0.19,0.23;15.38,10.275;"..mtos.theme.bgcolor2.."]"..--full window background
|
||||
app.app_info = app.app_info.." - Welcome "..mtos.sysram.current_player
|
||||
local formspec = "background[-0.19,0.23;15.38,10.275;"..mtos.theme.bgcolor2.."]"..--full window background
|
||||
mtos.theme:get_tableoptions()..
|
||||
"tablecolumns[" ..
|
||||
"image,align=center,1=laptop_mail.png,2=laptop_mail_read.png;".. --icon column
|
||||
"color;".. -- subject and date color
|
||||
@ -121,13 +120,13 @@ laptop.register_app("mail", {
|
||||
return formspec
|
||||
end,
|
||||
receive_fields_func = function(app, mtos, sender, fields)
|
||||
if sender:get_player_name() ~= mtos.sysram.last_player then
|
||||
if mtos.sysram.current_player ~= mtos.sysram.last_player then
|
||||
mtos:set_app() -- wrong player. Back to launcher
|
||||
return
|
||||
end
|
||||
|
||||
local cloud = mtos.bdev:get_app_storage('cloud', 'mail')
|
||||
local account = cloud[mtos.sysram.last_player]
|
||||
local account = cloud[mtos.sysram.current_player]
|
||||
if not account then
|
||||
mtos:set_app() -- wrong player. Back to launcher
|
||||
return
|
||||
@ -196,17 +195,17 @@ laptop.register_app("mail", {
|
||||
|
||||
laptop.register_view("mail:newplayer", {
|
||||
formspec_func = function(app, mtos)
|
||||
return mtos.theme:get_label('1,3', "No mail account for player "..mtos.sysram.last_player.. " found. Do you like to create a new account?")..
|
||||
return mtos.theme:get_label('1,3', "No mail account for player "..mtos.sysram.current_player.. " found. Do you like to create a new account?")..
|
||||
mtos.theme:get_button('1,4;3,1', 'major', 'create', 'Create Account')
|
||||
end,
|
||||
receive_fields_func = function(app, mtos, sender, fields)
|
||||
if sender:get_player_name() ~= mtos.sysram.last_player then
|
||||
if mtos.sysram.current_player ~= mtos.sysram.last_player then
|
||||
mtos:set_app() -- wrong player. Back to launcher
|
||||
return
|
||||
end
|
||||
if fields.create then
|
||||
local cloud = mtos.bdev:get_app_storage('cloud', 'mail')
|
||||
cloud[mtos.sysram.last_player] = {
|
||||
cloud[mtos.sysram.current_player] = {
|
||||
inbox = {},
|
||||
sentbox = {}
|
||||
}
|
||||
@ -230,7 +229,7 @@ laptop.register_view("mail:nonet", {
|
||||
laptop.register_view("mail:compose", {
|
||||
formspec_func = function(app, mtos)
|
||||
local cloud = mtos.bdev:get_app_storage('cloud', 'mail')
|
||||
local account = cloud[mtos.sysram.last_player]
|
||||
local account = cloud[mtos.sysram.current_player]
|
||||
account.newmessage = account.newmessage or {}
|
||||
local message = account.newmessage
|
||||
|
||||
@ -262,18 +261,18 @@ laptop.register_view("mail:compose", {
|
||||
return formspec
|
||||
end,
|
||||
receive_fields_func = function(app, mtos, sender, fields)
|
||||
if sender:get_player_name() ~= mtos.sysram.last_player then
|
||||
if mtos.sysram.current_player ~= mtos.sysram.last_player then
|
||||
mtos:set_app() -- wrong player. Back to launcher
|
||||
return
|
||||
end
|
||||
|
||||
local cloud = mtos.bdev:get_app_storage('cloud', 'mail')
|
||||
local account = cloud[mtos.sysram.last_player]
|
||||
local account = cloud[mtos.sysram.current_player]
|
||||
account.newmessage = account.newmessage or {}
|
||||
local message = account.newmessage
|
||||
|
||||
message.receiver = fields.receiver or message.receiver
|
||||
message.sender = mtos.sysram.last_player
|
||||
message.sender = mtos.sysram.current_player
|
||||
message.time = os.time()
|
||||
message.subject = fields.subject or message.subject
|
||||
message.body = fields.body or message.body
|
||||
|
@ -256,7 +256,7 @@ laptop.register_view("printer:app", {
|
||||
|
||||
formspec = formspec .. "background[7.15,0.4;7.6,1;"..mtos.theme.contrast_background.."]"..
|
||||
"label[7.3,0.6;Heading:]".."field[9.7,0.7;5,1;label;;"..minetest.formspec_escape(param.label or "").."]"..
|
||||
mtos.theme:get_label('9.7,1.7'," by "..(mtos.sysram.last_player or ""))..
|
||||
mtos.theme:get_label('9.7,1.7'," by "..(mtos.sysram.current_player or ""))..
|
||||
"background[7.15,2.55;7.6,6.0;"..mtos.theme.contrast_background.."]"..
|
||||
"textarea[7.5,2.5;7.5,7;;"..(minetest.formspec_escape(param.text) or "")..";]"
|
||||
|
||||
|
@ -579,7 +579,7 @@ register_piece("king")
|
||||
"list[context;board;3,1;8,8;]"..
|
||||
"listcolors[#00000000;#00000000;#00000000;#30434C;#FFF]"
|
||||
if data.messageOther then
|
||||
formspec = formspec..mtos.theme:get_label('4,9.3', mtos.sysram.last_player.." "..data.messageOther)
|
||||
formspec = formspec..mtos.theme:get_label('4,9.3', mtos.sysram.current_player.." "..data.messageOther)
|
||||
else
|
||||
formspec=formspec..
|
||||
mtos.theme:get_label('2,0.3', data.playerBlack.." "..(data.messageBlack or ""))..
|
||||
|
13
mtos.lua
13
mtos.lua
@ -251,16 +251,25 @@ function os_class:pass_to_app(method, reshow, sender, ...)
|
||||
self:set_app()
|
||||
return
|
||||
end
|
||||
local ret = app:receive_data(method, reshow, sender, ...)
|
||||
if sender then
|
||||
self.sysram.last_player = sender:get_player_name()
|
||||
self.sysram.current_player = sender:get_player_name()
|
||||
else
|
||||
self.sysram.current_player = nil
|
||||
end
|
||||
local ret = app:receive_data(method, reshow, sender, ...)
|
||||
|
||||
if self.sysram.current_app == appname and reshow then
|
||||
local formspec = app:get_formspec()
|
||||
if formspec ~= false then
|
||||
self.meta:set_string('formspec', formspec)
|
||||
end
|
||||
end
|
||||
if sender then
|
||||
self.sysram.last_player = sender:get_player_name()
|
||||
else
|
||||
self.sysram.last_player = nil
|
||||
end
|
||||
|
||||
self:save()
|
||||
return ret
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user