updated option panel
This commit is contained in:
parent
e2d31038f7
commit
0047334592
@ -344,14 +344,14 @@
|
||||
},
|
||||
"CustomUIAsset": [
|
||||
{
|
||||
"Name": "option-on",
|
||||
"Name": "option_on",
|
||||
"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,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
}
|
||||
],
|
||||
"Description": "",
|
||||
|
@ -344,14 +344,14 @@
|
||||
},
|
||||
"CustomUIAsset": [
|
||||
{
|
||||
"Name": "option-on",
|
||||
"Name": "option_on",
|
||||
"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,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
}
|
||||
],
|
||||
"Description": "",
|
||||
|
@ -344,14 +344,14 @@
|
||||
},
|
||||
"CustomUIAsset": [
|
||||
{
|
||||
"Name": "option-on",
|
||||
"Name": "option_on",
|
||||
"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,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
}
|
||||
],
|
||||
"Description": "",
|
||||
|
@ -344,14 +344,14 @@
|
||||
},
|
||||
"CustomUIAsset": [
|
||||
{
|
||||
"Name": "option-on",
|
||||
"Name": "option_on",
|
||||
"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,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
|
||||
}
|
||||
],
|
||||
"Description": "",
|
||||
|
@ -24,16 +24,6 @@ function onLoad()
|
||||
buttonParamaters.font_size = 120
|
||||
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
|
||||
Wait.time(function()
|
||||
updateColors()
|
||||
@ -117,8 +107,3 @@ function updateValue()
|
||||
-- update button label and color
|
||||
self.editButton({ index = 0, font_color = hasDES and "Green" or "White", label = size })
|
||||
end
|
||||
|
||||
-- discards a random non-hidden card from hand
|
||||
function discardRandom()
|
||||
playermatApi.doDiscardOne(matColor)
|
||||
end
|
||||
|
@ -267,8 +267,8 @@ function onObjectNumberTyped(hoveredObject, playerColor, number)
|
||||
end
|
||||
end
|
||||
|
||||
-- TTS event, used to redraw the playermat slot symbols after a small delay to account for the custom font loading
|
||||
function onPlayerConnect()
|
||||
-- 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
|
||||
|
||||
|
@ -10,17 +10,20 @@ local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
|
||||
|
||||
-- option panel data
|
||||
local availableOptions = {
|
||||
["Personal Settings"] = {
|
||||
["PERSONAL SETTINGS"] = {
|
||||
{
|
||||
id = "slotEditing",
|
||||
title = "Enable Slot Edit Mode",
|
||||
tooltip = "Makes each slot clickable to change the symbol.",
|
||||
type = "toggle",
|
||||
data = "false"
|
||||
type = "toggle"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- stores the value for each id
|
||||
local optionPanelData = {}
|
||||
optionPanelData.slotEditing = false
|
||||
|
||||
-- we use this to turn off collision handling until onLoad() is complete
|
||||
local collisionEnabled = false
|
||||
local currentlyEditingSlots = false
|
||||
@ -120,11 +123,16 @@ local ownedObjects = {}
|
||||
local matColor = self.getMemo()
|
||||
|
||||
function onSave()
|
||||
log(optionPanelData)
|
||||
log(type(optionPanelData))
|
||||
log(optionPanelData.slotEditing)
|
||||
|
||||
return JSON.encode({
|
||||
activeInvestigatorClass = activeInvestigatorClass,
|
||||
activeInvestigatorId = activeInvestigatorId,
|
||||
isClassTextureEnabled = isClassTextureEnabled,
|
||||
isDrawButtonVisible = isDrawButtonVisible,
|
||||
optionPanelData = optionPanelData,
|
||||
playerColor = playerColor,
|
||||
slotData = slotData
|
||||
})
|
||||
@ -137,6 +145,7 @@ function onLoad(savedData)
|
||||
activeInvestigatorId = loadedData.activeInvestigatorId
|
||||
isClassTextureEnabled = loadedData.isClassTextureEnabled
|
||||
isDrawButtonVisible = loadedData.isDrawButtonVisible
|
||||
--optionPanelData = loadedData.optionPanelData
|
||||
playerColor = loadedData.playerColor
|
||||
slotData = loadedData.slotData
|
||||
end
|
||||
@ -174,10 +183,10 @@ function onLoad(savedData)
|
||||
-- Upkeep button: can use the default parameters for this
|
||||
self.createButton(buttonParameters)
|
||||
|
||||
-- Slot editing button: modified default data
|
||||
buttonParameters.label = "Edit Slots"
|
||||
buttonParameters.click_function = "toggleSlotEditing"
|
||||
buttonParameters.tooltip = "Right-click to reset slot symbols"
|
||||
-- Discard 1 button: modified default data
|
||||
buttonParameters.label = "Discard 1"
|
||||
buttonParameters.click_function = "doDiscardOne"
|
||||
buttonParameters.tooltip = "Discard one random card from hand (hidden cards are excluded)."
|
||||
buttonParameters.position.z = 0.92
|
||||
self.createButton(buttonParameters)
|
||||
|
||||
@ -239,18 +248,6 @@ function round(num, numDecimalPlaces)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
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
|
||||
---@param clickedByColor string Colorstring of player who clicked a button
|
||||
function updateMessageColor(clickedByColor)
|
||||
@ -258,7 +255,7 @@ function updateMessageColor(clickedByColor)
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- Discard buttons
|
||||
-- Discard buttons (threat area)
|
||||
---------------------------------------------------------
|
||||
|
||||
-- handles discarding for a list of objects
|
||||
@ -418,7 +415,8 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
||||
-- draw up to 5 cards
|
||||
local cardsToDraw = 5 - #handCards + #cardsToDiscard
|
||||
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
|
||||
local k = 0
|
||||
@ -608,9 +606,12 @@ function doDiscardOne()
|
||||
|
||||
-- get a random eligible card (from the "choices" table)
|
||||
local num = math.random(1, #choices)
|
||||
deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())
|
||||
broadcastToAll(getColoredName(playerColor) .. " randomly discarded card "
|
||||
.. choices[num] .. "/" .. #hand .. ".", "White")
|
||||
local card = hand[choices[num]]
|
||||
local cardName = card.getName()
|
||||
local cardId = choices[num] .. "/" .. #hand
|
||||
|
||||
deckLib.placeOrMergeIntoDeck(card, returnGlobalDiscardPosition(), self.getRotation())
|
||||
broadcastToAll(getColoredName(playerColor) .. " randomly discarded " .. cardName " (" .. cardId .. ").", "White")
|
||||
end
|
||||
end
|
||||
|
||||
@ -714,18 +715,23 @@ function createXML()
|
||||
}
|
||||
table.insert(xml, defaultsXML)
|
||||
|
||||
-- work out the position
|
||||
local bounds = self.getBoundsNormalized()
|
||||
local setAsideDirection = bounds.center.z > 0 and 1 or -1
|
||||
|
||||
-- main window
|
||||
local optionPanelXML = {
|
||||
tag = "TableLayout",
|
||||
attributes = {
|
||||
scale = "0.2 0.2",
|
||||
width = "600",
|
||||
height = "600",
|
||||
scale = "0.11 0.11",
|
||||
width = "1000",
|
||||
height = "1200",
|
||||
rotation = "0 0 180",
|
||||
position = "300 0 -100",
|
||||
position = (setAsideDirection * 270) .. " -35 -58",
|
||||
--active = "false",
|
||||
raycastTarget = "true",
|
||||
color = "#000000",
|
||||
outlineSize = "2 2",
|
||||
outlineSize = "5 5",
|
||||
outline = "grey",
|
||||
showAnimation = "SlideIn_Right",
|
||||
hideAnimation = "SlideOut_Right",
|
||||
@ -735,18 +741,18 @@ function createXML()
|
||||
-- header
|
||||
{
|
||||
tag = "Row",
|
||||
--attributes = { preferredHeight = "60" },
|
||||
attributes = { preferredHeight = "200" },
|
||||
children = {
|
||||
{
|
||||
tag = "Cell",
|
||||
children = {
|
||||
{
|
||||
tag = "Panel",
|
||||
attributes = { padding = "10 0 0 0", scale = "0.3 0.3" },
|
||||
attributes = { padding = "30 0 0 0" },
|
||||
children = {
|
||||
{
|
||||
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
|
||||
local groupXML = {
|
||||
tag = "Row",
|
||||
--attributes = { preferredHeight = "44" },
|
||||
attributes = { preferredHeight = "150" },
|
||||
children = {
|
||||
{
|
||||
tag = "Cell",
|
||||
attributes = { padding = "10 10 0 0", columnSpan = "3", color = "#222222" },
|
||||
attributes = { padding = "20 10 0 0", columnSpan = "3", color = "#222222" },
|
||||
children = {
|
||||
{
|
||||
tag = "Panel",
|
||||
attributes = { padding = "5 0 0 0" },
|
||||
attributes = { padding = "40 0 0 0" },
|
||||
children = {
|
||||
{
|
||||
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
|
||||
for i, optionData in ipairs(groupData) do
|
||||
local optionXML = {
|
||||
{
|
||||
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 = "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 = {
|
||||
-- option title
|
||||
{
|
||||
tag = "Cell",
|
||||
attributes = { padding = "10 10 5 5", color = "#333333", columnSpan = "2" },
|
||||
attributes = { padding = "20 10 5 5", color = "#333333", columnSpan = "2" },
|
||||
children = {
|
||||
{
|
||||
tag = "Panel",
|
||||
attributes = { padding = "10 0 0 0" },
|
||||
attributes = { padding = "50 0 0 0" },
|
||||
children = {
|
||||
{
|
||||
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",
|
||||
attributes = {
|
||||
id = optionData.id,
|
||||
image = "option-off",
|
||||
image = optionData.data == true and "option_on" or "option_off",
|
||||
onClick = "onClick_toggleOption",
|
||||
rectAlignment = "MiddleRight",
|
||||
offsetXY = "-30 0",
|
||||
colors = "#FFFFFF|#dfdfdf",
|
||||
height = "36",
|
||||
width = "65",
|
||||
height = "72",
|
||||
width = "130",
|
||||
ignoreLayout = "True"
|
||||
}
|
||||
}
|
||||
@ -830,18 +840,30 @@ function createXML()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
table.insert(groupXML.children, optionXML)
|
||||
end
|
||||
table.insert(optionPanelXML.children, groupXML)
|
||||
table.insert(optionPanelXML.children, optionXML)
|
||||
end
|
||||
end
|
||||
table.insert(xml, optionPanelXML)
|
||||
|
||||
-- create buttons at the bottom
|
||||
|
||||
self.UI.setXmlTable(xml)
|
||||
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
|
||||
function updateSlotSymbols()
|
||||
for slotId, slotName in ipairs(slotData) do
|
||||
|
@ -63,6 +63,7 @@
|
||||
padding="0 17 3 3"/>
|
||||
<Button class="optionToggle"
|
||||
image="option_off"
|
||||
onClick="onClick_toggleOption"
|
||||
rectAlignment="MiddleRight"
|
||||
offsetXY="-30 0"
|
||||
colors="#FFFFFF|#dfdfdf"
|
||||
@ -156,8 +157,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showTitleSplash"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showTitleSplash"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -171,8 +171,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="enableCardHelpers"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="enableCardHelpers"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -196,8 +195,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="playAreaSnapTags"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="playAreaSnapTags"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -211,8 +209,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="playAreaConnections"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="playAreaConnections"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -243,8 +240,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="changePlayAreaImage"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="changePlayAreaImage"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -268,8 +264,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="useSnapTags"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="useSnapTags"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -283,8 +278,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showDrawButton"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showDrawButton"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -298,8 +292,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="useClassTexture"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="useClassTexture"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -313,8 +306,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="useClueClickers"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="useClueClickers"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -380,8 +372,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showAttachmentHelper"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showAttachmentHelper"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -395,8 +386,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showCleanUpHelper"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showCleanUpHelper"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -410,8 +400,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showCYOA"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showCYOA"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -425,8 +414,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showDisplacementTool"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showDisplacementTool"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -440,8 +428,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showHandHelper"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showHandHelper"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
|
||||
@ -455,8 +442,7 @@
|
||||
</Cell>
|
||||
<Cell class="option-button">
|
||||
<Button class="optionToggle"
|
||||
id="showSearchAssistant"
|
||||
onClick="onClick_toggleOption"/>
|
||||
id="showSearchAssistant"/>
|
||||
</Cell>
|
||||
</Row>
|
||||
</TableLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user