feat(CountersSelectors): add 'delete' shortcut + change 'm'

This commit is contained in:
Guillaume ARM 2024-05-23 22:38:29 +02:00
parent 642604da9d
commit 64176024f3

View File

@ -161,21 +161,25 @@ local function decrementSelectedCounter(countersMap, selectedCounter)
return false
end
local function switchMinMaxSelectedCounter(countersMap, selectedCounter, maxPossibleCount)
local function switchToMaxSelectedCounter(countersMap, selectedCounter, maxPossibleCount)
local counterPayload = countersMap[selectedCounter]
if counterPayload and counterPayload.count then
if counterPayload.count > 0 then
countersMap[selectedCounter] = {
count = 0,
name = counterPayload.name
}
else
countersMap[selectedCounter] = {
count = maxPossibleCount,
name = counterPayload.name
}
end
countersMap[selectedCounter] = {
count = maxPossibleCount,
name = counterPayload.name
}
end
end
local function switchToMinSelectedCounter(countersMap, selectedCounter)
local counterPayload = countersMap[selectedCounter]
if counterPayload and counterPayload.count then
countersMap[selectedCounter] = {
count = 0,
name = counterPayload.name
}
end
end
@ -227,7 +231,10 @@ local function CountersSelector(initialCountersMap, config)
globalCounter = globalCounter + 1
end
elseif keyPressed == keys.m then
switchMinMaxSelectedCounter(countersMap, selectedCounter, counterMax - globalCounter)
switchToMaxSelectedCounter(countersMap, selectedCounter, counterMax - globalCounter)
globalCounter = getTotalCount(countersMap)
elseif keyPressed == keys.delete then
switchToMinSelectedCounter(countersMap, selectedCounter)
globalCounter = getTotalCount(countersMap)
elseif keyPressed == keys.r then
countersMap = resetAllCounters(countersMap)