unifieddyes support - sort dyes by extended color value
This commit is contained in:
parent
560ad2a754
commit
289f7f17e5
@ -3,3 +3,4 @@ sfinv?
|
|||||||
3d_armor?
|
3d_armor?
|
||||||
skinsdb?
|
skinsdb?
|
||||||
doc_items?
|
doc_items?
|
||||||
|
unifieddyes?
|
||||||
|
@ -157,7 +157,7 @@ local function update_group_selection(state, rebuild)
|
|||||||
if state.param.crafting_group_list[sel_id] then
|
if state.param.crafting_group_list[sel_id] then
|
||||||
state.param.crafting_craftable_list = grouped[state.param.crafting_group_list[sel_id]].items
|
state.param.crafting_craftable_list = grouped[state.param.crafting_group_list[sel_id]].items
|
||||||
table.sort(state.param.crafting_craftable_list, function(a,b)
|
table.sort(state.param.crafting_craftable_list, function(a,b)
|
||||||
return a.item < b.item
|
return a.sort_value < b.sort_value
|
||||||
end)
|
end)
|
||||||
grid:setList(state.param.crafting_craftable_list)
|
grid:setList(state.param.crafting_craftable_list)
|
||||||
label:setText(groups_sel:getSelectedItem())
|
label:setText(groups_sel:getSelectedItem())
|
||||||
|
@ -65,7 +65,7 @@ local function update_group_selection(state, changed_group)
|
|||||||
-- update grid list
|
-- update grid list
|
||||||
if outlist then
|
if outlist then
|
||||||
table.sort(outlist, function(a,b)
|
table.sort(outlist, function(a,b)
|
||||||
return a.item < b.item
|
return a.sort_value < b.sort_value
|
||||||
end)
|
end)
|
||||||
grid:setList(outlist)
|
grid:setList(outlist)
|
||||||
state.param.creative_outlist = outlist
|
state.param.creative_outlist = outlist
|
||||||
|
14
ui_tools.lua
14
ui_tools.lua
@ -432,6 +432,17 @@ function ui_tools.get_list_grouped(itemtable)
|
|||||||
end
|
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
|
-- Prepare root lists for all users
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
@ -449,6 +460,9 @@ local function prepare_root_lists()
|
|||||||
item = itemname,
|
item = itemname,
|
||||||
is_button = true
|
is_button = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry.sort_value = unifieddyes_getpaletteidx(entry) or itemname
|
||||||
|
|
||||||
if cache.citems[itemname].cgroups["shape"] then
|
if cache.citems[itemname].cgroups["shape"] then
|
||||||
table.insert(ui_tools.root_list_shape, entry)
|
table.insert(ui_tools.root_list_shape, entry)
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user