add group name to description. Some description related cleanups. Bugfix in groups sorting
This commit is contained in:
parent
8a7e87abcf
commit
4b20c2d306
@ -1,5 +1,4 @@
|
||||
local filter = smart_inventory.filter
|
||||
local txt = smart_inventory.txt
|
||||
|
||||
local cache = {}
|
||||
cache.cgroups = {}
|
||||
|
@ -1,5 +1,4 @@
|
||||
local txt = smart_inventory.txt
|
||||
local txt_usage = minetest.setting_getbool("smart_inventory_friendly_group_names") --or true
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- Filter class
|
||||
@ -18,11 +17,11 @@ function filter_class:check_item_by_def(def)
|
||||
end
|
||||
|
||||
function filter_class:_get_description(group)
|
||||
if txt_usage ~= false then
|
||||
if txt then
|
||||
if txt[group.name] then
|
||||
return txt[group.name]
|
||||
return txt[group.name].." ("..group.name..")"
|
||||
elseif group.parent and group.parent.childs[group.name] and txt[group.parent.name] then
|
||||
return txt[group.parent.name].." "..group.parent.childs[group.name]
|
||||
return txt[group.parent.name].." "..group.parent.childs[group.name].." ("..group.name..")"
|
||||
else
|
||||
return group.name
|
||||
end
|
||||
@ -33,11 +32,7 @@ end
|
||||
filter_class.get_description = filter_class._get_description
|
||||
|
||||
function filter_class:_get_keyword(group)
|
||||
if txt_usage ~= false then
|
||||
return group.name.." "..group.group_desc
|
||||
else
|
||||
return group.name
|
||||
end
|
||||
return group.group_desc
|
||||
end
|
||||
|
||||
filter_class.get_keyword = filter_class._get_keyword
|
||||
@ -331,9 +326,9 @@ filter.register_filter({
|
||||
check_item_by_def = function(self, def) end,
|
||||
get_description = function(self, group)
|
||||
local itemname = group.name:sub(12)
|
||||
if txt["ingredient"] and
|
||||
if txt and txt["ingredient"] and
|
||||
minetest.registered_items[itemname] and minetest.registered_items[itemname].description then
|
||||
return txt["ingredient"] .." "..minetest.registered_items[itemname].description
|
||||
return txt["ingredient"] .." "..minetest.registered_items[itemname].description.." ("..group.name..")"
|
||||
else
|
||||
return group.name
|
||||
end
|
||||
@ -342,7 +337,7 @@ filter.register_filter({
|
||||
if group.name ~= self.name then
|
||||
local itemname = group.name:sub(12)
|
||||
if minetest.registered_items[itemname] then
|
||||
return minetest.registered_items[itemname].description
|
||||
return itemname.." "..minetest.registered_items[itemname].description
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
local txt_usage = minetest.setting_getbool("smart_inventory_friendly_group_names") --or true
|
||||
if txt_usage == false then
|
||||
return {}
|
||||
return false
|
||||
end
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname()).."/locale"
|
||||
|
@ -85,7 +85,7 @@ local function update_page(state)
|
||||
local grouptext
|
||||
if k == "groups" then
|
||||
for gn, gv in pairs(v) do
|
||||
if txt["armor:"..gn] then
|
||||
if txt and txt["armor:"..gn] then
|
||||
grouptext = txt["armor:"..gn]
|
||||
else
|
||||
grouptext = "armor:"..gn
|
||||
@ -103,7 +103,7 @@ local function update_page(state)
|
||||
end
|
||||
end
|
||||
if is_physics then
|
||||
if txt["physics:"..k] then
|
||||
if txt and txt["physics:"..k] then
|
||||
grouptext = txt["physics:"..k]
|
||||
else
|
||||
grouptext = "physics:"..k
|
||||
@ -112,7 +112,7 @@ local function update_page(state)
|
||||
a_list:addItem(grouptext..": "..v)
|
||||
end
|
||||
else
|
||||
if txt["armor:"..k] then
|
||||
if txt and txt["armor:"..k] then
|
||||
grouptext = txt["armor:"..k]
|
||||
else
|
||||
grouptext = "armor:"..k
|
||||
|
26
ui_tools.lua
26
ui_tools.lua
@ -30,13 +30,17 @@ function ui_tools.update_group_selection(grouped, groups_sel, groups_tab)
|
||||
|
||||
table.sort(group_sorted, function(a,b)
|
||||
local sort_fixed_order = {
|
||||
["all"] = " ", -- at the begin
|
||||
["other"] = "ZZ1", -- at the end
|
||||
["shape"] = "ZZ2", --at the end
|
||||
["all"] = 5, -- at the begin
|
||||
["other"] = 80, -- at the end
|
||||
["shape"] = 90, --at the end
|
||||
}
|
||||
local aval = sort_fixed_order[a.name] or a.name
|
||||
local bval = sort_fixed_order[b.name] or b.name
|
||||
return aval < bval
|
||||
local aval = sort_fixed_order[a.name] or 10
|
||||
local bval = sort_fixed_order[b.name] or 10
|
||||
if aval ~= bval then
|
||||
return aval < bval
|
||||
else
|
||||
return a.name < b.name
|
||||
end
|
||||
end)
|
||||
|
||||
-- apply groups to the groups_sel table and to the new groups_tab
|
||||
@ -351,14 +355,20 @@ function ui_tools.get_list_grouped(itemtable)
|
||||
-- default groups
|
||||
outtab.all = {}
|
||||
outtab.all.name = "all"
|
||||
outtab.all.group_desc = txt[outtab.all.name] or "all"
|
||||
outtab.all.items = itemtable
|
||||
|
||||
outtab.other = {}
|
||||
outtab.other.name = "other"
|
||||
outtab.other.group_desc = txt[outtab.other.name] or "other"
|
||||
outtab.other.items = other
|
||||
|
||||
if txt then
|
||||
outtab.all.group_desc = txt[outtab.all.name] or "all"
|
||||
outtab.other.group_desc = txt[outtab.other.name] or "other"
|
||||
else
|
||||
outtab.all.group_desc = "all"
|
||||
outtab.other.group_desc = "other"
|
||||
end
|
||||
|
||||
return outtab
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user