initial commit

This commit is contained in:
Chr1Z93 2023-09-21 12:42:21 +02:00
parent 69b2302c7d
commit 616d58218d
3 changed files with 40 additions and 9 deletions

View File

@ -900,12 +900,39 @@ function returnLanguageId(code)
end end
end end
-- called by the resource counter selection dropdown
function resourceCounterSelected(_, selectedIndex, id)
local optionList = {
"enabled",
"custom",
"disabled"
}
optionPanel[id] = optionList[tonumber(selectedIndex) + 1]
print(optionPanel[id])
end
function returnResourceCounterId(name)
local optionList = {
"enabled",
"custom",
"disabled"
}
for index, optionName in ipairs(optionList) do
if optionName == name then
return index
end
end
end
-- sets the option panel to the correct state (corresponding to 'optionPanel') -- sets the option panel to the correct state (corresponding to 'optionPanel')
function updateOptionPanelState() function updateOptionPanelState()
for id, optionValue in pairs(optionPanel) do for id, optionValue in pairs(optionPanel) do
if id == "cardLanguage" and type(optionValue) == "string" then if id == "cardLanguage" and type(optionValue) == "string" then
local dropdownId = returnLanguageId(optionValue) - 1 local dropdownId = returnLanguageId(optionValue) - 1
UI.setAttribute(id, "value", dropdownId) UI.setAttribute(id, "value", dropdownId)
elseif id == "useResourceCounters" and type(optionValue) == "string" then
local dropdownId = returnResourceCounterId(optionValue) - 1
UI.setAttribute(id, "value", dropdownId)
elseif (type(optionValue) == "boolean" and optionValue) elseif (type(optionValue) == "boolean" and optionValue)
or (type(optionValue) == "string" and optionValue) or (type(optionValue) == "string" and optionValue)
or (type(optionValue) == "table" and #optionValue ~= 0) then or (type(optionValue) == "table" and #optionValue ~= 0) then
@ -938,10 +965,6 @@ function applyOptionPanelChange(id, state)
-- update master clue counter -- update master clue counter
getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state) getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state)
-- option: Clickable resource counters
elseif id == "useResourceCounters" then
optionPanel[id] = state
-- option: Play area snap tags -- option: Play area snap tags
elseif id == "playAreaSnapTags" then elseif id == "playAreaSnapTags" then
playAreaAPI.setLimitSnapsByType(state) playAreaAPI.setLimitSnapsByType(state)

View File

@ -166,7 +166,9 @@ do
if tokenType == "damage" or tokenType == "horror" then if tokenType == "damage" or tokenType == "horror" then
TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown) TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)
elseif tokenType == "resource" and optionPanel["useResourceCounters"] then elseif tokenType == "resource" and optionPanel["useResourceCounters"] == "enabled" then
TokenManager.spawnResourceCounterToken(card, tokenCount)
elseif tokenType == "resource" and optionPanel["useResourceCounters"] == "custom" and tokenCount == 0 then
TokenManager.spawnResourceCounterToken(card, tokenCount) TokenManager.spawnResourceCounterToken(card, tokenCount)
else else
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType) TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)

View File

@ -216,15 +216,21 @@
<!-- Option: use clickable resource counters --> <!-- Option: use clickable resource counters -->
<Row class="option-text"> <Row class="option-text">
<Cell class="option-text"> <Cell class="option-dropdowntext">
<VerticalLayout class="text-column"> <VerticalLayout class="text-column">
<Text class="option-header">Use clickable resource tokens</Text> <Text class="option-header">Use clickable resource tokens</Text>
<Text class="description">This enables spawning of clickable resource tokens for player cards.</Text> <Text class="description">This enables spawning of clickable resource tokens for player cards.</Text>
</VerticalLayout> </VerticalLayout>
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-dropdown">
<Toggle id="useResourceCounters" <Panel padding="0 17 13 13">
onValueChanged="onClick_toggleOption(useResourceCounters)"/> <Dropdown id="useResourceCounters"
onValueChanged="resourceCounterSelected(selectedIndex)">
<Option>Enabled</Option>
<Option>Chef's Selection</Option>
<Option>Disabled</Option>
</Dropdown>
</Panel>
</Cell> </Cell>
</Row> </Row>