Merge pull request #343 from argonui/tool-promotion

Tool promotion: Chaos Bag Manager and Token Arranger
This commit is contained in:
BootleggerFinn 2023-08-22 12:46:49 -05:00 committed by GitHub
commit 477db4dc84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 72 additions and 122 deletions

View File

@ -3,7 +3,6 @@
"ComponentTags_path": "ComponentTags.json", "ComponentTags_path": "ComponentTags.json",
"CustomUIAssets_path": "CustomUIAssets.json", "CustomUIAssets_path": "CustomUIAssets.json",
"DecalPallet_path": "DecalPallet.json", "DecalPallet_path": "DecalPallet.json",
"Decals": [],
"GameComplexity": "", "GameComplexity": "",
"GameMode": "Arkham Horror LCG - Super Complete Edition", "GameMode": "Arkham Horror LCG - Super Complete Edition",
"GameType": "", "GameType": "",
@ -201,7 +200,9 @@
"NavigationOverlayHandler.797ede", "NavigationOverlayHandler.797ede",
"CampaignImporterExporter.334ee3", "CampaignImporterExporter.334ee3",
"Bloodborne-CityoftheUnseen.1e7a0b", "Bloodborne-CityoftheUnseen.1e7a0b",
"TheColorOutofOz.806d9a" "TheColorOutofOz.806d9a",
"TokenArranger.022907",
"ChaosBagManager.023240"
], ],
"PlayArea": 1, "PlayArea": 1,
"PlayerCounts": [ "PlayerCounts": [

View File

@ -83,6 +83,10 @@
{ {
"displayed": "CameraZoom_ignore", "displayed": "CameraZoom_ignore",
"normalized": "camerazoom_ignore" "normalized": "camerazoom_ignore"
},
{
"displayed": "TokenArranger",
"normalized": "tokenarranger"
} }
] ]
} }

View File

