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": [], "acknowledgedUpgradeVersions": [],
"blurseVisibility": [],
"chaosTokensGUID": [], "chaosTokensGUID": [],
"handVisibility": [], "handVisibility": [],
"optionPanel": { "optionPanel": {

View File

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

View File

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