From 2e1ee1b2f87ab95a8715f76b68abf03be9675126 Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Tue, 8 Aug 2023 13:22:59 -0400 Subject: [PATCH] Added Playmat Image Support Added the ability to import playmat images --- src/accessories/CampaignImporterExporter.ttslua | 10 ++++++---- src/core/PlayAreaApi.ttslua | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 4f9b8880..97dc33b2 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -47,7 +47,7 @@ local DAMAGE_HORROR_GUIDS = { } local chaosBagApi = require("chaosbag/ChaosBagApi") -local playAreaAPI = require("core/PlayAreaApi") +local playAreaApi = require("core/PlayAreaApi") local deckImporterApi = require("arkhamdb/DeckImporterApi") local optionPanelApi = require("core/OptionPanelApi") local blessCurseApi = require("chaosbag/BlessCurseManagerApi") @@ -149,7 +149,7 @@ function createCampaignFromToken(importData) deckImporterApi.setUiState(importData["decks"]) end --set investigator count - playAreaAPI.setInvestigatorCount(importData["clueCount"]) + playAreaApi.setInvestigatorCount(importData["clueCount"]) --set campaign guide page if findCampaignGuide() then Wait.condition( @@ -171,6 +171,7 @@ function createCampaignFromToken(importData) 0.5 ) tourApi.deleteTour() + playAreaApi.updateSurface(importData["playmat"]) broadcastToAll("Campaign successfully imported!", Color.Green) end @@ -226,9 +227,10 @@ function createCampaignToken(_, playerColor, _) bag = chaosBagApi.getChaosBagState(), trauma = traumaValues, decks = deckImporterApi.getUiState(), - clueCount = playAreaAPI.getInvestigatorCount(), + clueCount = playAreaApi.getInvestigatorCount(), guide = campaignGuidePage, - options = optionPanelApi.getOptions() + options = optionPanelApi.getOptions(), + playmat = playAreaApi.getSurface() } campaignTokenData.GMNotes = JSON.encode(campaignData) campaignTokenData.Nickname = os.date("%b %d ") .. getObjectFromGUID(campaignBoxGUID).getName() .. " Save" diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 3bbc1be4..c141c61a 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -3,6 +3,8 @@ do local PLAY_AREA_GUID = "721ba2" + 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() @@ -83,5 +85,13 @@ do return getObjectFromGUID(PLAY_AREA_GUID).call("isInPlayArea", object) end + PlayAreaApi.getSurface = function() + return getObjectFromGUID(PLAY_AREA_GUID).getCustomObject().image + end + + PlayAreaApi.updateSurface = function(url) + return getObjectFromGUID(IMAGE_SWAPPER).call("updateSurface", url) + end + return PlayAreaApi end