From 8f51447e59b4a25a6e84bdd142ba01c4ada5bba1 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 27 Sep 2024 15:47:44 +0200 Subject: [PATCH] added global xml for bless curse manager --- modsettings/CustomUIAssets.json | 10 ++++ src/chaosbag/BlessCurseManager.ttslua | 24 +++++++-- src/core/Global.ttslua | 7 +++ xml/Global/BlessCurseManager.xml | 71 +++++++++++++++++++++++++++ xml/Global/Global.xml | 1 + 5 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 xml/Global/BlessCurseManager.xml diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index fbb683d1..5ca63e31 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -104,6 +104,16 @@ "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2450610458480705628/FE3FD9F32E8704BEB7DD6327225D9D8244115A48/" }, + { + "Name": "arrow-down", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2448359292156394304/63B2D48BB94DD4CD4F897D8528E049D521298B02/" + }, + { + "Name": "caret", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2448359292156394421/CFAF0262FEDE662D399A5D786E7450B49B952C99/" + }, { "Name": "Exit", "Type": 0, 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..10979138 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -1172,6 +1172,13 @@ function onClick_spawnPlaceholder(player) changeWindowVisibilityForColor(player.color, "downloadWindow", false) end +-- toggles the visbility 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) +end + -- toggles the visibility of the respective UI ---@param player tts__Player Player that triggered this ---@param windowId string Name of the UI to toggle diff --git a/xml/Global/BlessCurseManager.xml b/xml/Global/BlessCurseManager.xml new file mode 100644 index 00000000..aeda7f64 --- /dev/null +++ b/xml/Global/BlessCurseManager.xml @@ -0,0 +1,71 @@ + + + + + + + +