Merge pull request #714 from argonui/attachtment-helper

Updated Attachment Helper
This commit is contained in:
dscarpac 2024-06-14 18:21:18 -05:00 committed by GitHub
commit 5913a180e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,6 +49,12 @@ local BACKGROUNDS = {
fontcolor = { 1, 1, 1 },
icons = false
},
{
title = "Hunting Jacket",
url = "http://cloud-3.steamusercontent.com/ugc/2450601762292308846/0E171E3F3F0D016EEC574F3CA25738A46D95595C/",
fontcolor = { 1, 1, 1 },
icons = false
},
{
title = "Ikiaq",
url = "http://cloud-3.steamusercontent.com/ugc/2021606446228198966/5A408D8D760221DEA164E986B9BE1F79C4803071/",
@ -110,6 +116,7 @@ function onLoad(savedData)
printToColor("Show skill icons of cards: " .. tostring(showIcons), color, "White")
refresh()
end)
self.addContextMenuItem("Draw all cards", function(color) self.deal(self.getQuantity(), color) end)
end
-- gets the font color based on background url
@ -232,38 +239,30 @@ end
-- gets cost and icons for a card
function findCard(guid, name, GMNotes)
local icons = {}
local metadata = JSON.decode(GMNotes) or {}
local buttonLabel = name or "unnamed"
local hasIcons = false
if metadata.cost then
buttonLabel = "[" .. metadata.cost .. "] " .. buttonLabel
end
if showIcons then
if metadata ~= {} then
icons[1] = metadata.wildIcons
icons[2] = metadata.willpowerIcons
icons[3] = metadata.intellectIcons
icons[4] = metadata.combatIcons
icons[5] = metadata.agilityIcons
end
local IconTypes = { "Wild", "Willpower", "Intellect", "Combat", "Agility" }
local found = false
for i = 1, 5 do
if icons[i] ~= nil and icons[i] ~= "" then
if found == false then
local iconTypes = { "Wild", "Willpower", "Intellect", "Combat", "Agility" }
for _, iconName in ipairs(iconTypes) do
local mdName = string.lower(iconName) .. "Icons"
if metadata[mdName] ~= nil then
if hasIcons == false then
buttonLabel = buttonLabel .. "\n"
found = true
hasIcons = true
else
buttonLabel = buttonLabel .. " "
end
buttonLabel = buttonLabel .. IconTypes[i] .. ": " .. icons[i]
buttonLabel = buttonLabel .. iconName .. ": " .. metadata[mdName]
end
end
end
table.insert(cardsInBag, { buttonLabel = buttonLabel, hasIcons = (#icons > 0), name = name, guid = guid })
table.insert(cardsInBag, { buttonLabel = buttonLabel, hasIcons = hasIcons, name = name, guid = guid })
end
-- recreates buttons with up-to-date labels