Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins/Bars: Add option for sorting bars: Ascending or Descending. #1919

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 50 additions & 14 deletions Plugins/Bars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ plugin.defaultDB = {
growup = false,
text = true,
time = true,
sorting = "ASCENDING",
alignText = "LEFT",
alignTime = "RIGHT",
icon = true,
Expand Down Expand Up @@ -435,21 +436,30 @@ do
updateProfile()
end,
},
sorting = {
type = "select",
name = L.sorting,
order = 9,
values = {
ASCENDING = L.ascending,
DESCENDING = L.descending,
},
},
header2 = {
type = "header",
name = "",
order = 9,
order = 10,
},
text = {
type = "toggle",
name = L.text,
desc = L.textDesc,
order = 10,
order = 11,
},
alignText = {
type = "select",
name = L.alignText,
order = 11,
order = 12,
values = {
LEFT = L.left,
CENTER = L.center,
Expand All @@ -459,18 +469,18 @@ do
textSpacer = {
type = "description",
name = " ",
order = 12,
order = 13,
},
time = {
type = "toggle",
name = L.time,
desc = L.timeDesc,
order = 13,
order = 14,
},
alignTime = {
type = "select",
name = L.alignTime,
order = 14,
order = 15,
values = {
LEFT = L.left,
CENTER = L.center,
Expand All @@ -480,19 +490,19 @@ do
timeSpacer = {
type = "description",
name = " ",
order = 15,
order = 16,
},
icon = {
type = "toggle",
name = L.icon,
desc = L.iconDesc,
order = 16,
order = 17,
},
iconPosition = {
type = "select",
name = L.iconPosition,
desc = L.iconPositionDesc,
order = 17,
order = 18,
values = {
LEFT = L.left,
RIGHT = L.right,
Expand All @@ -502,14 +512,14 @@ do
header3 = {
type = "header",
name = "",
order = 18,
order = 19,
},
reset = {
type = "execute",
name = L.resetAll,
desc = L.resetBarsDesc,
func = function() plugin.db:ResetProfile() updateProfile() end,
order = 19,
order = 20,
},
},
},
Expand Down Expand Up @@ -863,16 +873,23 @@ end
--

do
local function barSorter(a, b)
return a.remaining < b.remaining and true or false
end
local function ascendSorter(a, b)
return a.remaining < b.remaining and true or false
end

local function descendSorter(a, b)
return a.remaining > b.remaining and true or false
end
rearrangeBars = function(anchor)
if not anchor or not next(anchor.bars) then return end

local tmp = {}
for bar in next, anchor.bars do
tmp[#tmp + 1] = bar
end

local ascending = db.sorting == "ASCENDING"
local barSorter = ascending and ascendSorter or descendSorter
table.sort(tmp, barSorter)
local lastBar = nil
local up, barLimit
Expand All @@ -883,6 +900,25 @@ do
up = db.emphasizeGrowup
barLimit = db.visibleBarLimitEmph
end

-- This is a workaround when descending to not get the bars to
-- keep getting shoved upwards by the hidden new bars. Ideally it
-- would be a good idea to separate `timers` and `bars`, and only
-- create bars when something should be visible. Then lots of logic
-- for sorting bars and this rule when descending could be avoided.
if #tmp > barLimit and not ascending then
local shift = (#tmp - barLimit) % #tmp
local rotated = {}
for i = 1, #tmp do
local fromIndex = ((i - 1) + shift) % #tmp + 1
rotated[i] = tmp[fromIndex]
end

for i = 1, #tmp do
tmp[i] = rotated[i]
end
end

for i = 1, #tmp do
local bar = tmp[i]
if i > barLimit then
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Hervorheben bei... (Sekunden)"
L.growingUpwards = "Nach oben erweitern"
L.growingUpwardsDesc = "Legt fest, ob die Leisten aufwärts oder abwärts vom Ankerpunkt angezeigt werden."
L.texture = "Textur"
L.sorting = "Sortierung"
L.ascending = "Aufsteigend"
L.descending = "Absteigend"
L.emphasize = "Hervorheben"
L.emphasizeMultiplier = "Größenmultiplikator"
L.emphasizeMultiplierDesc = "Wenn das Bewegen der Leisten zu den hervorgehobenen Leisten deaktiviert ist, entscheidet diese Option welche Größe die hervorgehobenen Leisten multipliziert mit den normalen Leisten haben."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ L.emphasizeAt = "Emphasize at... (seconds)"
L.growingUpwards = "Grow upwards"
L.growingUpwardsDesc = "Toggle growing upwards or downwards from the anchor."
L.texture = "Texture"
L.sorting = "Sorting"
L.ascending = "Ascending"
L.descending = "Descending"
L.emphasize = "Emphasize"
L.emphasizeMultiplier = "Size Multiplier"
L.emphasizeMultiplierDesc = "If you disable the bars moving to the emphasize anchor, this option will decide what size the emphasized bars will be by multiplying the size of the normal bars."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Enfatizar en... (segundos)"
L.growingUpwards = "Crecer ascendente"
L.growingUpwardsDesc = "Cambia el crecimiento hacia arriba o hacia abajo desde el punto de anclaje."
L.texture = "Textura"
L.sorting = "Clasificación"
L.ascending = "Ascendente"
L.descending = "Descendente"
L.emphasize = "Enfatizar"
L.emphasizeMultiplier = "Multiplicador de tamaño"
L.emphasizeMultiplierDesc = "Si desactivas que las barras se muevan al ancla de Enfatizar, esta opción decidirá qué tamaño tendrán las barras enfatizadas multiplicando el tamaño de las barras normales."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/esMX.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Enfatiza en... (segundos)"
L.growingUpwards = "Crecer hacia arriba"
L.growingUpwardsDesc = "Alterna el crecimiento hacia arriba o abajo desde el punto de anclaje."
L.texture = "Textura"
L.sorting = "Clasificación"
L.ascending = "Ascendente"
L.descending = "Descendente"
L.emphasize = "Enfatizar"
L.emphasizeMultiplier = "Multiplicador de tamaño"
L.emphasizeMultiplierDesc = "Si desactiva las barras moviéndose el anclaje enfatizado, esta opción decidirá el tamaño de las barras enfatizadas multiplicando el tamaño de las barras normales."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Mettre en évidence à... (secondes)"
L.growingUpwards = "Ajouter vers le haut"
L.growingUpwardsDesc = "Permute le sens d'ajout des éléments par rapport à l'ancre entre vers le haut et vers le bas."
L.texture = "Texture"
L.sorting = "Tri"
L.ascending = "Croissant"
L.descending = "Décroissant"
L.emphasize = "Mise en évidence"
L.emphasizeMultiplier = "Multiplicateur de taille"
L.emphasizeMultiplierDesc = "Si vous désactivez le déplacement des barres vers l'ancre de mise en évidence, cette option décidera la taille des barres mises en évidence en multipliant la taille des barres normales."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/itIT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Enfatizza a... (secondi)"
L.growingUpwards = "Cresci verso l'altro"
L.growingUpwardsDesc = "Attiva o disattiva il riempimento crescente o decrescente rispetto al punto di ancoraggio."
L.texture = "Texture"
L.sorting = "Ordinamento"
L.ascending = "Ascendente"
L.descending = "Discendente"
L.emphasize = "Enfatizza"
L.emphasizeMultiplier = "Moltiplicatore di dimensioni"
L.emphasizeMultiplierDesc = "Se disabiliti le barre muovendole dall'ancora di enfatizzazione, questa opzione deciderà la dimensione delle barre enfatizzate moltiplicando la dimensione delle barre normali."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/koKR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "다음에 강조... (초)"
L.growingUpwards = "위로 확장"
L.growingUpwardsDesc = "고정기로부터 위 또는 아래로 확장하도록 전환합니다."
L.texture = "텍스쳐"
L.sorting = "정렬"
L.ascending = "오름차순"
L.descending = "내림차순"
L.emphasize = "강조"
L.emphasizeMultiplier = "배율"
L.emphasizeMultiplierDesc = "강조 고정기로 이동하는 바가 활성화되지 않았을때, 이 옵션은 해당 바를 강조 바로 이동하지 않고 바의 크기를 주어진 배율만큼 확대시킵니다."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/ptBR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Enfatizar em... (segundos)"
L.growingUpwards = "Crescimento para cima"
L.growingUpwardsDesc = "Alterna crescimento para cima ou para baixo a partir da âncora."
L.texture = "Textura"
L.sorting = "Classificação"
L.ascending = "Crescente"
L.descending = "Decrescente"
L.emphasize = "Enfatizar"
L.emphasizeMultiplier = "Multiplicador de Tamanho"
L.emphasizeMultiplierDesc = "Se você desabilitar as barras movendo-as para a âncora em destaque, esta opção irá decidir qual tamanho as barras em destaque terão, ao se multiplicar o tamanho das barras normais."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "Увеличение на... (секунды)"
L.growingUpwards = "Рост вверх"
L.growingUpwardsDesc = "Переключение направления роста вверх или вниз от якоря."
L.texture = "Текстура"
L.sorting = "Сортировка"
L.ascending = "По возрастанию"
L.descending = "По убыванию"
L.emphasize = "Увеличение"
L.emphasizeMultiplier = "Множитель Размера"
L.emphasizeMultiplierDesc = "Если Вы отмените перемещение увеличенных полос к своему якорю, эта опция будет просто определять, насколько будут увеличиваться полосы по отношению к нормальным."
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "…(秒)后醒目"
L.growingUpwards = "向上成长"
L.growingUpwardsDesc = "切换在锚点向上或向下成长。"
L.texture = "材质"
L.sorting = "排序"
L.ascending = "升序"
L.descending = "降序"
L.emphasize = "醒目"
L.emphasizeMultiplier = "尺寸倍数"
L.emphasizeMultiplierDesc = "如禁用计时条移向醒目锚点,此选项将决定以一般计时条乘以尺寸倍数作为醒目计时条的尺寸。"
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ L.emphasizeAt = "…(秒)後強調"
L.growingUpwards = "向上成長"
L.growingUpwardsDesc = "切換在錨點向上或向下成長。"
L.texture = "材質"
L.sorting = "排序"
L.ascending = "升序"
L.descending = "降序"
L.emphasize = "強調"
L.emphasizeMultiplier = "尺寸倍數"
L.emphasizeMultiplierDesc = "如果你禁止計時條移動到強調計時條錨點,此選項可以調整一般計時條進入強調倒數後的放大倍率。"
Expand Down