Skip to content

Commit

Permalink
Move contributor_grouping to selected_idxs
Browse files Browse the repository at this point in the history
  • Loading branch information
Athozus committed Apr 6, 2024
1 parent 3670fe7 commit c6d8543
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mail = {
multipleselection = {},
optionstab = {},
settings_group = {},
contributor_grouping = {},
},

message_drafts = {}
Expand Down
17 changes: 10 additions & 7 deletions ui/about.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ local contributors = {
{ name = "y5nw", groups = {"c", "i"} },
}

function mail.show_about(name, contributor_grouping)
contributor_grouping = tonumber(contributor_grouping) or 1
function mail.show_about(name)
mail.selected_idxs.contributor_grouping[name] = tonumber(mail.selected_idxs.contributor_grouping[name]) or 1

local formspec = [[
size[10,6;]
Expand All @@ -71,14 +71,16 @@ function mail.show_about(name, contributor_grouping)
button[2,5.7;2,0.5;contentdb;ContentDB]
box[4,0;3,0.45;]] .. mail.get_color("highlighted") .. [[]
label[4.2,0;]] .. S("Contributors") .. "]" ..
label[4.2,0;]] .. S("Contributors") .. [[]
("dropdown[4,0.75;6.4;contributor_grouping;%s,%s;%d;true]"):format(
S("Group by name"), S("Group by contribution"), contributor_grouping)
dropdown[4,0.75;6.4;contributor_grouping;]]
.. S("Group by name") .. ","
.. S("Group by contribution") .. ";" .. mail.selected_idxs.contributor_grouping[name] .. [[;true]
]]

local contributor_list, contributor_columns = {}

if contributor_grouping == 2 then
if mail.selected_idxs.contributor_grouping[name] == 2 then
contributor_columns = "color;text"
local sorted = {}
for _, g in ipairs(groups) do
Expand Down Expand Up @@ -144,6 +146,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.contentdb then
minetest.chat_send_player(playername, "https://content.minetest.net/packages/mt-mods/mail")
elseif fields.contributor_grouping then
mail.show_about(playername, fields.contributor_grouping)
mail.selected_idxs.contributor_grouping[playername] = fields.contributor_grouping
mail.show_about(playername)
end
end)

0 comments on commit c6d8543

Please sign in to comment.