added more options

This commit is contained in:
Chr1Z93 2024-08-02 13:03:59 +02:00
parent 8c165b6fa0
commit 8c98334979
9 changed files with 163 additions and 94 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -249,7 +249,7 @@
<Cell class="group-header">
<Panel class="group-header"
image="header_cover">
<Text class="group-header">PLAYERMAT SETTINGS</Text>
<Text class="group-header">GLOBAL PLAYERMAT SETTINGS</Text>
</Panel>
</Cell>
</Row>