Merge branch 'main' into featured-and-notes

This commit is contained in:
Chr1Z93 2024-06-17 00:34:21 +02:00
commit 76f9f51894
3 changed files with 47 additions and 46 deletions

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

View File

@ -33,8 +33,8 @@ Spawner.spawnCards = function(cardList, pos, rot, sort, callback)
table.insert(standardCards, card)
end
end
-- Spawn each of the three types individually. Each Y position shift accounts for the thickness
-- of the spawned deck
-- Spawn each of the three types individually. Y position accounts for the thickness of the spawned deck
local position = { x = pos.x, y = pos.y, z = pos.z }
Spawner.spawn(investigatorCards, position, rot, callback)
@ -90,25 +90,18 @@ Spawner.spawn = function(cardList, pos, rot, callback)
if cardList[1].data.SidewaysCard then
rot = { rot.x, rot.y - 90, rot.z }
end
spawnObjectData({
return spawnObjectData({
data = cardList[1].data,
position = pos,
rotation = rot,
callback_function = callback
})
return
end
-- For multiple cards, construct a deck and spawn that
local deck = Spawner.buildDeckDataTemplate()
-- Decks won't inherently scale to the cards in them. The card list being spawned should be all
-- the same type/size by this point, so use the first card to set the size
deck.Transform = {
scaleX = cardList[1].data.Transform.scaleX,
scaleY = 1,
scaleZ = cardList[1].data.Transform.scaleZ
}
local deckScaleX = cardList[1].data.Transform.scaleX
local deckScaleZ = cardList[1].data.Transform.scaleZ
local deck = Spawner.buildDeckDataTemplate(deckScaleX, deckScaleZ)
local sidewaysDeck = true
for _, spawnCard in ipairs(cardList) do
@ -123,7 +116,7 @@ Spawner.spawn = function(cardList, pos, rot, callback)
rot = { rot.x, rot.y - 90, rot.z }
end
spawnObjectData({
return spawnObjectData({
data = deck,
position = pos,
rotation = rot,
@ -176,7 +169,7 @@ end
-- creates a new table on each call without using metatables or previous
-- definitions because we can't be sure that TTS doesn't modify the structure
---@return table deck Table containing the minimal TTS deck data structure
Spawner.buildDeckDataTemplate = function()
Spawner.buildDeckDataTemplate = function(deckScaleX, deckScaleZ)
local deck = {}
deck.Name = "Deck"
@ -186,10 +179,12 @@ Spawner.buildDeckDataTemplate = function()
deck.CustomDeck = {}
-- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here
-- Decks won't inherently scale to the cards in them. The card list being spawned should be all
-- the same type/size by this point, so use the first card to set the size
deck.Transform = {
scaleX = 1,
scaleX = deckScaleX or 1,
scaleY = 1,
scaleZ = 1,
scaleZ = deckScaleZ or 1,
}
return deck

View File

@ -887,8 +887,15 @@ function maybeUpdateActiveInvestigator(card)
return
end
-- set proper scale for the card
card.setScale({1.15, 1, 1.15})
-- set proper scale for investigators
local cardData = card.getData()
if cardData["SidewaysCard"] == true then
-- 115% for easier readability
card.setScale({ 1.15, 1, 1.15 })
else
-- Zoop-exported investigators are horizontal cards and TTS scales them differently
card.setScale({ 0.8214, 1, 0.8214 })
end
-- remove old action tokens
for _, obj in ipairs(searchAroundSelf("isUniversalToken")) do