From 7ac947e7376e986de0bcc0bf228d2cecc4caa33f Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 3 Aug 2024 00:03:24 +0200 Subject: [PATCH] update color change handling --- src/core/Global.ttslua | 6 ++++++ src/playermat/Playermat.ttslua | 38 +++++++++++++++++----------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 5bebb0aa..a7ba50a9 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -1566,6 +1566,12 @@ end -- removes a playermat and all related objects from play ---@param matColor string Color of the playermat to remove function removePlayermat(matColor) + -- if there's a seated player, move them to grey + local handColor = playermatApi.getPlayerColor(matColor) + if Player[handColor].seated then + Player[handColor].changeColor("Grey") + end + local matObjects = guidReferenceApi.getObjectsByOwner(matColor) if not matObjects.Playermat then return end diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index de7f1019..b1814e18 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -944,33 +944,33 @@ function onClick_handColorSelect(player) end -- show the option dialog for color selection to the player that triggered this - player.showOptionsDialog("Select a new color:", colorList, _, function(color) + player.showOptionsDialog("Select a new color:", colorList, _, function(newColor) -- update the color of the hand zone local handZone = ownedObjects.HandZone - handZone.setValue(color) + handZone.setValue(newColor) - -- 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) + -- update visibility for old and new color + Global.call("changeWindowVisibilityForColorWrapper", { + color = playerColor, + windowId = "optionPanelMain", + owner = self + }) + Global.call("changeWindowVisibilityForColorWrapper", { + color = newColor, + windowId = "optionPanelMain", + owner = self + }) + navigationOverlayApi.copyVisibility(playerColor, newColor) - -- update visibility for old and new color - Global.call("changeWindowVisibilityForColorWrapper", { - color = playerColor, - windowId = "optionPanelMain", - owner = self - }) - Global.call("changeWindowVisibilityForColorWrapper", { - color = color, - windowId = "optionPanelMain", - owner = self - }) + -- if there was a seated player, reseat to the new color + if Player[playerColor].seated then + Player[playerColor].changeColor(newColor) else - printToColor("Updated handcolor for this playermat to " .. color .. ".", player.color) + printToColor("Updated handcolor for this playermat to " .. newColor .. ".", player.color) end -- update the internal variable - playerColor = color + playerColor = newColor updateSave() end) end