From e4dbbc29fe3e8daeeb5ddfdb5a6bb0857eaa90f9 Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Tue, 8 Aug 2023 12:59:52 -0400 Subject: [PATCH 1/3] Added Remove Tour Support Added very simple functionality to delete the tour object on import. --- src/accessories/CampaignImporterExporter.ttslua | 2 ++ src/core/tour/TourApi.ttslua | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/core/tour/TourApi.ttslua diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 444db7ca..4f9b8880 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -51,6 +51,7 @@ local playAreaAPI = require("core/PlayAreaApi") local deckImporterApi = require("arkhamdb/DeckImporterApi") local optionPanelApi = require("core/OptionPanelApi") local blessCurseApi = require("chaosbag/BlessCurseManagerApi") +local tourApi = require("core/tour/TourApi") local campaignBoxGUID @@ -169,6 +170,7 @@ function createCampaignFromToken(importData) function() optionPanelApi.loadSettings(importData["options"]) end, 0.5 ) + tourApi.deleteTour() broadcastToAll("Campaign successfully imported!", Color.Green) end diff --git a/src/core/tour/TourApi.ttslua b/src/core/tour/TourApi.ttslua new file mode 100644 index 00000000..1e51b874 --- /dev/null +++ b/src/core/tour/TourApi.ttslua @@ -0,0 +1,11 @@ +do + local TourApi = {} + + local TOUR_GUID = "0e5aa8" + + TourApi.deleteTour = function() + getObjectFromGUID(TOUR_GUID).call("deleteStarter", nil, nil, nil) + end + + return TourApi +end \ No newline at end of file From 2e1ee1b2f87ab95a8715f76b68abf03be9675126 Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Tue, 8 Aug 2023 13:22:59 -0400 Subject: [PATCH 2/3] 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 From 302ebfe11cf759ee2ef66725b9d619c877e6479d Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Thu, 10 Aug 2023 16:47:31 -0400 Subject: [PATCH 3/3] Final PR Comments Addressed For sure this time XD --- .../CampaignImporterExporter.ttslua | 20 ++++++++++++------- src/core/tour/TourApi.ttslua | 11 ---------- 2 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 src/core/tour/TourApi.ttslua diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 97dc33b2..fe7834a7 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -51,7 +51,8 @@ local playAreaApi = require("core/PlayAreaApi") local deckImporterApi = require("arkhamdb/DeckImporterApi") local optionPanelApi = require("core/OptionPanelApi") local blessCurseApi = require("chaosbag/BlessCurseManagerApi") -local tourApi = require("core/tour/TourApi") + +local TOUR_GUID = "0e5aa8" local campaignBoxGUID @@ -151,18 +152,23 @@ function createCampaignFromToken(importData) --set investigator count playAreaApi.setInvestigatorCount(importData["clueCount"]) --set campaign guide page - if findCampaignGuide() then + local guide = findCampaignGuide() + if guide then Wait.condition( + -- Called after the condition function returns true function() - --log("Campaign Guide import successful!") + log("Campaign Guide import successful!") end, + -- Condition function that is called continiously until returs true or timeout is reached function() - findCampaignGuide().Book.setPage(importData["guide"]) - return findCampaignGuide().Book.getPage() == importData["guide"] + guide.Book.setPage(importData["guide"]) + return guide.Book.getPage() == importData["guide"] end, + -- Amount of time in seconds until the Wait times out 1, + -- Called if the Wait times out function() - --log("Campaign Guide import failed!") + log("Campaign Guide import failed!") end ) end @@ -170,7 +176,7 @@ function createCampaignFromToken(importData) function() optionPanelApi.loadSettings(importData["options"]) end, 0.5 ) - tourApi.deleteTour() + getObjectFromGUID(TOUR_GUID).destruct() playAreaApi.updateSurface(importData["playmat"]) broadcastToAll("Campaign successfully imported!", Color.Green) end diff --git a/src/core/tour/TourApi.ttslua b/src/core/tour/TourApi.ttslua deleted file mode 100644 index 1e51b874..00000000 --- a/src/core/tour/TourApi.ttslua +++ /dev/null @@ -1,11 +0,0 @@ -do - local TourApi = {} - - local TOUR_GUID = "0e5aa8" - - TourApi.deleteTour = function() - getObjectFromGUID(TOUR_GUID).call("deleteStarter", nil, nil, nil) - end - - return TourApi -end \ No newline at end of file