Goldbeutel: freie Taschenplätze, Rüstungszustand und Gegenstandsstufe

Der Rahmen zeigt jetzt in einer Zeile Gold, freie Taschenplätze, den
Zustand des am stärksten beschädigten Teils und die durchschnittliche
Gegenstandsstufe der angelegten Ausrüstung. Spezialtaschen zählen nicht
mit. Wenig Platz oder niedriger Zustand werden gelb bzw. rot.

Der Tooltip zeigt zusätzlich Spezialtaschen, den Gesamtzustand der
Rüstung samt schwächstem Teil und die Gegenstandsstufe mit bester
Ausrüstung aus den Taschen. Mehrere Ereignisse kurz hintereinander lösen
nur eine Aktualisierung aus.

Tests für die neue Anzeige ergänzt, ZIP neu gebaut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mikeandClaude Opus 5.5 committed 2026-11-24 12:18:46 +01:00
1 parent 4959c470c1
commit 3065c3e70e
4 files changed
+212 -11

No files matched your search

+152 -8
View File
@@ -1,7 +1,9 @@
-- Goldbeutel: zeigt dein Gold in einem kleinen, verschiebbaren Rahmen.
-- Goldbeutel: zeigt Gold, freie Taschenplaetze, Ruestungszustand und
-- Gegenstandsstufe in einem kleinen, verschiebbaren Rahmen.
-- Linksziehen verschieben
-- Rechtsklick sperren / entsperren
-- Mauszeiger drauf Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
-- Mauszeiger drauf Details zu Taschen, Ruestung und Gegenstandsstufe,
-- Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
-- /gold ein-/ausblenden
-- /gold lock sperren / entsperren
-- /gold reset Position zurücksetzen
@@ -13,6 +15,20 @@ 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 SEP = " |cff666666||r " -- "||" ist ein woertliches |
local LABEL = "|cffaaaaaa" -- Beschriftungen im Rahmen
local YELLOW = "|cffffd100"
local RED = "|cffff3333"
-- Rucksack (0) und die vier Taschenplaetze, dahinter ggf. die Reagenzientasche
local NORMAL_BAGS = NUM_BAG_SLOTS or 4
local LAST_BAG = math.max(NUM_TOTAL_EQUIPPED_BAG_SLOTS or 0, NORMAL_BAGS)
local FIRST_SLOT = INVSLOT_FIRST_EQUIPPED or 1
local LAST_SLOT = INVSLOT_LAST_EQUIPPED or 19
local GetNumSlots = C_Container and C_Container.GetContainerNumSlots or GetContainerNumSlots
local GetFreeSlots = C_Container and C_Container.GetContainerNumFreeSlots or GetContainerNumFreeSlots
local db, realm, player, sessionStart
local frame, text
@@ -40,6 +56,24 @@ local function formatMoney(c)
return string.format("%d%s", k, COPPER)
end
-- 245.34 -> "245,3"
local function decimal(x)
return (string.format("%.1f", x):gsub("%.", ","))
end
local function paint(s, color)
if color then return color .. s .. "|r" end
return s
end
local function pctColor(p)
if p < 20 then return RED elseif p < 50 then return YELLOW end
end
local function freeColor(n)
if n == 0 then return RED elseif n <= 5 then return YELLOW end
end
local function classColored(name, class)
local c = class and RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
if c and c.colorStr then
@@ -56,6 +90,65 @@ local function lower(s)
end))
end
-- Freie und gesamte Plaetze. Spezialtaschen (Koecher, Kraeuter-, Reagenzientasche
-- usw.) zaehlen getrennt, weil dort nicht alles hineinpasst.
local function bagSpace()
local free, total, sFree, sTotal = 0, 0, 0, 0
for bag = 0, LAST_BAG do
local n = GetNumSlots(bag) or 0
if n > 0 then
local f, family = GetFreeSlots(bag)
f = f or 0
if bag <= NORMAL_BAGS and (family or 0) == 0 then
free, total = free + f, total + n
else
sFree, sTotal = sFree + f, sTotal + n
end
end
end
return free, total, sFree, sTotal
end
-- Zustand des am staerksten beschaedigten Teils (Prozent und Slot) und der
-- Gesamtzustand in Prozent. nil, wenn nichts mit Haltbarkeit angelegt ist.
local function durability()
local low, lowSlot, cur, max
cur, max = 0, 0
for slot = FIRST_SLOT, LAST_SLOT do
local c, m = GetInventoryItemDurability(slot)
if c and m and m > 0 then
local p = c / m * 100
if not low or p < low then low, lowSlot = p, slot end
cur, max = cur + c, max + m
end
end
if low then return low, lowSlot, cur / max * 100 end
end
-- Durchschnittliche Gegenstandsstufe wie im Charakterfenster: angelegt und mit
-- der besten Ausruestung aus den Taschen. nil, solange der Client sie nicht kennt.
local function itemLevel()
if not GetAverageItemLevel then return end
local best, equipped = GetAverageItemLevel()
if equipped and equipped > 0 then return equipped, best end
end
-- Eine Zeile: Gold | Taschen 23 | 87% | iLvl 245
local function frameText()
local parts = { formatMoney(GetMoney()) }
local free = bagSpace()
parts[#parts + 1] = LABEL .. "Taschen|r " .. paint(free, freeColor(free))
local low = durability()
if low then
parts[#parts + 1] = paint(math.floor(low) .. "%", pctColor(low))
end
local ilvl = itemLevel()
if ilvl then
parts[#parts + 1] = LABEL .. "iLvl|r " .. math.floor(ilvl)
end
return table.concat(parts, SEP)
end
-- Felder aktualisieren statt den Eintrag zu ersetzen, damit der
-- Sitzungsstart (session) erhalten bleibt
local function record()
@@ -66,10 +159,32 @@ local function record()
me.money, me.class = GetMoney(), class
end
local function update()
record()
text:SetText(formatMoney(GetMoney()))
frame:SetSize(math.ceil(text:GetStringWidth()) + 20, math.ceil(text:GetStringHeight()) + 14)
local function addStatusLines()
local free, total, sFree, sTotal = bagSpace()
GameTooltip:AddDoubleLine("Taschen frei:", paint(free, freeColor(free)) .. " / " .. total,
1, 0.82, 0, 1, 1, 1)
if sTotal > 0 then
GameTooltip:AddDoubleLine("Spezialtaschen frei:", sFree .. " / " .. sTotal, 1, 0.82, 0, 1, 1, 1)
end
local low, lowSlot, overall = durability()
if low then
GameTooltip:AddDoubleLine("Rüstung gesamt:", paint(math.floor(overall) .. "%", pctColor(overall)),
1, 0.82, 0, 1, 1, 1)
if low < 100 then
local link = GetInventoryItemLink("player", lowSlot) or "?"
GameTooltip:AddDoubleLine(" " .. link, paint(math.floor(low) .. "%", pctColor(low)),
1, 1, 1, 1, 1, 1)
end
end
local ilvl, best = itemLevel()
if ilvl then
GameTooltip:AddDoubleLine("Gegenstandsstufe:", decimal(ilvl), 1, 0.82, 0, 1, 1, 1)
if best and best - ilvl >= 0.05 then
GameTooltip:AddDoubleLine("Beste Ausrüstung:", decimal(best), 1, 0.82, 0, 0.6, 0.6, 0.6)
end
end
end
local function showTooltip(self)
@@ -78,6 +193,8 @@ local function showTooltip(self)
local anchor = (y and y > UIParent:GetHeight() / 2) and "ANCHOR_BOTTOM" or "ANCHOR_TOP"
GameTooltip:SetOwner(self, anchor)
GameTooltip:AddLine("Goldbeutel")
addStatusLines()
GameTooltip:AddLine(" ")
local diff = GetMoney() - sessionStart
local sign, r, g, b = "", 1, 1, 1
@@ -115,6 +232,25 @@ local function showTooltip(self)
GameTooltip:Show()
end
local function update()
record()
text:SetText(frameText())
frame:SetSize(math.ceil(text:GetStringWidth()) + 20, math.ceil(text:GetStringHeight()) + 14)
if GameTooltip:IsOwned(frame) then showTooltip(frame) end
end
-- Mehrere Ereignisse kurz hintereinander (Ausruestung wechseln, Taschen sortieren)
-- loesen nur eine Aktualisierung im naechsten Frame aus
local queued = false
local function queueUpdate()
if queued or not frame then return end
queued = true
C_Timer.After(0, function()
queued = false
update()
end)
end
local function toggleLock()
db.locked = not db.locked
say(db.locked and "Rahmen gesperrt." or "Rahmen entsperrt.")
@@ -185,6 +321,11 @@ ev:RegisterEvent("PLAYER_LOGIN")
ev:RegisterEvent("PLAYER_MONEY")
ev:RegisterEvent("PLAYER_LOGOUT")
ev:RegisterEvent("PLAYER_ENTERING_WORLD")
-- Taschen, Ruestung, Gegenstandsstufe. pcall, falls ein Client eines davon nicht kennt.
for _, e in ipairs({ "BAG_UPDATE_DELAYED", "UPDATE_INVENTORY_DURABILITY",
"PLAYER_EQUIPMENT_CHANGED", "PLAYER_AVG_ITEM_LEVEL_UPDATE" }) do
pcall(ev.RegisterEvent, ev, e)
end
ev:SetScript("OnEvent", function(self, event, arg1, arg2)
if event == "ADDON_LOADED" then
if arg1 ~= ADDON then return end
@@ -208,10 +349,13 @@ ev:SetScript("OnEvent", function(self, event, arg1, arg2)
else
me.session = sessionStart
end
elseif event == "PLAYER_MONEY" then
if frame then update() end
-- Taschen und Ausruestung sind jetzt sicher vollstaendig geladen
queueUpdate()
elseif event == "PLAYER_LOGOUT" then
if realm then record() end
else
-- PLAYER_MONEY und die Ereignisse fuer Taschen, Ruestung und Gegenstandsstufe
queueUpdate()
end
end)
+1 -1
View File
@@ -1,5 +1,5 @@
## Interface: 16001
## Title: Goldbeutel
## Notes: Zeigt dein Gold in einem kleinen, verschiebbaren Rahmen. /gold
## Notes: Zeigt Gold, freie Taschenplätze, Rüstungszustand und Gegenstandsstufe in einem kleinen, verschiebbaren Rahmen. /gold
## SavedVariables: GoldbeutelDB
Goldbeutel.lua