Ursprüngliche Version der drei WoW-Forever-Addons

ForeverScale, Goldbeutel und Leistenabstand mit dem Chatverlauf im
README, Stand 23.11.2026, vor dem Code-Review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mikeandClaude Opus 5.5 committed 2026-11-24 12:02:06 +01:00
commit da38820c2e
7 files changed
+1341

No files matched your search

+284
View File
@@ -0,0 +1,284 @@
-- Leistenabstand: erlaubt bei Blizzards Aktionsleisten Symbolabstaende unter 2.
-- Der Bearbeitungsmodus (Edit Mode) bleibt fuer Position, Reihen, Symbolgroesse usw.
-- zustaendig. Nach jedem Blizzard-Layout schiebt das Addon nur die Buttons enger
-- zusammen. Es aendert keine Blizzard-Variablen (das wuerde Taint-Fehler ausloesen),
-- sondern setzt nur die Anker der Buttons neu, und nie im Kampf.
--
-- /abstand Status und Hilfe
-- /abstand 0 Abstand fuer alle Leisten (-4 bis 10)
-- /abstand 3 1 nur Aktionsleiste 3 (1-8, haltung, pet)
-- /abstand 3 aus Leiste 3 wieder Blizzard ueberlassen (danach /reload)
-- /abstand aus alles aus (danach /reload)
-- /abstand rahmen Leistenrahmen mitverkleinern an/aus (experimentell)
local ADDON = ...
local BARS = {
{ key = "1", name = "Aktionsleiste 1", frames = { "MainActionBar", "MainMenuBar" }, prefix = "ActionButton", n = 12 },
{ key = "2", name = "Aktionsleiste 2", frames = { "MultiBarBottomLeft" }, prefix = "MultiBarBottomLeftButton", n = 12 },
{ key = "3", name = "Aktionsleiste 3", frames = { "MultiBarBottomRight" }, prefix = "MultiBarBottomRightButton", n = 12 },
{ key = "4", name = "Aktionsleiste 4", frames = { "MultiBarRight" }, prefix = "MultiBarRightButton", n = 12 },
{ key = "5", name = "Aktionsleiste 5", frames = { "MultiBarLeft" }, prefix = "MultiBarLeftButton", n = 12 },
{ 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 },
{ key = "pet", name = "Begleiterleiste", frames = { "PetActionBar" }, prefix = "PetActionButton", n = 10 },
}
local BY_KEY = {}
for _, def in ipairs(BARS) do BY_KEY[def.key] = def end
local MIN_PAD, MAX_PAD = -4, 10
local db
local ev = CreateFrame("Frame")
local pending, scheduled = {}, {}
local function say(s)
print("|cff66bbffLeistenabstand:|r " .. s)
end
local function padFor(def)
local v = db.bars[def.key]
if v == false then return nil end
if v ~= nil then return v end
return db.all
end
local function getButtons(def)
local bar = def.bar
if bar and type(bar.actionButtons) == "table" and #bar.actionButtons > 0 then
return bar.actionButtons
end
local list = {}
for i = 1, def.n do
local b = _G[def.prefix .. i]
if b 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)
local reps = {}
for _, v in ipairs(values) do
if #reps == 0 or math.abs(v - reps[#reps]) > tol then reps[#reps + 1] = v end
end
return reps
end
local function rank(reps, v, tol)
for i, r in ipairs(reps) do
if math.abs(v - r) <= tol then return i end
end
return 1
end
-- Rechteck eines Buttons in Koordinaten der Leiste
local function rectIn(btn, bar)
local L, R, T, B = btn:GetLeft(), btn:GetRight(), btn:GetTop(), btn:GetBottom()
if not L then return end
local k = btn:GetEffectiveScale() / bar:GetEffectiveScale()
return L * k, R * k, T * k, B * k
end
-- Leistenrahmen auf die zusammengeschobenen Buttons verkleinern. Der Rand wird
-- 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 l, r, t, b
for _, btn in ipairs(shown) do
local L, R, T, B = rectIn(btn, bar)
if L then
l = l and math.min(l, L) or L
r = r and math.max(r, R) or R
t = t and math.max(t, T) or T
b = b and math.min(b, B) or B
end
end
local aL, _, _, aB = rectIn(anchor, bar)
local bL, bR, bT, bB = bar:GetLeft(), bar:GetRight(), bar:GetTop(), bar:GetBottom()
if not (l and aL and bL) then return end
local ix = (math.abs(aL - l) < 0.5) and (l - bL) or (bR - r)
local iy = (math.abs(aB - b) < 0.5) and (b - bB) or (bT - t)
if ix < 0 or iy < 0 then return end
bar:SetSize(r - l + 2 * ix, t - b + 2 * iy)
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
-- 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]
for i = 1, anchor:GetNumPoints() do
local _, rel = anchor:GetPoint(i)
for _, b in ipairs(shown) do
if rel == b then return end
end
end
-- Raster (Spalte/Reihe) aus Blizzards Positionen ablesen, in Bildschirmkoordinaten
local w, h = anchor:GetSize()
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
local x, y = b:GetCenter()
local es = b:GetEffectiveScale()
px[i], py[i] = x * es, -y * es -- y negiert: Reihe 1 = oben
xs[i], ys[i] = px[i], py[i]
end
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]
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
end
local function apply(def)
local pad = padFor(def)
if not pad or not def.bar then return end
if InCombatLockdown() then
pending[def] = true
ev:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
compress(def, pad)
end
-- einen Frame spaeter ausfuehren, damit Blizzards Layout komplett fertig ist
local function schedule(def)
if scheduled[def] then return end
scheduled[def] = true
C_Timer.After(0, function()
scheduled[def] = nil
apply(def)
end)
end
local function scheduleAll()
for _, def in ipairs(BARS) do schedule(def) end
end
local function setup()
for _, def in ipairs(BARS) do
for _, fname in ipairs(def.frames) do
if _G[fname] then
def.bar = _G[fname]
break
end
end
local bar = def.bar
if bar then
if type(bar.UpdateGridLayout) == "function" then
hooksecurefunc(bar, "UpdateGridLayout", function() schedule(def) end)
end
bar:HookScript("OnShow", function() schedule(def) end)
end
end
end
ev:RegisterEvent("ADDON_LOADED")
ev:RegisterEvent("PLAYER_LOGIN")
ev:RegisterEvent("PLAYER_ENTERING_WORLD")
ev:RegisterEvent("EDIT_MODE_LAYOUTS_UPDATED")
ev:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" then
if arg1 ~= ADDON then return end
LeistenabstandDB = LeistenabstandDB or { all = 0 }
db = LeistenabstandDB
db.bars = db.bars or {}
self:UnregisterEvent("ADDON_LOADED")
elseif event == "PLAYER_LOGIN" then
setup()
scheduleAll()
elseif event == "PLAYER_REGEN_ENABLED" then
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
for def in pairs(pending) do
pending[def] = nil
apply(def)
end
else
scheduleAll()
end
end)
local function fmt(v)
if v == nil then return "Blizzard" end
return (string.format("%.2f", v):gsub("%.?0+$", ""))
end
local function status()
say("Alle Leisten: " .. fmt(db.all) .. (db.resize and ", Rahmen verkleinern: an" or ""))
local missing = {}
for _, def in ipairs(BARS) do
if not def.bar then
missing[#missing + 1] = def.key
elseif db.bars[def.key] ~= nil then
say(" " .. def.name .. ": " .. fmt(padFor(def)))
end
end
if #missing > 0 then say("Nicht gefunden: " .. table.concat(missing, ", ")) end
say("/abstand <Wert>, /abstand <1-8|haltung|pet> <Wert|aus>, /abstand aus, /abstand rahmen")
end
local function parsePad(s)
local v = tonumber((s:gsub(",", ".")))
if v and v >= MIN_PAD and v <= MAX_PAD then return v end
end
SLASH_LEISTENABSTAND1 = "/abstand"
SLASH_LEISTENABSTAND2 = "/leistenabstand"
SlashCmdList.LEISTENABSTAND = function(input)
local a, b = strtrim(input or ""):lower():match("^(%S*)%s*(%S*)")
if a == "" then
status()
elseif a == "aus" then
db.all, db.bars = nil, {}
say("aus. /reload stellt Blizzards Abstände wieder her.")
elseif a == "rahmen" then
db.resize = not db.resize
if db.resize then
say("Rahmen werden mitverkleinert (experimentell). Bei Fehlermeldungen wieder ausschalten.")
scheduleAll()
else
say("Rahmen werden nicht mehr verkleinert. /reload, um sie zurückzusetzen.")
end
elseif b == "" and parsePad(a) then
db.all = parsePad(a)
say("Abstand für alle Leisten: " .. fmt(db.all))
scheduleAll()
elseif BY_KEY[a] and b ~= "" then
local def = BY_KEY[a]
if b == "aus" then
db.bars[a] = false
say(def.name .. ": Blizzard. /reload, damit es wirkt.")
elseif parsePad(b) then
db.bars[a] = parsePad(b)
say(def.name .. ": " .. fmt(db.bars[a]))
if not def.bar then say("(" .. def.name .. " gibt es in diesem Client nicht.)") end
schedule(def)
else
say("Wert muss zwischen " .. MIN_PAD .. " und " .. MAX_PAD .. " liegen.")
end
else
status()
end
end