From 82bf62f874a98d9de19d5e6d713bafdbb5115d62 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 2 Aug 2024 14:10:29 +0200 Subject: [PATCH] updated option panel --- modsettings/CustomUIAssets.json | 5 ++++ objects/Playermat1White.8b081b.json | 5 ++++ objects/Playermat2Orange.bd0ff4.json | 5 ++++ objects/Playermat3Green.383d8b.json | 5 ++++ objects/Playermat4Red.0840d5.json | 5 ++++ src/core/Global.ttslua | 18 ++++++++++--- src/playermat/Playermat.ttslua | 40 +++++++++++++++++++++++++--- 7 files changed, 75 insertions(+), 8 deletions(-) diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index d8a05821..8d4586a2 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -29,6 +29,11 @@ "Type": 0, "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", "Type": 0, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index 6cf0ee11..744fecd8 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -357,6 +357,11 @@ "Name": "option_button", "Type": 0, "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": "", diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index 3cbd2af1..c17bef2c 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -357,6 +357,11 @@ "Name": "option_button", "Type": 0, "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": "", diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index e4edba58..b3229002 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -357,6 +357,11 @@ "Name": "option_button", "Type": 0, "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": "", diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index 5579934e..49c88946 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -357,6 +357,11 @@ "Name": "option_button", "Type": 0, "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": "", diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index a39bf6de..5bebb0aa 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -1164,14 +1164,24 @@ function onClick_toggleUi(player, windowId) changeWindowVisibilityForColor(player.color, windowId) 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 ---@param color string Player color to toggle the visibility for ---@param windowId string ID of the XML element ---@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 -function changeWindowVisibilityForColor(color, windowId, overrideState) +function changeWindowVisibilityForColor(color, windowId, overrideState, owner) + local targetUi = UI + if owner then + targetUi = owner.UI + end + -- current state - local colorString = UI.getAttribute(windowId, "visibility") or "" + local colorString = targetUi.getAttribute(windowId, "visibility") or "" -- parse the visibility string local visible = false @@ -1210,8 +1220,8 @@ function changeWindowVisibilityForColor(color, windowId, overrideState) newColorString = newColorString:sub(1, -2) -- update the visibility of the XML - UI.setAttribute(windowId, "visibility", newColorString) - UI.setAttribute(windowId, "active", newColorString ~= "") + targetUi.setAttribute(windowId, "visibility", newColorString) + targetUi.setAttribute(windowId, "active", newColorString ~= "") return visible end diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 75a180eb..017847a8 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -724,6 +724,29 @@ function createXML() local bounds = self.getBoundsNormalized() 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 local rowHeight = { header = 200, @@ -737,11 +760,11 @@ function createXML() local optionPanelXML = { tag = "TableLayout", attributes = { + id = "optionPanelMain", scale = scale .. " " .. scale, width = "1000", rotation = "0 0 180", - --active = "false", - raycastTarget = "true", + active = "false", color = "#000000", outlineSize = "5 5", outline = "grey", @@ -874,7 +897,6 @@ function createXML() } } end - table.insert(optionXML.children, typeXML) table.insert(optionPanelXML.children, optionXML) end @@ -890,9 +912,17 @@ function createXML() self.UI.setXmlTable(xml) end +function onClick_hideOrShowOptions(player) + Global.call("changeWindowVisibilityForColorWrapper", { + color = player.color, + windowId = "optionPanelMain", + owner = self + }) +end + function onClick_textureSelect(player) local textureList = {} - for texture, url in pairs(nameToTexture) do + for texture, _ in pairs(nameToTexture) do table.insert(textureList, texture) end player.showOptionsDialog("Select a texture:", textureList, _, updateTexture) @@ -920,6 +950,8 @@ function onClick_handColorSelect(player) if player.color == playerColor then navigationOverlayApi.copyVisibility(playerColor, color) Player[playerColor].changeColor(color) + else + printToColor("Updated handcolor for this playermat to " .. playerColor .. ".", player.color) end -- update the internal variable