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>
115 lines
5.9 KiB
Lua
115 lines
5.9 KiB
Lua
-- Aufruf aus dem Repo-Wurzelverzeichnis oder von ueberall: luajit tests/test_goldbeutel_foreverscale.lua
|
||
-- Testet das Addon in einer nachgebauten WoW-Umgebung (Mock), nicht im echten Client.
|
||
local ROOT = ((arg and arg[0] or ""):match("^(.*/)") or "./") .. "../"
|
||
local out = print
|
||
local fails = 0
|
||
local function check(name, cond) out((cond and " OK " or " FEHLER ") .. name); if not cond then fails = fails + 1 end end
|
||
local noop = function() end
|
||
local function obj(t) return setmetatable(t or {}, {__index = function() return noop end}) end
|
||
|
||
---------------------------------------------------------------- Goldbeutel
|
||
local money, ev, lines
|
||
local function startGold(name, db)
|
||
GoldbeutelDB = db
|
||
print = noop
|
||
SlashCmdList = {}
|
||
strtrim = function(s) return (s:gsub("^%s+",""):gsub("%s+$","")) end
|
||
GetRealmName = function() return "Blackmoore" end
|
||
UnitName = function() return name end
|
||
UnitClass = function() return "Magier", "MAGE" end
|
||
GetMoney = function() return money end
|
||
UIParent = obj{ GetHeight = function() return 800 end }
|
||
lines = {}
|
||
GameTooltip = obj{ AddDoubleLine = function(_, l, r) lines[l] = r end, IsOwned = function() return false end }
|
||
local frames = {}
|
||
CreateFrame = function()
|
||
local f; f = obj{ scripts = {}, shown = true,
|
||
SetScript = function(self, n, fn) self.scripts[n] = fn end,
|
||
GetCenter = function() return 500, 300 end,
|
||
SetShown = function(self, v) self.shown = v end,
|
||
IsShown = function(self) return self.shown end,
|
||
CreateFontString = function() return obj{ GetStringWidth = function() return 80 end, GetStringHeight = function() return 12 end } end }
|
||
frames[#frames + 1] = f
|
||
return f
|
||
end
|
||
assert(loadfile(ROOT .. "Goldbeutel/Goldbeutel.lua"))("Goldbeutel")
|
||
ev = frames[1]
|
||
ev.scripts.OnEvent(ev, "ADDON_LOADED", "Goldbeutel")
|
||
ev.scripts.OnEvent(ev, "PLAYER_LOGIN")
|
||
return frames[2] -- GoldbeutelFrame
|
||
end
|
||
local function sessionLine(frame) lines = {}; frame.scripts.OnEnter(frame); return lines["Diese Sitzung:"] end
|
||
|
||
out("Goldbeutel: Sitzung ueber /reload")
|
||
money = 1000000 -- 100 g
|
||
local fr = startGold("Testmagier", nil)
|
||
ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", true, false) -- echter Login
|
||
money = 1500000; ev.scripts.OnEvent(ev, "PLAYER_MONEY")
|
||
check("+50 g nach Login", sessionLine(fr):match("^%+50|TInterface\\MoneyFrame\\UI%-GoldIcon") ~= nil)
|
||
local saved = GoldbeutelDB
|
||
ev.scripts.OnEvent(ev, "PLAYER_LOGOUT")
|
||
fr = startGold("Testmagier", saved) -- /reload
|
||
ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", false, true)
|
||
check("+50 g bleibt nach /reload", sessionLine(fr):match("^%+50|T") ~= nil)
|
||
money = 1400000; ev.scripts.OnEvent(ev, "PLAYER_MONEY")
|
||
check("+40 g nach Ausgabe", sessionLine(fr):match("^%+40|T") ~= nil)
|
||
ev.scripts.OnEvent(ev, "PLAYER_LOGOUT")
|
||
fr = startGold("Testmagier", GoldbeutelDB) -- neuer Login
|
||
ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", true, false)
|
||
check("Neuer Login beginnt bei 0", sessionLine(fr):match("^0|T") ~= nil)
|
||
check("Gold und Klasse weiter gespeichert",
|
||
GoldbeutelDB.chars.Blackmoore.Testmagier.money == 1400000 and GoldbeutelDB.chars.Blackmoore.Testmagier.class == "MAGE")
|
||
|
||
out("Goldbeutel: /gold forget mit Umlauten und Akzenten")
|
||
local chars = GoldbeutelDB.chars.Blackmoore
|
||
chars["Ärger"] = { money = 1 }; chars["Élodie"] = { money = 2 }; chars["Öx×y"] = { money = 3 }
|
||
SlashCmdList.GOLDBEUTEL("forget ärger"); check("ärger -> Ärger entfernt", chars["Ärger"] == nil)
|
||
SlashCmdList.GOLDBEUTEL("forget ÉLODIE"); check("ÉLODIE -> Élodie entfernt", chars["Élodie"] == nil)
|
||
SlashCmdList.GOLDBEUTEL("forget öx×y"); check("öx×y -> Öx×y entfernt (× unveraendert)", chars["Öx×y"] == nil)
|
||
SlashCmdList.GOLDBEUTEL("forget testmagier"); check("Eigener Charakter bleibt", chars.Testmagier ~= nil)
|
||
|
||
---------------------------------------------------------------- ForeverScale
|
||
local scale, h, combat, timers, f
|
||
local function startScale(db)
|
||
ForeverScaleDB = db
|
||
print = noop; SlashCmdList = {}
|
||
strtrim = function(s) return (s:gsub("^%s+",""):gsub("%s+$","")) end
|
||
scale, timers, combat = 1, {}, false
|
||
UIParent = obj{ GetScale = function() return scale end, SetScale = function(_, s) scale = s end }
|
||
GetPhysicalScreenSize = function() return h * 16 / 9, h end
|
||
InCombatLockdown = function() return combat end
|
||
C_Timer = { After = function(_, fn) timers[#timers + 1] = fn end }
|
||
CreateFrame = function()
|
||
f = obj{ scripts = {}, SetScript = function(self, n, fn) self.scripts[n] = fn end }
|
||
return f
|
||
end
|
||
assert(loadfile(ROOT .. "ForeverScale/ForeverScale.lua"))("ForeverScale")
|
||
f.scripts.OnEvent(f, "ADDON_LOADED", "ForeverScale")
|
||
end
|
||
local function fire(e) f.scripts.OnEvent(f, e); while #timers > 0 do table.remove(timers, 1)() end end
|
||
local function near(a, b) return math.abs(a - b) < 0.0001 end
|
||
|
||
out("ForeverScale")
|
||
h = 1440; startScale(nil); fire("PLAYER_LOGIN")
|
||
SlashCmdList.FOREVERSCALE("pixel")
|
||
check("pixel bei 1440p = 0,5333", near(scale, 768/1440))
|
||
h = 2160; fire("DISPLAY_SIZE_CHANGED")
|
||
check("Aufloesung 4K -> neu berechnet 0,3556", near(scale, 768/2160))
|
||
local saved = ForeverScaleDB
|
||
h = 2880; startScale(saved); fire("PLAYER_LOGIN")
|
||
check("pixel-Modus ueberlebt Relog (5K -> 0,2667)", near(scale, 768/2880))
|
||
SlashCmdList.FOREVERSCALE("0.7"); h = 1440; fire("DISPLAY_SIZE_CHANGED")
|
||
check("Fester Wert 0,7 bleibt bei Aufloesungswechsel", near(scale, 0.7))
|
||
combat = true; SlashCmdList.FOREVERSCALE("pixel")
|
||
check("Im Kampf nichts geaendert", near(scale, 0.7))
|
||
combat = false; fire("PLAYER_REGEN_ENABLED")
|
||
check("Nach dem Kampf angewendet", near(scale, 768/1440))
|
||
SlashCmdList.FOREVERSCALE("reset"); scale = 1; fire("UI_SCALE_CHANGED")
|
||
check("reset: kein Override mehr", near(scale, 1))
|
||
startScale({ scale = 0.5333 }); fire("PLAYER_LOGIN")
|
||
check("Alter gespeicherter Wert (ohne pixel-Flag) gilt weiter", near(scale, 0.5333))
|
||
|
||
out(fails == 0 and "\nAlle Tests bestanden." or ("\n" .. fails .. " Test(s) fehlgeschlagen."))
|
||
|
||
os.exit(fails == 0 and 0 or 1)
|