Merge pull request #883 from argonui/blurse-xml

Added a global XML UI for the Bless/Curse Manager
This commit is contained in:
dscarpac 2024-09-29 16:07:04 -05:00 committed by GitHub
commit fb6c39c741
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 131 additions and 26 deletions

View File

@ -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,

View File

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

View File

@ -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)

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()
@ -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
---------------------------------------------------------

View File

@ -0,0 +1,57 @@
<Defaults>
<Text font="font_teutonic-arkham"
alignment="MiddleCenter"
rectAlignment="MiddleCenter"/>
<Panel class="showHide"
color="black"
height="30"
width="30"
rectAlignment="MiddleRight"
offsetXY="0 69"
outlineSize="2 2"
outline="#303030"/>
</Defaults>
<!-- window to control bless / curse tokens in chaos bag -->
<!-- height = row heights + 2x outline -->
<TableLayout id="blessCurseManager"
color="black"
active="false"
height="104"
width="144"
offsetXY="-1 250"
rectAlignment="LowerRight"
raycastTarget="true"
outlineSize="2 2"
outline="#303030">
<!-- token counts -->
<Row preferredHeight="30">
<Cell>
<Text id="countBless"
fontSize="25"
text="0 + 0"/>
</Cell>
<Cell>
<Text id="countCurse"
fontSize="25"
text="0 + 0"/>
</Cell>
</Row>
<!-- token buttons -->
<Row preferredHeight="70">
<Cell>
<Panel padding="4 4 4 4">
<Button image="token-bless"
id="imageBless"
onClick="5933fb/xmlClick"/>
</Panel>
</Cell>
<Cell>
<Panel padding="4 4 4 4">
<Button image="token-curse"
id="imageCurse"
onClick="5933fb/xmlClick"/>
</Panel>
</Cell>
</Row>
</TableLayout>

View File

@ -1,20 +1,28 @@
<Defaults>
<Button class="navbar"
tooltipOffset="-300"
tooltipPosition="Left"
tooltipBackgroundColor="rgba(0,0,0,1)"
color="clear"/>
<VerticalLayout class="navbar"
width="800"
padding="70 70 70 70"
scale="0.05 0.05 1"
color="#000000"
outlineSize="20 20"
outline="#303030"
rectAlignment="LowerRight"/>
</Defaults>
<!-- Buttons at the bottom right (height: n * width + spacing) -->
<VerticalLayout visibility="Admin"
color="#000000"
outlineSize="1 1"
outline="#303030"
rectAlignment="LowerRight"
width="38"
height="78"
offsetXY="-1 123"
spacing="2">
<!-- Buttons at the bottom right (height: n * width) -->
<VerticalLayout class="navbar"
visibility="Admin"
height="2400"
offsetXY="-1 120">
<Button class="navbar"
icon="blurse"
tooltip="Bless/Curse Manager"
onClick="onClick_toggleUi(blessCurseManager)"/>
<Button class="navbar"
icon="devourer"
tooltip="Downloadable Content"
@ -25,17 +33,12 @@
onClick="onClick_toggleUi(optionPanel)"/>
</VerticalLayout>
<!-- Navigation Overlay button (not visibly to Grey and Black) -->
<Panel visibility="White|Brown|Red|Orange|Yellow|Green|Teal|Blue|Purple|Pink"
color="#000000"
outlineSize="1 1"
outline="#303030"
rectAlignment="LowerRight"
width="38"
height="38"
offsetXY="-1 85">
<!-- Navigation Overlay button -->
<VerticalLayout class="navbar"
height="800"
offsetXY="-1 80">
<Button class="navbar"
icon="NavigationOverlayIcon"
tooltip="Navigation Overlay"
onClick="onClick_toggleUi(Navigation Overlay)"/>
</Panel>
</VerticalLayout>

View File

@ -9,5 +9,6 @@
<Include src="Global/PlayAreaGallery.xml"/>
<Include src="Global/TitleSplash.xml"/>
<Include src="Global/NavigationOverlay.xml"/>
<Include src="Global/BlessCurseManager.xml"/>
<Include src="Global/OptionPanel.xml"/>
<Include src="Global/UpdateNotification.xml"/>