From 8c9833497957a8fd88d79b75cbfe7533c5b54773 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 2 Aug 2024 13:03:59 +0200 Subject: [PATCH] added more options --- 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/accessories/HandHelper.ttslua | 4 +- src/core/Global.ttslua | 5 - src/playermat/Playermat.ttslua | 221 ++++++++++++++++----------- xml/Global/OptionPanel.xml | 2 +- 9 files changed, 163 insertions(+), 94 deletions(-) diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index 71152a89..d8a05821 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -39,6 +39,11 @@ "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" }, + { + "Name": "option_button", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" + }, { "Name": "font_arkhamicons", "Type": 1, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index b7f3b111..6cf0ee11 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -352,6 +352,11 @@ "Name": "option_off", "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" + }, + { + "Name": "option_button", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" } ], "Description": "", diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index c80d0d3d..3cbd2af1 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -352,6 +352,11 @@ "Name": "option_off", "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" + }, + { + "Name": "option_button", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" } ], "Description": "", diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index 40179bdd..e4edba58 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -352,6 +352,11 @@ "Name": "option_off", "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" + }, + { + "Name": "option_button", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" } ], "Description": "", diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index 24942a4c..5579934e 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -352,6 +352,11 @@ "Name": "option_off", "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" + }, + { + "Name": "option_button", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" } ], "Description": "", diff --git a/src/accessories/HandHelper.ttslua b/src/accessories/HandHelper.ttslua index cce2209e..2e0fcda1 100644 --- a/src/accessories/HandHelper.ttslua +++ b/src/accessories/HandHelper.ttslua @@ -11,7 +11,7 @@ function onLoad() buttonParamaters.hover_color = "White" buttonParamaters.label = 0 buttonParamaters.click_function = "none" - buttonParamaters.position = Vector(0, 0.11, -0.4) + buttonParamaters.position = Vector(0, 0.11, -0.2) buttonParamaters.height = 0 buttonParamaters.width = 0 buttonParamaters.font_size = 500 @@ -20,7 +20,7 @@ function onLoad() -- index 1: button to toggle "des" buttonParamaters.label = "DES: ✗" - buttonParamaters.position.z = 0.25 + buttonParamaters.position.z = 0.45 buttonParamaters.font_size = 120 self.createButton(buttonParamaters) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index e0d4cb03..a39bf6de 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -267,11 +267,6 @@ function onObjectNumberTyped(hoveredObject, playerColor, number) end end --- TTS event, used to redraw the playermat slot symbols after a delay to account for the custom font loading -function onPlayerChangeColor() - Wait.time(function() playermatApi.redrawSlotSymbols("All") end, 0.2) -end - -- disable delete action (only applies to promoted players) and discard objects instead function onPlayerAction(player, action, targets) if action == Player.Action.Delete and not player.admin then diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 272d0aff..75a180eb 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -14,8 +14,17 @@ local availableOptions = { { id = "slotEditing", title = "Enable Slot Edit Mode", - tooltip = "Makes each slot clickable to change the symbol.", type = "toggle" + }, + { + id = "textureSelect", + title = "Select Playermat Texture", + type = "button" + }, + { + id = "handColorSelect", + title = "Select Hand Color", + type = "button" } } } @@ -68,7 +77,7 @@ local ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38 } local buttonParameters = { label = "Upkeep", click_function = "doUpkeep", - tooltip = "Right-click to change color", + tooltip = "Right-click to skip resource gain and card draw", function_owner = self, position = { x = 1.82, y = 0.1, z = -0.45 }, scale = { 0.12, 0.12, 0.12 }, @@ -309,11 +318,6 @@ function doUpkeepFromHotkey(clickedByColor) end function doUpkeep(_, clickedByColor, isRightClick) - if isRightClick then - changeColor(clickedByColor) - return - end - updateMessageColor(clickedByColor) -- unexhaust cards in play zone, flip action tokens and find Forced Learning / Dream-Enhancing Serum @@ -379,6 +383,11 @@ function doUpkeep(_, clickedByColor, isRightClick) end end + if isRightClick then + printToColor("Skipping resource gain and card draw", messageColor) + return + end + -- gain a resource (or two if playing Jenny Barnes) if string.match(activeInvestigatorId, "%d%d%d%d%d") == "02003" then updateCounter({ type = "ResourceCounter", modifier = 2 }) @@ -715,15 +724,22 @@ function createXML() local bounds = self.getBoundsNormalized() local setAsideDirection = bounds.center.z > 0 and 1 or -1 + -- work out the size + local rowHeight = { + header = 200, + groupHeader = 150, + option = 150 + } + local totalHeight = rowHeight.header + local scale = 0.11 + -- main window local optionPanelXML = { tag = "TableLayout", attributes = { - scale = "0.11 0.11", + scale = scale .. " " .. scale, width = "1000", - height = "1200", rotation = "0 0 180", - position = (setAsideDirection * 270) .. " -35 -58", --active = "false", raycastTarget = "true", color = "#000000", @@ -737,7 +753,7 @@ function createXML() -- header { tag = "Row", - attributes = { preferredHeight = "200" }, + attributes = { preferredHeight = rowHeight.header }, children = { { tag = "Cell", @@ -761,10 +777,11 @@ function createXML() -- add options groups for groupName, groupData in pairs(availableOptions) do + totalHeight = totalHeight + rowHeight.groupHeader -- group header local groupXML = { tag = "Row", - attributes = { preferredHeight = "150" }, + attributes = { preferredHeight = rowHeight.groupHeader }, children = { { tag = "Cell", @@ -788,62 +805,128 @@ function createXML() -- options for _, optionData in ipairs(groupData) do - local optionXML = {} - if optionData.type ~= "toggle" then - log("This isn't implemented yet ;)") - else - optionXML = { - tag = "Row", - attributes = { preferredHeight = "150", tooltip = optionData.tooltip, tooltipPosition = "Left", tooltipBackgroundColor = "rgba(0,0,0,1)" }, - children = { - -- option title - { - tag = "Cell", - attributes = { padding = "20 10 5 5", color = "#333333", columnSpan = "2" }, - children = { - { - tag = "Panel", - attributes = { padding = "50 0 0 0" }, - children = { - { - tag = "Text", - attributes = { fontSize = "65", font = "font_teutonic-arkham", text = optionData.title } - } + totalHeight = totalHeight + rowHeight.option + local optionXML = { + tag = "Row", + attributes = { preferredHeight = rowHeight.option}, + children = { + -- option title + { + tag = "Cell", + attributes = { padding = "20 10 5 5", color = "#333333", columnSpan = "2" }, + children = { + { + tag = "Panel", + attributes = { padding = "50 0 0 0" }, + children = { + { + tag = "Text", + attributes = { fontSize = "65", font = "font_teutonic-arkham", text = optionData.title } } } } - }, - -- option button + } + }, + } + } + + local typeXML + if optionData.type == "toggle" then + typeXML = { + tag = "Cell", + attributes = { padding = "10 10 5 5", color = "#333333" }, + children = { { - tag = "Cell", - attributes = { padding = "10 10 5 5", color = "#333333" }, - children = { - { - tag = "Button", - attributes = { - id = optionData.id, - image = optionData.data == true and "option_on" or "option_off", - onClick = "onClick_toggleOption", - rectAlignment = "MiddleRight", - offsetXY = "-30 0", - colors = "#FFFFFF|#dfdfdf", - height = "72", - width = "130", - ignoreLayout = "True" - } - } + tag = "Button", + attributes = { + id = optionData.id, + image = optionData.data == true and "option_on" or "option_off", + onClick = "onClick_toggleOption", + rectAlignment = "MiddleRight", + offsetXY = "-30 0", + colors = "#FFFFFF|#dfdfdf", + height = "108", + width = "195", + ignoreLayout = "True" + } + } + } + } + elseif optionData.type == "button" then + typeXML = { + tag = "Cell", + attributes = { padding = "10 10 5 5", color = "#333333" }, + children = { + { + tag = "Button", + attributes = { + id = optionData.id, + image = "option_button", + onClick = "onClick_" .. optionData.id, + rectAlignment = "MiddleRight", + offsetXY = "-30 0", + colors = "#FFFFFF|#dfdfdf", + height = "108", + width = "195", + ignoreLayout = "True" } } } } end + + table.insert(optionXML.children, typeXML) table.insert(optionPanelXML.children, optionXML) end end table.insert(xml, optionPanelXML) + + -- set correct height + optionPanelXML.attributes.height = totalHeight + + -- set correct position to align with playermat + optionPanelXML.attributes.position = (setAsideDirection * 270) .. " " .. (- 95 + scale * totalHeight / 2) .. " -65" + self.UI.setXmlTable(xml) end +function onClick_textureSelect(player) + local textureList = {} + for texture, url in pairs(nameToTexture) do + table.insert(textureList, texture) + end + player.showOptionsDialog("Select a texture:", textureList, _, updateTexture) +end + +function onClick_handColorSelect(player) + local colorList = Player.getColors() + + -- remove existing colors from the list of choices + for _, existingColor in ipairs(Player.getAvailableColors()) do + for i, newColor in ipairs(colorList) do + if existingColor == newColor or newColor == "Black" or newColor == "Grey" then + table.remove(colorList, i) + end + end + end + + -- show the option dialog for color selection to the player that triggered this + player.showOptionsDialog("Select a new color:", colorList, _, function(color) + -- update the color of the hand zone + local handZone = ownedObjects.HandZone + handZone.setValue(color) + + -- if the seated player clicked this, reseat him to the new color + if player.color == playerColor then + navigationOverlayApi.copyVisibility(playerColor, color) + Player[playerColor].changeColor(color) + end + + -- update the internal variable + playerColor = color + end) +end + -- changes the UI state and the internal variable for the togglebuttons function onClick_toggleOption(player, _, id) local state = optionPanelData[id] @@ -932,40 +1015,6 @@ function resetSlotSymbols() updateSlotSymbols() end ---------------------------------------------------------- --- color related functions ---------------------------------------------------------- - --- changes the player color -function changeColor(clickedByColor) - local colorList = Player.getColors() - - -- remove existing colors from the list of choices - for _, existingColor in ipairs(Player.getAvailableColors()) do - for i, newColor in ipairs(colorList) do - if existingColor == newColor or newColor == "Black" or newColor == "Grey" then - table.remove(colorList, i) - end - end - end - - -- show the option dialog for color selection to the player that triggered this - Player[clickedByColor].showOptionsDialog("Select a new color:", colorList, _, function(color) - -- update the color of the hand zone - local handZone = ownedObjects.HandZone - handZone.setValue(color) - - -- if the seated player clicked this, reseat him to the new color - if clickedByColor == playerColor then - navigationOverlayApi.copyVisibility(playerColor, color) - Player[playerColor].changeColor(color) - end - - -- update the internal variable - playerColor = color - end) -end - --------------------------------------------------------- -- playermat token spawning --------------------------------------------------------- diff --git a/xml/Global/OptionPanel.xml b/xml/Global/OptionPanel.xml index 49f7fb68..d2b79f49 100644 --- a/xml/Global/OptionPanel.xml +++ b/xml/Global/OptionPanel.xml @@ -249,7 +249,7 @@ - PLAYERMAT SETTINGS + GLOBAL PLAYERMAT SETTINGS