added play area connection color selection

This commit is contained in:
Chr1Z93 2023-11-24 14:15:41 +01:00
parent 6556918ce4
commit fd63605623
5 changed files with 73 additions and 34 deletions

View File

@ -1 +1 @@
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","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","playAreaConnectionColor":[0.4,0.4,0.4,1],"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

@ -1151,6 +1151,13 @@ function onClick_toggleOption(_, id)
applyOptionPanelChange(id, state)
end
-- color selection for playarea
function onClick_playAreaConnectionColor(player, _, id)
player.showColorDialog(optionPanel[id], function(color)
applyOptionPanelChange(id, color)
end)
end
-- called by the language selection dropdown
function languageSelected(_, selectedIndex, id)
optionPanel[id] = LANGUAGES[tonumber(selectedIndex) + 1].code
@ -1188,6 +1195,9 @@ function updateOptionPanelState()
elseif id == "useResourceCounters" and type(optionValue) == "string" then
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)
or (type(optionValue) == "table" and #optionValue ~= 0) then
@ -1221,6 +1231,12 @@ function applyOptionPanelChange(id, state)
local counter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "MasterClueCounter")
counter.setVar("useClickableCounters", state)
-- option: Play area connection color
elseif id == "playAreaConnectionColor" then
playAreaApi.setConnectionColor(state)
UI.setAttribute(id, "color", "#" .. Color.new(state):toHex())
optionPanel[id] = state
-- option: Play area snap tags
elseif id == "playAreaSnapTags" then
playAreaApi.setLimitSnapsByType(state)
@ -1369,6 +1385,7 @@ function onClick_defaultSettings()
-- clean reset of variables
optionPanel = {
cardLanguage = "en",
playAreaConnectionColor = { 0.4, 0.4, 0.4, 1 },
playAreaSnapTags = true,
showAttachmentHelper = false,
showCleanUpHelper = false,

View File

@ -11,7 +11,6 @@ local INCOMING_ONE_WAY = 2
local CONNECTION_THICKNESS = 0.015
local DRAGGING_CONNECTION_THICKNESS = 0.15
local DRAGGING_CONNECTION_COLOR = { 0.8, 0.8, 0.8, 1 }
local CONNECTION_COLOR = { 0.4, 0.4, 0.4, 1 }
local DIRECTIONAL_ARROW_DISTANCE = 3.5
local ARROW_ARM_LENGTH = 0.9
local ARROW_ANGLE = 25
@ -62,16 +61,16 @@ function onSave()
return JSON.encode({
trackedLocations = locations,
currentScenario = currentScenario,
connectionColor = connectionColor
})
end
function onLoad(saveState)
-- records locations we have spawned clues for
local save = JSON.decode(saveState) or {}
locations = save.trackedLocations or {}
currentScenario = save.currentScenario
function onLoad(savedData)
local loadedData = JSON.decode(savedData) or {}
locations = loadedData.trackedLocations or {}
currentScenario = loadedData.currentScenario
connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 }
self.interactable = false
Wait.time(function() collisionEnabled = true end, 1)
end
@ -431,7 +430,7 @@ function addBidirectionalVector(card1, card2, vectorOwner, lines)
table.insert(lines, {
points = { pos1, pos2 },
color = vectorOwner == self and CONNECTION_COLOR or DRAGGING_CONNECTION_COLOR,
color = vectorOwner == self and connectionColor or DRAGGING_CONNECTION_COLOR,
thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS,
})
end
@ -489,7 +488,7 @@ function addArrowLines(arrowheadPos, originPos, vectorOwner, lines)
local arm2 = vectorOwner.positionToLocal(arrowArm2)
table.insert(lines, {
points = { arm1, head, arm2 },
color = vectorOwner == self and CONNECTION_COLOR or DRAGGING_CONNECTION_COLOR,
color = vectorOwner == self and connectionColor or DRAGGING_CONNECTION_COLOR,
thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS,
})
end

View File

@ -46,6 +46,12 @@ do
return getPlayArea().call("resetSpawnedCards")
end
-- Sets the connection color
PlayAreaApi.setConnectionColor = function(color)
getPlayArea().setTable("connectionColor", color)
getPlayArea().call("drawBaseConnections")
end
-- Event to be called when the current scenario has changed.
---@param scenarioName Name of the new scenario
PlayAreaApi.onScenarioChanged = function(scenarioName)

View File

