diff --git a/src/arkhamdb/ArkhamDb.ttslua b/src/arkhamdb/ArkhamDb.ttslua index 6f1957af..286f58f1 100644 --- a/src/arkhamdb/ArkhamDb.ttslua +++ b/src/arkhamdb/ArkhamDb.ttslua @@ -57,7 +57,7 @@ do callback) -- Get a simple card to see if the bag indexes are complete. If not, abort -- the deck load. The called method will handle player notification. - local checkCard = allCardsBagApi.getCardById({ id = "01001" }) + local checkCard = allCardsBagApi.getCardById("01001") if (checkCard ~= nil and checkCard.data == nil) then return end @@ -241,7 +241,7 @@ do internal.maybeAddCustomizeUpgradeSheets = function(slots) for cardId, _ in pairs(slots) do -- upgrade sheets for customizable cards - local upgradesheet = allCardsBagApi.getCardById({ id = cardId .. "-c" }) + local upgradesheet = allCardsBagApi.getCardById(cardId .. "-c") if upgradesheet ~= nil then slots[cardId .. "-c"] = 1 end @@ -282,7 +282,7 @@ do local bondedCards = { } local bondedList = { } for cardId, cardCount in pairs(slots) do - local card = allCardsBagApi.getCardById({ id = cardId }) + local card = allCardsBagApi.getCardById(cardId) if (card ~= nil and card.metadata.bonded ~= nil) then for _, bond in ipairs(card.metadata.bonded) do bondedCards[bond.id] = bond.count @@ -311,9 +311,9 @@ do -- Make sure there's a taboo version of the card before we replace it -- SCED only maintains the most recent taboo cards. If a deck is using -- an older taboo list it's possible the card isn't a taboo any more - local tabooCard = allCardsBagApi.getCardById({ id = cardId .. "-t" }) + local tabooCard = allCardsBagApi.getCardById(cardId .. "-t") if tabooCard == nil then - local basicCard = allCardsBagApi.getCardById({ id = cardId }) + local basicCard = allCardsBagApi.getCardById(cardId) internal.maybePrint("Taboo version for " .. basicCard.data.Nickname .. " is not available. Using standard version", playerColor) else slots[cardId .. "-t"] = slots[cardId] diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 3bd4f069..8c0cfb2f 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -74,7 +74,7 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo local yPos = {} local cardsToSpawn = {} for cardId, cardCount in pairs(slots) do - local card = allCardsBagApi.getCardById({ id = cardId }) + local card = allCardsBagApi.getCardById(cardId) if card ~= nil then local cardZone = getDefaultCardZone(card.metadata, bondedList) for i = 1, cardCount do @@ -183,7 +183,7 @@ end -- Returns the simple name of a card given its ID. This will find the card and strip any trailing -- SCED-specific suffixes such as (Taboo) or (Level) function getCardName(cardId) - local card = allCardsBagApi.getCardById({ id = cardId }) + local card = allCardsBagApi.getCardById(cardId) if (card ~= nil) then local name = card.data.Nickname if (string.find(name, " %(")) then diff --git a/src/arkhamdb/DeckImporterUi.ttslua b/src/arkhamdb/DeckImporterUi.ttslua index 4c9b8f08..59ad1ac8 100644 --- a/src/arkhamdb/DeckImporterUi.ttslua +++ b/src/arkhamdb/DeckImporterUi.ttslua @@ -219,7 +219,6 @@ function loadDecks() -- testLoadLotsOfDecks() -- Method in DeckImporterMain, visible due to inclusion - -- TODO: Make this use the configuration ID for the all cards bag local indexReady = allCardsBagApi.isIndexReady() if (not indexReady) then broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2}) diff --git a/src/chaosbag/ChaosBagApi.ttslua b/src/chaosbag/ChaosBagApi.ttslua index 4a95830f..e0252266 100644 --- a/src/chaosbag/ChaosBagApi.ttslua +++ b/src/chaosbag/ChaosBagApi.ttslua @@ -50,8 +50,8 @@ do end -- called by playermats (by the "Draw chaos token" button) - ChaosBagApi.drawChaosToken = function(params) - return Global.call("drawChaosToken", params) + ChaosBagApi.drawChaosToken = function(mat, tokenOffset, isRightClick) + return Global.call("drawChaosToken", {mat, tokenOffset, isRightClick}) end -- returns a Table List of chaos token ids in the current chaos bag diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index d182b272..54e09d5a 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -28,6 +28,8 @@ local collisionEnabled = false -- used for recreating the link to a custom data helper after image change customDataHelper = nil +local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/" + local SHIFT_OFFSETS = { left = { x = 0.00, y = 0, z = 7.67 }, right = { x = 0.00, y = 0, z = -7.67 }, @@ -94,6 +96,29 @@ function updateLocations(args) end end +function updateSurface(newURL) + local customInfo = self.getCustomObject() + + if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then + customInfo.image = newURL + broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 }) + else + customInfo.image = DEFAULT_URL + broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 }) + end + + self.setCustomObject(customInfo) + + local guid = nil + + if customDataHelper then guid = customDataHelper.getGUID() end + self.reload() + + if guid ~= nil then + Wait.time(function() updateLocations({ guid }) end, 1) + end +end + function onCollisionEnter(collisionInfo) local obj = collisionInfo.collision_object local objType = obj.name diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index d262aa17..66784904 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -4,8 +4,6 @@ do local PLAY_AREA_GUID = "721ba2" local INVESTIGATOR_COUNTER_GUID = "f182ee" - local IMAGE_SWAPPER = "b7b45b" - -- Returns the current value of the investigator counter from the playmat ---@return Integer. Number of investigators currently set on the counter PlayAreaApi.getInvestigatorCount = function() @@ -91,7 +89,7 @@ do end PlayAreaApi.updateSurface = function(url) - return getObjectFromGUID(IMAGE_SWAPPER).call("updateSurface", url) + return getObjectFromGUID(PLAY_AREA_GUID).call("updateSurface", url) end -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the @@ -105,17 +103,5 @@ do return getObjectFromGUID(PLAY_AREA_GUID).getVar("customDataHelper") end - PlayAreaApi.getCustomObject = function() - return getObjectFromGUID(PLAY_AREA_GUID).getCustomObject() - end - - PlayAreaApi.setCustomObject = function(customInfo) - return getObjectFromGUID(PLAY_AREA_GUID).setCustomObject(customInfo) - end - - PlayAreaApi.reload = function() - return getObjectFromGUID(PLAY_AREA_GUID).reload() - end - return PlayAreaApi end diff --git a/src/core/PlayAreaSelector.ttslua b/src/core/PlayAreaSelector.ttslua index ac1a7dcb..e5958102 100644 --- a/src/core/PlayAreaSelector.ttslua +++ b/src/core/PlayAreaSelector.ttslua @@ -1,5 +1,4 @@ local controlActive = false -local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/" local playAreaAPI = require("core/PlayAreaApi") -- parameters for open/close button for reusing @@ -63,38 +62,16 @@ end -- click function for apply button function click_applySurface(_, _, isRightClick) - updateSurface(isRightClick and "" or self.getInputs()[1].value) + playAreaAPI.updateSurface(isRightClick and "" or self.getInputs()[1].value) +end + +function updateSurface(newURL) + playAreaAPI.updateSurface(newURL) end -- input function for the input box function none() end --- main function (can be called by other objects) -function updateSurface(newURL) - local customInfo = playAreaAPI.getCustomObject() - - if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then - customInfo.image = newURL - broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 }) - else - customInfo.image = DEFAULT_URL - broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 }) - end - - playAreaAPI.setCustomObject(customInfo) - - -- get custom data helper and call the playarea with it after reloading - local customDataHelper = playAreaAPI.getCustomDataHelper() - local guid - - if customDataHelper then guid = customDataHelper.getGUID() end - playAreaAPI.reload() - - if guid ~= nil then - Wait.time(function() playAreaAPI.updateLocations({ guid }) end, 1) - end -end - -- creates the main button function createOpenCloseButton() buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel" diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 8cfa95b0..c9223331 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -9,8 +9,8 @@ do -- returned. Otherwise, a single table with the following fields -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata - AllCardsBagApi.getCardById = function(params) - return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardById", params) + AllCardsBagApi.getCardById = function(id) + return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardById", {id = id}) end -- Gets a random basic weakness from the bag. Once a given ID has been returned @@ -37,11 +37,11 @@ do -- Searches the bag for cards which match the given name and returns a list. Note that this is -- an O(n) search without index support. It may be slow. - -- @param array must contain these fields to define the search: + -- @param -- name String or string fragment to search for names -- exact Whether the name match should be exact - AllCardsBagApi.getCardsByName = function(params) - return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByName", params) + AllCardsBagApi.getCardsByName = function(name, exact) + return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByName", {name = name, exact = exact}) end AllCardsBagApi.isBagPresent = function() @@ -49,15 +49,15 @@ do end -- Returns a list of cards from the bag matching a class and level (0 or upgraded) - -- @param table: + -- @param -- class: String class to retrieve ("Guardian", "Seeker", etc) - -- isUpgraded: true for upgraded cards (Level 1-5), false for Level 0 + -- upgraded: true for upgraded cards (Level 1-5), false for Level 0 -- @return: If the indexes are still being constructed, returns an empty table. -- Otherwise, a list of tables, each with the following fields -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata - AllCardsBagApi.getCardsByClassAndLevel = function(params) - return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", params) + AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded) + return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", {class = class, upgraded = upgraded}) end AllCardsBagApi.getCardsByCycle = function(cycle) diff --git a/src/playercards/CardSearch.ttslua b/src/playercards/CardSearch.ttslua index 43ce8d0c..fd4f7e3d 100644 --- a/src/playercards/CardSearch.ttslua +++ b/src/playercards/CardSearch.ttslua @@ -108,7 +108,7 @@ function search() end -- search all objects in bag - local cardList = allCardsBagApi.getCardsByName({ name = inputParameters.value, exact = searchExact }) + local cardList = allCardsBagApi.getCardsByName(inputParameters.value, searchExact) if cardList == nil or #cardList == 0 then printToAll("No match found.", "Red") return diff --git a/src/playercards/PlayerCardPanel.ttslua b/src/playercards/PlayerCardPanel.ttslua index 5d0f55d8..135699ab 100644 --- a/src/playercards/PlayerCardPanel.ttslua +++ b/src/playercards/PlayerCardPanel.ttslua @@ -583,13 +583,13 @@ function placeClassCards(cardClass, isUpgraded) broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2}) return end - local cardIdList = allCardsBagApi.getCardsByClassAndLevel({class = cardClass, upgraded = isUpgraded}) + local cardIdList = allCardsBagApi.getCardsByClassAndLevel(cardClass, isUpgraded) local skillList = { } local eventList = { } local assetList = { } for _, cardId in ipairs(cardIdList) do - local cardMetadata = allCardsBagApi.getCardById({ id = cardId }).metadata + local cardMetadata = allCardsBagApi.getCardById(cardId).metadata if (cardMetadata.type == "Skill") then table.insert(skillList, cardId) elseif (cardMetadata.type == "Event") then @@ -700,7 +700,7 @@ function spawnWeaknesses() local basicWeaknessList = { } local otherWeaknessList = { } for i, id in ipairs(weaknessIdList) do - local cardMetadata = allCardsBagApi.getCardById({ id = id }).metadata + local cardMetadata = allCardsBagApi.getCardById(id).metadata if cardMetadata.basicWeaknessCount ~= nil and cardMetadata.basicWeaknessCount > 0 then table.insert(basicWeaknessList, id) elseif excludedNonBasicWeaknesses[id] == nil then diff --git a/src/playercards/SpawnBag.ttslua b/src/playercards/SpawnBag.ttslua index 1042c037..5591ec53 100644 --- a/src/playercards/SpawnBag.ttslua +++ b/src/playercards/SpawnBag.ttslua @@ -92,7 +92,7 @@ do local cardsToSpawn = { } local cardList = spawnSpec.cards for _, cardId in ipairs(cardList) do - local cardData = allCardsBagApi.getCardById({ id = cardId }) + local cardData = allCardsBagApi.getCardById(cardId) if (cardData ~= nil) then table.insert(cardsToSpawn, cardData) else diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 387db44a..0c99d6a2 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -774,7 +774,7 @@ end --------------------------------------------------------- function drawChaosTokenButton(_, _, isRightClick) - chaosBagApi.drawChaosToken({self, DRAWN_CHAOS_TOKEN_OFFSET, isRightClick}) + chaosBagApi.drawChaosToken(self, DRAWN_CHAOS_TOKEN_OFFSET, isRightClick) end function drawEncountercard(_, _, isRightClick)