added image loading

This commit is contained in:
Chr1Z93 2023-11-29 13:11:25 +01:00
parent 94d544fc02
commit 422aa58f53
10 changed files with 172 additions and 92 deletions

View File

@ -1 +1 @@
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showPlayermatHider":false,"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}}
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showPlayermatHider":false,"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}}

View File

@ -62,6 +62,7 @@ local GuidReferences = {
OptionPanelSource = "830bd0",
PlaceholderBoxDummy = "a93466",
PlayArea = "721ba2",
PlayAreaImageSelector = "b7b45b",
PlayAreaZone = "a2f932",
PlayerCardPanel = "2d30ee",
ResourceTokenBag = "9fadf9",

View File

@ -48,7 +48,7 @@ local currentListItem = 1
local xmlVisibility = {
downloadWindow = false,
optionPanel = false,
playareaGallery = false,
playAreaGallery = false,
updateNotification = false
}
local tabIdTable = {
@ -867,10 +867,10 @@ function onClick_toggleUi(player, title)
navigationOverlayApi.cycleVisibility(player.color)
return
-- hide the playareaGallery if visible
elseif title == "downloadWindow" and xmlVisibility.playareaGallery then
onClick_toggleUi(_, "playareaGallery")
elseif title == "downloadWindow" and xmlVisibility.playAreaGallery then
onClick_toggleUi(_, "playAreaGallery")
-- hide the downloadWindow if visible
elseif title == "playareaGallery" and xmlVisibility.downloadWindow then
elseif title == "playAreaGallery" and xmlVisibility.downloadWindow then
onClick_toggleUi(_, "downloadWindow")
end
@ -884,8 +884,8 @@ function onClick_toggleUi(player, title)
end
-- forwards the call to the onClick function
function togglePlayareaGallery()
onClick_toggleUi(_, "playareaGallery")
function togglePlayAreaGallery()
onClick_toggleUi(_, "playAreaGallery")
end
-- updates the preview window
@ -1151,7 +1151,7 @@ function onClick_toggleOption(_, id)
applyOptionPanelChange(id, state)
end
-- color selection for playarea
-- color selection for playArea
function onClick_playAreaConnectionColor(player, _, id)
player.showColorDialog(optionPanel[id], function(color)
applyOptionPanelChange(id, color)
@ -1196,7 +1196,6 @@ function updateOptionPanelState()
local dropdownId = returnResourceCounterId(optionValue) - 1
UI.setAttribute(id, "value", dropdownId)
elseif id == "playAreaConnectionColor" then
log(optionValue)
UI.setAttribute(id, "color", "#" .. Color.new(optionValue):toHex())
elseif (type(optionValue) == "boolean" and optionValue)
or (type(optionValue) == "string" and optionValue)
@ -1246,6 +1245,10 @@ function applyOptionPanelChange(id, state)
elseif id == "showTitleSplash" then
optionPanel[id] = state
-- option: Change custom playarea image on setup
elseif id == "changePlayAreaImage" then
optionPanel[id] = state
-- option: Show clean up helper
elseif id == "showCleanUpHelper" then
optionPanel[id] = spawnOrRemoveHelper(state, "Clean Up Helper", {-66, 1.6, 46})

View File

@ -104,8 +104,15 @@ end
-- fires if the scenario title changes
function fireScenarioChangedEvent()
-- maybe show the title splash screen
Wait.frames(function() Global.call('titleSplash', currentScenario) end, 20)
-- set the scenario for the playarea (connections might be disabled)
playAreaApi.onScenarioChanged(currentScenario)
-- maybe update the playarea image
local playAreaImageSelector = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaImageSelector")
playAreaImageSelector.call("maybeUpdatePlayAreaImage", currentScenario)
end
-- fires if the scenario title or the difficulty changes

View File

@ -84,6 +84,7 @@ function updateLocations(args)
end
end
-- sets the image of the playarea
function updateSurface(newURL)
local customInfo = self.getCustomObject()
@ -107,6 +108,7 @@ function updateSurface(newURL)
end
end
-- TTS event, called for each object that is placed on the playarea
function onCollisionEnter(collisionInfo)
local obj = collisionInfo.collision_object
local objType = obj.name

View File

@ -6,11 +6,11 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/6NWqg1K/Zealot-Gathering.jpg"
},
{
Name = "III - Devourer Below 1",
Name = "III - The Devourer Below 1",
URL = "https://i.ibb.co/x5QFzrx/Zealot-3-Devourer-Below-Helen-Castelow.png"
},
{
Name = "III - Devourer Below 2",
Name = "III - The Devourer Below 2",
URL = "https://i.ibb.co/6r6LFGz/Zealot-3-Devourer-Below-Sarah-Miller.png"
}
},
@ -28,31 +28,31 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/nnJdwL2/Dunwich-1-Extracurricular-Activity-Tomasz-Jedruszek.jpg"
},
{
Name = "I-B - House Always Wins 1",
Name = "I-B - The House Always Wins 1",
URL = "https://i.ibb.co/8XPLdr9/Dunwich-2-House-Always-Wins-Jonny-Klein.jpg"
},
{
Name = "I-B - House Always Wins 2",
Name = "I-B - The House Always Wins 2",
URL = "https://i.ibb.co/HtX95GK/Dunwich-2-House-Always-Wins-Robert-Laskey.jpg"
},
{
Name = "I-B - House Always Wins 3",
Name = "I-B - The House Always Wins 3",
URL = "https://i.ibb.co/MCLP3Sz/Dunwich-2-House-Always-Wins-XX-l.jpg"
},
{
Name = "I-B - House Always Wins 4",
Name = "I-B - The House Always Wins 4",
URL = "https://i.ibb.co/w7Pf5sd/Dunwich-2-House-Always-Wins-XX-l-2.jpg"
},
{
Name = "II - Miskatonic Museum 1",
Name = "II - The Miskatonic Museum 1",
URL = "https://i.ibb.co/x1Kf7qG/Dunwich-3-Miskatonic-Museum-Emre-Aktuna.jpg"
},
{
Name = "II - Miskatonic Museum 2",
Name = "II - The Miskatonic Museum 2",
URL = "https://i.ibb.co/yWXVPcN/Dunwich-3-Miskatonic-Museum-Richard-Wright.jpg"
},
{
Name = "III - Essex County Express",
Name = "III - The Essex County Express",
URL = "https://i.ibb.co/602CMZb/Dunwich-4-Essex-County-Express-David-Alvarez.jpg"
},
{
@ -126,15 +126,15 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/TcnKXJD/Carcosa-1-Curtain-Call-Mark-Molnar.jpg"
},
{
Name = "II - Last King 1",
Name = "II - The Last King 1",
URL = "https://i.ibb.co/JRQJKR8/Carcosa-2-Last-King-Cristi-Balanescu.jpg"
},
{
Name = "II - Last King 2",
Name = "II - The Last King 2",
URL = "https://i.ibb.co/NZzBwgv/Carcosa-2-Last-King-Cristi-Balanescu-2.jpg"
},
{
Name = "II - Last King 3",
Name = "II - The Last King 3",
URL = "https://i.ibb.co/x56ZHt7/Carcosa-2-Last-King-Wu-Mengjia.jpg"
},
{
@ -142,39 +142,39 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/R6gSm0D/Carcosa-3-Echoes-of-the-Past-Heather-Savage.jpg"
},
{
Name = "IV - Unspeakable Oath 1",
Name = "IV - The Unspeakable Oath 1",
URL = "https://i.ibb.co/DzzDQQQ/Carcosa-4-Unspeakable-Oath.jpg"
},
{
Name = "IV - Unspeakable Oath 2",
Name = "IV - The Unspeakable Oath 2",
URL = "https://i.ibb.co/9gqBzXr/Carcosa-4-Unspeakable-Oath-2-Mark-Molnar.jpg"
},
{
Name = "IV - Unspeakable Oath 3",
Name = "IV - The Unspeakable Oath 3",
URL = "https://i.ibb.co/wWL73c9/Carcosa-4-Unspeakable-Oath-Paul-Fairbairn.jpg"
},
{
Name = "V - Phantom of Truth 1",
Name = "V - A Phantom of Truth 1",
URL = "https://i.ibb.co/mzpz1Dd/Carcosa-5-Phantom-of-Truth-Lucas-Staniec.jpg"
},
{
Name = "V - Phantom of Truth 2",
Name = "V - A Phantom of Truth 2",
URL = "https://i.ibb.co/Vp1wNbT/Carcosa-5-Phantom-of-Truth-Tomasz-Jedruszek.jpg"
},
{
Name = "VI - Pallid Mask 1",
Name = "VI - The Pallid Mask 1",
URL = "https://i.ibb.co/Bf5LByY/Carcosa-6-Pallid-Mask-Greg-Bobrowski.jpg"
},
{
Name = "VI - Pallid Mask 2",
Name = "VI - The Pallid Mask 2",
URL = "https://i.ibb.co/1v1J9Xx/Carcosa-6-Pallid-Mask-Rafal-Pyra.jpg"
},
{
Name = "VII - Black Star Rises 1",
Name = "VII - Black Stars Rise 1",
URL = "https://i.ibb.co/TB451t7/Carcosa-7-Black-Star-Rises-Audric-Gatoux.jpg"
},
{
Name = "VII - Black Star Rises 2",
Name = "VII - Black Stars Rise 2",
URL = "https://i.ibb.co/nC8Ncxx/Carcosa-7-Black-Star-Rises-Chris-Kintner.jpg"
},
{
@ -188,35 +188,35 @@ PLAYAREA_IMAGE_DATA = {
},
["The Forgotten Age"] = {
{
Name = "I - Untamed Wilds 1",
Name = "I - The Untamed Wilds 1",
URL = "https://i.ibb.co/BLhwCG1/Forgotten-Age-1-Untamed-Wilds-David-Frasheski.jpg"
},
{
Name = "I - Untamed Wilds 2",
Name = "I - The Untamed Wilds 2",
URL = "https://i.ibb.co/SnJfsNy/Forgotten-Age-1-Untamed-Wilds-David-Frasheski-2.jpg"
},
{
Name = "I - Untamed Wilds 3",
Name = "I - The Untamed Wilds 3",
URL = "https://i.ibb.co/kcx1tvp/Forgotten-Age-1-Untamed-Wilds-Ethan-Patrick-Harris.jpg"
},
{
Name = "I - Untamed Wilds 4",
Name = "I - The Untamed Wilds 4",
URL = "https://i.ibb.co/HPbJwXk/Forgotten-Age-1-Untamed-Wilds-Lucas-Staniec.jpg"
},
{
Name = "I - Untamed Wilds 5",
Name = "I - The Untamed Wilds 5",
URL = "https://i.ibb.co/bbq1ZrK/Forgotten-Age-1-Untamed-Wilds-Nele-Diel.jpg"
},
{
Name = "II - Doom of Etzli 1",
Name = "II - The Doom of Etzli 1",
URL = "https://i.ibb.co/Pw4by4q/Forgotten-Age-2-Doom-of-Eztli-Cristi-Balanescu.jpg"
},
{
Name = "II - Doom of Etzli 2",
Name = "II - The Doom of Etzli 2",
URL = "https://i.ibb.co/xqW6cXR/Forgotten-Age-2-Doom-of-Eztli-Greg-Bobrowski.jpg"
},
{
Name = "II - Doom of Etzli 3",
Name = "II - The Doom of Etzli 3",
URL = "https://i.ibb.co/kgsC3pb/Forgotten-Age-2-Doom-of-Eztli-Nele-Diel.jpg"
},
{
@ -224,51 +224,51 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/Bn0Pjng/Forgotten-Age-3-Threads-of-Fate-Jokubas-Uogintas.jpg"
},
{
Name = "IV - Boundary Beyond 1",
Name = "IV - The Boundary Beyond 1",
URL = "https://i.ibb.co/yPZ9v2X/Forgotten-Age-4-Boundary-Beyond-Greg-Bobrowski-2-jpg.jpg"
},
{
Name = "IV - Boundary Beyond 2",
Name = "IV - The Boundary Beyond 2",
URL = "https://i.ibb.co/vm0JgFs/Forgotten-Age-4-Boundary-Beyond-Greg-Bobrowski-jpg.jpg"
},
{
Name = "IV - Boundary Beyond 3",
Name = "IV - The Boundary Beyond 3",
URL = "https://i.ibb.co/D1rh9Ry/Forgotten-Age-4-Boundary-Beyond-Nele-Diel.jpg"
},
{
Name = "V - Heart of the Elders I-1",
Name = "V - Heart of the Elders 1",
URL = "https://i.ibb.co/jzKvv6P/Forgotten-Age-5-Heart-of-the-Elders-I-Lucas-Staniec.jpg"
},
{
Name = "V - Heart of the Elders I-2",
Name = "V - Heart of the Elders 2",
URL = "https://i.ibb.co/mR79MX4/Forgotten-Age-5-Heart-of-the-Elders-I-Lucas-Staniec-2.jpg"
},
{
Name = "V - Heart of the Elders II",
Name = "V - Heart of the Elders 3",
URL = "https://i.ibb.co/pQSbL0t/Forgotten-Age-5-Heart-of-the-Elders-II-Nele-Diel.jpg"
},
{
Name = "VI - City of Archives 1",
Name = "VI - The City of Archives 1",
URL = "https://i.ibb.co/f04DSPb/Forgotten-Age-6-City-of-Archives.jpg"
},
{
Name = "VI - City of Archives 2",
Name = "VI - The City of Archives 2",
URL = "https://i.ibb.co/WsSBrYj/Forgotten-Age-6-City-of-Archives-2.jpg"
},
{
Name = "VI - City of Archives 3",
Name = "VI - The City of Archives 3",
URL = "https://i.ibb.co/qdPbSZ8/Forgotten-Age-6-City-of-Archives-Chris-Ostrowski.jpg"
},
{
Name = "VII - Depths of Yoth 1",
Name = "VII - The Depths of Yoth 1",
URL = "https://i.ibb.co/dbLKgGv/Forgotten-Age-7-Depths-of-Yoth-Diego-Arbetta.jpg"
},
{
Name = "VII - Depths of Yoth 2",
Name = "VII - The Depths of Yoth 2",
URL = "https://i.ibb.co/NW7Wp98/Forgotten-Age-7-Depths-of-Yoth-Greg-Bobrowski.jpg"
},
{
Name = "VII - Depths of Yoth 3",
Name = "VII - The Depths of Yoth 3",
URL = "https://i.ibb.co/257zr7c/Forgotten-Age-7-Depths-of-Yoth-Greg-Bobrowski-2-jpg.jpg"
},
{
@ -282,11 +282,11 @@ PLAYAREA_IMAGE_DATA = {
},
["The Circle Undone"] = {
{
Name = "0 - Prologue",
Name = "0 - Disappearance at the Twilight Estate",
URL = "https://i.ibb.co/gm4C6yy/Circle-Undone-0-Prologue-Ted-Galaday.jpg"
},
{
Name = "I - Witching Hour",
Name = "I - The Witching Hour",
URL = "https://i.ibb.co/kgJ34WS/Circle-Undone-1-Witching-Hour-Nele-Diel.jpg"
},
{
@ -318,19 +318,19 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/0D7LzxV/Circle-Undone-3-The-Secret-Name-Robert-Laskey.jpg"
},
{
Name = "IV - Wages of Sin 1",
Name = "IV - The Wages of Sin 1",
URL = "https://i.ibb.co/fDMqH1C/Circle-Undone-4-Wages-of-Sin-Emilio-Rodriguez.jpg"
},
{
Name = "IV - Wages of Sin 2",
Name = "IV - The Wages of Sin 2",
URL = "https://i.ibb.co/HDrKkZF/Circle-Undone-4-Wages-of-Sin-Emilio-Rodriguez-2.jpg"
},
{
Name = "IV - Wages of Sin 3",
Name = "IV - The Wages of Sin 3",
URL = "https://i.ibb.co/vkpG8cM/Circle-Undone-4-Wages-of-Sin-Greg-Bobrowski.jpg"
},
{
Name = "IV - Wages of Sin 4",
Name = "IV - The Wages of Sin 4",
URL = "https://i.ibb.co/CMj007q/Circle-Undone-4-Wages-of-Sin-Mateusz-Michalski.jpg"
},
{
@ -396,35 +396,35 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/sWsZCv8/Dream-Eaters-1-B-Waking-Nightmare-Josh-Gould-jpg.jpg"
},
{
Name = "II-A - Search for Kadath 1",
Name = "II-A - The Search for Kadath 1",
URL = "https://i.ibb.co/4SwzCD8/Dream-Eaters-2-A-Search-for-Kadath-Andrei-Khrutskii.jpg"
},
{
Name = "II-A - Search for Kadath 2",
Name = "II-A - The Search for Kadath 2",
URL = "https://i.ibb.co/WpZ4fMc/Dream-Eaters-2-A-Search-for-Kadath-Dan-Iorgulescu.jpg"
},
{
Name = "II-A - Search for Kadath 3",
Name = "II-A - The Search for Kadath 3",
URL = "https://i.ibb.co/jwsn0jf/Dream-Eaters-2-A-Search-for-Kadath-Diana-Tsareva.jpg"
},
{
Name = "II-A - Search for Kadath 4",
Name = "II-A - The Search for Kadath 4",
URL = "https://i.ibb.co/pd9vxmL/Dream-Eaters-2-A-Search-for-Kadath-Helen-Ilnytska.jpg"
},
{
Name = "II-A - Search for Kadath 5",
Name = "II-A - The Search for Kadath 5",
URL = "https://i.ibb.co/MZ7Qtcc/Dream-Eaters-2-A-Search-for-Kadath-Nele-Diel.jpg"
},
{
Name = "II-B - Thousand Shapes of Horror 1",
Name = "II-B - A Thousand Shapes of Horror 1",
URL = "https://i.ibb.co/9s7M0PP/Dream-Eaters-2-B-Thousand-Shapes-of-Horror-Nele-Diel-2.jpg"
},
{
Name = "II-B - Thousand Shapes of Horror 2",
Name = "II-B - A Thousand Shapes of Horror 2",
URL = "https://i.ibb.co/T4Pqx0H/Dream-Eaters-2-B-Thousand-Shapes-of-Horror-Nele-Diel.jpg"
},
{
Name = "II-B - Thousand Shapes of Horror 3",
Name = "II-B - A Thousand Shapes of Horror 3",
URL = "https://i.ibb.co/VJFQVYd/Dream-Eaters-2-B-Thousand-Shapes-of-Horror-Greg-Bobrowski.jpg"
},
{
@ -462,27 +462,27 @@ PLAYAREA_IMAGE_DATA = {
},
["The Innsmouth Conspiracy"] = {
{
Name = "I - Pit of Despair 1",
Name = "I - The Pit of Despair 1",
URL = "https://i.ibb.co/2sc0F61/Innsmouth-1-Pit-of-Despair-Amanda-Castrillo.jpg"
},
{
Name = "I - Pit of Despair 2",
Name = "I - The Pit of Despair 2",
URL = "https://i.ibb.co/Nj9JLBQ/Innsmouth-1-Pit-of-Despair-J-Mill.jpg"
},
{
Name = "II - Vanishing of Elina Harper 1",
Name = "II - The Vanishing of Elina Harper 1",
URL = "https://i.ibb.co/2j74cVn/Innsmouth-2-Vanishing-of-Elina-Harper-Konstantin-Vohwinkel.jpg"
},
{
Name = "II - Vanishing of Elina Harper 2",
Name = "II - The Vanishing of Elina Harper 2",
URL = "https://i.ibb.co/r2VqHSn/Innsmouth-2-Vanishing-of-Elina-Harper-Mihail-Bila.jpg"
},
{
Name = "II - Vanishing of Elina Harper 3",
Name = "II - The Vanishing of Elina Harper 3",
URL = "https://i.ibb.co/hFQMm7N/Innsmouth-2-Vanishing-of-Elina-Harper-Richard-Wright.jpg"
},
{
Name = "II - Vanishing of Elina Harper 4",
Name = "II - The Vanishing of Elina Harper 4",
URL = "https://i.ibb.co/2nZKGN6/Innsmouth-2-Vanishing-of-Elina-Harper-Tomasz-Jedruszek-1.jpg"
},
{
@ -526,19 +526,19 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/YkLFy7y/Innsmouth-5-Horror-in-High-Gear-Rostyslav-Zagornov.jpg"
},
{
Name = "VI - Light in the Fog 1",
Name = "VI - A Light in the Fog 1",
URL = "https://i.ibb.co/v1rhgqJ/Innsmouth-6-Light-in-the-Fog-Florian-Aupetit.jpg"
},
{
Name = "VI - Light in the Fog 2",
Name = "VI - A Light in the Fog 2",
URL = "https://i.ibb.co/Db2pRd6/Innsmouth-6-Light-in-the-Fog-JB-Caillet.jpg"
},
{
Name = "VII - Lair of Dagon 1",
Name = "VII - The Lair of Dagon 1",
URL = "https://i.ibb.co/QPwzQL5/Innsmouth-7-Lair-of-Dagon-Daria-Khlebnikova.jpg"
},
{
Name = "VII - Lair of Dagon 2",
Name = "VII - The Lair of Dagon 2",
URL = "https://i.ibb.co/MZBpCbs/Innsmouth-7-Lair-of-Dagon-Guillem-H-Pongiluppi.jpg"
},
{
@ -584,11 +584,11 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://i.ibb.co/ncRvHr3/Edge-4-City-Francois-Baranger-2.png"
},
{
Name = "IV - Heart of Madness 1",
Name = "IV - The Heart of Madness 1",
URL = "https://i.ibb.co/rk0qR4z/Edge-5-Heart-of-Madness-Karol-Sollich.png"
},
{
Name = "IV - Heart of Madness 2",
Name = "IV - The Heart of Madness 2",
URL = "https://i.ibb.co/NVFjx6N/Edge-5-Heart-of-Madness-Miguel-Coimbra.png"
}
},
@ -626,15 +626,15 @@ PLAYAREA_IMAGE_DATA = {
URL = "http://cloud-3.steamusercontent.com/ugc/2038485431566444330/3ED2CCE95DE933546E1B5CBBF445D773E6D65465/"
},
{
Name = "56-Y ???",
Name = "56-Y Without a Trace",
URL = "http://cloud-3.steamusercontent.com/ugc/2038485431566444450/FE4C335B0F72E83900A4EED0FD1A1D304D70D6B7/"
},
{
Name = "59-Z Congress of Keys I",
Name = "59-Z Congress of Keys 1",
URL = "http://cloud-3.steamusercontent.com/ugc/2038485431566444576/5BB32469ED412D59BB0A46E57D226500B1D0568B/"
},
{
Name = "59-Z Congress of Keys II",
Name = "59-Z Congress of Keys 2",
URL = "http://cloud-3.steamusercontent.com/ugc/2038485431566444690/B01A1FEAB57473D9B6DF11B92D62C214AA1C2C02/"
}
}
@ -858,7 +858,7 @@ PLAYAREA_IMAGE_DATA = {
URL = "https://github.com/ArkhamDotCards/theghostsofonigawa/blob/main/product/onigawa-playmat-01.png?raw=true"
},
{
Name = "II - In The Shadow Of Mount Kokoro",
Name = "II - In The Shadow Of Mount Kokoro",
URL = "https://github.com/ArkhamDotCards/theghostsofonigawa/blob/main/product/onigawa-playmat-02.png?raw=true"
},
{

View File

@ -1,14 +1,15 @@
require("core/PlayAreaImageData") -- this fills the variable "PLAYAREA_IMAGE_DATA"
local playAreaApi = require("core/PlayAreaApi")
local typeIndex, selectionIndex
local typeIndex, selectionIndex, plainNameCache
function onSave() return JSON.encode({typeIndex = typeIndex, selectionIndex = selectionIndex}) end
function onSave() return JSON.encode({ typeIndex = typeIndex, selectionIndex = selectionIndex }) end
function onLoad(savedData)
self.createButton({
function_owner = self,
click_function = "onClick_toggleGallery",
tooltip = "Show Image Gallery",
position = {0, 0.06, 0},
height = 1500,
width = 1500,
color = { 1, 1, 1, 0 }
@ -17,17 +18,18 @@ function onLoad(savedData)
local loadedData = JSON.decode(savedData) or {}
typeIndex = loadedData.typeIndex or 1
selectionIndex = loadedData.selectionIndex or 1
Wait.time(updatePlayareaGallery, 0.5)
Wait.time(updatePlayAreaGallery, 0.5)
math.randomseed(os.time())
end
-- click function for main button
function onClick_toggleGallery()
Global.call("togglePlayareaGallery")
Global.call("togglePlayAreaGallery")
end
function onClick_defaultImage()
playAreaApi.updateSurface()
Global.call("togglePlayareaGallery")
Global.call("togglePlayAreaGallery")
end
function getDataSubTableByIndex(dataTable, index)
@ -39,7 +41,7 @@ function getDataSubTableByIndex(dataTable, index)
return {}
end
function updatePlayareaGallery()
function updatePlayAreaGallery()
-- get subtables
local dataForType = getDataSubTableByIndex(PLAYAREA_IMAGE_DATA, typeIndex)
local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)
@ -97,12 +99,12 @@ end
function onClick_imageTab(_, _, tabId)
typeIndex = tonumber(tabId:sub(9))
selectionIndex = 1
updatePlayareaGallery()
updatePlayAreaGallery()
end
function onClick_listItem(_, _, listId)
selectionIndex = tonumber(listId:sub(10))
updatePlayareaGallery()
updatePlayAreaGallery()
end
function onClick_image(_, _, id)
@ -111,7 +113,7 @@ function onClick_image(_, _, id)
local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)
local newURL = dataForSelection[imageIndex].URL
playAreaApi.updateSurface(newURL)
Global.call("togglePlayareaGallery")
Global.call("togglePlayAreaGallery")
end
function highlightTabAndItem()
@ -146,3 +148,54 @@ function round(num, numDecimalPlaces)
local mult = 10 ^ (numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function maybeUpdatePlayAreaImage(scenarioName)
-- initialize cache if nil
if not plainNameCache then
plainNameCache = {}
for i, dataForType in pairs(PLAYAREA_IMAGE_DATA) do
for j, dataForCycle in pairs(dataForType) do
for k, data in ipairs(dataForCycle) do
local plainName = getPlainName(data.Name)
log(plainName)
if not plainNameCache[plainName] then
plainNameCache[plainName] = {}
end
table.insert(plainNameCache[plainName], data.URL)
end
end
end
end
-- look for matching playarea image or use generic ones instead
local listOfEligibleImages = {}
if plainNameCache[scenarioName] then
listOfEligibleImages = plainNameCache[scenarioName]
else
listOfEligibleImages = plainNameCache["Generic"]
end
-- get a random entry from the eligible list
local newImageIndex = math.random(#listOfEligibleImages)
playAreaApi.updateSurface(listOfEligibleImages[newImageIndex])
end
-- attempts to extract the plain scenario name from the playarea image name
function getPlainName(str)
-- remove prefix type 1
str = str:gsub("%w+%-%w%s%-%s", "") -- matches "II-B - Thousand Shapes of Horror 1"
-- remove prefix type 2
str = str:gsub("%w+%-%w%s", "") -- matches "59-Z Congress of Keys 1"
-- remove prefix type 3
str = str:gsub("%w+%s%-%s", "") -- matches "III - The Secret Name 4"
-- remove prefix type 4
str = str:gsub("%?+%s%-%s", "") -- matches "??? - Fatal Mirage"
-- remove suffix (numbering)
str = str:gsub("%s%d+", "")
return str
end

View File

@ -6,7 +6,7 @@
<Include src="Global/BottomBar.xml"/>
<Include src="Global/DownloadWindow.xml"/>
<Include src="Global/PlayareaGallery.xml"/>
<Include src="Global/PlayAreaGallery.xml"/>
<Include src="Global/TitleSplash.xml"/>
<Include src="Global/NavigationOverlay.xml"/>
<Include src="Global/OptionPanel.xml"/>

View File

@ -182,6 +182,20 @@
</Cell>
</Row>
<!-- Option: change custom playarea image on setup -->
<Row class="option-text"
tooltip="Attempts to set the playarea to a fitting image&#xA;from the playarea image gallery.">
<Cell class="option-text">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Change playarea background on setup</Text>
</Panel>
</Cell>
<Cell class="option-button">
<Toggle id="changePlayAreaImage"
onValueChanged="onClick_toggleOption(changePlayAreaImage)"/>
</Cell>
</Row>
<!-- Group: playermat settings -->
<Row class="group-header">
<Cell class="group-header">

View File

@ -39,7 +39,7 @@
<VerticalLayout childForceExpandHeight="false"/>
</Defaults>
<VerticalLayout id="playareaGallery"
<VerticalLayout id="playAreaGallery"
active="false"
color="black"
height="880"
@ -66,7 +66,7 @@
tooltip="Close"
tooltipPosition="Right"
tooltipBackgroundColor="rgba(0,0,0,1)"
onClick="onClick_toggleUi(playareaGallery)"/>
onClick="onClick_toggleUi(playAreaGallery)"/>
</Panel>
</Panel>