Merge pull request #1008 from argonui/discard-buttons

Updated token stack size display and discard button search size
This commit is contained in:
dscarpac 2024-11-19 21:00:20 -06:00 committed by GitHub
commit d364767626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 10 deletions

View File

@ -390,6 +390,12 @@ function updateStackSize()
local topToken = getObjectFromGUID(sealedTokens[#sealedTokens])
if topToken == nil then return end
-- handling for two-digit numbers
local fontsize = 380
if #sealedTokens > 9 then
fontsize = 360
end
topToken.UI.setXmlTable({
{
tag = "Panel",
@ -404,7 +410,7 @@ function updateStackSize()
children = {
tag = "Text",
attributes = {
fontSize = "380",
fontSize = fontsize,
font = "font_teutonic-arkham",
color = "#ffffff",
outline = "#000000",

View File

@ -308,11 +308,11 @@ end
---@param id number Index of the discard button (from left to right, must be unique)
function makeDiscardButton(id)
local xValue = DISCARD_BUTTON_X_START + (id - 1) * DISCARD_BUTTON_X_OFFSET
local position = { xValue, 0.1, -0.94 }
local searchPosition = { -position[1], position[2], position[3] + 0.32 }
local position = Vector(xValue, 0.1, -0.94)
local searchPosition = Vector(-position[1], 1, position[3] + 0.32)
local handlerName = 'handler' .. id
self.setVar(handlerName, function()
local cardSizeSearch = { 2, 1, 3.2 }
local cardSizeSearch = Vector(2, 2, 3.2)
local globalSearchPosition = self.positionToWorld(searchPosition)
local searchResult = searchArea(globalSearchPosition, cardSizeSearch)
return discardListOfObjects(searchResult)
@ -331,13 +331,12 @@ end
-- build a hybrid button to discard from searchPosition or move a card/deck to empty threat area on right click
function makeDrawAreaButton()
local position = { -1.365, 0.1, -0.94 }
self.createButton({
label = "Discard / ➜",
click_function = "discardOrMove",
tooltip = "Right-click to move to threat area",
function_owner = self,
position = position,
position = { -1.365, 0.1, -0.94 },
scale = { 0.12, 0.12, 0.12 },
width = 1190,
height = 350,
@ -346,8 +345,8 @@ function makeDrawAreaButton()
end
function discardOrMove(_, playerColor, isRightClick)
local searchPosition = { 1.365, 0.1, -0.62 }
local cardSizeSearch = { 2, 1, 3.2 }
local searchPosition = Vector(1.365, 1, -0.62)
local cardSizeSearch = Vector(2, 2, 3.2)
local globalSearchPosition = self.positionToWorld(searchPosition)
local searchResult = searchArea(globalSearchPosition, cardSizeSearch)
@ -1297,12 +1296,10 @@ function onCollisionEnter(collisionInfo)
-- this is mostly for helpers like Stella and Kohaku
spawnTokensOrShowHelper(object)
end
elseif inArea(localCardPos, DECK_DISCARD_AREA) then
GlobalApi.handleTokenDetaching(object)
tokenSpawnTrackerApi.resetTokensSpawned(object)
GlobalApi.removeTokensFromObject(object, matColor)
elseif object.is_face_down == false then
-- main uses spawning
if inArea(localCardPos, MAIN_PLAY_AREA) and (md.type == "Asset" or md.type == "Event") then