mirror of
https://github.com/mt-mods/mail.git
synced 2025-07-05 14:10:31 -04:00
Add colors utilities (#121)
* Add colors utilities Local function get_base_color(), conversions hex <=> rgb, rgb color mixer, and global function get_color() * Round numbers to avoid eventual float in string.format * Simplify inbox/outbox mixing of color Use a single if statement for each property and concatenate to displayed_color then execute mail.get_color(displayed_color) instead of making many combined if statements * Convert 3-chars hex colors to 6-chars hex colors Could break the code, the hex convert to rgb always run on 6-chars * Rework color utility using tables Instead of one-letter symbols, it now supports tables of identifiers or single strings
This commit is contained in:
parent
802f9f727b
commit
3bad371353
15 changed files with 86 additions and 61 deletions
|
@ -65,7 +65,7 @@ function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
|
|||
button[3.5,9.5;2.5,0.5;selectall;]] .. S("(Un)select all") .. [[]
|
||||
|
||||
tablecolumns[color;text;text]
|
||||
table[0,0.7;5.75,7.45;outbox;]] .. mail.colors.header .. "," .. S("To") .. "," .. S("Subject")
|
||||
table[0,0.7;5.75,7.45;outbox;]] .. mail.get_color("header") .. "," .. S("To") .. "," .. S("Subject")
|
||||
local formspec = { outbox_formspec }
|
||||
|
||||
mail.message_drafts[name] = nil
|
||||
|
@ -73,6 +73,7 @@ function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
|
|||
if #messages > 0 then
|
||||
for _, message in ipairs(messages) do
|
||||
local selected_id = 0
|
||||
local displayed_color = {}
|
||||
-- check if message is in selection list and return its id
|
||||
if mail.selected_idxs.outbox[name] and #mail.selected_idxs.outbox[name] > 0 then
|
||||
for i, selected_msg in ipairs(mail.selected_idxs.outbox[name]) do
|
||||
|
@ -83,10 +84,9 @@ function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
|
|||
end
|
||||
end
|
||||
if selected_id > 0 then
|
||||
formspec[#formspec + 1] = "," .. mail.colors.selected
|
||||
else
|
||||
formspec[#formspec + 1] = ","
|
||||
table.insert(displayed_color, "selected")
|
||||
end
|
||||
formspec[#formspec + 1] = "," .. mail.get_color(displayed_color)
|
||||
formspec[#formspec + 1] = ","
|
||||
if string.len(message.to) > 20 then
|
||||
formspec[#formspec + 1] = minetest.formspec_escape(string.sub(message.to, 1, 17))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue