updated option panel

This commit is contained in:
Chr1Z93 2024-08-02 11:53:36 +02:00
parent e2d31038f7
commit 0047334592
8 changed files with 127 additions and 134 deletions

View File

@ -344,14 +344,14 @@
}, },
"CustomUIAsset": [ "CustomUIAsset": [
{ {
"Name": "option-on", "Name": "option_on",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
}, },
{ {
"Name": "option-off", "Name": "option_off",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
} }
], ],
"Description": "", "Description": "",

View File

@ -344,14 +344,14 @@
}, },
"CustomUIAsset": [ "CustomUIAsset": [
{ {
"Name": "option-on", "Name": "option_on",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
}, },
{ {
"Name": "option-off", "Name": "option_off",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
} }
], ],
"Description": "", "Description": "",

View File

@ -344,14 +344,14 @@
}, },
"CustomUIAsset": [ "CustomUIAsset": [
{ {
"Name": "option-on", "Name": "option_on",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
}, },
{ {
"Name": "option-off", "Name": "option_off",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
} }
], ],
"Description": "", "Description": "",

View File

@ -344,14 +344,14 @@
}, },
"CustomUIAsset": [ "CustomUIAsset": [
{ {
"Name": "option-on", "Name": "option_on",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
}, },
{ {
"Name": "option-off", "Name": "option_off",
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
} }
], ],
"Description": "", "Description": "",

View File

@ -24,16 +24,6 @@ function onLoad()
buttonParamaters.font_size = 120 buttonParamaters.font_size = 120
self.createButton(buttonParamaters) self.createButton(buttonParamaters)
-- index 2: button to discard a card
buttonParamaters.label = "Discard Random Card"
buttonParamaters.click_function = "discardRandom"
buttonParamaters.position.z = 0.7
buttonParamaters.height = 175
buttonParamaters.width = 900
buttonParamaters.font_size = 90
buttonParamaters.font_color = "Black"
self.createButton(buttonParamaters)
-- make sure this part executes after the playermats are loaded -- make sure this part executes after the playermats are loaded
Wait.time(function() Wait.time(function()
updateColors() updateColors()
@ -117,8 +107,3 @@ function updateValue()
-- update button label and color -- update button label and color
self.editButton({ index = 0, font_color = hasDES and "Green" or "White", label = size }) self.editButton({ index = 0, font_color = hasDES and "Green" or "White", label = size })
end end
-- discards a random non-hidden card from hand
function discardRandom()
playermatApi.doDiscardOne(matColor)
end

View File

@ -267,8 +267,8 @@ function onObjectNumberTyped(hoveredObject, playerColor, number)
end end
end end
-- TTS event, used to redraw the playermat slot symbols after a small delay to account for the custom font loading -- TTS event, used to redraw the playermat slot symbols after a delay to account for the custom font loading
function onPlayerConnect() function onPlayerChangeColor()
Wait.time(function() playermatApi.redrawSlotSymbols("All") end, 0.2) Wait.time(function() playermatApi.redrawSlotSymbols("All") end, 0.2)
end end

View File

@ -10,17 +10,20 @@ local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
-- option panel data -- option panel data
local availableOptions = { local availableOptions = {
["Personal Settings"] = { ["PERSONAL SETTINGS"] = {
{ {
id = "slotEditing", id = "slotEditing",
title = "Enable Slot Edit Mode", title = "Enable Slot Edit Mode",
tooltip = "Makes each slot clickable to change the symbol.", tooltip = "Makes each slot clickable to change the symbol.",
type = "toggle", type = "toggle"
data = "false"
} }
} }
} }
-- stores the value for each id
local optionPanelData = {}
optionPanelData.slotEditing = false
-- we use this to turn off collision handling until onLoad() is complete -- we use this to turn off collision handling until onLoad() is complete
local collisionEnabled = false local collisionEnabled = false
local currentlyEditingSlots = false local currentlyEditingSlots = false
@ -120,11 +123,16 @@ local ownedObjects = {}
local matColor = self.getMemo() local matColor = self.getMemo()
function onSave() function onSave()
log(optionPanelData)
log(type(optionPanelData))
log(optionPanelData.slotEditing)
return JSON.encode({ return JSON.encode({
activeInvestigatorClass = activeInvestigatorClass, activeInvestigatorClass = activeInvestigatorClass,
activeInvestigatorId = activeInvestigatorId, activeInvestigatorId = activeInvestigatorId,
isClassTextureEnabled = isClassTextureEnabled, isClassTextureEnabled = isClassTextureEnabled,
isDrawButtonVisible = isDrawButtonVisible, isDrawButtonVisible = isDrawButtonVisible,
optionPanelData = optionPanelData,
playerColor = playerColor, playerColor = playerColor,
slotData = slotData slotData = slotData
}) })
@ -137,6 +145,7 @@ function onLoad(savedData)
activeInvestigatorId = loadedData.activeInvestigatorId activeInvestigatorId = loadedData.activeInvestigatorId
isClassTextureEnabled = loadedData.isClassTextureEnabled isClassTextureEnabled = loadedData.isClassTextureEnabled
isDrawButtonVisible = loadedData.isDrawButtonVisible isDrawButtonVisible = loadedData.isDrawButtonVisible
--optionPanelData = loadedData.optionPanelData
playerColor = loadedData.playerColor playerColor = loadedData.playerColor
slotData = loadedData.slotData slotData = loadedData.slotData
end end
@ -174,10 +183,10 @@ function onLoad(savedData)
-- Upkeep button: can use the default parameters for this -- Upkeep button: can use the default parameters for this
self.createButton(buttonParameters) self.createButton(buttonParameters)
-- Slot editing button: modified default data -- Discard 1 button: modified default data
buttonParameters.label = "Edit Slots" buttonParameters.label = "Discard 1"
buttonParameters.click_function = "toggleSlotEditing" buttonParameters.click_function = "doDiscardOne"
buttonParameters.tooltip = "Right-click to reset slot symbols" buttonParameters.tooltip = "Discard one random card from hand (hidden cards are excluded)."
buttonParameters.position.z = 0.92 buttonParameters.position.z = 0.92
self.createButton(buttonParameters) self.createButton(buttonParameters)
@ -239,18 +248,6 @@ function round(num, numDecimalPlaces)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end
-- edits the label of a button
---@param oldLabel string Old label of the button
---@param newLabel string New label of the button
function editButtonLabel(oldLabel, newLabel)
local buttons = self.getButtons()
for i = 1, #buttons do
if buttons[i].label == oldLabel then
self.editButton({ index = buttons[i].index, label = newLabel })
end
end
end
-- updates the internal "messageColor" which is used for print/broadcast statements if no player is seated -- updates the internal "messageColor" which is used for print/broadcast statements if no player is seated
---@param clickedByColor string Colorstring of player who clicked a button ---@param clickedByColor string Colorstring of player who clicked a button
function updateMessageColor(clickedByColor) function updateMessageColor(clickedByColor)
@ -258,7 +255,7 @@ function updateMessageColor(clickedByColor)
end end
--------------------------------------------------------- ---------------------------------------------------------
-- Discard buttons -- Discard buttons (threat area)
--------------------------------------------------------- ---------------------------------------------------------
-- handles discarding for a list of objects -- handles discarding for a list of objects
@ -418,7 +415,8 @@ function doUpkeep(_, clickedByColor, isRightClick)
-- draw up to 5 cards -- draw up to 5 cards
local cardsToDraw = 5 - #handCards + #cardsToDiscard local cardsToDraw = 5 - #handCards + #cardsToDiscard
if cardsToDraw > 0 then if cardsToDraw > 0 then
printToColor("Discarding " .. #cardsToDiscard .. " and drawing " .. cardsToDraw .. " card(s). (Patrice)", messageColor) printToColor("Discarding " .. #cardsToDiscard .. " and drawing " .. cardsToDraw .. " card(s). (Patrice)",
messageColor)
-- add some time if there are any cards to discard -- add some time if there are any cards to discard
local k = 0 local k = 0
@ -608,9 +606,12 @@ function doDiscardOne()
-- get a random eligible card (from the "choices" table) -- get a random eligible card (from the "choices" table)
local num = math.random(1, #choices) local num = math.random(1, #choices)
deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation()) local card = hand[choices[num]]
broadcastToAll(getColoredName(playerColor) .. " randomly discarded card " local cardName = card.getName()
.. choices[num] .. "/" .. #hand .. ".", "White") local cardId = choices[num] .. "/" .. #hand
deckLib.placeOrMergeIntoDeck(card, returnGlobalDiscardPosition(), self.getRotation())
broadcastToAll(getColoredName(playerColor) .. " randomly discarded " .. cardName " (" .. cardId .. ").", "White")
end end
end end
@ -714,18 +715,23 @@ function createXML()
} }
table.insert(xml, defaultsXML) table.insert(xml, defaultsXML)
-- work out the position
local bounds = self.getBoundsNormalized()
local setAsideDirection = bounds.center.z > 0 and 1 or -1
-- main window -- main window
local optionPanelXML = { local optionPanelXML = {
tag = "TableLayout", tag = "TableLayout",
attributes = { attributes = {
scale = "0.2 0.2", scale = "0.11 0.11",
width = "600", width = "1000",
height = "600", height = "1200",
rotation = "0 0 180", rotation = "0 0 180",
position = "300 0 -100", position = (setAsideDirection * 270) .. " -35 -58",
--active = "false", --active = "false",
raycastTarget = "true",
color = "#000000", color = "#000000",
outlineSize = "2 2", outlineSize = "5 5",
outline = "grey", outline = "grey",
showAnimation = "SlideIn_Right", showAnimation = "SlideIn_Right",
hideAnimation = "SlideOut_Right", hideAnimation = "SlideOut_Right",
@ -735,18 +741,18 @@ function createXML()
-- header -- header
{ {
tag = "Row", tag = "Row",
--attributes = { preferredHeight = "60" }, attributes = { preferredHeight = "200" },
children = { children = {
{ {
tag = "Cell", tag = "Cell",
children = { children = {
{ {
tag = "Panel", tag = "Panel",
attributes = { padding = "10 0 0 0", scale = "0.3 0.3" }, attributes = { padding = "30 0 0 0" },
children = { children = {
{ {
tag = "Text", tag = "Text",
attributes = { font = "font_teutonic-arkham", fontSize = "35", text = "Options" } attributes = { font = "font_teutonic-arkham", fontSize = "110", text = "Options" }
} }
} }
} }
@ -762,19 +768,19 @@ function createXML()
-- group header -- group header
local groupXML = { local groupXML = {
tag = "Row", tag = "Row",
--attributes = { preferredHeight = "44" }, attributes = { preferredHeight = "150" },
children = { children = {
{ {
tag = "Cell", tag = "Cell",
attributes = { padding = "10 10 0 0", columnSpan = "3", color = "#222222" }, attributes = { padding = "20 10 0 0", columnSpan = "3", color = "#222222" },
children = { children = {
{ {
tag = "Panel", tag = "Panel",
attributes = { padding = "5 0 0 0" }, attributes = { padding = "40 0 0 0" },
children = { children = {
{ {
tag = "Text", tag = "Text",
attributes = { fontSize = "28", font = "font_teutonic-arkham", text = groupName } attributes = { fontSize = "75", font = "font_teutonic-arkham", text = groupName }
} }
} }
} }
@ -782,26 +788,30 @@ function createXML()
} }
} }
} }
table.insert(optionPanelXML.children, groupXML)
-- options -- options
for i, optionData in ipairs(groupData) do for _, optionData in ipairs(groupData) do
local optionXML = { local optionXML = {}
{ if optionData.type ~= "toggle" then
log("This isn't implemented yet ;)")
else
optionXML = {
tag = "Row", tag = "Row",
--attributes = { preferredHeight = "50", tooltip = optionData.tooltip, tooltipPosition = "Left", tooltipBackgroundColor = "rgba(0,0,0,1)" }, attributes = { preferredHeight = "150", tooltip = optionData.tooltip, tooltipPosition = "Left", tooltipBackgroundColor = "rgba(0,0,0,1)" },
children = { children = {
-- option title -- option title
{ {
tag = "Cell", tag = "Cell",
attributes = { padding = "10 10 5 5", color = "#333333", columnSpan = "2" }, attributes = { padding = "20 10 5 5", color = "#333333", columnSpan = "2" },
children = { children = {
{ {
tag = "Panel", tag = "Panel",
attributes = { padding = "10 0 0 0" }, attributes = { padding = "50 0 0 0" },
children = { children = {
{ {
tag = "Text", tag = "Text",
attributes = { fontSize = "22", font = "font_teutonic-arkham", text = optionData.title } attributes = { fontSize = "65", font = "font_teutonic-arkham", text = optionData.title }
} }
} }
} }
@ -816,13 +826,13 @@ function createXML()
tag = "Button", tag = "Button",
attributes = { attributes = {
id = optionData.id, id = optionData.id,
image = "option-off", image = optionData.data == true and "option_on" or "option_off",
onClick = "onClick_toggleOption", onClick = "onClick_toggleOption",
rectAlignment = "MiddleRight", rectAlignment = "MiddleRight",
offsetXY = "-30 0", offsetXY = "-30 0",
colors = "#FFFFFF|#dfdfdf", colors = "#FFFFFF|#dfdfdf",
height = "36", height = "72",
width = "65", width = "130",
ignoreLayout = "True" ignoreLayout = "True"
} }
} }
@ -830,18 +840,30 @@ function createXML()
} }
} }
} }
}
table.insert(groupXML.children, optionXML)
end end
table.insert(optionPanelXML.children, groupXML) table.insert(optionPanelXML.children, optionXML)
end
end end
table.insert(xml, optionPanelXML) table.insert(xml, optionPanelXML)
-- create buttons at the bottom
self.UI.setXmlTable(xml) self.UI.setXmlTable(xml)
end end
-- changes the UI state and the internal variable for the togglebuttons
function onClick_toggleOption(player, _, id)
local state = optionPanelData[id]
local newState = not state
applyOptionPanelChange(id, newState, player.color)
self.UI.setAttribute(id, "image", newState and "option_on" or "option_off")
end
function applyOptionPanelChange(id, state, clickedByColor)
optionPanelData[id] = state
if id == "slotEditing" then
toggleSlotEditing(_, clickedByColor)
end
end
-- updates the XML for the slot symbols based on the slotData table -- updates the XML for the slot symbols based on the slotData table
function updateSlotSymbols() function updateSlotSymbols()
for slotId, slotName in ipairs(slotData) do for slotId, slotName in ipairs(slotData) do

View File

@ -63,6 +63,7 @@
padding="0 17 3 3"/> padding="0 17 3 3"/>
<Button class="optionToggle" <Button class="optionToggle"
image="option_off" image="option_off"
onClick="onClick_toggleOption"
rectAlignment="MiddleRight" rectAlignment="MiddleRight"
offsetXY="-30 0" offsetXY="-30 0"
colors="#FFFFFF|#dfdfdf" colors="#FFFFFF|#dfdfdf"
@ -156,8 +157,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showTitleSplash" id="showTitleSplash"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -171,8 +171,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="enableCardHelpers" id="enableCardHelpers"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -196,8 +195,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="playAreaSnapTags" id="playAreaSnapTags"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -211,8 +209,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="playAreaConnections" id="playAreaConnections"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -243,8 +240,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="changePlayAreaImage" id="changePlayAreaImage"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -268,8 +264,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="useSnapTags" id="useSnapTags"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -283,8 +278,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showDrawButton" id="showDrawButton"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -298,8 +292,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="useClassTexture" id="useClassTexture"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -313,8 +306,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="useClueClickers" id="useClueClickers"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -380,8 +372,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showAttachmentHelper" id="showAttachmentHelper"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -395,8 +386,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showCleanUpHelper" id="showCleanUpHelper"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -410,8 +400,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showCYOA" id="showCYOA"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -425,8 +414,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showDisplacementTool" id="showDisplacementTool"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -440,8 +428,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showHandHelper" id="showHandHelper"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
@ -455,8 +442,7 @@
</Cell> </Cell>
<Cell class="option-button"> <Cell class="option-button">
<Button class="optionToggle" <Button class="optionToggle"
id="showSearchAssistant" id="showSearchAssistant"/>
onClick="onClick_toggleOption"/>
</Cell> </Cell>
</Row> </Row>
</TableLayout> </TableLayout>