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:
commit
da38820c2e
7 files changed
+1341
No files matched your search
@@ -0,0 +1,749 @@
|
||||
# WoW Forever: UI-Skalierung, Goldbeutel und Leistenabstand
|
||||
|
||||
Chat mit Claude, 23. November 2026. Der Quellcode der drei Addons steht im Anhang am Ende.
|
||||
|
||||
---
|
||||
|
||||
## 1. UI-Skalierung in WoW Forever
|
||||
|
||||
**Mike:** wow forever scale ui
|
||||
|
||||
**Claude:**
|
||||
|
||||
I took this to mean you want to change the UI scale in WoW: Forever and have it stay that way. There are three ways, depending on how small you want it.
|
||||
|
||||
**1. Built-in slider (0.64 and up).** Go to Esc → Options → System → Graphics. There's a checkbox and a slider tied to the `useUiScale` and `uiScale` CVars. Tick the checkbox to set your own scale. This setting is saved. You can also type it in chat:
|
||||
|
||||
```
|
||||
/console useUiScale 1
|
||||
/console uiScale 0.75
|
||||
```
|
||||
|
||||
The catch is that Blizzard's UI scale slider stops at 0.64, which can still be too big on a large or high-resolution monitor.
|
||||
|
||||
**2. Below 0.64 (1440p, 4K, MacBook screens).** For a pixel-perfect UI, use 768 divided by your screen height: 0.5333 at 1440p, 0.3556 at 4K. `/run UIParent:SetScale(0.5333)` works right away, but it only lasts for the current session and resets when you log out. To keep it, you need an addon:
|
||||
|
||||
- **Master Scale (ready-made):** it supports WoW Retail (Interface 120105) and WoW Forever (Interface 16001) from one codebase, with a range of 0.50 to 1.50. If Blizzard resets the scale, for example after a resolution or UI Scale change, Master Scale puts yours back. There are no slash commands. You set it in Esc > Options > AddOns > Master Scale. Nameplates aren't scaled.
|
||||
- **ForeverScale.zip (I wrote this one):** about 60 lines of Lua with no dependencies, if you'd rather not use a third-party addon. It applies your scale again after every login, reload or display change, and waits until combat ends before changing anything. That matters because Forever runs on the modern WoW interface and the Midnight addon restrictions apply. The commands are `/fscale 0.5333`, `/fscale pixel` (works out 768 ÷ your screen height) and `/fscale reset`. The setting is saved for your whole account.
|
||||
|
||||
**Install:** Forever addons go in World of Warcraft > _forever_ > Interface > AddOns, not in the Classic or Retail folder. On a Mac that's `/Applications/World of Warcraft/_forever_/Interface/AddOns/`. Then restart the game completely.
|
||||
|
||||
I checked the syntax and ran the logic against a mock of the WoW functions it calls, but I haven't tried it in the actual Forever client. If the game marks it "out of date" after a patch, run `/dump select(4, GetBuildInfo())` and put that number in the `## Interface:` line of the `.toc` file. Only use one scaling addon at a time, or they'll keep overriding each other.
|
||||
|
||||
*Datei: ForeverScale.zip (Quellcode im Anhang A)*
|
||||
|
||||
---
|
||||
|
||||
## 2. Goldbeutel: Gold in einem verschiebbaren Rahmen
|
||||
|
||||
**Mike:** cool, kannDu mir auch ein Aden schreiben das meinen Goldstand in einem kleinen beweglichen Rahmen anzeigt
|
||||
|
||||
**Claude:**
|
||||
|
||||
Ich habe dir das Addon geschrieben: **Goldbeutel.zip**. Es zeigt dein Gold mit Gold-, Silber- und Kupfermünzen in einem kleinen dunklen Rahmen. Der Rahmen passt seine Breite an den Betrag an und aktualisiert sich bei jeder Änderung.
|
||||
|
||||
**Bedienung**
|
||||
|
||||
- **Linke Maustaste gedrückt halten und ziehen:** Rahmen verschieben. Die Position wird gespeichert.
|
||||
- **Rechtsklick:** Rahmen sperren oder entsperren, damit du ihn nicht aus Versehen verschiebst.
|
||||
- **Maus über den Rahmen:** Ein Tooltip zeigt:
|
||||
- wie viel Gold du in dieser Sitzung gewonnen (grün) oder verloren (rot) hast
|
||||
- alle deine Charaktere auf dem Realm, in Klassenfarbe und nach Gold sortiert
|
||||
- die Gesamtsumme
|
||||
|
||||
Andere Charaktere erscheinen erst in der Liste, nachdem du dich einmal mit ihnen eingeloggt hast.
|
||||
- **Befehle:**
|
||||
- `/gold` blendet den Rahmen aus oder ein.
|
||||
- `/gold lock` sperrt oder entsperrt ihn.
|
||||
- `/gold reset` setzt die Position zurück.
|
||||
- `/gold forget <Name>` entfernt einen gelöschten Charakter aus der Liste.
|
||||
|
||||
**Installation:** Wie bei ForeverScale: entpacken nach `World of Warcraft/_forever_/Interface/AddOns/`, dann WoW komplett neu starten. Weil der Rahmen am normalen Interface hängt, wird er mit ForeverScale automatisch mitskaliert.
|
||||
|
||||
**Getestet:** Ich habe das Addon gegen eine nachgebaute WoW-Umgebung laufen lassen, über zwei Sitzungen mit zwei Charakteren. Dabei funktionierten Anzeige, Verschieben, Sperren, Tooltip, gespeicherte Position und alle Befehle. Im echten Forever-Client konnte ich es nicht ausprobieren. Falls dort Fehler auftreten, schick mir einfach die Meldung.
|
||||
|
||||
*Datei: Goldbeutel.zip (Quellcode im Anhang B)*
|
||||
|
||||
---
|
||||
|
||||
## 3. Leistenabstand: Symbolabstand unter 2
|
||||
|
||||
**Mike:** bei Aktionsleisten kann ich den Symbolabstand nicht kleiner 2 einstellen
|
||||
|
||||
**Claude:**
|
||||
|
||||
Ich habe dir dafür das Addon **Leistenabstand.zip** geschrieben. Der Bearbeitungsmodus (Edit Mode) lässt beim Symbolabstand nicht weniger als 2 zu. Nach der Installation stehen alle Leisten auf **Abstand 0**.
|
||||
|
||||
**So funktioniert es:** Das Addon ändert Blizzards Abstandswert nicht direkt. Das führt nachweislich zu Fehlern: Wer `buttonPadding` direkt ändert, „verseucht“ diesen Wert (Taint). Der Edit Mode und anderer Blizzard-Code lesen ihn aber, und dann kommen Meldungen über blockierte Aktionen. Empfohlen wird stattdessen, die einzelnen Buttons zu nehmen und ihren Abstand per `SetPoint` neu zu setzen. Genau so macht es das Addon. Jedes Mal, wenn Blizzard eine Leiste neu anordnet, schiebt es die Buttons danach zusammen, und zwar nie im Kampf. Position, Reihen, Symbolgröße und Richtung stellst du weiter im Edit Mode ein. Den Abstandsregler dort übergeht das Addon.
|
||||
|
||||
**Befehle**
|
||||
|
||||
- `/abstand` zeigt den Status.
|
||||
- `/abstand 0` setzt den Abstand für alle Leisten. Erlaubt sind Werte von -4 bis 10, auch Kommazahlen wie `-0,5`. Negative Werte lassen die Ränder überlappen.
|
||||
- `/abstand 3 1` gilt nur für Aktionsleiste 3. Statt der Nummer gehen auch `haltung` (Haltungsleiste) oder `pet` (Begleiterleiste).
|
||||
- `/abstand 3 aus` gibt Leiste 3 wieder an Blizzard zurück. Danach `/reload`.
|
||||
- `/abstand rahmen` schaltet ein, dass auch der Leistenrahmen mit verkleinert wird (experimentell, siehe unten).
|
||||
|
||||
**Zwei Einschränkungen**
|
||||
|
||||
- **Rahmen im Edit Mode:** Ohne `rahmen` bleibt der Markierungsrahmen der Leiste im Edit Mode so groß wie bei Abstand 2. Wenn du eine zweite Leiste daneben einrastest, bleibt deshalb eine Lücke. Mit `rahmen` passt der Rahmen genau. Das geht aber über die bewährte Methode hinaus. Falls Meldungen wie „Aktion blockiert“ kommen, schalte es wieder aus.
|
||||
- **Kampf:** Ordnet Blizzard eine Leiste mitten im Kampf neu an (selten), sind die alten Abstände bis Kampfende zurück. Vorher darf ein Addon die Buttons nicht anfassen.
|
||||
|
||||
**Getestet:** Ich habe es in einer nachgebauten Umgebung mit echtem Ankersystem durchgespielt:
|
||||
|
||||
- waagerechte, senkrechte und mehrreihige Leisten, auch nach links oder unten wachsend
|
||||
- 125 % Symbolgröße
|
||||
- Änderungen im Edit Mode
|
||||
- Kampf
|
||||
- wiederholtes Anwenden ohne Verrutschen
|
||||
|
||||
Die Abstände waren danach überall exakt. Die Namen der Leisten habe ich vom aktuellen Retail-Client übernommen. Wenn `/abstand` in Forever „Nicht gefunden“ meldet oder eine Leiste nicht reagiert, schick mir die Ausgabe, dann passe ich es an.
|
||||
|
||||
Falls du lieber komplett eigene Leisten statt Blizzards willst: McAwesome Action Bars ersetzt die Aktionsleisten in WoW Forever vollständig und hat unter anderem einen eigenen Symbolabstand pro Leiste.
|
||||
|
||||
*Datei: Leistenabstand.zip (Quellcode im Anhang C)*
|
||||
|
||||
---
|
||||
|
||||
## Quellen
|
||||
|
||||
- [Master Scale – CurseForge](https://www.curseforge.com/wow/addons/master-scale)
|
||||
- [UI scaling – Warcraft Wiki](https://warcraft.wiki.gg/wiki/UI_scaling)
|
||||
- [Scale'thas – CurseForge](https://www.curseforge.com/wow/addons/scalethas)
|
||||
- [In Game Menu and UI rescale via custom addon – Blizzard-Forum (EU)](https://eu.forums.blizzard.com/en/wow/t/in-game-menu-and-ui-rescale-via-custom-addon/527340)
|
||||
- [How to modify padding for MainMenuBar (action bar 1) in addon – Blizzard-Forum (US)](https://us.forums.blizzard.com/en/wow/t/how-to-modify-padding-for-mainmenubar-action-bar-1-in-addon/1394658)
|
||||
- [McAwesome Action Bars – CurseForge](https://www.curseforge.com/wow/addons/mcawesome-action-bars)
|
||||
|
||||
---
|
||||
|
||||
## Anhang: Quellcode
|
||||
|
||||
Jedes Addon ist ein eigener Ordner unter `World of Warcraft/_forever_/Interface/AddOns/` mit genau den zwei Dateien, die hier stehen.
|
||||
|
||||
### Anhang A: ForeverScale
|
||||
|
||||
`ForeverScale/ForeverScale.toc`
|
||||
|
||||
```
|
||||
## Interface: 16001
|
||||
## Title: ForeverScale
|
||||
## Notes: Keeps your UI scale after reloads and relogs, including below Blizzard's 0.64 floor. /fscale
|
||||
## SavedVariables: ForeverScaleDB
|
||||
ForeverScale.lua
|
||||
```
|
||||
|
||||
`ForeverScale/ForeverScale.lua`
|
||||
|
||||
```lua
|
||||
-- ForeverScale: re-applies a fixed UIParent scale on every login/reload,
|
||||
-- so values below Blizzard's 0.64 slider floor stick.
|
||||
-- /fscale 0.5333 set a scale (0.30 - 1.50), saved account-wide
|
||||
-- /fscale pixel pixel-perfect: 768 / your vertical resolution
|
||||
-- /fscale reset stop overriding (then /reload)
|
||||
|
||||
local ADDON = ...
|
||||
local f = CreateFrame("Frame")
|
||||
|
||||
local function apply()
|
||||
local s = ForeverScaleDB and ForeverScaleDB.scale
|
||||
if not s then return end
|
||||
if InCombatLockdown() then
|
||||
-- UIParent has protected children; wait until combat ends
|
||||
f:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
return
|
||||
end
|
||||
if math.abs(UIParent:GetScale() - s) > 0.0001 then
|
||||
UIParent:SetScale(s)
|
||||
end
|
||||
end
|
||||
|
||||
f:RegisterEvent("ADDON_LOADED")
|
||||
f:RegisterEvent("PLAYER_LOGIN")
|
||||
f:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
f:RegisterEvent("UI_SCALE_CHANGED")
|
||||
f:RegisterEvent("DISPLAY_SIZE_CHANGED")
|
||||
|
||||
f:SetScript("OnEvent", function(self, event, arg1)
|
||||
if event == "ADDON_LOADED" then
|
||||
if arg1 == ADDON then
|
||||
ForeverScaleDB = ForeverScaleDB or {}
|
||||
self:UnregisterEvent("ADDON_LOADED")
|
||||
end
|
||||
return
|
||||
end
|
||||
if event == "PLAYER_REGEN_ENABLED" then
|
||||
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
|
||||
end
|
||||
-- Blizzard may re-apply its own scale during these events; go after it
|
||||
C_Timer.After(0, apply)
|
||||
end)
|
||||
|
||||
SLASH_FOREVERSCALE1 = "/fscale"
|
||||
SlashCmdList.FOREVERSCALE = function(msg)
|
||||
msg = strtrim(msg or ""):lower()
|
||||
|
||||
if msg == "reset" then
|
||||
ForeverScaleDB.scale = nil
|
||||
print("ForeverScale: override cleared. /reload to return to Blizzard's scale.")
|
||||
return
|
||||
elseif msg == "pixel" then
|
||||
local _, h = GetPhysicalScreenSize()
|
||||
ForeverScaleDB.scale = 768 / h
|
||||
else
|
||||
local v = tonumber(msg)
|
||||
if not v or v < 0.3 or v > 1.5 then
|
||||
print(string.format(
|
||||
"ForeverScale: /fscale <0.30-1.50> | pixel | reset (current %.4f)",
|
||||
UIParent:GetScale()))
|
||||
return
|
||||
end
|
||||
ForeverScaleDB.scale = v
|
||||
end
|
||||
|
||||
apply()
|
||||
print(string.format("ForeverScale: scale set to %.4f%s", ForeverScaleDB.scale,
|
||||
InCombatLockdown() and " (applies after combat)" or ""))
|
||||
end
|
||||
```
|
||||
|
||||
### Anhang B: Goldbeutel
|
||||
|
||||
`Goldbeutel/Goldbeutel.toc`
|
||||
|
||||
```
|
||||
## Interface: 16001
|
||||
## Title: Goldbeutel
|
||||
## Notes: Zeigt dein Gold in einem kleinen, verschiebbaren Rahmen. /gold
|
||||
## SavedVariables: GoldbeutelDB
|
||||
Goldbeutel.lua
|
||||
```
|
||||
|
||||
`Goldbeutel/Goldbeutel.lua`
|
||||
|
||||
```lua
|
||||
-- Goldbeutel: zeigt dein Gold in einem kleinen, verschiebbaren Rahmen.
|
||||
-- Linksziehen verschieben
|
||||
-- Rechtsklick sperren / entsperren
|
||||
-- Mauszeiger drauf Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
|
||||
-- /gold ein-/ausblenden
|
||||
-- /gold lock sperren / entsperren
|
||||
-- /gold reset Position zurücksetzen
|
||||
-- /gold forget <Name> Charakter aus der Liste entfernen
|
||||
|
||||
local ADDON = ...
|
||||
|
||||
local GOLD = "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t"
|
||||
local SILVER = "|TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0|t"
|
||||
local COPPER = "|TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t"
|
||||
|
||||
local db, realm, player, sessionStart
|
||||
local frame, text
|
||||
|
||||
local function say(s)
|
||||
print("|cffffd100Goldbeutel:|r " .. s)
|
||||
end
|
||||
|
||||
-- 1234567 -> "1.234.567" (nutzt das Trennzeichen des Clients, falls vorhanden)
|
||||
local function thousands(n)
|
||||
if BreakUpLargeNumbers then return BreakUpLargeNumbers(n) end
|
||||
local s = tostring(n):reverse():gsub("(%d%d%d)", "%1."):reverse()
|
||||
return (s:gsub("^%.", ""))
|
||||
end
|
||||
|
||||
local function formatMoney(c)
|
||||
c = math.floor(c or 0)
|
||||
local g = math.floor(c / 10000)
|
||||
local s = math.floor(c / 100) % 100
|
||||
local k = c % 100
|
||||
if g > 0 then
|
||||
return string.format("%s%s %02d%s %02d%s", thousands(g), GOLD, s, SILVER, k, COPPER)
|
||||
elseif s > 0 then
|
||||
return string.format("%d%s %02d%s", s, SILVER, k, COPPER)
|
||||
end
|
||||
return string.format("%d%s", k, COPPER)
|
||||
end
|
||||
|
||||
local function classColored(name, class)
|
||||
local c = class and RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
|
||||
if c and c.colorStr then
|
||||
return "|c" .. c.colorStr .. name .. "|r"
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
local function record()
|
||||
local _, class = UnitClass("player")
|
||||
db.chars[realm][player] = { money = GetMoney(), class = class }
|
||||
end
|
||||
|
||||
local function update()
|
||||
record()
|
||||
text:SetText(formatMoney(GetMoney()))
|
||||
frame:SetSize(math.ceil(text:GetStringWidth()) + 20, math.ceil(text:GetStringHeight()) + 14)
|
||||
end
|
||||
|
||||
local function showTooltip(self)
|
||||
-- Tooltip zur Bildschirmmitte hin öffnen, damit er den Rahmen nicht verdeckt
|
||||
local _, y = self:GetCenter()
|
||||
local anchor = (y and y > UIParent:GetHeight() / 2) and "ANCHOR_BOTTOM" or "ANCHOR_TOP"
|
||||
GameTooltip:SetOwner(self, anchor)
|
||||
GameTooltip:AddLine("Goldbeutel")
|
||||
|
||||
local diff = GetMoney() - sessionStart
|
||||
local sign, r, g, b = "", 1, 1, 1
|
||||
if diff > 0 then
|
||||
sign, r, g, b = "+", 0.2, 1, 0.2
|
||||
elseif diff < 0 then
|
||||
sign, r, g, b = "-", 1, 0.3, 0.3
|
||||
end
|
||||
GameTooltip:AddDoubleLine("Diese Sitzung:", sign .. formatMoney(math.abs(diff)), 1, 0.82, 0, r, g, b)
|
||||
GameTooltip:AddLine(" ")
|
||||
|
||||
local list, total = {}, 0
|
||||
for name, info in pairs(db.chars[realm]) do
|
||||
local m = info.money or 0
|
||||
list[#list + 1] = { name = name, money = m, class = info.class }
|
||||
total = total + m
|
||||
end
|
||||
table.sort(list, function(a, b) return a.money > b.money end)
|
||||
|
||||
for _, e in ipairs(list) do
|
||||
local label = classColored(e.name, e.class)
|
||||
if e.name == player then label = label .. " *" end
|
||||
GameTooltip:AddDoubleLine(label, formatMoney(e.money), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
if #list > 1 then
|
||||
GameTooltip:AddDoubleLine("Gesamt (" .. realm .. "):", formatMoney(total), 1, 0.82, 0, 1, 1, 1)
|
||||
end
|
||||
|
||||
GameTooltip:AddLine(" ")
|
||||
if db.locked then
|
||||
GameTooltip:AddLine("Gesperrt. Rechtsklick zum Entsperren.", 0.6, 0.6, 0.6)
|
||||
else
|
||||
GameTooltip:AddLine("Ziehen: verschieben, Rechtsklick: sperren", 0.6, 0.6, 0.6)
|
||||
end
|
||||
GameTooltip:Show()
|
||||
end
|
||||
|
||||
local function toggleLock()
|
||||
db.locked = not db.locked
|
||||
say(db.locked and "Rahmen gesperrt." or "Rahmen entsperrt.")
|
||||
if GameTooltip:IsOwned(frame) then showTooltip(frame) end
|
||||
end
|
||||
|
||||
local function savePos()
|
||||
local point, _, relPoint, x, y = frame:GetPoint(1)
|
||||
db.pos = { point, relPoint, x, y }
|
||||
end
|
||||
|
||||
local function restorePos()
|
||||
frame:ClearAllPoints()
|
||||
local p = db.pos
|
||||
if p then
|
||||
frame:SetPoint(p[1], UIParent, p[2], p[3], p[4])
|
||||
else
|
||||
frame:SetPoint("CENTER", UIParent, "CENTER", 0, -200)
|
||||
end
|
||||
end
|
||||
|
||||
local function createFrame()
|
||||
frame = CreateFrame("Frame", "GoldbeutelFrame", UIParent, "BackdropTemplate")
|
||||
frame:SetFrameStrata("MEDIUM")
|
||||
frame:SetClampedToScreen(true)
|
||||
frame:SetMovable(true)
|
||||
frame:EnableMouse(true)
|
||||
frame:RegisterForDrag("LeftButton")
|
||||
-- Position speichern wir selbst, nicht im layout-cache des Clients
|
||||
if frame.SetDontSavePosition then frame:SetDontSavePosition(true) end
|
||||
|
||||
frame:SetBackdrop({
|
||||
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 12,
|
||||
insets = { left = 3, right = 3, top = 3, bottom = 3 },
|
||||
})
|
||||
frame:SetBackdropColor(0, 0, 0, 0.75)
|
||||
frame:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
|
||||
|
||||
text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||
text:SetPoint("CENTER")
|
||||
|
||||
frame:SetScript("OnDragStart", function(self)
|
||||
if db.locked then return end
|
||||
self.dragging = true
|
||||
self:StartMoving()
|
||||
end)
|
||||
frame:SetScript("OnDragStop", function(self)
|
||||
if not self.dragging then return end
|
||||
self.dragging = false
|
||||
self:StopMovingOrSizing()
|
||||
savePos()
|
||||
end)
|
||||
frame:SetScript("OnMouseUp", function(_, button)
|
||||
if button == "RightButton" then toggleLock() end
|
||||
end)
|
||||
frame:SetScript("OnEnter", showTooltip)
|
||||
frame:SetScript("OnLeave", function() GameTooltip:Hide() end)
|
||||
|
||||
restorePos()
|
||||
frame:SetShown(not db.hidden)
|
||||
end
|
||||
|
||||
local ev = CreateFrame("Frame")
|
||||
ev:RegisterEvent("ADDON_LOADED")
|
||||
ev:RegisterEvent("PLAYER_LOGIN")
|
||||
ev:RegisterEvent("PLAYER_MONEY")
|
||||
ev:RegisterEvent("PLAYER_LOGOUT")
|
||||
ev:SetScript("OnEvent", function(self, event, arg1)
|
||||
if event == "ADDON_LOADED" then
|
||||
if arg1 ~= ADDON then return end
|
||||
GoldbeutelDB = GoldbeutelDB or {}
|
||||
db = GoldbeutelDB
|
||||
db.chars = db.chars or {}
|
||||
self:UnregisterEvent("ADDON_LOADED")
|
||||
elseif event == "PLAYER_LOGIN" then
|
||||
realm, player = GetRealmName(), UnitName("player")
|
||||
db.chars[realm] = db.chars[realm] or {}
|
||||
sessionStart = GetMoney()
|
||||
createFrame()
|
||||
update()
|
||||
elseif event == "PLAYER_MONEY" then
|
||||
if frame then update() end
|
||||
elseif event == "PLAYER_LOGOUT" then
|
||||
if realm then record() end
|
||||
end
|
||||
end)
|
||||
|
||||
SLASH_GOLDBEUTEL1 = "/gold"
|
||||
SLASH_GOLDBEUTEL2 = "/goldbeutel"
|
||||
SlashCmdList.GOLDBEUTEL = function(input)
|
||||
local cmd, arg = strtrim(input or ""):match("^(%S*)%s*(.-)$")
|
||||
cmd = cmd:lower()
|
||||
|
||||
if cmd == "" then
|
||||
db.hidden = frame:IsShown()
|
||||
frame:SetShown(not db.hidden)
|
||||
if db.hidden then say("ausgeblendet. /gold blendet ihn wieder ein.") end
|
||||
elseif cmd == "lock" then
|
||||
toggleLock()
|
||||
elseif cmd == "reset" then
|
||||
db.pos, db.hidden = nil, false
|
||||
restorePos()
|
||||
frame:Show()
|
||||
say("Position zurückgesetzt.")
|
||||
elseif cmd == "forget" and arg ~= "" then
|
||||
local chars = db.chars[realm]
|
||||
for name in pairs(chars) do
|
||||
if name:lower() == arg:lower() and name ~= player then
|
||||
chars[name] = nil
|
||||
say(name .. " entfernt.")
|
||||
return
|
||||
end
|
||||
end
|
||||
say("Kein anderer Charakter namens '" .. arg .. "' auf " .. realm .. ".")
|
||||
else
|
||||
say("/gold (ein/aus), /gold lock, /gold reset, /gold forget <Name>")
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
### Anhang C: Leistenabstand
|
||||
|
||||
`Leistenabstand/Leistenabstand.toc`
|
||||
|
||||
```
|
||||
## Interface: 16001
|
||||
## Title: Leistenabstand
|
||||
## Notes: Symbolabstand der Aktionsleisten unter 2 (auch 0 oder negativ). /abstand
|
||||
## SavedVariables: LeistenabstandDB
|
||||
Leistenabstand.lua
|
||||
```
|
||||
|
||||
`Leistenabstand/Leistenabstand.lua`
|
||||
|
||||
```lua
|
||||
-- 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
|
||||
```
|
||||
Reference in new issue
Block a user