From b47619c4a6eaddaa0b5b3322f6c4f9942fe52027 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 29 Sep 2024 19:12:37 +0200 Subject: [PATCH] added padding and save/load function --- objects/LuaScriptState.luascriptstate | 1 + src/core/Global.ttslua | 22 +++++++++++++++--- xml/Global/BlessCurseManager.xml | 32 +++++++++++++++------------ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/objects/LuaScriptState.luascriptstate b/objects/LuaScriptState.luascriptstate index ad0f2467..38e5e7f2 100644 --- a/objects/LuaScriptState.luascriptstate +++ b/objects/LuaScriptState.luascriptstate @@ -1,5 +1,6 @@ { "acknowledgedUpgradeVersions": [], + "blurseVisibility": [], "chaosTokensGUID": [], "handVisibility": [], "optionPanel": { diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 10979138..c0e778b9 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -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 --------------------------------------------------------- diff --git a/xml/Global/BlessCurseManager.xml b/xml/Global/BlessCurseManager.xml index da22646b..947e8f02 100644 --- a/xml/Global/BlessCurseManager.xml +++ b/xml/Global/BlessCurseManager.xml @@ -7,42 +7,46 @@ height="30" width="30" rectAlignment="MiddleRight" - offsetXY="0 67" + offsetXY="0 69" outlineSize="2 2" outline="#303030"/> +