diff --git a/components/ConfigEditor.lua b/components/ConfigEditor.lua index cb18312..b543626 100644 --- a/components/ConfigEditor.lua +++ b/components/ConfigEditor.lua @@ -161,10 +161,16 @@ if not subSchema.__type or true then local fields = subSchema local xOffset = 0 + local isArray = false + local arrayLabel = nil if subSchema.__type and subSchema.__type:sub(1,5) == "array" and subSchema.__entry then fields = score.copyDeep(subConfig) numKeys = numKeys + 1 xOffset = 1 + isArray = true + if subSchema.__label then + arrayLabel = subSchema.__label + end end for k, _ in pairs(fields) do numKeys = numKeys + 1 @@ -303,17 +309,30 @@ end end if type(v) == "table" or type(v) == "string" and v:sub(1,5) == "sound" then + local label = k + if isArray and arrayLabel then + local labelPath = fullPath .. "." .. arrayLabel + if labelPath:sub(1,1) == "." then + labelPath = labelPath:sub(2) + end + if type(v) == "table" and configDiffs[labelPath] then + label = configDiffs[labelPath] + elseif type(v) == "table" and subConfig[tonumber(k)] and subConfig[tonumber(k)][arrayLabel] then + label = subConfig[tonumber(k)][arrayLabel] + end + end + print(textutils.serialize(configDiffs)) if textY >= props.y + 1 and textY <= props.y + props.height then table.insert(elements, BasicButton { key = "config-"..k, display = props.display, align = "left", - text = " " .. k .. " ", + text = " " .. label .. " ", x = props.x + xOffset, y = textY, color = buttonTextColor, bg = buttonColor, - width = math.min(#k+2, props.width - 2) - xOffset, + width = math.min(#label+2, props.width - 2) - xOffset, onClick = function() props.terminalState.scroll = 0 table.insert(paths, k) @@ -332,7 +351,7 @@ y = textY, color = buttonTextColor, bg = buttonColor, - width = math.min(#k+2, props.width - 2) - xOffset, + width = math.min(#label+2, props.width - 2) - xOffset, onClick = function() props.terminalState.scroll = 0 table.insert(paths, k) diff --git a/core/schemas.lua b/core/schemas.lua index 544d3df..ce428d5 100644 --- a/core/schemas.lua +++ b/core/schemas.lua @@ -171,6 +171,7 @@ }, currencies = { __type = "array", + __label = "id", __min = 1, __entry = { id = "string", @@ -214,6 +215,7 @@ local productsSchema = { __type = "array", + __label = "name", __entry = { modid = "string?", productId = "string?", @@ -225,6 +227,7 @@ price = "number", priceOverrides = { __type = "array?", + __label = "currency", __entry = { currency = "string", price = "number" @@ -232,6 +235,7 @@ }, bundle = { __type = "array?", + __label = "product", __entry = { product = "string", quantity = "number" diff --git a/radon.lua b/radon.lua index 648d5b9..7932fe9 100644 --- a/radon.lua +++ b/radon.lua @@ -1,4 +1,4 @@ -local version = "1.3.23" +local version = "1.3.24" local configHelpers = require "util.configHelpers" local schemas = require "core.schemas" local ScanInventory = require("core.inventory.ScanInventory")