Skip to content

Commit

Permalink
1.1.x (#68)
Browse files Browse the repository at this point in the history
* Fix close button which makes the formspec blinking (#65)

* Fix header click + use them as sorting (#66)

* Abort checking messages when clicking on a header row (indexing a nil value)

* Use headers clicks to change sorting

* Fix oversized selected number #67  (#67)

* about.lua to 1.1.1
  • Loading branch information
Athozus authored Apr 15, 2023
1 parent 54a566f commit 79d5ad8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/about.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function mail.show_about(name)
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.0]
label[0,0.8;Version: 1.1.1]
label[0,1.4;Licenses:]
label[0.2,1.8;Expat (code), WTFPL (textures)]
label[0,2.4;https://github.com/mt-mods/mail]
Expand Down
28 changes: 27 additions & 1 deletion ui/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "mail:inbox" and formname ~= "mail:sent" and formname ~= "mail:drafts" then
return
elseif fields.quit then
return
end

-- Get player name and handle / convert common input fields
Expand Down Expand Up @@ -50,6 +52,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Hanmdle formspec event
if fields.inbox then -- inbox table
local evt = minetest.explode_table_event(fields.inbox)
if evt.row == 1 then -- header
if mail.selected_idxs.sortfield[name] == evt.column-1 then -- if already this field, then change direction
mail.selected_idxs.sortdirection[name] = mail.selected_idxs.sortdirection[name] == "2" and "1" or "2"
end
mail.selected_idxs.sortfield[name] = evt.column-1 -- update column
mail.show_mail_menu(name)
return
end
if mail.selected_idxs.multipleselection[name] then
if not mail.selected_idxs.inbox[name] then
mail.selected_idxs.inbox[name] = {}
Expand Down Expand Up @@ -80,6 +90,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)

if fields.sent then -- sent table
local evt = minetest.explode_table_event(fields.sent)
if evt.row == 1 then -- header
if mail.selected_idxs.sortfield[name] == evt.column-1 then -- if already this field, then change direction
mail.selected_idxs.sortdirection[name] = mail.selected_idxs.sortdirection[name] == "2" and "1" or "2"
end
mail.selected_idxs.sortfield[name] = evt.column-1 -- update column
mail.show_mail_menu(name)
return
end
if mail.selected_idxs.multipleselection[name] then
if not mail.selected_idxs.sent[name] then
mail.selected_idxs.sent[name] = {}
Expand Down Expand Up @@ -110,6 +128,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)

if fields.drafts then -- drafts table
local evt = minetest.explode_table_event(fields.drafts)
if evt.row == 1 then -- header
if mail.selected_idxs.sortfield[name] == evt.column-1 then -- if already this field, then change direction
mail.selected_idxs.sortdirection[name] = mail.selected_idxs.sortdirection[name] == "2" and "1" or "2"
end
mail.selected_idxs.sortfield[name] = evt.column-1 -- update column
mail.show_mail_menu(name)
return
end
mail.selected_idxs.drafts[name] = evt.row - 1
if evt.type == "DCL" and messagesDrafts[mail.selected_idxs.drafts[name]] then
mail.show_compose(name,
Expand Down Expand Up @@ -248,7 +274,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if #mail.selected_idxs.sent[name] >= #getOutbox() then -- if selection is full
mail.selected_idxs.sent[name] = {}
else
mail.selected_idxs.inbox[name] = {} -- reset to avoid duplicates
mail.selected_idxs.sent[name] = {} -- reset to avoid duplicates
mail.selected_idxs.multipleselection[name] = true
for _, msg in ipairs(getOutbox()) do
table.insert(mail.selected_idxs.sent[name], msg.id)
Expand Down

0 comments on commit 79d5ad8

Please sign in to comment.