@ -46,18 +46,18 @@
columnSpan="2"/>
<Cell class="option-button"
color="#333333"/>
<Cell class="option-dropdowntext"
<Cell class="option-singleColumn"
color="#333333"
columnSpan="1"/>
<Cell class="option-dropdown"
<Cell class="option-doubleColumn"
color="#333333"
columnSpan="2"/>
<Panel class="option-wrapper"
<Panel class="singleColumn-wrapper"
padding="10 0 0 0"/>
<Text class="option-header"
fontSize="22"
font="font_teutonic-arkham"/>
<Panel class="dropdown-wrapper"
<Panel class="doubleColumn-wrapper"
padding="0 17 3 3"/>
<!-- buttons at the bottom -->
@ -117,13 +117,13 @@
<!-- Option: card language -->
<!-- disabled until we have the backend in place
<Row class="option-text" tooltip="Downloading a campaign or importing a deck will use&#xA;this language for cards (NOT FUNCTIONAL YET!).">
<Cell class="option-dropdowntext">
<Panel class="option-wrapper">
<Cell class="option-singleColumn">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Card language</Text>
</Panel>
</Cell>
<Cell class="option-dropdown">
<Panel class="dropdown-wrapper">
<Cell class="option-doubleColumn">
<Panel class="doubleColumn-wrapper">
<Dropdown id="cardLanguage" onValueChanged="languageSelected(selectedIndex)">
<Option>简体中文</Option>
<Option>繁體中文</Option>
@ -141,7 +141,7 @@
<Row class="option-text"
tooltip="Only cards with the tag 'Location' will snap (official cards are supported by default).&#xA;Disable this if you are having issues with custom content.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Enable snap tags for play area</Text>
</Panel>
</Cell>
@ -151,11 +151,28 @@
</Cell>
</Row>
<!-- Option: play area connection color -->
<Row class="option-text"
tooltip="This color will be used to draw lines&#xA;for location connections.">
<Cell class="option-singleColumn">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Choose color for location connections</Text>
</Panel>
</Cell>
<Cell class="option-doubleColumn">
<Panel class="doubleColumn-wrapper">
<Button id="playAreaConnectionColor"
onClick="onClick_playAreaConnectionColor">
</Button>
</Panel>
</Cell>
</Row>
<!-- Option: splash scenario name on setup -->
<Row class="option-text"
tooltip="Fade in the name of the scenario for 2 seconds&#xA;when placing down a scenario.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Show scenario title on setup</Text>
</Panel>
</Cell>
@ -179,7 +196,7 @@
<Row class="option-text"
tooltip="Only cards with the tag 'Asset' will snap (official cards are supported by default).&#xA;Disable this if you are having issues with custom content.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Enable snap tags</Text>
</Panel>
</Cell>
@ -193,7 +210,7 @@
<Row class="option-text"
tooltip="Displays a button below the 'Upkeep' button that draws a card from your deck.&#xA;Useful for multi-handed solo play.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Show "Draw 1" button</Text>
</Panel>
</Cell>
@ -207,7 +224,7 @@
<Row class="option-text"
tooltip="Instead of automatically counting clues in the respective area on your playermat,&#xA;this displays a clickable counter for clues.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Use clickable clue counters</Text>
</Panel>
</Cell>
@ -220,13 +237,13 @@
<!-- Option: use clickable resource counters -->
<Row class="option-text"
tooltip="This enables spawning of clickable resource tokens for player cards.&#xA;(Chef's Selection = assets with 0 uses)">
<Cell class="option-dropdowntext">
<Panel class="option-wrapper">
<Cell class="option-singleColumn">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Use clickable resource tokens</Text>
</Panel>
</Cell>
<Cell class="option-dropdown">
<Panel class="dropdown-wrapper">
<Cell class="option-doubleColumn">
<Panel class="doubleColumn-wrapper">
<Dropdown id="useResourceCounters"
onValueChanged="resourceCounterSelected(selectedIndex)">
<Option>Enabled</Option>
@ -251,7 +268,7 @@
<Row class="option-text"
tooltip="Provides a card-sized bag for cards that are attached to other cards&#xA;(e.g. Backpack).">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Attachment Helper</Text>
</Panel>
</Cell>
@ -265,7 +282,7 @@
<Row class="option-text"
tooltip="Useful for campaign-play:&#xA;It resets play areas to allow continuous gameplay in the same savegame.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Clean Up Helper</Text>
</Panel>
</Cell>
@ -279,7 +296,7 @@
<Row class="option-text"
tooltip="Displays in a 'Choose Your Own Adventure'&#xA;style redesigned campaign guides.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">CYOA Campaign Guides</Text>
</Panel>
</Cell>
@ -293,7 +310,7 @@
<Row class="option-text"
tooltip="This allows moving all objects on the main playmat&#xA;in a chosen direction.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Displacement Tool</Text>
</Panel>
</Cell>
@ -307,7 +324,7 @@
<Row class="option-text"
tooltip="Never count your hand cards again! This tool does that for you&#xA;and additionally enables easy discarding of random cards.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Hand Helper</Text>
</Panel>
</Cell>
@ -321,7 +338,7 @@
<Row class="option-text"
tooltip="Use this tool to hide unused playermats&#xA;for more table space.">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Playmat Hider</Text>
</Panel>
</Cell>
@ -335,7 +352,7 @@
<Row class="option-text"
tooltip="Quickly search 3, 6, 9 or the top X&#xA;cards of your deck!">
<Cell class="option-text">
<Panel class="option-wrapper">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Search Assistant</Text>
</Panel>
</Cell>