Fehler aus dem Code-Review behoben, Tests hinzugefügt
Leistenabstand: Leere, ausgeblendete Slots ("Immer Buttons anzeigen" aus)
werden mit angeordnet. Vorher wurde ihre Lücke zugeschoben, und sobald
sie wieder erschienen, lagen sie fast genau auf dem Nachbarbutton.
Buttons jenseits von "Anzahl Symbole" bleiben außen vor (numShowingButtons,
sonst bis zum letzten sichtbaren Button). Die Haltungsleiste ordnet weiter
nur sichtbare Buttons an.
Goldbeutel: "Diese Sitzung" läuft über /reload weiter (Startwert pro
Charakter gespeichert, Reset nur bei echtem Login). /gold forget findet
auch Namen mit Umlauten und Akzenten unabhängig von Groß-/Kleinschreibung.
ForeverScale: /fscale pixel ist jetzt ein Modus und wird bei jedem
Auflösungswechsel neu berechnet. Kann absichtlich unter 0,30 liegen.
README: Quellcode-Anhang auf den neuen Stand gebracht.
tests/: Mock-Tests für alle drei Addons (luajit tests/<datei>.lua).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da38820c2e
commit
f1eca2d1c5
7 files changed
+425
-50
No files matched your search
@@ -22,7 +22,8 @@ local BARS = {
|
||||
{ key = "6", name = "Aktionsleiste 6", frames = { "MultiBar5" }, prefix = "MultiBar5Button", n = 12 },
|
||||
{ key = "7", name = "Aktionsleiste 7", frames = { "MultiBar6" }, prefix = "MultiBar6Button", n = 12 },
|
||||
{ key = "8", name = "Aktionsleiste 8", frames = { "MultiBar7" }, prefix = "MultiBar7Button", n = 12 },
|
||||
{ key = "haltung", name = "Haltungsleiste", frames = { "StanceBar" }, prefix = "StanceButton", n = 10 },
|
||||
-- Haltungsbuttons sind nie "leer": ausgeblendet heisst, die Haltung gibt es nicht
|
||||
{ key = "haltung", name = "Haltungsleiste", frames = { "StanceBar" }, prefix = "StanceButton", n = 10, onlyShown = true },
|
||||
{ key = "pet", name = "Begleiterleiste", frames = { "PetActionBar" }, prefix = "PetActionButton", n = 10 },
|
||||
}
|
||||
local BY_KEY = {}
|
||||
@@ -58,6 +59,33 @@ local function getButtons(def)
|
||||
return list
|
||||
end
|
||||
|
||||
-- Die Buttons, die Blizzard ins Raster legt. Dazu gehoeren auch leere Slots, die
|
||||
-- bei ausgeschaltetem "Immer Buttons anzeigen" ausgeblendet sind: Blizzard laesst
|
||||
-- ihre Luecke stehen, und wenn sie wieder erscheinen (Zauber hineingezogen, Raster
|
||||
-- beim Ziehen, Leistenwechsel), muessen sie schon am richtigen Platz sein. Buttons
|
||||
-- jenseits von "Anzahl Symbole" gehoeren nicht dazu.
|
||||
local function gridButtons(def)
|
||||
local all = getButtons(def)
|
||||
local n
|
||||
if not def.onlyShown then
|
||||
n = def.bar.numShowingButtons
|
||||
if type(n) ~= "number" then
|
||||
-- Feld fehlt: bis zum letzten sichtbaren Button, Luecken dazwischen zaehlen mit
|
||||
n = 0
|
||||
for i, b in ipairs(all) do
|
||||
if b:IsShown() then n = i end
|
||||
end
|
||||
end
|
||||
end
|
||||
local list = {}
|
||||
for i, b in ipairs(all) do
|
||||
local inGrid
|
||||
if n then inGrid = i <= n else inGrid = b:IsShown() end
|
||||
if inGrid and b:GetCenter() then list[#list + 1] = b end
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
-- sortiert die Werte und fasst nahe beieinanderliegende zu einer Spalte/Reihe zusammen
|
||||
local function clusters(values, tol)
|
||||
table.sort(values)
|
||||
@@ -87,9 +115,9 @@ end
|
||||
-- auf der Seite des ersten Buttons gemessen (den verschiebt das Addon nie) und
|
||||
-- auf der anderen Seite gespiegelt. So bleibt das Ergebnis stabil, egal ob der
|
||||
-- Rahmen vorher Blizzards Groesse hatte oder schon verkleinert war.
|
||||
local function fitBar(bar, anchor, shown)
|
||||
local function fitBar(bar, anchor, grid)
|
||||
local l, r, t, b
|
||||
for _, btn in ipairs(shown) do
|
||||
for _, btn in ipairs(grid) do
|
||||
local L, R, T, B = rectIn(btn, bar)
|
||||
if L then
|
||||
l = l and math.min(l, L) or L
|
||||
@@ -109,19 +137,16 @@ end
|
||||
|
||||
local function compress(def, pad)
|
||||
local bar = def.bar
|
||||
local shown = {}
|
||||
for _, b in ipairs(getButtons(def)) do
|
||||
if b:IsShown() and b:GetCenter() then shown[#shown + 1] = b end
|
||||
end
|
||||
if #shown < 2 then return end
|
||||
local grid = gridButtons(def)
|
||||
if #grid < 2 then return end
|
||||
|
||||
-- Der erste Button bleibt, wo Blizzard ihn hingesetzt hat; alle anderen
|
||||
-- werden relativ zu ihm angeordnet. Falls er selbst an einem anderen
|
||||
-- Button haengt, lieber nichts anfassen (sonst Ankerschleife).
|
||||
local anchor = shown[1]
|
||||
local anchor = grid[1]
|
||||
for i = 1, anchor:GetNumPoints() do
|
||||
local _, rel = anchor:GetPoint(i)
|
||||
for _, b in ipairs(shown) do
|
||||
for _, b in ipairs(grid) do
|
||||
if rel == b then return end
|
||||
end
|
||||
end
|
||||
@@ -131,7 +156,7 @@ local function compress(def, pad)
|
||||
local s = anchor:GetEffectiveScale()
|
||||
local tolX, tolY = w * s / 2, h * s / 2
|
||||
local px, py, xs, ys = {}, {}, {}, {}
|
||||
for i, b in ipairs(shown) do
|
||||
for i, b in ipairs(grid) do
|
||||
local x, y = b:GetCenter()
|
||||
local es = b:GetEffectiveScale()
|
||||
px[i], py[i] = x * es, -y * es -- y negiert: Reihe 1 = oben
|
||||
@@ -140,15 +165,15 @@ local function compress(def, pad)
|
||||
local cols, rows = clusters(xs, tolX), clusters(ys, tolY)
|
||||
local c0, r0 = rank(cols, px[1], tolX), rank(rows, py[1], tolY)
|
||||
|
||||
for i = 2, #shown do
|
||||
local b = shown[i]
|
||||
for i = 2, #grid do
|
||||
local b = grid[i]
|
||||
local dc = rank(cols, px[i], tolX) - c0
|
||||
local dr = rank(rows, py[i], tolY) - r0
|
||||
b:ClearAllPoints()
|
||||
b:SetPoint("CENTER", anchor, "CENTER", dc * (w + pad), -dr * (h + pad))
|
||||
end
|
||||
|
||||
if db.resize then fitBar(bar, anchor, shown) end
|
||||
if db.resize then fitBar(bar, anchor, grid) end
|
||||
end
|
||||
|
||||
local function apply(def)
|
||||
|
||||
Reference in new issue
Block a user