added padding and save/load function

This commit is contained in:
Chr1Z93 2024-09-29 19:12:37 +02:00
parent c483c98fad
commit b47619c4a6
3 changed files with 38 additions and 17 deletions

View File

@ -1,5 +1,6 @@
{
"acknowledgedUpgradeVersions": [],
"blurseVisibility": [],
"chaosTokensGUID": [],
"handVisibility": [],
"optionPanel": {

View File

@ -71,8 +71,9 @@ local RESOURCE_OPTIONS = {
"disabled"
}
-- tracks the visibility of each hand
-- track player-specific visibilities
local handVisibility = {}
local blurseVisibility = {}
---------------------------------------------------------
-- data for tokens
@ -137,6 +138,7 @@ function onSave()
acknowledgedUpgradeVersions = acknowledgedUpgradeVersions,
chaosTokensLastMatGUID = chaosTokensLastMatGUID,
chaosTokensGUID = chaosTokensGUID,
blurseVisibility = blurseVisibility,
handVisibility = handVisibility,
optionPanel = optionPanel
})
@ -147,6 +149,7 @@ function onLoad(savedData)
local loadedData = JSON.decode(savedData)
acknowledgedUpgradeVersions = loadedData.acknowledgedUpgradeVersions
chaosTokensLastMatGUID = loadedData.chaosTokensLastMatGUID
blurseVisibility = loadedData.blurseVisibility
handVisibility = loadedData.handVisibility
optionPanel = loadedData.optionPanel
@ -165,6 +168,7 @@ function onLoad(savedData)
getModVersion()
updateHandVisibility()
updateBlurseVisibility()
math.randomseed(os.time())
TokenManager.initialiize()
@ -1172,11 +1176,11 @@ function onClick_spawnPlaceholder(player)
changeWindowVisibilityForColor(player.color, "downloadWindow", false)
end
-- toggles the visbility of the bless / curse manager UI
-- toggles the visibility of the bless / curse manager UI
function showHideBlurse(player)
local visibility = changeWindowVisibilityForColor(player.color, "blessCurseManager")
changeWindowVisibilityForColor(player.color, "hideBlurse", visibility)
changeWindowVisibilityForColor(player.color, "showBlurse", not visibility)
blurseVisibility[player.color] = visibility
end
-- toggles the visibility of the respective UI
@ -1896,6 +1900,18 @@ function applyHidingToCard(card, handColor)
end
end
function updateBlurseVisibility()
function coroBlurse()
for playerColor, state in pairs(blurseVisibility) do
changeWindowVisibilityForColor(playerColor, "blessCurseManager", state)
changeWindowVisibilityForColor(playerColor, "hideBlurse", state)
coroutine.yield()
end
return 1
end
startLuaCoroutine(Global, "coroBlurse")
end
---------------------------------------------------------
-- Update notification related functionality
---------------------------------------------------------

View File

@ -7,42 +7,46 @@
height="30"
width="30"
rectAlignment="MiddleRight"
offsetXY="0 67"
offsetXY="0 69"
outlineSize="2 2"
outline="#303030"/>
<Button class="blurseButton"
onClick="showHideBlurse"
tooltipPosition="Left"
tooltipBackgroundColor="rgba(0,0,0,1)"
color="White" />
</Defaults>
<!-- show button for the Bless / Curse Manager -->
<Panel class="showHide"
id="showBlurse">
<Button class="blurseButton"
tooltip="Show Bless/Curse Manager"
image="arrow-down"/>
</Panel>
<!-- hide button for the Bless / Curse Manager -->
<Panel class="showHide"
active="false"
id="hideBlurse">
<Button onClick="showHideBlurse"
color="White"
<Button class="blurseButton"
tooltip="Hide Bless/Curse Manager"
image="caret"/>
</Panel>
<!-- show button for the Bless / Curse Manager -->
<Panel class="showHide"
active="true"
id="showBlurse">
<Button onClick="showHideBlurse"
color="White"
image="arrow-down"/>
</Panel>
<!-- window to control bless / curse tokens in chaos bag -->
<!-- height = row heights + 2x outline -->
<TableLayout id="blessCurseManager"
color="black"
active="false"
height="100"
height="104"
width="144"
rectAlignment="MiddleRight"
raycastTarget="true"
outlineSize="2 2"
outline="#303030">
<!-- token counts -->
<Row preferredHeight="26">
<Row preferredHeight="30">
<Cell>
<Text id="countBless"
fontSize="25"