diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index fbb683d1..9c0e8dd9 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -104,6 +104,11 @@ "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2450610458480705628/FE3FD9F32E8704BEB7DD6327225D9D8244115A48/" }, + { + "Name": "blurse", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2448359292169458161/DDF4F777B738E2BDD9AF7B3B98AF200DB12485C0/" + }, { "Name": "Exit", "Type": 0, 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/chaosbag/BlessCurseManager.ttslua b/src/chaosbag/BlessCurseManager.ttslua index cf08c733..db1d8052 100644 --- a/src/chaosbag/BlessCurseManager.ttslua +++ b/src/chaosbag/BlessCurseManager.ttslua @@ -89,12 +89,23 @@ function initializeState() end end - updateButtonLabels() + -- delay this update to make sure the XML is ready + Wait.time(updateButtonLabels, 2) end +-- updates the Lua and XML labels with the current bless / curse count function updateButtonLabels() - self.editButton({ index = 2, label = formatTokenCount("Bless", true) }) - self.editButton({ index = 3, label = formatTokenCount("Curse", true) }) + -- get formatted labels + local blessLabel = formatTokenCount("Bless", true) + local curseLabel = formatTokenCount("Curse", true) + + -- edit Lua buttons on the helper + self.editButton({ index = 2, label = blessLabel }) + self.editButton({ index = 3, label = curseLabel }) + + -- edit global XML buttons + Global.UI.setAttribute("countBless", "text", blessLabel) + Global.UI.setAttribute("countCurse", "text", curseLabel) end function broadcastCount(token) @@ -186,6 +197,13 @@ end -- click functions --------------------------------------------------------- +function xmlClick(player, clickType, id) + playerColor = player.color + local isRightClick = (clickType == "-2") + local tokenType = string.sub(id, 6) + callFunctions(tokenType, isRightClick) +end + function clickBless(_, color, isRightClick) playerColor = color callFunctions("Bless", isRightClick) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index a9f292c3..ef9e0b83 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() @@ -1176,14 +1180,21 @@ end ---@param player tts__Player Player that triggered this ---@param windowId string Name of the UI to toggle function onClick_toggleUi(player, windowId) + -- let the Navigation Overlay handle the toggling of its visibility modes if windowId == "Navigation Overlay" then navigationOverlayApi.cycleVisibility(player.color) return end -- hide the playAreaGallery / downloadWindow if visible - if windowId == "downloadWindow" or windowId == "playAreaGallery" then - changeWindowVisibilityForColor(player.color, windowId, false) + if windowId == "downloadWindow" then + changeWindowVisibilityForColor(player.color, "playAreaGallery", false) + elseif windowId == "playAreaGallery" then + changeWindowVisibilityForColor(player.color, "downloadWindow", false) + elseif windowId == "blessCurseManager" then + -- store the state of the Bless/Curse Manager UI to restore it onLoad() + blurseVisibility[player.color] = changeWindowVisibilityForColor(player.color, "blessCurseManager") + return end changeWindowVisibilityForColor(player.color, windowId) @@ -1889,6 +1900,15 @@ function applyHidingToCard(card, handColor) end end +-- loads the visibility of the Bless/Curse Manager XML from the internal variable +function updateBlurseVisibility() + local count = 1 + for playerColor, state in pairs(blurseVisibility) do + Wait.frames(function() changeWindowVisibilityForColor(playerColor, "blessCurseManager", state) end, count) + count = count + 3 + end +end + --------------------------------------------------------- -- Update notification related functionality --------------------------------------------------------- diff --git a/xml/Global/BlessCurseManager.xml b/xml/Global/BlessCurseManager.xml new file mode 100644 index 00000000..5cbe6b59 --- /dev/null +++ b/xml/Global/BlessCurseManager.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + +