updated slot xml to allow more XML
This commit is contained in:
parent
cc86d223d0
commit
40908aa78f
@ -238,11 +238,6 @@ 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
|
|
||||||
function onPlayerConnect()
|
|
||||||
Wait.time(function() playermatApi.redrawSlotSymbols("All") end, 0.2)
|
|
||||||
end
|
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- chaos token drawing
|
-- chaos token drawing
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
@ -166,7 +166,7 @@ function onLoad(savedData)
|
|||||||
self.createButton(buttonParameters)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
showDrawButton(isDrawButtonVisible)
|
showDrawButton(isDrawButtonVisible)
|
||||||
redrawSlotSymbols()
|
createXML()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
Wait.time(function() collisionEnabled = true end, 0.1)
|
Wait.time(function() collisionEnabled = true end, 0.1)
|
||||||
end
|
end
|
||||||
@ -255,13 +255,11 @@ function discardListOfObjects(objList)
|
|||||||
else
|
else
|
||||||
deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })
|
deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- put chaos tokens back into bag (e.g. Unrelenting)
|
|
||||||
elseif tokenChecker.isChaosToken(obj) then
|
elseif tokenChecker.isChaosToken(obj) then
|
||||||
|
-- put chaos tokens back into bag (e.g. Unrelenting)
|
||||||
chaosBagApi.returnChaosTokenToBag(obj)
|
chaosBagApi.returnChaosTokenToBag(obj)
|
||||||
|
|
||||||
-- don't touch locked objects (like the table etc.) or specific objects (like key tokens)
|
|
||||||
elseif not obj.getLock() and not obj.hasTag("DontDiscard") then
|
elseif not obj.getLock() and not obj.hasTag("DontDiscard") then
|
||||||
|
-- don't touch locked objects (like the table etc.) or specific objects (like key tokens)
|
||||||
ownedObjects.Trash.putObject(obj)
|
ownedObjects.Trash.putObject(obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -395,19 +393,17 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local j = 0
|
-- perform discarding 1 by 1
|
||||||
local k = 0
|
local pos = returnGlobalDiscardPosition()
|
||||||
|
local count = #cardsToDiscard
|
||||||
for i = #cardsToDiscard, 1, -1 do
|
for i = count, 1, -1 do
|
||||||
j = j + 1
|
Wait.time(function() deckLib.placeOrMergeIntoDeck(cardsToDiscard[i], pos, rot) end, (count - i + 1) * 0.1)
|
||||||
Wait.time(function() deckLib.placeOrMergeIntoDeck(cardsToDiscard[i], returnGlobalDiscardPosition(), self.getRotation()) end, j * 0.1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add some time if there are any cards to discard, if not, draw up to 5 immediately
|
-- add some time if there are any cards to discard, if not, draw up to 5 immediately
|
||||||
if j > 0 then
|
local k = 0
|
||||||
k = 0.7 + (j * 0.1)
|
if count > 0 then
|
||||||
else
|
k = 0.7 + (count * 0.1)
|
||||||
k = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
@ -600,15 +596,16 @@ function checkForDES()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- slot symbol displaying
|
-- XML creation and modifying
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- this will redraw the XML for the slot symbols based on the slotData table
|
-- initializes the XML
|
||||||
function redrawSlotSymbols()
|
function createXML()
|
||||||
local xml = {}
|
local xml = {}
|
||||||
local snapId = 0
|
|
||||||
|
|
||||||
|
-- create a panel for each slot symbol
|
||||||
-- use the snap point positions in the main play area for positions
|
-- use the snap point positions in the main play area for positions
|
||||||
|
local snapId = 0
|
||||||
for _, snap in ipairs(self.getSnapPoints()) do
|
for _, snap in ipairs(self.getSnapPoints()) do
|
||||||
if inArea(snap.position, MAIN_PLAY_AREA) then
|
if inArea(snap.position, MAIN_PLAY_AREA) then
|
||||||
snapId = snapId + 1
|
snapId = snapId + 1
|
||||||
@ -623,6 +620,8 @@ function redrawSlotSymbols()
|
|||||||
tag = "Panel",
|
tag = "Panel",
|
||||||
attributes = {
|
attributes = {
|
||||||
id = "slotPanel" .. snapId,
|
id = "slotPanel" .. snapId,
|
||||||
|
raycastTarget = "false", -- this disables the click function temporarily
|
||||||
|
onClick = "slotClickFunction",
|
||||||
scale = "0.1 0.1 1",
|
scale = "0.1 0.1 1",
|
||||||
width = "175",
|
width = "175",
|
||||||
height = "175",
|
height = "175",
|
||||||
@ -646,9 +645,27 @@ function redrawSlotSymbols()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- create the personal option panel
|
||||||
|
|
||||||
self.UI.setXmlTable(xml)
|
self.UI.setXmlTable(xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- updates the XML for the slot symbols based on the slotData table
|
||||||
|
function updateSlotSymbols()
|
||||||
|
for slotId, slotName in ipairs(slotData) do
|
||||||
|
-- update the symbol
|
||||||
|
self.UI.setAttributes("slot" .. slotId, {
|
||||||
|
rotation = getSlotRotation(slotName),
|
||||||
|
text = slotNameToChar[slotName]
|
||||||
|
})
|
||||||
|
|
||||||
|
-- update availability of the click function
|
||||||
|
self.UI.setAttribute("slotPanel" .. slotId, "raycastTarget", currentlyEditingSlots)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: update the "edit slots button"?
|
||||||
|
end
|
||||||
|
|
||||||
-- toggle the "slot editing mode"
|
-- toggle the "slot editing mode"
|
||||||
function toggleSlotEditing(_, clickedByColor, isRightClick)
|
function toggleSlotEditing(_, clickedByColor, isRightClick)
|
||||||
if isRightClick then
|
if isRightClick then
|
||||||
@ -660,19 +677,15 @@ function toggleSlotEditing(_, clickedByColor, isRightClick)
|
|||||||
|
|
||||||
-- toggle internal variable
|
-- toggle internal variable
|
||||||
currentlyEditingSlots = not currentlyEditingSlots
|
currentlyEditingSlots = not currentlyEditingSlots
|
||||||
|
updateSlotSymbols()
|
||||||
|
|
||||||
if currentlyEditingSlots then
|
if currentlyEditingSlots then
|
||||||
editButtonLabel("Edit Slots", "Stop editing")
|
|
||||||
broadcastToColor("Click on a slot symbol (or an empty slot) to edit it.", messageColor, "Orange")
|
broadcastToColor("Click on a slot symbol (or an empty slot) to edit it.", messageColor, "Orange")
|
||||||
addClickFunctionToSlots()
|
|
||||||
else
|
|
||||||
editButtonLabel("Stop editing", "Edit Slots")
|
|
||||||
redrawSlotSymbols()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- click function for slot symbols during the "slot editing mode"
|
-- click function for slot symbols during the "slot editing mode"
|
||||||
function slotClickfunction(player, _, id)
|
function slotClickFunction(player, _, id)
|
||||||
local slotIndex = id:gsub("slotPanel", "")
|
local slotIndex = id:gsub("slotPanel", "")
|
||||||
slotIndex = tonumber(slotIndex)
|
slotIndex = tonumber(slotIndex)
|
||||||
|
|
||||||
@ -686,12 +699,7 @@ function slotClickfunction(player, _, id)
|
|||||||
player.showOptionsDialog("Choose Slot Symbol", slotNames, slotData[slotIndex],
|
player.showOptionsDialog("Choose Slot Symbol", slotNames, slotData[slotIndex],
|
||||||
function(chosenSlotName)
|
function(chosenSlotName)
|
||||||
slotData[slotIndex] = chosenSlotName
|
slotData[slotIndex] = chosenSlotName
|
||||||
|
updateSlotSymbols()
|
||||||
-- update slot symbol
|
|
||||||
self.UI.setAttribute("slot" .. slotIndex, "text", slotNameToChar[chosenSlotName])
|
|
||||||
|
|
||||||
-- update slot rotation
|
|
||||||
self.UI.setAttribute("slot" .. slotIndex, "rotation", getSlotRotation(chosenSlotName))
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -711,20 +719,7 @@ function resetSlotSymbols()
|
|||||||
for _, slotName in ipairs(defaultSlotData) do
|
for _, slotName in ipairs(defaultSlotData) do
|
||||||
table.insert(slotData, slotName)
|
table.insert(slotData, slotName)
|
||||||
end
|
end
|
||||||
|
updateSlotSymbols()
|
||||||
redrawSlotSymbols()
|
|
||||||
|
|
||||||
-- need to re-add the click functions if currently in edit mode
|
|
||||||
if currentlyEditingSlots then
|
|
||||||
addClickFunctionToSlots()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- enables the click functions for editing
|
|
||||||
function addClickFunctionToSlots()
|
|
||||||
for i = 1, #slotData do
|
|
||||||
self.UI.setAttribute("slotPanel" .. i, "onClick", "slotClickfunction")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -1023,6 +1018,7 @@ function updateTexture(overrideName)
|
|||||||
|
|
||||||
self.script_state = onSave()
|
self.script_state = onSave()
|
||||||
customInfo.image = newUrl
|
customInfo.image = newUrl
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
self.setCustomObject(customInfo)
|
self.setCustomObject(customInfo)
|
||||||
local reloadedMat = self.reload()
|
local reloadedMat = self.reload()
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ do
|
|||||||
PlayermatApi.loadSlotData = function(matColor, newSlotData)
|
PlayermatApi.loadSlotData = function(matColor, newSlotData)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.setTable("slotData", newSlotData)
|
mat.setTable("slotData", newSlotData)
|
||||||
mat.call("redrawSlotSymbols")
|
mat.call("updateSlotSymbols")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -316,11 +316,11 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Redraws the XML for the slot symbols based on the slotData table
|
-- Updates the XML for the slot symbols based on the slotData table
|
||||||
---@param matColor string Color of the playermat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playermat - White, Orange, Green, Red or All
|
||||||
PlayermatApi.redrawSlotSymbols = function(matColor)
|
PlayermatApi.updateSlotSymbols = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("redrawSlotSymbols")
|
mat.call("updateSlotSymbols")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user