updated investigator scaling

This commit is contained in:
Chr1Z93 2024-06-13 13:56:46 +02:00
parent 21cbeb220d
commit 4928822051
2 changed files with 31 additions and 29 deletions

View File

@ -6,8 +6,8 @@ local SPREAD_X_SHIFT = -3.66
Spawner = { } Spawner = { }
-- Spawns a list of cards at the given position/rotation. This will separate cards by size - -- Spawns a list of cards at the given position/rotation. This will separate cards by size -
-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If -- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If
-- there are different types, the provided callback will be called once for each type as it spawns -- there are different types, the provided callback will be called once for each type as it spawns
-- either a card or deck. -- either a card or deck.
---@param cardList table A list of Player Card data structures (data/metadata) ---@param cardList table A list of Player Card data structures (data/metadata)
@ -33,8 +33,8 @@ Spawner.spawnCards = function(cardList, pos, rot, sort, callback)
table.insert(standardCards, card) table.insert(standardCards, card)
end end
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 } local position = { x = pos.x, y = pos.y, z = pos.z }
Spawner.spawn(investigatorCards, position, rot, callback) Spawner.spawn(investigatorCards, position, rot, callback)
@ -52,7 +52,7 @@ Spawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callb
local position = { x = startPos.x, y = startPos.y, z = startPos.z } local position = { x = startPos.x, y = startPos.y, z = startPos.z }
-- Special handle the first row if we have less than a full single row, but only if there's a -- Special handle the first row if we have less than a full single row, but only if there's a
-- reasonable max column count. Single-row spreads will send a large value for maxCols -- reasonable max column count. Single-row spreads will send a large value for maxCols
if maxCols < 100 and #cardList < maxCols then if maxCols < 100 and #cardList < maxCols then
position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT) position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)
end end
@ -75,7 +75,7 @@ Spawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callb
end end
end end
-- Spawn a specific list of cards. This method is for internal use and should not be called -- Spawn a specific list of cards. This method is for internal use and should not be called
-- directly, use spawnCards instead. -- directly, use spawnCards instead.
---@param cardList table A list of Player Card data structures (data/metadata) ---@param cardList table A list of Player Card data structures (data/metadata)
---@param pos table Position where the cards should be spawned (global) ---@param pos table Position where the cards should be spawned (global)
@ -90,25 +90,18 @@ Spawner.spawn = function(cardList, pos, rot, callback)
if cardList[1].data.SidewaysCard then if cardList[1].data.SidewaysCard then
rot = { rot.x, rot.y - 90, rot.z } rot = { rot.x, rot.y - 90, rot.z }
end end
spawnObjectData({ return spawnObjectData({
data = cardList[1].data, data = cardList[1].data,
position = pos, position = pos,
rotation = rot, rotation = rot,
callback_function = callback callback_function = callback
}) })
return
end end
-- For multiple cards, construct a deck and spawn that -- For multiple cards, construct a deck and spawn that
local deck = Spawner.buildDeckDataTemplate() local deckScaleX = cardList[1].data.Transform.scaleX
local deckScaleZ = cardList[1].data.Transform.scaleZ
-- Decks won't inherently scale to the cards in them. The card list being spawned should be all local deck = Spawner.buildDeckDataTemplate(deckScaleX, deckScaleZ)
-- 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 sidewaysDeck = true local sidewaysDeck = true
for _, spawnCard in ipairs(cardList) do 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 } rot = { rot.x, rot.y - 90, rot.z }
end end
spawnObjectData({ return spawnObjectData({
data = deck, data = deck,
position = pos, position = pos,
rotation = rot, rotation = rot,
@ -131,12 +124,12 @@ Spawner.spawn = function(cardList, pos, rot, callback)
}) })
end end
-- Inserts a card into the given deck. This does three things: -- Inserts a card into the given deck. This does three things:
-- 1. Add the card's data to ContainedObjects -- 1. Add the card's data to ContainedObjects
-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's -- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's
-- ID list. Note that the deck's ID list is "DeckIDs" even though it -- ID list. Note that the deck's ID list is "DeckIDs" even though it
-- contains a list of card Ids -- contains a list of card Ids
-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's -- 3. Extract the card's CustomDeck table and add it to the deck. The deck's
-- "CustomDeck" field is a list of all CustomDecks used by cards within the -- "CustomDeck" field is a list of all CustomDecks used by cards within the
-- deck, keyed by the DeckID and referencing the custom deck table -- deck, keyed by the DeckID and referencing the custom deck table
---@param deck table TTS deck data structure to add to ---@param deck table TTS deck data structure to add to
@ -176,20 +169,22 @@ end
-- creates a new table on each call without using metatables or previous -- 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 -- 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 ---@return table deck Table containing the minimal TTS deck data structure
Spawner.buildDeckDataTemplate = function() Spawner.buildDeckDataTemplate = function(deckScaleX, deckScaleZ)
local deck = {} local deck = {}
deck.Name = "Deck" deck.Name = "Deck"
-- Card data. DeckIDs and CustomDeck entries will be built from the cards -- Card data. DeckIDs and CustomDeck entries will be built from the cards
deck.ContainedObjects = {} deck.ContainedObjects = {}
deck.DeckIDs = {} deck.DeckIDs = {}
deck.CustomDeck = {} deck.CustomDeck = {}
-- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here -- 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 = { deck.Transform = {
scaleX = 1, scaleX = deckScaleX or 1,
scaleY = 1, scaleY = 1,
scaleZ = 1, scaleZ = deckScaleZ or 1,
} }
return deck return deck
@ -220,14 +215,14 @@ Spawner.getpbcn = function(metadata)
end end
end end
-- Comparison function used to sort the cards in a deck. Groups bonded or -- Comparison function used to sort the cards in a deck. Groups bonded or
-- permanent cards first, then sorts within theose types by name/subname. -- permanent cards first, then sorts within theose types by name/subname.
-- Normal cards will sort in standard alphabetical order, while -- Normal cards will sort in standard alphabetical order, while
-- permanent/bonded/customizable will be in reverse alphabetical order. -- permanent/bonded/customizable will be in reverse alphabetical order.
-- --
-- Since cards spawn in the order provided by this comparator, with the first -- Since cards spawn in the order provided by this comparator, with the first
-- cards ending up at the bottom of a pile, this ordering will spawn in reverse -- cards ending up at the bottom of a pile, this ordering will spawn in reverse
-- alphabetical order. This presents the cards in order for non-face-down -- alphabetical order. This presents the cards in order for non-face-down
-- areas, and presents them in order when Searching the face-down deck. -- areas, and presents them in order when Searching the face-down deck.
Spawner.cardComparator = function(card1, card2) Spawner.cardComparator = function(card1, card2)
local pbcn1 = Spawner.getpbcn(card1.metadata) local pbcn1 = Spawner.getpbcn(card1.metadata)

View File

@ -887,8 +887,15 @@ function maybeUpdateActiveInvestigator(card)
return return
end end
-- set proper scale for the card -- set proper scale for investigators
card.setScale({1.15, 1, 1.15}) 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.825, 1, 0.825 })
end
-- remove old action tokens -- remove old action tokens
for _, obj in ipairs(searchAroundSelf("isUniversalToken")) do for _, obj in ipairs(searchAroundSelf("isUniversalToken")) do