diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index cffb6107..e0c35ff2 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -46,7 +46,7 @@ local collisionEnabled = false local currentlyEditingSlots = false -- for stopping multiple collisions of the same object -local collisionTable = {} +local collisionTable = {} -- x-Values for discard buttons local DISCARD_BUTTON_X_START = -1.365 @@ -1098,9 +1098,8 @@ end -- instruct Global to update this mat's hand visibility function onClick_visibilitySelect(player) if player.color == playerColor then - printToColor( - "This is meant to be clicked by other players to be able to see your hand (primarily for multi-handed gameplay). It won't do anything for you.", - playerColor) + printToColor("This is meant to be clicked by other players to be able to see your hand " .. + "(primarily for multi-handed gameplay). It won't do anything for you.", playerColor) return end @@ -1108,19 +1107,26 @@ function onClick_visibilitySelect(player) end -- changes the UI state and the internal variable for the togglebuttons -function onClick_toggleOption(player, _, id) +function onClick_toggleOption(player, clickType, id) + updateMessageColor(player.color) + local state = optionPanelData[id] local newState = not state - applyOptionPanelChange(id, newState, player.color) + applyOptionPanelChange(id, newState, clickType) self.UI.setAttribute(id, "image", newState and "option_on" or "option_off") end -function applyOptionPanelChange(id, state, clickedByColor) +function applyOptionPanelChange(id, state, clickType) optionPanelData[id] = state - updateSave() if id == "slotEditing" then - toggleSlotEditing(_, clickedByColor) + if clickType == "-2" then -- right-clicked + resetSlotSymbols() + elseif clickType == "-3" then -- middle-clicked + resetSlotSymbols(true) + else + toggleSlotEditing() + end end end @@ -1139,15 +1145,7 @@ function updateSlotSymbols() end -- toggle the "slot editing mode" -function toggleSlotEditing(_, clickedByColor, isRightClick) - if isRightClick then - resetSlotSymbols() - return - end - - updateMessageColor(clickedByColor) - - -- toggle internal variable +function toggleSlotEditing() currentlyEditingSlots = not currentlyEditingSlots updateSlotSymbols() @@ -1188,10 +1186,15 @@ function getSlotRotation(slotName) end -- reset the slot symbols by making a deep copy of the default data and redrawing -function resetSlotSymbols() +---@param empty? boolean If true, will set the slot symbols to "any" (empty) instead of the defaults +function resetSlotSymbols(empty) slotData = {} for _, slotName in ipairs(defaultSlotData) do - table.insert(slotData, slotName) + if empty then + table.insert(slotData, "any") + else + table.insert(slotData, slotName) + end end updateSave() updateSlotSymbols()