updated option panel

This commit is contained in:
Chr1Z93 2024-08-02 14:10:29 +02:00
parent 8c98334979
commit 82bf62f874
7 changed files with 75 additions and 8 deletions

View File

@ -29,6 +29,11 @@
"Type": 0, "Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2026086584372569912/5CB461AEAE2E59D3064D90A776EB86C46081EC78/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2026086584372569912/5CB461AEAE2E59D3064D90A776EB86C46081EC78/"
}, },
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
},
{ {
"Name": "option_on", "Name": "option_on",
"Type": 0, "Type": 0,

View File

@ -357,6 +357,11 @@
"Name": "option_button", "Name": "option_button",
"Type": 0, "Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
} }
], ],
"Description": "", "Description": "",

View File

@ -357,6 +357,11 @@
"Name": "option_button", "Name": "option_button",
"Type": 0, "Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
} }
], ],
"Description": "", "Description": "",

View File

@ -357,6 +357,11 @@
"Name": "option_button", "Name": "option_button",
"Type": 0, "Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
} }
], ],
"Description": "", "Description": "",

View File

@ -357,6 +357,11 @@
"Name": "option_button", "Name": "option_button",
"Type": 0, "Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
} }
], ],
"Description": "", "Description": "",

View File

@ -1164,14 +1164,24 @@ function onClick_toggleUi(player, windowId)
changeWindowVisibilityForColor(player.color, windowId) changeWindowVisibilityForColor(player.color, windowId)
end end
function changeWindowVisibilityForColorWrapper(params)
changeWindowVisibilityForColor(params.color, params.windowId, params.overrideState, params.owner)
end
-- toggles the visibility of the specific window for the specified color -- toggles the visibility of the specific window for the specified color
---@param color string Player color to toggle the visibility for ---@param color string Player color to toggle the visibility for
---@param windowId string ID of the XML element ---@param windowId string ID of the XML element
---@param overrideState? boolean Forcefully sets the new visibility ---@param overrideState? boolean Forcefully sets the new visibility
---@param owner? tts__Object Object that owns the XML (or nil if Global)
---@return boolean visible Returns the new state of the visibility ---@return boolean visible Returns the new state of the visibility
function changeWindowVisibilityForColor(color, windowId, overrideState) function changeWindowVisibilityForColor(color, windowId, overrideState, owner)
local targetUi = UI
if owner then
targetUi = owner.UI
end
-- current state -- current state
local colorString = UI.getAttribute(windowId, "visibility") or "" local colorString = targetUi.getAttribute(windowId, "visibility") or ""
-- parse the visibility string -- parse the visibility string
local visible = false local visible = false
@ -1210,8 +1220,8 @@ function changeWindowVisibilityForColor(color, windowId, overrideState)
newColorString = newColorString:sub(1, -2) newColorString = newColorString:sub(1, -2)
-- update the visibility of the XML -- update the visibility of the XML
UI.setAttribute(windowId, "visibility", newColorString) targetUi.setAttribute(windowId, "visibility", newColorString)
UI.setAttribute(windowId, "active", newColorString ~= "") targetUi.setAttribute(windowId, "active", newColorString ~= "")
return visible return visible
end end

View File

@ -724,6 +724,29 @@ function createXML()
local bounds = self.getBoundsNormalized() local bounds = self.getBoundsNormalized()
local setAsideDirection = bounds.center.z > 0 and 1 or -1 local setAsideDirection = bounds.center.z > 0 and 1 or -1
-- create a button to toggle the option panel visibility
local gearPos
if setAsideDirection == -1 then
-- next to upkeep button
gearPos = "-202 -45 -11"
else
-- below encounter card drawing
gearPos = "203 -21 -11"
end
local toggleOptionPanelXML = {
tag = "Button",
attributes = {
onClick = "onClick_hideOrShowOptions",
width = "7",
height = "7",
position = gearPos,
rotation = "0 0 180",
image = "option_gear_white"
}
}
table.insert(xml, toggleOptionPanelXML)
-- work out the size -- work out the size
local rowHeight = { local rowHeight = {
header = 200, header = 200,
@ -737,11 +760,11 @@ function createXML()
local optionPanelXML = { local optionPanelXML = {
tag = "TableLayout", tag = "TableLayout",
attributes = { attributes = {
id = "optionPanelMain",
scale = scale .. " " .. scale, scale = scale .. " " .. scale,
width = "1000", width = "1000",
rotation = "0 0 180", rotation = "0 0 180",
--active = "false", active = "false",
raycastTarget = "true",
color = "#000000", color = "#000000",
outlineSize = "5 5", outlineSize = "5 5",
outline = "grey", outline = "grey",
@ -874,7 +897,6 @@ function createXML()
} }
} }
end end
table.insert(optionXML.children, typeXML) table.insert(optionXML.children, typeXML)
table.insert(optionPanelXML.children, optionXML) table.insert(optionPanelXML.children, optionXML)
end end
@ -890,9 +912,17 @@ function createXML()
self.UI.setXmlTable(xml) self.UI.setXmlTable(xml)
end end
function onClick_hideOrShowOptions(player)
Global.call("changeWindowVisibilityForColorWrapper", {
color = player.color,
windowId = "optionPanelMain",
owner = self
})
end
function onClick_textureSelect(player) function onClick_textureSelect(player)
local textureList = {} local textureList = {}
for texture, url in pairs(nameToTexture) do for texture, _ in pairs(nameToTexture) do
table.insert(textureList, texture) table.insert(textureList, texture)
end end
player.showOptionsDialog("Select a texture:", textureList, _, updateTexture) player.showOptionsDialog("Select a texture:", textureList, _, updateTexture)
@ -920,6 +950,8 @@ function onClick_handColorSelect(player)
if player.color == playerColor then if player.color == playerColor then
navigationOverlayApi.copyVisibility(playerColor, color) navigationOverlayApi.copyVisibility(playerColor, color)
Player[playerColor].changeColor(color) Player[playerColor].changeColor(color)
else
printToColor("Updated handcolor for this playermat to " .. playerColor .. ".", player.color)
end end
-- update the internal variable -- update the internal variable