Updates slot editing

This commit is contained in:
Chr1Z93 2024-11-19 12:51:25 +01:00
parent d898676b6a
commit c76be365c4

View File

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