@ -32,7 +32,7 @@
"HideWhenFaceDown": false, "HideWhenFaceDown": false,
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": false, "Locked": true,
"LuaScript": "require(\"accessories/ChaosBagManager\")", "LuaScript": "require(\"accessories/ChaosBagManager\")",
"LuaScriptState": "", "LuaScriptState": "",
"MeasureMovement": false, "MeasureMovement": false,
@ -45,9 +45,9 @@
], ],
"Tooltip": true, "Tooltip": true,
"Transform": { "Transform": {
"posX": 22.215, "posX": -66,
"posY": 5.651, "posY": 1.531,
"posZ": -34.811, "posZ": -49.5,
"rotX": 0, "rotX": 0,
"rotY": 270, "rotY": 270,
"rotZ": 0, "rotZ": 0,

View File

@ -1 +1 @@
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","playAreaSnapTags":true,"showAttachmentHelper":false,"showChaosBagManager":false,"showCleanUpHelper":false,"showCustomPlaymatImages":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showSearchAssistant":[],"showTitleSplash":true,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}} {"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCustomPlaymatImages":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useSnapTags":true}}

View File

@ -14,8 +14,6 @@
"r": 0.70588 "r": 0.70588
}, },
"ContainedObjects_order": [ "ContainedObjects_order": [
"ChaosBagManager.023240",
"TokenArranger.022907",
"CYOACampaignGuides.e87ea2", "CYOACampaignGuides.e87ea2",
"AttachmentHelper.7f4976", "AttachmentHelper.7f4976",
"SearchAssistant.17aed0", "SearchAssistant.17aed0",

View File

@ -32,9 +32,9 @@
"HideWhenFaceDown": false, "HideWhenFaceDown": false,
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": false, "Locked": true,
"LuaScript": "require(\"accessories/TokenArranger\")", "LuaScript": "require(\"accessories/TokenArranger\")",
"LuaScriptState": "", "LuaScriptState_path": "TokenArranger.022907.luascriptstate",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Token", "Name": "Custom_Token",
"Nickname": "Token Arranger", "Nickname": "Token Arranger",
@ -46,7 +46,7 @@
"Tooltip": true, "Tooltip": true,
"Transform": { "Transform": {
"posX": -42.3, "posX": -42.3,
"posY": 1.53, "posY": 1.531,
"posZ": -46.5, "posZ": -46.5,
"rotX": 0, "rotX": 0,
"rotY": 270, "rotY": 270,

View File

@ -0,0 +1 @@
{"percentage":false,"tokenPrecedence":{"":[0,11],"Auto-fail":[-100,7],"Bless":[101,8],"Cultist":[-2,4],"Curse":[-101,9],"Elder Sign":[100,2],"Elder Thing":[-4,6],"Frost":[-99,10],"Skull":[-1,3],"Tablet":[-3,5]}}

View File

@ -59,7 +59,6 @@ function onLoad(saveState)
end end
createButtonsAndInputs(true) createButtonsAndInputs(true)
layout()
-- context menu items -- context menu items
self.addContextMenuItem("Load default values", function() self.addContextMenuItem("Load default values", function()
@ -73,8 +72,7 @@ function onLoad(saveState)
percentage = false percentage = false
else else
percentage = "basic" percentage = "basic"
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
"Yellow")
end end
layout() layout()
end) end)
@ -85,8 +83,7 @@ function onLoad(saveState)
else else
percentage = "cumulative" percentage = "cumulative"
end end
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
"Yellow")
layout() layout()
end) end)
end end
@ -228,51 +225,54 @@ function deleteCopiedTokens()
createButtonsAndInputs() createButtonsAndInputs()
end end
-- creates percentage representation buttons -- creates buttons as labels as display for percentage values
function createPercentageButton(basePercentage, valueCount, tokenName, cumulativePercentage) function createPercentageButton(tokenCount, valueCount, tokenName)
local buttonScale, offset, textColor, labelString -- parameters for button creation
local percentageLabel = {}
percentageLabel.click_function = "none"
percentageLabel.width = 0
percentageLabel.height = 0
local startPos = Vector(2.3, -0.05, 0.875 * valueCount)
if percentage == "cumulative" then if percentage == "cumulative" then
buttonScale = {1.5, 1.5, 1.5} percentageLabel.scale = {1.5, 1.5, 1.5}
offset = -2.85 percentageLabel.position = startPos - Vector(0, 0, 2.85)
else else
buttonScale = {2, 2, 2} percentageLabel.scale = {2, 2, 2}
offset = -2.675 percentageLabel.position = startPos - Vector(0, 0, 2.675)
end end
-- if this is a cumulative button (bottom one of the two created buttons) -- determine font_color
if cumulativePercentage then if tokenName == "Elder Sign" then
offset = -2.45 percentageLabel.font_color = {0.35, 0.71, 0.85}
textColor = {1, 1, 1} elseif tokenName == "Auto-fail" then
percentageLabel.font_color = {0.86, 0.1, 0.1}
-- check if the tokenName contains letters (e.g. symbol token)
elseif string.match(tokenName, "%a") ~= nil then
percentageLabel.font_color = {0.68, 0.53, 0.86}
else
percentageLabel.font_color = {0.85, 0.67, 0.33}
end
-- create label for base percentage
local basePercentage = math.floor((tokenCount.row / tokenCount.total) * 10000) / 100
percentageLabel.label = string.format("%s", string.format("%05.2f", basePercentage) .. "%")
self.createButton(percentageLabel)
-- optionally create label for cumulative percentage
if percentage == "cumulative" then
percentageLabel.position = startPos - Vector(0, 0, 2.45)
percentageLabel.font_color = {1, 1, 1}
-- only display one digit for 100% -- only display one digit for 100%
if cumulativePercentage == 100 then if tokenCount.sum == tokenCount.total then
labelString = string.format("%s", string.format("%05.1f", cumulativePercentage) .. "%") percentageLabel.label = "100.0%"
else else
labelString = string.format("%s", string.format("%05.2f", cumulativePercentage) .. "%") local cumulativePercentage = math.floor((tokenCount.sum / tokenCount.total) * 10000) / 100
end percentageLabel.label = string.format("%s", string.format("%05.2f", cumulativePercentage) .. "%")
else
labelString = string.format("%s", string.format("%05.2f", basePercentage) .. "%")
if tokenName == "Elder Sign" then
textColor = {0.35, 0.71, 0.85}
elseif tokenName == "Auto-fail" then
textColor = {0.86, 0.1, 0.1}
elseif tokenName then
textColor = {0.68, 0.53, 0.86}
else
textColor = {0.85, 0.67, 0.33}
end end
self.createButton(percentageLabel)
end end
self.createButton({
label = labelString,
click_function = "none",
width = 0,
height = 0,
scale = buttonScale,
font_color = textColor,
position = Vector(2.3, -0.05, offset + 0.875 * valueCount)
})
end end
-- main function (delete old tokens, clone chaos bag content, sort it and position it) -- main function (delete old tokens, clone chaos bag content, sort it and position it)
@ -293,14 +293,13 @@ function layout(_, _, isRightClick)
-- clone tokens from chaos bag (default position above trash can) -- clone tokens from chaos bag (default position above trash can)
for i, obj in ipairs(chaosBag.getData().ContainedObjects) do for i, obj in ipairs(chaosBag.getData().ContainedObjects) do
obj["Tags"] = { "tempToken" } obj["Tags"] = { "tempToken" }
local value = tonumber(obj.Nickname)
local precedence = tokenPrecedence[obj.Nickname]
local spawnedObj = spawnObjectData({ local spawnedObj = spawnObjectData({
data = obj, data = obj,
position = { 0.49, 3, 0 } position = { 0.49, 3, 0 }
}) })
local value = tonumber(obj.Nickname)
local precedence = tokenPrecedence[obj.Nickname]
data[i] = { data[i] = {
token = spawnedObj, token = spawnedObj,
value = value or precedence[1] value = value or precedence[1]
@ -323,50 +322,37 @@ function layout(_, _, isRightClick)
local location = { x = pos.x, y = pos.y, z = pos.z } local location = { x = pos.x, y = pos.y, z = pos.z }
local currentValue = data[1].value local currentValue = data[1].value
local tokenCount = 0 local tokenCount = { row = 0, sum = 0, total = #data }
local valueCount = 1 local valueCount = 1
local cumulativePercentage = 0
local tokenName = false local tokenName = false
for _, item in ipairs(data) do for i, item in ipairs(data) do
-- this is true for the first token in a new row
if item.value ~= currentValue then if item.value ~= currentValue then
if percentage then if percentage then
local basePercentage = math.floor((tokenCount / #data) * 10000) / 100 tokenCount.sum = tokenCount.sum + tokenCount.row
createPercentageButton(basePercentage, valueCount, tokenName) createPercentageButton(tokenCount, valueCount, tokenName)
if percentage == "cumulative" then
cumulativePercentage = cumulativePercentage + basePercentage
createPercentageButton(basePercentage, valueCount, tokenName, cumulativePercentage)
end
end end
location.x = location.x - 1.75 location.x = location.x - 1.75
location.z = pos.z location.z = pos.z
currentValue = item.value currentValue = item.value
valueCount = valueCount + 1 valueCount = valueCount + 1
tokenCount = 0 tokenCount.row = 0
end end
item.token.setPosition(location) item.token.setPosition(location)
item.token.setRotation(self.getRotation()) item.token.setRotation(self.getRotation())
item.token.setLock(true)
location.z = location.z - 1.75 location.z = location.z - 1.75
tokenCount = tokenCount + 1
tokenName = item.token.getName() tokenName = item.token.getName()
tokenCount.row = tokenCount.row + 1
-- set tokenName to false if it does not contain letters
-- tokenName is used by `createPercentageButton()` to determine the textcolor for percentages
if string.match(tokenName, "%a") == nil then
tokenName = false
end
end end
-- this is repeated to create the button for the last token -- this is repeated to create the button for the last token
if percentage then if percentage then
local basePercentage = math.floor((tokenCount / #data) * 10000) / 100 tokenCount.sum = tokenCount.sum + tokenCount.row
createPercentageButton(basePercentage, valueCount, tokenName) createPercentageButton(tokenCount, valueCount, tokenName)
if percentage == "cumulative" then
cumulativePercentage = cumulativePercentage + basePercentage
createPercentageButton(basePercentage, valueCount, tokenName, cumulativePercentage)
end
end end
-- introducing a small delay to limit update calls -- introducing a small delay to limit update calls

View File

@ -951,10 +951,6 @@ function applyOptionPanelChange(id, state)
elseif id == "showTitleSplash" then elseif id == "showTitleSplash" then
optionPanel[id] = state optionPanel[id] = state
-- option: Show token arranger
elseif id == "showTokenArranger" then
optionPanel[id] = spawnOrRemoveHelper(state, "Token Arranger", {-42.3, 1.6, -46.5})
-- option: Show clean up helper -- option: Show clean up helper
elseif id == "showCleanUpHelper" then elseif id == "showCleanUpHelper" then
optionPanel[id] = spawnOrRemoveHelper(state, "Clean Up Helper", {-66, 1.6, 46}) optionPanel[id] = spawnOrRemoveHelper(state, "Clean Up Helper", {-66, 1.6, 46})
@ -975,10 +971,6 @@ function applyOptionPanelChange(id, state)
optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot) optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot)
end end
-- option: Show chaos bag manager
elseif id == "showChaosBagManager" then
optionPanel[id] = spawnOrRemoveHelper(state, "Chaos Bag Manager", {-66, 1.6, -49.5})
-- option: Show attachment helper -- option: Show attachment helper
elseif id == "showAttachmentHelper" then elseif id == "showAttachmentHelper" then
optionPanel[id] = spawnOrRemoveHelper(state, "Attachment Helper", {-62, 1.4, 0}) optionPanel[id] = spawnOrRemoveHelper(state, "Attachment Helper", {-62, 1.4, 0})
@ -1049,11 +1041,9 @@ end
function removeHelperObject(name) function removeHelperObject(name)
-- links objects name to the respective option name (to grab the GUID for removal) -- links objects name to the respective option name (to grab the GUID for removal)
local referenceTable = { local referenceTable = {
["Token Arranger"] = "showTokenArranger",
["Clean Up Helper"] = "showCleanUpHelper", ["Clean Up Helper"] = "showCleanUpHelper",
["Hand Helper"] = "showHandHelper", ["Hand Helper"] = "showHandHelper",
["Search Assistant"] = "showSearchAssistant", ["Search Assistant"] = "showSearchAssistant",
["Chaos Bag Manager"] = "showChaosBagManager",
["Displacement Tool"] = "showDisplacementTool", ["Displacement Tool"] = "showDisplacementTool",
["Custom Playmat Images"] = "showCustomPlaymatImages", ["Custom Playmat Images"] = "showCustomPlaymatImages",
["Attachment Helper"] = "showAttachmentHelper", ["Attachment Helper"] = "showAttachmentHelper",
@ -1101,7 +1091,6 @@ function onClick_defaultSettings()
playAreaSnapTags = true, playAreaSnapTags = true,
showAttachmentHelper = false, showAttachmentHelper = false,
showCleanUpHelper = false, showCleanUpHelper = false,
showChaosBagManager = false,
showCustomPlaymatImages = false, showCustomPlaymatImages = false,
showCYOA = false, showCYOA = false,
showDisplacementTool = false, showDisplacementTool = false,
@ -1109,7 +1098,6 @@ function onClick_defaultSettings()
showHandHelper = {}, showHandHelper = {},
showSearchAssistant = {}, showSearchAssistant = {},
showTitleSplash = true, showTitleSplash = true,
showTokenArranger = false,
useClueClickers = false, useClueClickers = false,
useSnapTags = true useSnapTags = true
} }

View File

@ -252,20 +252,6 @@
</Cell> </Cell>
</Row> </Row>
<!-- Option: show chaos bag manager -->
<Row class="option-text">
<Cell class="option-text">
<VerticalLayout class="text-column">
<Text class="option-header">Chaos Bag Manager</Text>
<Text class="description">Panel for easy addition or removal of chaos tokens to the bag - very useful for EotE because of Frost tokens!</Text>
</VerticalLayout>
</Cell>
<Cell class="option-button">
<Toggle id="showChaosBagManager"
onValueChanged="onClick_toggleOption(showChaosBagManager)"/>
</Cell>
</Row>
<!-- Option: show clean up helper --> <!-- Option: show clean up helper -->
<Row class="option-text"> <Row class="option-text">
<Cell class="option-text"> <Cell class="option-text">
@ -349,20 +335,6 @@
onValueChanged="onClick_toggleOption(showSearchAssistant)"/> onValueChanged="onClick_toggleOption(showSearchAssistant)"/>
</Cell> </Cell>
</Row> </Row>
<!-- Option: show token arranger -->
<Row class="option-text">
<Cell class="option-text">
<VerticalLayout class="text-column">
<Text class="option-header">Token Arranger</Text>
<Text class="description">See the contents of the chaos bag at a glance! This tool displays a sorted table of the tokens to allow easier guessing of your odds.</Text>
</VerticalLayout>
</Cell>
<Cell class="option-button">
<Toggle id="showTokenArranger"
onValueChanged="onClick_toggleOption(showTokenArranger)"/>
</Cell>
</Row>
</TableLayout> </TableLayout>
</VerticalScrollView> </VerticalScrollView>
</Cell> </Cell>