unifieddyes support - sort dyes by extended color value

master
Alexander Weber 2018-04-11 21:21:50 +02:00
parent 560ad2a754
commit 289f7f17e5
4 changed files with 17 additions and 2 deletions

View File

@ -3,3 +3,4 @@ sfinv?
3d_armor?
skinsdb?
doc_items?
unifieddyes?

View File

@ -157,7 +157,7 @@ local function update_group_selection(state, rebuild)
if state.param.crafting_group_list[sel_id] then
state.param.crafting_craftable_list = grouped[state.param.crafting_group_list[sel_id]].items
table.sort(state.param.crafting_craftable_list, function(a,b)
return a.item < b.item
return a.sort_value < b.sort_value
end)
grid:setList(state.param.crafting_craftable_list)
label:setText(groups_sel:getSelectedItem())

View File

@ -65,7 +65,7 @@ local function update_group_selection(state, changed_group)
-- update grid list
if outlist then
table.sort(outlist, function(a,b)
return a.item < b.item
return a.sort_value < b.sort_value
end)
grid:setList(outlist)
state.param.creative_outlist = outlist

View File

@ -432,6 +432,17 @@ function ui_tools.get_list_grouped(itemtable)
end
local function unifieddyes_getpaletteidx() end
if minetest.global_exists("unifieddyes") then
function unifieddyes_getpaletteidx(entry)
local ret = unifieddyes.getpaletteidx(entry.item, "extended")
if ret then
local ret2= string.format("%02X", ret)
return 'dye '..ret2
end
end
end
-----------------------------------------------------
-- Prepare root lists for all users
-----------------------------------------------------
@ -449,6 +460,9 @@ local function prepare_root_lists()
item = itemname,
is_button = true
}
entry.sort_value = unifieddyes_getpaletteidx(entry) or itemname
if cache.citems[itemname].cgroups["shape"] then
table.insert(ui_tools.root_list_shape, entry)
else