Compare commits
8
Commits
4959c470c1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60e6b9fa1a | ||
|
|
d4b1e270b7 | ||
|
|
ef00f123ec | ||
|
|
b1598a7701 | ||
|
|
759617543b | ||
|
|
014db940dd | ||
|
|
3b4f25d87c | ||
|
|
3065c3e70e |
No files matched your search
+273
-8
@@ -1,7 +1,9 @@
|
|||||||
-- Goldbeutel: zeigt dein Gold in einem kleinen, verschiebbaren Rahmen.
|
-- Goldbeutel: zeigt Gold, freie Taschenplaetze, Ruestungszustand und
|
||||||
|
-- GearScore in einem kleinen, verschiebbaren Rahmen.
|
||||||
-- Linksziehen verschieben
|
-- Linksziehen verschieben
|
||||||
-- Rechtsklick sperren / entsperren
|
-- Rechtsklick sperren / entsperren
|
||||||
-- Mauszeiger drauf Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
|
-- Mauszeiger drauf Details zu Taschen, Ruestung, GearScore und Gegenstandsstufe,
|
||||||
|
-- Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
|
||||||
-- /gold ein-/ausblenden
|
-- /gold ein-/ausblenden
|
||||||
-- /gold lock sperren / entsperren
|
-- /gold lock sperren / entsperren
|
||||||
-- /gold reset Position zurücksetzen
|
-- /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 SILVER = "|TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0|t"
|
||||||
local COPPER = "|TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t"
|
local COPPER = "|TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t"
|
||||||
|
|
||||||
|
local SEP = " |cff666666|||r " -- grauer Strich: "||" ist ein woertliches |, dann "|r"
|
||||||
|
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 db, realm, player, sessionStart
|
||||||
local frame, text
|
local frame, text
|
||||||
|
|
||||||
@@ -40,6 +56,19 @@ local function formatMoney(c)
|
|||||||
return string.format("%d%s", k, COPPER)
|
return string.format("%d%s", k, COPPER)
|
||||||
end
|
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 function classColored(name, class)
|
||||||
local c = class and RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
|
local c = class and RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
|
||||||
if c and c.colorStr then
|
if c and c.colorStr then
|
||||||
@@ -56,6 +85,189 @@ local function lower(s)
|
|||||||
end))
|
end))
|
||||||
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
|
||||||
|
|
||||||
|
-- GearScore genau wie im Addon "GearScore Forever" (Daeler), das die Formel von
|
||||||
|
-- GearScoreLite uebernimmt. Das Addon bietet keine Schnittstelle nach aussen,
|
||||||
|
-- deshalb ist die Rechnung hier nachgebaut. So stimmt der Wert mit der
|
||||||
|
-- Charakteransicht ueberein, und Goldbeutel braucht das Addon nicht.
|
||||||
|
-- Die Punkte eines Gegenstands haengen nur von Stufe, Qualitaet und Platz ab.
|
||||||
|
local GS_SLOT = {
|
||||||
|
INVTYPE_RELIC = 0.3164, INVTYPE_TRINKET = 0.5625, INVTYPE_2HWEAPON = 2.0000,
|
||||||
|
INVTYPE_WEAPONMAINHAND = 1.0000, INVTYPE_WEAPONOFFHAND = 1.0000,
|
||||||
|
INVTYPE_RANGED = 0.3164, INVTYPE_THROWN = 0.3164, INVTYPE_RANGEDRIGHT = 0.3164,
|
||||||
|
INVTYPE_SHIELD = 1.0000, INVTYPE_WEAPON = 1.0000, INVTYPE_HOLDABLE = 1.0000,
|
||||||
|
INVTYPE_HEAD = 1.0000, INVTYPE_NECK = 0.5625, INVTYPE_SHOULDER = 0.7500,
|
||||||
|
INVTYPE_CHEST = 1.0000, INVTYPE_ROBE = 1.0000, INVTYPE_WAIST = 0.7500,
|
||||||
|
INVTYPE_LEGS = 1.0000, INVTYPE_FEET = 0.7500, INVTYPE_WRIST = 0.5625,
|
||||||
|
INVTYPE_HAND = 0.7500, INVTYPE_FINGER = 0.5625, INVTYPE_CLOAK = 0.5625,
|
||||||
|
INVTYPE_BODY = 0,
|
||||||
|
}
|
||||||
|
-- [Qualitaet] = { A, B } fuer (Stufe - A) / B
|
||||||
|
local GS_HIGH = { [4] = { 91.45, 0.65 }, [3] = { 81.375, 0.8125 }, [2] = { 73, 1 } }
|
||||||
|
local GS_LOW = { [4] = { 26, 1.2 }, [3] = { 0.75, 1.8 }, [2] = { 8, 2 }, [1] = { 0, 2.25 } }
|
||||||
|
local GS_EPIC60 = { [4] = { 0.25, 1.6275 } } -- Epics unter Stufe 100
|
||||||
|
local GS_HUNTER = { [16] = 0.3164, [17] = 0.3164, [18] = 5.3224 } -- Nahkampf wenig, Fernkampf viel
|
||||||
|
|
||||||
|
-- Farbverlauf je Abschnitt der Skala wie in GearScoreLite: grau, weiss, gruen,
|
||||||
|
-- blau, lila, orange. Je Farbkanal r, g, b: { Start, Abschnitt, Steigung, Richtung }
|
||||||
|
local GS_COLOR = {
|
||||||
|
{ { 0.55, 0, 0.00045, 1 }, { 0.55, 0, 0.00045, 1 }, { 0.55, 0, 0.00045, 1 } },
|
||||||
|
{ { 1, 1, 0.00088, -1 }, { 1, 0, 0, 0 }, { 1, 1, 0.001, -1 } },
|
||||||
|
{ { 0.12, 2, 0.00012, -1 }, { 1, 2, 0.0005, -1 }, { 0, 2, 0.001, 1 } },
|
||||||
|
{ { 0, 3, 0.00069, 1 }, { 0.5, 3, 0.00022, -1 }, { 1, 3, 0.00003, -1 } },
|
||||||
|
{ { 0.69, 4, 0.00025, 1 }, { 0.28, 4, 0.00019, 1 }, { 0.97, 4, 0.00096, -1 } },
|
||||||
|
{ { 0.94, 5, 0.00006, 1 }, { 0.47, 5, 0.00047, -1 }, { 0, 0, 0, 0 } },
|
||||||
|
}
|
||||||
|
|
||||||
|
local GetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
|
||||||
|
local GetDetailedItemLevelInfo = C_Item and C_Item.GetDetailedItemLevelInfo or GetDetailedItemLevelInfo
|
||||||
|
|
||||||
|
local function requestItem(item)
|
||||||
|
if C_Item and C_Item.RequestLoadItemDataByID then pcall(C_Item.RequestLoadItemDataByID, item) end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Punkte und Stufe eines Gegenstands. nil, solange der Client ihn nicht kennt.
|
||||||
|
local function itemScore(link)
|
||||||
|
local _, _, rarity, level, _, _, _, _, equipLoc = GetItemInfo(link)
|
||||||
|
if not rarity or not level then
|
||||||
|
requestItem(link)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local slotMod = GS_SLOT[equipLoc]
|
||||||
|
if not slotMod then return 0, 0 end
|
||||||
|
if GetDetailedItemLevelInfo then -- tatsaechliche Stufe bei skalierenden Gegenstaenden
|
||||||
|
local ok, l = pcall(GetDetailedItemLevelInfo, link)
|
||||||
|
if ok and type(l) == "number" and l > 0 then level = l end
|
||||||
|
end
|
||||||
|
local scale = 1
|
||||||
|
if rarity == 5 or rarity == 6 then -- legendaer, Artefakt
|
||||||
|
scale, rarity = 1.3, 4
|
||||||
|
elseif rarity == 7 then -- Erbstueck zaehlt wie blau
|
||||||
|
rarity = 3
|
||||||
|
elseif rarity <= 1 then -- grau, weiss: fast nichts
|
||||||
|
scale, rarity = 0.005, 2
|
||||||
|
end
|
||||||
|
local tbl
|
||||||
|
if level < 100 and rarity == 4 then
|
||||||
|
tbl = GS_EPIC60
|
||||||
|
elseif (level < 168 and rarity == 4) or (level < 148 and rarity == 3)
|
||||||
|
or (level < 138 and rarity == 2) or level <= 120 then
|
||||||
|
tbl = GS_LOW
|
||||||
|
else
|
||||||
|
tbl = GS_HIGH
|
||||||
|
end
|
||||||
|
local f = tbl[rarity] or GS_LOW[rarity]
|
||||||
|
if not f then return 0, level end
|
||||||
|
local base = (level - f[1]) / f[2] * 1.8618
|
||||||
|
return math.max(math.floor(base * slotMod * scale), 0), level
|
||||||
|
end
|
||||||
|
|
||||||
|
-- true, solange Gegenstandsdaten fehlen; dann wird bei GET_ITEM_INFO_RECEIVED
|
||||||
|
-- neu gerechnet
|
||||||
|
local gsPending = false
|
||||||
|
|
||||||
|
-- GearScore und durchschnittliche Gegenstandsstufe der angelegten Ausruestung
|
||||||
|
-- (Plaetze 1-18 ohne Hemd, also auch ohne Wappenrock), beide wie in GearScore Forever.
|
||||||
|
local function gearScore()
|
||||||
|
local function equipLoc(link) return select(9, GetItemInfo(link)) end
|
||||||
|
local mh, oh = GetInventoryItemLink("player", 16), GetInventoryItemLink("player", 17)
|
||||||
|
local grip = 1 -- Titanengriff: zwei Zweihaender zaehlen je zur Haelfte
|
||||||
|
if mh and oh and (equipLoc(mh) == "INVTYPE_2HWEAPON" or equipLoc(oh) == "INVTYPE_2HWEAPON") then
|
||||||
|
grip = 0.5
|
||||||
|
end
|
||||||
|
local _, class = UnitClass("player")
|
||||||
|
local total, count, levels, complete = 0, 0, 0, true
|
||||||
|
for slot = 1, 18 do
|
||||||
|
if slot ~= 4 then
|
||||||
|
local link = GetInventoryItemLink("player", slot)
|
||||||
|
if link then
|
||||||
|
local score, level = itemScore(link)
|
||||||
|
if score then
|
||||||
|
if class == "HUNTER" and GS_HUNTER[slot] then score = score * GS_HUNTER[slot] end
|
||||||
|
if slot == 16 or slot == 17 then score = score * grip end
|
||||||
|
total, count, levels = total + score, count + 1, levels + level
|
||||||
|
else
|
||||||
|
complete = false
|
||||||
|
end
|
||||||
|
elseif GetInventoryItemID("player", slot) then
|
||||||
|
complete = false
|
||||||
|
requestItem(GetInventoryItemID("player", slot))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
gsPending = not complete
|
||||||
|
return math.floor(total), count > 0 and math.floor(levels / count) or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Farbe wie in GearScore Forever. Dessen Skala waechst mit dem hoechsten
|
||||||
|
-- GearScore, den es je gesehen hat (auch bei anderen Spielern). Den liest
|
||||||
|
-- Goldbeutel aus dessen Einstellungen, falls das Addon installiert ist.
|
||||||
|
local function gsColor(score)
|
||||||
|
if score > 2000 then return "|cffff69b5" end -- rosa
|
||||||
|
local gdb = type(GearscoreForeverDB) == "table" and GearscoreForeverDB or {}
|
||||||
|
local seen = math.max(score, tonumber(gdb.maxScoreSeen) or 0)
|
||||||
|
-- 200 je Farbe wie in Classic, hoechstens 325, damit Orange bei 2000 endet
|
||||||
|
local step = math.min(325, math.max(200, math.ceil(seen / 5.5 / 25) * 25))
|
||||||
|
score = math.min(score, step * 6 - 1)
|
||||||
|
local q = GS_COLOR[math.ceil(score / step)]
|
||||||
|
local rgb = {}
|
||||||
|
for i, c in ipairs(q) do
|
||||||
|
local v = c[1] + (score - c[2] * step) * c[3] * c[4]
|
||||||
|
rgb[i] = math.floor(math.min(1, math.max(0, v)) * 255 + 0.5)
|
||||||
|
end
|
||||||
|
return string.format("|cff%02x%02x%02x", rgb[1], rgb[2], rgb[3])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Eine Zeile: Gold | 23 freie Taschenplaetze | 87% | GS 1234
|
||||||
|
local function frameText()
|
||||||
|
local parts = { formatMoney(GetMoney()) }
|
||||||
|
local free = bagSpace()
|
||||||
|
parts[#parts + 1] = paint(free, freeColor(free))
|
||||||
|
local low = durability()
|
||||||
|
if low then
|
||||||
|
parts[#parts + 1] = paint(math.floor(low) .. "%", pctColor(low))
|
||||||
|
end
|
||||||
|
local gs = gearScore()
|
||||||
|
if gs > 0 then
|
||||||
|
parts[#parts + 1] = LABEL .. "GS|r " .. paint(gs, gsColor(gs))
|
||||||
|
end
|
||||||
|
return table.concat(parts, SEP)
|
||||||
|
end
|
||||||
|
|
||||||
-- Felder aktualisieren statt den Eintrag zu ersetzen, damit der
|
-- Felder aktualisieren statt den Eintrag zu ersetzen, damit der
|
||||||
-- Sitzungsstart (session) erhalten bleibt
|
-- Sitzungsstart (session) erhalten bleibt
|
||||||
local function record()
|
local function record()
|
||||||
@@ -66,10 +278,30 @@ local function record()
|
|||||||
me.money, me.class = GetMoney(), class
|
me.money, me.class = GetMoney(), class
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update()
|
local function addStatusLines()
|
||||||
record()
|
local free, total, sFree, sTotal = bagSpace()
|
||||||
text:SetText(formatMoney(GetMoney()))
|
GameTooltip:AddDoubleLine("Taschen frei:", paint(free, freeColor(free)) .. " / " .. total,
|
||||||
frame:SetSize(math.ceil(text:GetStringWidth()) + 20, math.ceil(text:GetStringHeight()) + 14)
|
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 gs, ilvl = gearScore()
|
||||||
|
if gs > 0 then
|
||||||
|
GameTooltip:AddDoubleLine("GearScore:", paint(gs, gsColor(gs)), 1, 0.82, 0, 1, 1, 1)
|
||||||
|
GameTooltip:AddDoubleLine("Gegenstandsstufe:", ilvl, 1, 0.82, 0, 1, 1, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function showTooltip(self)
|
local function showTooltip(self)
|
||||||
@@ -78,6 +310,8 @@ local function showTooltip(self)
|
|||||||
local anchor = (y and y > UIParent:GetHeight() / 2) and "ANCHOR_BOTTOM" or "ANCHOR_TOP"
|
local anchor = (y and y > UIParent:GetHeight() / 2) and "ANCHOR_BOTTOM" or "ANCHOR_TOP"
|
||||||
GameTooltip:SetOwner(self, anchor)
|
GameTooltip:SetOwner(self, anchor)
|
||||||
GameTooltip:AddLine("Goldbeutel")
|
GameTooltip:AddLine("Goldbeutel")
|
||||||
|
addStatusLines()
|
||||||
|
GameTooltip:AddLine(" ")
|
||||||
|
|
||||||
local diff = GetMoney() - sessionStart
|
local diff = GetMoney() - sessionStart
|
||||||
local sign, r, g, b = "", 1, 1, 1
|
local sign, r, g, b = "", 1, 1, 1
|
||||||
@@ -115,6 +349,25 @@ local function showTooltip(self)
|
|||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
end
|
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()
|
local function toggleLock()
|
||||||
db.locked = not db.locked
|
db.locked = not db.locked
|
||||||
say(db.locked and "Rahmen gesperrt." or "Rahmen entsperrt.")
|
say(db.locked and "Rahmen gesperrt." or "Rahmen entsperrt.")
|
||||||
@@ -185,6 +438,11 @@ ev:RegisterEvent("PLAYER_LOGIN")
|
|||||||
ev:RegisterEvent("PLAYER_MONEY")
|
ev:RegisterEvent("PLAYER_MONEY")
|
||||||
ev:RegisterEvent("PLAYER_LOGOUT")
|
ev:RegisterEvent("PLAYER_LOGOUT")
|
||||||
ev:RegisterEvent("PLAYER_ENTERING_WORLD")
|
ev:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
-- Taschen, Ruestung, GearScore. pcall, falls ein Client eines davon nicht kennt.
|
||||||
|
for _, e in ipairs({ "BAG_UPDATE_DELAYED", "UPDATE_INVENTORY_DURABILITY",
|
||||||
|
"PLAYER_EQUIPMENT_CHANGED", "GET_ITEM_INFO_RECEIVED" }) do
|
||||||
|
pcall(ev.RegisterEvent, ev, e)
|
||||||
|
end
|
||||||
ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
||||||
if event == "ADDON_LOADED" then
|
if event == "ADDON_LOADED" then
|
||||||
if arg1 ~= ADDON then return end
|
if arg1 ~= ADDON then return end
|
||||||
@@ -208,10 +466,17 @@ ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
|||||||
else
|
else
|
||||||
me.session = sessionStart
|
me.session = sessionStart
|
||||||
end
|
end
|
||||||
elseif event == "PLAYER_MONEY" then
|
-- Taschen und Ausruestung sind jetzt sicher vollstaendig geladen
|
||||||
if frame then update() end
|
queueUpdate()
|
||||||
elseif event == "PLAYER_LOGOUT" then
|
elseif event == "PLAYER_LOGOUT" then
|
||||||
if realm then record() end
|
if realm then record() end
|
||||||
|
elseif event == "GET_ITEM_INFO_RECEIVED" then
|
||||||
|
-- kommt fuer jeden Gegenstand, den der Client laedt; nur interessant,
|
||||||
|
-- solange dem GearScore noch Daten fehlen
|
||||||
|
if gsPending then queueUpdate() end
|
||||||
|
else
|
||||||
|
-- PLAYER_MONEY und die Ereignisse fuer Taschen, Ruestung und Ausruestung
|
||||||
|
queueUpdate()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
## Interface: 16001
|
## Interface: 16001
|
||||||
## Title: Goldbeutel
|
## Title: Goldbeutel
|
||||||
## Notes: Zeigt dein Gold in einem kleinen, verschiebbaren Rahmen. /gold
|
## Notes: Zeigt Gold, freie Taschenplätze, Rüstungszustand und GearScore in einem kleinen, verschiebbaren Rahmen. /gold
|
||||||
## SavedVariables: GoldbeutelDB
|
## SavedVariables: GoldbeutelDB
|
||||||
Goldbeutel.lua
|
Goldbeutel.lua
|
||||||
@@ -0,0 +1,705 @@
|
|||||||
|
-- Halbklick: Klick-Zauber auf den Rahmen von Grid2, aehnlich wie Clique. Jede
|
||||||
|
-- Belegung gilt fuer den ganzen Rahmen oder nur fuer seine linke oder rechte
|
||||||
|
-- Haelfte. So passen z. B. zwei Heilzauber auf dieselbe Maustaste. Andere
|
||||||
|
-- Rahmen (Blizzard, andere Rahmen-Addons) bleiben unberuehrt.
|
||||||
|
--
|
||||||
|
-- /hk Fenster mit allen Belegungen (auch /halbklick)
|
||||||
|
-- /hk liste Belegungen im Chat auflisten
|
||||||
|
-- /hk status angemeldete Rahmen und Zustand
|
||||||
|
--
|
||||||
|
-- So funktioniert es: Jeder Grid2-Rahmen bekommt einen geschuetzten
|
||||||
|
-- Vorab-Handler fuer OnClick (WrapScript). Der laeuft auch im Kampf. Er liest
|
||||||
|
-- die Mausposition im Rahmen (GetMousePosition: 0 = linker, 1 = rechter Rand),
|
||||||
|
-- die Modifikatortasten und ob die Einheit freundlich oder feindlich ist, und
|
||||||
|
-- sucht dazu eine Belegung. Gibt es eine, stellt er Aktion und Einheit am
|
||||||
|
-- eigenen Button "HalbklickProxy" ein und leitet den Klick als "Button31" und
|
||||||
|
-- mit der Aktion "click" dorthin. Ohne passende Belegung bleibt der Klick, wie
|
||||||
|
-- er ist (Linksklick Ziel, Rechtsklick Menue).
|
||||||
|
--
|
||||||
|
-- Warum "Button31": Blizzards Unit-Buttons reichen den Tastennamen an
|
||||||
|
-- C_ClickBindings.GetBindingType weiter. Ein erfundener Name waere dort ein
|
||||||
|
-- Risiko, eine echte Maustaste nicht. Maeuse mit 31 Tasten gibt es praktisch
|
||||||
|
-- nicht. Ein echter, unbelegter Button31-Klick wird verworfen, damit er nicht
|
||||||
|
-- die letzte Aktion am Proxy wiederholt.
|
||||||
|
--
|
||||||
|
-- Der Proxy ist ein normaler SecureActionButton. Blizzards eigene Unit-Buttons
|
||||||
|
-- pruefen bei "target" und "menu" die Klick-Bindungen von C_ClickBindings und
|
||||||
|
-- verwerfen den Klick, wenn es dort keine gibt. Ueber den Proxy funktionieren
|
||||||
|
-- auch diese Aktionen mit jeder Tastenkombination.
|
||||||
|
--
|
||||||
|
-- Geschuetzter Code darf weder "{", "}" noch das Wort "function" enthalten.
|
||||||
|
-- Zaubernamen und Makrotexte stehen deshalb nie im Code der Snippets, sondern
|
||||||
|
-- in Attributen des Kopf-Frames ("hkt:<Kombination>" Aktion, "hkv:..." Wert).
|
||||||
|
|
||||||
|
local ADDON = ...
|
||||||
|
|
||||||
|
-- Belegte Klicks laufen als "Button31" zum Proxy (siehe CLICK_SNIPPET). Die
|
||||||
|
-- Attribute dafuer enden auf "31", so wie "type1" zu LeftButton gehoert.
|
||||||
|
local ROUTE_SUFFIX = "31"
|
||||||
|
local PREFIX_TYPE, PREFIX_VALUE = "hkt:", "hkv:"
|
||||||
|
|
||||||
|
local BUTTONS = { "LeftButton", "RightButton", "MiddleButton", "Button4", "Button5" }
|
||||||
|
local BUTTON_NAME = {
|
||||||
|
LeftButton = "Linksklick", RightButton = "Rechtsklick", MiddleButton = "Mittelklick",
|
||||||
|
}
|
||||||
|
local AREAS = {
|
||||||
|
{ key = "A", name = "ganzer Rahmen" },
|
||||||
|
{ key = "L", name = "linke Hälfte" },
|
||||||
|
{ key = "R", name = "rechte Hälfte" },
|
||||||
|
}
|
||||||
|
local REACTIONS = {
|
||||||
|
{ key = "any", name = "alle" },
|
||||||
|
{ key = "help", name = "freundlich" },
|
||||||
|
{ key = "harm", name = "feindlich" },
|
||||||
|
}
|
||||||
|
-- type = Aktion am SecureActionButton, value = braucht Zaubername bzw. Makrotext
|
||||||
|
local ACTIONS = {
|
||||||
|
{ key = "spell", name = "Zauber", type = "spell", value = true },
|
||||||
|
{ key = "macro", name = "Makro", type = "macro", value = true },
|
||||||
|
{ key = "target", name = "Ziel auswählen", type = "target" },
|
||||||
|
{ key = "focus", name = "Fokus setzen", type = "focus" },
|
||||||
|
{ key = "menu", name = "Menü öffnen", type = "togglemenu" },
|
||||||
|
}
|
||||||
|
local function byKey(list)
|
||||||
|
local t = {}
|
||||||
|
for i, e in ipairs(list) do t[e.key] = e; e.order = i end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
local AREA, REACTION, ACTION = byKey(AREAS), byKey(REACTIONS), byKey(ACTIONS)
|
||||||
|
local BUTTON_ORDER = {}
|
||||||
|
for i, b in ipairs(BUTTONS) do BUTTON_ORDER[b] = i end
|
||||||
|
|
||||||
|
-- Andere Klick-Zauber-Addons, die sich mit Halbklick in die Quere kommen
|
||||||
|
local RIVALS = { "Clique", "CliqueForever", "ForeverClick", "HealingForever", "RankClick" }
|
||||||
|
|
||||||
|
local db
|
||||||
|
local ev = CreateFrame("Frame")
|
||||||
|
|
||||||
|
local function say(s)
|
||||||
|
print("|cff66ddaaHalbklick:|r " .. s)
|
||||||
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Belegungen
|
||||||
|
|
||||||
|
-- Modifikatoren in Blizzards Reihenfolge, genau wie im geschuetzten Snippet
|
||||||
|
local function currentMods()
|
||||||
|
return (IsAltKeyDown() and "alt-" or "")
|
||||||
|
.. (IsControlKeyDown() and "ctrl-" or "")
|
||||||
|
.. (IsShiftKeyDown() and "shift-" or "")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- "shift-LeftButton:L:help" = Shift-Linksklick, linke Haelfte, freundliche Einheit
|
||||||
|
local function combo(b)
|
||||||
|
return b.mods .. b.button .. ":" .. b.area .. ":" .. b.reaction
|
||||||
|
end
|
||||||
|
|
||||||
|
local function buttonName(button)
|
||||||
|
local n = button:match("^Button(%d+)$")
|
||||||
|
return BUTTON_NAME[button] or (n and "Maustaste " .. n) or button
|
||||||
|
end
|
||||||
|
|
||||||
|
local function clickName(mods, button)
|
||||||
|
local parts = {}
|
||||||
|
if mods:find("alt-", 1, true) then parts[#parts + 1] = "Alt" end
|
||||||
|
if mods:find("ctrl-", 1, true) then parts[#parts + 1] = "Strg" end
|
||||||
|
if mods:find("shift-", 1, true) then parts[#parts + 1] = "Shift" end
|
||||||
|
parts[#parts + 1] = buttonName(button)
|
||||||
|
return table.concat(parts, " + ")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function firstLine(s)
|
||||||
|
local line = s:match("^[^\n]*")
|
||||||
|
if line ~= s then line = line .. " ..." end
|
||||||
|
return line
|
||||||
|
end
|
||||||
|
|
||||||
|
local function describe(b)
|
||||||
|
local where = AREA[b.area].name
|
||||||
|
if b.reaction ~= "any" then where = where .. ", " .. REACTION[b.reaction].name end
|
||||||
|
local what
|
||||||
|
if b.action == "spell" then
|
||||||
|
what = b.value
|
||||||
|
elseif b.action == "macro" then
|
||||||
|
what = "Makro: " .. firstLine(b.value)
|
||||||
|
else
|
||||||
|
what = ACTION[b.action].name
|
||||||
|
end
|
||||||
|
return clickName(b.mods, b.button) .. " |cff999999(" .. where .. ")|r: " .. what
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sortKey(b)
|
||||||
|
return string.format("%02d%s|%-16s|%d%d", BUTTON_ORDER[b.button] or 99, b.button, b.mods,
|
||||||
|
AREA[b.area].order, REACTION[b.reaction].order)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sortBindings()
|
||||||
|
table.sort(db.bindings, function(x, y) return sortKey(x) < sortKey(y) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Kaputte oder unbekannte Eintraege aus den SavedVariables verwerfen
|
||||||
|
local function valid(b)
|
||||||
|
if type(b) ~= "table" or type(b.button) ~= "string" or b.button == "" then return false end
|
||||||
|
if type(b.mods) ~= "string" or not AREA[b.area] or not REACTION[b.reaction] then return false end
|
||||||
|
local a = ACTION[b.action]
|
||||||
|
if not a then return false end
|
||||||
|
if a.value then return type(b.value) == "string" and b.value ~= "" end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Geschuetzter Teil
|
||||||
|
|
||||||
|
local header = CreateFrame("Frame", "HalbklickHeader", UIParent, "SecureHandlerBaseTemplate")
|
||||||
|
-- Ohne Elternrahmen und ohne Groesse: unsichtbar, aber per Click() ausloesbar
|
||||||
|
local proxy = CreateFrame("Button", "HalbklickProxy", nil, "SecureActionButtonTemplate")
|
||||||
|
|
||||||
|
local INIT_SNIPPET = [[
|
||||||
|
H = self
|
||||||
|
P = self:GetFrameRef("proxy")
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Laeuft vor jedem Klick auf einen angemeldeten Rahmen, auch im Kampf.
|
||||||
|
-- self = der Rahmen, button = echte Maustaste. Rueckgabe "Button31" leitet
|
||||||
|
-- den Klick zum Proxy, nil laesst ihn unveraendert, false verwirft ihn.
|
||||||
|
-- GetEffectiveAttribute beachtet "useparent-...": Grid2-Rahmen erben
|
||||||
|
-- unitsuffix und toggleForVehicle vom Gruppen-Header.
|
||||||
|
local CLICK_SNIPPET = [[
|
||||||
|
local unit = self:GetEffectiveAttribute("unit", nil, "", "")
|
||||||
|
if not unit or not H then return end
|
||||||
|
local suffix = self:GetEffectiveAttribute("unitsuffix", nil, "", "")
|
||||||
|
local mods = (IsAltKeyDown() and "alt-" or "") .. (IsControlKeyDown() and "ctrl-" or "") .. (IsShiftKeyDown() and "shift-" or "")
|
||||||
|
local base = mods .. button .. ":"
|
||||||
|
local x = self:GetMousePosition()
|
||||||
|
local side = "A"
|
||||||
|
if x then
|
||||||
|
if x < 0.5 then side = "L" else side = "R" end
|
||||||
|
end
|
||||||
|
local who = unit .. (suffix or "")
|
||||||
|
local react = "any"
|
||||||
|
if PlayerCanAttack(who) then react = "harm" elseif PlayerCanAssist(who) then react = "help" end
|
||||||
|
local c = base .. side .. ":" .. react
|
||||||
|
local t = H:GetAttribute("hkt:" .. c)
|
||||||
|
if not t then c = base .. side .. ":any"; t = H:GetAttribute("hkt:" .. c) end
|
||||||
|
if not t then c = base .. "A:" .. react; t = H:GetAttribute("hkt:" .. c) end
|
||||||
|
if not t then c = base .. "A:any"; t = H:GetAttribute("hkt:" .. c) end
|
||||||
|
if not t then
|
||||||
|
if button == "Button31" then return false end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local v = H:GetAttribute("hkv:" .. c)
|
||||||
|
P:SetAttribute("unit", unit)
|
||||||
|
P:SetAttribute("unitsuffix", suffix)
|
||||||
|
P:SetAttribute("toggleForVehicle", self:GetEffectiveAttribute("toggleForVehicle", nil, "", ""))
|
||||||
|
P:SetAttribute("type", t)
|
||||||
|
if t == "spell" then P:SetAttribute("spell", v) else P:SetAttribute("spell", nil) end
|
||||||
|
if t == "macro" then P:SetAttribute("macrotext", v) else P:SetAttribute("macrotext", nil) end
|
||||||
|
return "Button31"
|
||||||
|
]]
|
||||||
|
|
||||||
|
local ready = false -- Kopf und Proxy eingerichtet
|
||||||
|
local registered = {} -- Rahmen -> true
|
||||||
|
local nRegistered = 0
|
||||||
|
local pendingFrames = {} -- Rahmen, die nach dem Kampf angemeldet werden
|
||||||
|
local pendingApply = false -- Belegungen nach dem Kampf uebertragen
|
||||||
|
local applied = {} -- Kombinationen, die gerade als Attribute am Kopf stehen
|
||||||
|
|
||||||
|
-- true, wenn geschuetzte Rahmen jetzt geaendert werden duerfen (also nicht im
|
||||||
|
-- Kampf). Richtet beim ersten Mal Kopf und Proxy ein.
|
||||||
|
local function setupSecure()
|
||||||
|
if InCombatLockdown() then return false end
|
||||||
|
if not ready then
|
||||||
|
-- Click() uebergibt kein "down". Ohne das hier wuerde der Proxy bei
|
||||||
|
-- ActionButtonUseKeyDown = 1 nur auf Druecken reagieren, also nie.
|
||||||
|
proxy:SetAttribute("useOnKeyDown", false)
|
||||||
|
proxy:RegisterForClicks("AnyUp")
|
||||||
|
header:SetFrameRef("proxy", proxy)
|
||||||
|
header:Execute(INIT_SNIPPET)
|
||||||
|
ready = true
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Belegungen als Attribute an den Kopf-Frame uebertragen (nur ausserhalb des Kampfes)
|
||||||
|
local function apply()
|
||||||
|
if not db then return false end
|
||||||
|
if not setupSecure() then
|
||||||
|
pendingApply = true
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
pendingApply = false
|
||||||
|
for c in pairs(applied) do
|
||||||
|
header:SetAttribute(PREFIX_TYPE .. c, nil)
|
||||||
|
header:SetAttribute(PREFIX_VALUE .. c, nil)
|
||||||
|
applied[c] = nil
|
||||||
|
end
|
||||||
|
for _, b in ipairs(db.bindings) do
|
||||||
|
local c = combo(b)
|
||||||
|
header:SetAttribute(PREFIX_TYPE .. c, ACTION[b.action].type)
|
||||||
|
header:SetAttribute(PREFIX_VALUE .. c, b.value)
|
||||||
|
applied[c] = true
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function eligible(f)
|
||||||
|
if type(f) ~= "table" or type(f.IsForbidden) ~= "function" or f:IsForbidden() then return false end
|
||||||
|
if f == proxy or type(f.HasScript) ~= "function" or not f:HasScript("OnClick") then return false end
|
||||||
|
-- ungeschuetzte Rahmen bekaemen im Kampf keinen Vorab-Handler
|
||||||
|
return f:IsProtected() and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function register(f)
|
||||||
|
if registered[f] or not eligible(f) then return end
|
||||||
|
if not setupSecure() then
|
||||||
|
pendingFrames[f] = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pendingFrames[f] = nil
|
||||||
|
f:SetAttribute("*type" .. ROUTE_SUFFIX, "click")
|
||||||
|
f:SetAttribute("*clickbutton" .. ROUTE_SUFFIX, proxy)
|
||||||
|
header:WrapScript(f, "OnClick", CLICK_SNIPPET)
|
||||||
|
registered[f] = true
|
||||||
|
nRegistered = nRegistered + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function flush()
|
||||||
|
if InCombatLockdown() then return end
|
||||||
|
setupSecure()
|
||||||
|
for f in pairs(pendingFrames) do
|
||||||
|
pendingFrames[f] = nil
|
||||||
|
register(f)
|
||||||
|
end
|
||||||
|
if pendingApply then apply() end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Nur Grid2-Rahmen. Grid2 meldet jeden Rahmen ueber Grid2Frame:RegisterFrame
|
||||||
|
-- an. Fuer Rahmen aus Blizzards geschuetzten Gruppen-Headern ist das der einzige
|
||||||
|
-- Weg, ClickCastFrames fuellt Grid2 dort nur, wenn Clique geladen ist. Grid2
|
||||||
|
-- legt seine Rahmen ausserhalb des Kampfes vorab an und gibt sie nie wieder ab.
|
||||||
|
local grid2Hooked = false
|
||||||
|
local function registerGrid2()
|
||||||
|
local g = _G.Grid2Frame
|
||||||
|
if type(g) ~= "table" then return false end
|
||||||
|
if not grid2Hooked and type(g.RegisterFrame) == "function" then
|
||||||
|
hooksecurefunc(g, "RegisterFrame", function(_, frame) register(frame) end)
|
||||||
|
grid2Hooked = true
|
||||||
|
end
|
||||||
|
if type(g.registeredFrames) == "table" then
|
||||||
|
for _, frame in pairs(g.registeredFrames) do register(frame) end
|
||||||
|
end
|
||||||
|
-- falls Grid2 seine Liste einmal nicht mehr nach aussen gibt: ueber die Namen
|
||||||
|
for h = 1, 100 do
|
||||||
|
local name = "Grid2LayoutHeader" .. h
|
||||||
|
if not _G[name] then break end
|
||||||
|
for i = 1, 80 do
|
||||||
|
local frame = _G[name .. "UnitButton" .. i]
|
||||||
|
if not frame then break end
|
||||||
|
register(frame)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
registerGrid2()
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Fenster
|
||||||
|
|
||||||
|
local ui, rows, radios = nil, {}, {}
|
||||||
|
local draft, editing -- Belegung im Editor; Index in db.bindings beim Aendern
|
||||||
|
|
||||||
|
local refreshUI
|
||||||
|
|
||||||
|
local function resetDraft()
|
||||||
|
draft = { mods = "", area = "A", reaction = "any", action = "spell" }
|
||||||
|
editing = nil
|
||||||
|
if ui then ui.value:SetText("") end
|
||||||
|
end
|
||||||
|
resetDraft()
|
||||||
|
|
||||||
|
local function setStatus(text, isError)
|
||||||
|
if not ui then return end
|
||||||
|
ui.status:SetText(text or "")
|
||||||
|
if isError then ui.status:SetTextColor(1, 0.3, 0.3) else ui.status:SetTextColor(0.5, 1, 0.5) end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function spellName(id)
|
||||||
|
if not id then return end
|
||||||
|
if C_Spell and C_Spell.GetSpellName then return C_Spell.GetSpellName(id) end
|
||||||
|
if GetSpellInfo then return (GetSpellInfo(id)) end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Zauber oder Makro, das gerade am Mauszeiger haengt, in den Editor uebernehmen
|
||||||
|
local function takeCursor()
|
||||||
|
local kind, info1, _, info3 = GetCursorInfo()
|
||||||
|
if kind == "spell" or kind == "petaction" then
|
||||||
|
local name = spellName(kind == "spell" and info3 or info1)
|
||||||
|
if not name then return end
|
||||||
|
draft.action = "spell"
|
||||||
|
ui.value:SetText(name)
|
||||||
|
elseif kind == "macro" then
|
||||||
|
local _, _, body = GetMacroInfo(info1)
|
||||||
|
if not body or body == "" then return end
|
||||||
|
draft.action = "macro"
|
||||||
|
ui.value:SetText(strtrim(body))
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ClearCursor()
|
||||||
|
setStatus("")
|
||||||
|
refreshUI()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function loadBinding(i)
|
||||||
|
local b = db.bindings[i]
|
||||||
|
if not b then return end
|
||||||
|
draft = { button = b.button, mods = b.mods, area = b.area, reaction = b.reaction, action = b.action }
|
||||||
|
editing = i
|
||||||
|
ui.value:SetText(b.value or "")
|
||||||
|
setStatus("")
|
||||||
|
refreshUI()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function deleteBinding(i)
|
||||||
|
if not db.bindings[i] then return end
|
||||||
|
table.remove(db.bindings, i)
|
||||||
|
if editing == i then
|
||||||
|
resetDraft()
|
||||||
|
elseif editing and editing > i then
|
||||||
|
editing = editing - 1
|
||||||
|
end
|
||||||
|
if apply() then
|
||||||
|
setStatus("Belegung gelöscht.")
|
||||||
|
else
|
||||||
|
setStatus("Gelöscht. Wirkt nach dem Kampf.")
|
||||||
|
end
|
||||||
|
refreshUI()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function saveDraft()
|
||||||
|
if not draft.button then
|
||||||
|
return setStatus("Erst ins Klickfeld klicken, um die Maustaste festzulegen.", true)
|
||||||
|
end
|
||||||
|
local a = ACTION[draft.action]
|
||||||
|
local value
|
||||||
|
if a.value then
|
||||||
|
value = strtrim(ui.value:GetText() or "")
|
||||||
|
if draft.action == "spell" then value = strtrim((value:gsub("%s*[\r\n]+%s*", " "))) end
|
||||||
|
if value == "" then
|
||||||
|
return setStatus(draft.action == "spell" and "Welcher Zauber? Namen eintragen oder hineinziehen."
|
||||||
|
or "Der Makrotext fehlt.", true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local b = {
|
||||||
|
button = draft.button, mods = draft.mods, area = draft.area,
|
||||||
|
reaction = draft.reaction, action = draft.action, value = value,
|
||||||
|
}
|
||||||
|
-- Dieselbe Kombination gibt es nur einmal: die alte Belegung wird ersetzt
|
||||||
|
local c, replaced = combo(b), false
|
||||||
|
for i = #db.bindings, 1, -1 do
|
||||||
|
if i ~= editing and combo(db.bindings[i]) == c then
|
||||||
|
table.remove(db.bindings, i)
|
||||||
|
if editing and editing > i then editing = editing - 1 end
|
||||||
|
replaced = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if editing then db.bindings[editing] = b else db.bindings[#db.bindings + 1] = b end
|
||||||
|
sortBindings()
|
||||||
|
local ok = apply()
|
||||||
|
resetDraft()
|
||||||
|
if not ok then
|
||||||
|
setStatus("Gespeichert. Wirkt nach dem Kampf.")
|
||||||
|
elseif replaced then
|
||||||
|
setStatus("Gespeichert, die alte Belegung dieser Kombination wurde ersetzt.")
|
||||||
|
else
|
||||||
|
setStatus("Gespeichert.")
|
||||||
|
end
|
||||||
|
refreshUI()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function label(parent, text, x, y, font)
|
||||||
|
local fs = parent:CreateFontString(nil, "OVERLAY", font or "GameFontNormal")
|
||||||
|
fs:SetPoint("TOPLEFT", x, y)
|
||||||
|
fs:SetJustifyH("LEFT")
|
||||||
|
fs:SetText(text)
|
||||||
|
return fs
|
||||||
|
end
|
||||||
|
|
||||||
|
local function radioGroup(field, title, list, y)
|
||||||
|
label(ui, title, 16, y - 1)
|
||||||
|
local group = {}
|
||||||
|
for i, e in ipairs(list) do
|
||||||
|
local rb = CreateFrame("CheckButton", nil, ui, "UIRadioButtonTemplate")
|
||||||
|
local col, row = (i - 1) % 3, math.floor((i - 1) / 3)
|
||||||
|
rb:SetPoint("TOPLEFT", 96 + col * 126, y - row * 20)
|
||||||
|
local text = rb.text
|
||||||
|
if not text then
|
||||||
|
text = rb:CreateFontString(nil, "OVERLAY")
|
||||||
|
text:SetPoint("LEFT", rb, "RIGHT", 5, 0)
|
||||||
|
end
|
||||||
|
text:SetFontObject("GameFontHighlightSmall")
|
||||||
|
text:SetText(e.name)
|
||||||
|
rb:SetHitRectInsets(0, -100, 0, 0)
|
||||||
|
rb.key = e.key
|
||||||
|
rb:SetScript("OnClick", function()
|
||||||
|
draft[field] = e.key
|
||||||
|
refreshUI()
|
||||||
|
end)
|
||||||
|
group[#group + 1] = rb
|
||||||
|
end
|
||||||
|
radios[field] = group
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getRow(i)
|
||||||
|
if rows[i] then return rows[i] end
|
||||||
|
local row = CreateFrame("Button", nil, ui.list)
|
||||||
|
row:SetHeight(20)
|
||||||
|
row:SetPoint("TOPLEFT", 0, -(i - 1) * 20)
|
||||||
|
row:SetPoint("RIGHT", ui.list, "RIGHT", 0, 0)
|
||||||
|
row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD")
|
||||||
|
row.text = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
|
||||||
|
row.text:SetPoint("LEFT", 4, 0)
|
||||||
|
row.text:SetPoint("RIGHT", -24, 0)
|
||||||
|
row.text:SetJustifyH("LEFT")
|
||||||
|
row.text:SetWordWrap(false)
|
||||||
|
row:SetScript("OnClick", function(self) loadBinding(self.index) end)
|
||||||
|
row.del = CreateFrame("Button", nil, row, "UIPanelCloseButton")
|
||||||
|
row.del:SetSize(22, 22)
|
||||||
|
row.del:SetPoint("RIGHT", 0, 0)
|
||||||
|
row.del:SetScript("OnClick", function(self) deleteBinding(self:GetParent().index) end)
|
||||||
|
rows[i] = row
|
||||||
|
return row
|
||||||
|
end
|
||||||
|
|
||||||
|
function refreshUI()
|
||||||
|
if not ui or not db then return end
|
||||||
|
-- Liste
|
||||||
|
for i, b in ipairs(db.bindings) do
|
||||||
|
local row = getRow(i)
|
||||||
|
row.index = i
|
||||||
|
row.text:SetText(describe(b))
|
||||||
|
if editing == i then row:LockHighlight() else row:UnlockHighlight() end
|
||||||
|
row:Show()
|
||||||
|
end
|
||||||
|
for i = #db.bindings + 1, #rows do rows[i]:Hide() end
|
||||||
|
ui.list:SetHeight(math.max(1, #db.bindings * 20))
|
||||||
|
ui.empty:SetShown(#db.bindings == 0)
|
||||||
|
|
||||||
|
-- Editor
|
||||||
|
ui.editTitle:SetText(editing and "Belegung ändern" or "Neue Belegung")
|
||||||
|
ui.capture:SetText(draft.button and clickName(draft.mods, draft.button)
|
||||||
|
or "Hier mit der gewünschten Maustaste klicken")
|
||||||
|
for field, group in pairs(radios) do
|
||||||
|
for _, rb in ipairs(group) do rb:SetChecked(draft[field] == rb.key) end
|
||||||
|
end
|
||||||
|
local a = ACTION[draft.action]
|
||||||
|
if a.value then
|
||||||
|
ui.valueLabel:SetText(draft.action == "spell"
|
||||||
|
and "Zauber: Namen eintragen oder aus dem Zauberbuch hierher ziehen"
|
||||||
|
or "Makrotext: für die angeklickte Einheit [@mouseover] verwenden")
|
||||||
|
ui.valueBox:Show()
|
||||||
|
else
|
||||||
|
ui.valueLabel:SetText("")
|
||||||
|
ui.valueBox:Hide()
|
||||||
|
ui.value:ClearFocus()
|
||||||
|
end
|
||||||
|
ui.save:SetText(editing and "Ändern" or "Hinzufügen")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function createUI()
|
||||||
|
ui = CreateFrame("Frame", "HalbklickFrame", UIParent, "BackdropTemplate")
|
||||||
|
ui:SetSize(480, 540)
|
||||||
|
ui:SetPoint("CENTER")
|
||||||
|
ui:SetFrameStrata("DIALOG")
|
||||||
|
ui:SetToplevel(true)
|
||||||
|
ui:SetClampedToScreen(true)
|
||||||
|
ui:SetMovable(true)
|
||||||
|
ui:EnableMouse(true)
|
||||||
|
ui:RegisterForDrag("LeftButton")
|
||||||
|
ui:SetScript("OnDragStart", ui.StartMoving)
|
||||||
|
ui:SetScript("OnDragStop", ui.StopMovingOrSizing)
|
||||||
|
ui:SetBackdrop({
|
||||||
|
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
||||||
|
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||||
|
tile = true, tileSize = 16, edgeSize = 14,
|
||||||
|
insets = { left = 4, right = 4, top = 4, bottom = 4 },
|
||||||
|
})
|
||||||
|
ui:SetBackdropColor(0.05, 0.05, 0.05, 0.95)
|
||||||
|
ui:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
|
||||||
|
ui:Hide()
|
||||||
|
tinsert(UISpecialFrames, "HalbklickFrame") -- Esc schliesst das Fenster
|
||||||
|
|
||||||
|
local close = CreateFrame("Button", nil, ui, "UIPanelCloseButton")
|
||||||
|
close:SetPoint("TOPRIGHT", -2, -2)
|
||||||
|
label(ui, "Halbklick", 16, -14, "GameFontNormalLarge")
|
||||||
|
label(ui, "Klick-Zauber für Grid2, auf Wunsch getrennt nach linker und rechter Rahmenhälfte",
|
||||||
|
16, -36, "GameFontDisableSmall")
|
||||||
|
|
||||||
|
-- Liste der Belegungen
|
||||||
|
local scroll = CreateFrame("ScrollFrame", "HalbklickListe", ui, "UIPanelScrollFrameTemplate")
|
||||||
|
scroll:SetPoint("TOPLEFT", 14, -58)
|
||||||
|
scroll:SetPoint("TOPRIGHT", -34, -58)
|
||||||
|
scroll:SetHeight(180)
|
||||||
|
ui.list = CreateFrame("Frame", nil, scroll)
|
||||||
|
ui.list:SetSize(432, 1)
|
||||||
|
scroll:SetScrollChild(ui.list)
|
||||||
|
ui.empty = label(ui, "Noch keine Belegungen. Unten eine anlegen.", 18, -64, "GameFontDisable")
|
||||||
|
|
||||||
|
local line = ui:CreateTexture(nil, "ARTWORK")
|
||||||
|
line:SetColorTexture(0.6, 0.6, 0.6, 0.4)
|
||||||
|
line:SetHeight(1)
|
||||||
|
line:SetPoint("TOPLEFT", 12, -246)
|
||||||
|
line:SetPoint("TOPRIGHT", -12, -246)
|
||||||
|
|
||||||
|
-- Editor
|
||||||
|
ui.editTitle = label(ui, "", 16, -256, "GameFontNormalLarge")
|
||||||
|
label(ui, "Klick", 16, -287)
|
||||||
|
ui.capture = CreateFrame("Button", "HalbklickKlickfeld", ui, "UIPanelButtonTemplate")
|
||||||
|
ui.capture:SetSize(300, 26)
|
||||||
|
ui.capture:SetPoint("TOPLEFT", 96, -280)
|
||||||
|
ui.capture:RegisterForClicks("AnyUp")
|
||||||
|
ui.capture:SetScript("OnClick", function(_, button)
|
||||||
|
if GetCursorInfo() then return takeCursor() end
|
||||||
|
draft.button, draft.mods = button, currentMods()
|
||||||
|
setStatus("")
|
||||||
|
refreshUI()
|
||||||
|
end)
|
||||||
|
ui.capture:SetScript("OnReceiveDrag", takeCursor)
|
||||||
|
label(ui, "Shift, Strg oder Alt dabei gedrückt halten, um sie mit zu belegen",
|
||||||
|
96, -308, "GameFontDisableSmall")
|
||||||
|
|
||||||
|
radioGroup("area", "Bereich", AREAS, -328)
|
||||||
|
radioGroup("reaction", "Einheit", REACTIONS, -350)
|
||||||
|
radioGroup("action", "Aktion", ACTIONS, -372)
|
||||||
|
|
||||||
|
ui.valueLabel = label(ui, "", 16, -418, "GameFontNormalSmall")
|
||||||
|
ui.valueBox = CreateFrame("Frame", nil, ui, "BackdropTemplate")
|
||||||
|
ui.valueBox:SetPoint("TOPLEFT", 14, -432)
|
||||||
|
ui.valueBox:SetPoint("TOPRIGHT", -14, -432)
|
||||||
|
ui.valueBox:SetHeight(58)
|
||||||
|
ui.valueBox: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 },
|
||||||
|
})
|
||||||
|
ui.valueBox:SetBackdropColor(0, 0, 0, 0.8)
|
||||||
|
ui.valueBox:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
|
||||||
|
ui.value = CreateFrame("EditBox", "HalbklickWert", ui.valueBox)
|
||||||
|
ui.value:SetMultiLine(true)
|
||||||
|
ui.value:SetAutoFocus(false)
|
||||||
|
ui.value:SetMaxLetters(255) -- so lang darf ein Makro sein
|
||||||
|
ui.value:SetFontObject("ChatFontNormal")
|
||||||
|
ui.value:SetPoint("TOPLEFT", 8, -6)
|
||||||
|
ui.value:SetPoint("BOTTOMRIGHT", -8, 6)
|
||||||
|
ui.value:SetWidth(430)
|
||||||
|
ui.value:SetScript("OnEscapePressed", ui.value.ClearFocus)
|
||||||
|
ui.value:SetScript("OnReceiveDrag", takeCursor)
|
||||||
|
ui.value:HookScript("OnMouseDown", function() if GetCursorInfo() then takeCursor() end end)
|
||||||
|
ui.valueBox:EnableMouse(true)
|
||||||
|
ui.valueBox:SetScript("OnMouseDown", function()
|
||||||
|
if GetCursorInfo() then takeCursor() else ui.value:SetFocus() end
|
||||||
|
end)
|
||||||
|
ui.valueBox:SetScript("OnReceiveDrag", takeCursor)
|
||||||
|
|
||||||
|
ui.save = CreateFrame("Button", nil, ui, "UIPanelButtonTemplate")
|
||||||
|
ui.save:SetSize(110, 24)
|
||||||
|
ui.save:SetPoint("BOTTOMLEFT", 14, 16)
|
||||||
|
ui.save:SetScript("OnClick", saveDraft)
|
||||||
|
local new = CreateFrame("Button", nil, ui, "UIPanelButtonTemplate")
|
||||||
|
new:SetSize(80, 24)
|
||||||
|
new:SetPoint("LEFT", ui.save, "RIGHT", 6, 0)
|
||||||
|
new:SetText("Neu")
|
||||||
|
new:SetScript("OnClick", function()
|
||||||
|
resetDraft()
|
||||||
|
setStatus("")
|
||||||
|
refreshUI()
|
||||||
|
end)
|
||||||
|
ui.status = ui:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
|
||||||
|
ui.status:SetPoint("LEFT", new, "RIGHT", 10, 0)
|
||||||
|
ui.status:SetPoint("RIGHT", ui, "RIGHT", -14, 0)
|
||||||
|
ui.status:SetJustifyH("LEFT")
|
||||||
|
ui.status:SetWordWrap(true)
|
||||||
|
|
||||||
|
ui:SetScript("OnShow", function()
|
||||||
|
if InCombatLockdown() then setStatus("Im Kampf: Änderungen wirken erst danach.") end
|
||||||
|
refreshUI()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function toggleUI()
|
||||||
|
if not ui then createUI() end
|
||||||
|
ui:SetShown(not ui:IsShown())
|
||||||
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Ereignisse
|
||||||
|
|
||||||
|
ev:RegisterEvent("ADDON_LOADED")
|
||||||
|
ev:RegisterEvent("PLAYER_LOGIN")
|
||||||
|
ev:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
ev:RegisterEvent("GROUP_ROSTER_UPDATE")
|
||||||
|
ev:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||||
|
ev:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||||
|
ev:SetScript("OnEvent", function(self, event, arg1)
|
||||||
|
if event == "ADDON_LOADED" then
|
||||||
|
if arg1 ~= ADDON then return end
|
||||||
|
self:UnregisterEvent("ADDON_LOADED")
|
||||||
|
HalbklickDB = HalbklickDB or {}
|
||||||
|
db = HalbklickDB
|
||||||
|
local list = {}
|
||||||
|
for _, b in ipairs(type(db.bindings) == "table" and db.bindings or {}) do
|
||||||
|
if valid(b) then list[#list + 1] = b end
|
||||||
|
end
|
||||||
|
db.bindings = list
|
||||||
|
sortBindings()
|
||||||
|
apply()
|
||||||
|
elseif event == "PLAYER_LOGIN" then
|
||||||
|
if not registerGrid2() then
|
||||||
|
say("|cffff5555Grid2 ist nicht aktiv.|r Halbklick wirkt nur in den Rahmen von Grid2.")
|
||||||
|
end
|
||||||
|
local isLoaded = (C_AddOns and C_AddOns.IsAddOnLoaded) or IsAddOnLoaded
|
||||||
|
for _, name in ipairs(RIVALS) do
|
||||||
|
if isLoaded and isLoaded(name) then
|
||||||
|
say("|cffff5555Achtung:|r " .. name .. " ist auch aktiv. Zwei Klick-Zauber-Addons "
|
||||||
|
.. "stören sich gegenseitig, bitte nur eins verwenden.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif event == "PLAYER_REGEN_ENABLED" then
|
||||||
|
flush()
|
||||||
|
if ui and ui:IsShown() then setStatus("") end
|
||||||
|
elseif event == "PLAYER_REGEN_DISABLED" then
|
||||||
|
if ui and ui:IsShown() then setStatus("Im Kampf: Änderungen wirken erst danach.") end
|
||||||
|
else -- PLAYER_ENTERING_WORLD, GROUP_ROSTER_UPDATE
|
||||||
|
registerGrid2()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Befehle
|
||||||
|
|
||||||
|
local function listBindings()
|
||||||
|
if #db.bindings == 0 then
|
||||||
|
say("Noch keine Belegungen. /hk öffnet das Fenster.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for _, b in ipairs(db.bindings) do say(" " .. describe(b)) end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function showStatus()
|
||||||
|
local waiting = 0
|
||||||
|
for _ in pairs(pendingFrames) do waiting = waiting + 1 end
|
||||||
|
say(#db.bindings .. " Belegung(en), " .. nRegistered .. " Grid2-Rahmen angemeldet"
|
||||||
|
.. (waiting > 0 and (", " .. waiting .. " warten auf Kampfende") or "")
|
||||||
|
.. ((pendingApply or not ready) and ", Belegungen wirken nach dem Kampf" or "") .. ".")
|
||||||
|
end
|
||||||
|
|
||||||
|
SLASH_HALBKLICK1 = "/hk"
|
||||||
|
SLASH_HALBKLICK2 = "/halbklick"
|
||||||
|
SlashCmdList.HALBKLICK = function(input)
|
||||||
|
local cmd = strtrim(input or ""):lower()
|
||||||
|
if cmd == "" then
|
||||||
|
toggleUI()
|
||||||
|
elseif cmd == "liste" then
|
||||||
|
listBindings()
|
||||||
|
elseif cmd == "status" then
|
||||||
|
showStatus()
|
||||||
|
else
|
||||||
|
say("/hk Fenster öffnen, /hk liste Belegungen anzeigen, /hk status Zustand")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
## Interface: 16001
|
||||||
|
## Title: Halbklick
|
||||||
|
## Notes: Klick-Zauber auf den Rahmen von Grid2 wie Clique, wahlweise getrennt nach linker und rechter Rahmenhälfte. /hk
|
||||||
|
## OptionalDeps: Grid2
|
||||||
|
## SavedVariablesPerCharacter: HalbklickDB
|
||||||
|
Halbklick.lua
|
||||||
@@ -1,814 +1,219 @@
|
|||||||
# WoW Forever: UI-Skalierung, Goldbeutel und Leistenabstand
|
# WoW Forever Addons
|
||||||
|
|
||||||
Chat mit Claude, 23. November 2026. Der Quellcode der drei Addons steht im Anhang am Ende.
|
Vier kleine, voneinander unabhängige Addons für **World of Warcraft: Forever**. Jedes Addon besteht aus einer einzigen Lua-Datei und braucht keine weiteren Bibliotheken.
|
||||||
|
|
||||||
**Download:** [WoW-Forever-Addons.zip](https://git.micw.org/mike/wow-forever-addons/raw/branch/master/WoW-Forever-Addons.zip) enthält alle drei Addons. Entpacke sie nach `World of Warcraft/_forever_/Interface/AddOns/` und starte WoW danach komplett neu.
|
| Addon | Wozu | Befehl |
|
||||||
|
|---|---|---|
|
||||||
|
| [**ForeverScale**](#foreverscale) | UI-Skalierung auch unter Blizzards Minimum von 0,64, dauerhaft gespeichert | `/fscale` |
|
||||||
|
| [**Goldbeutel**](#goldbeutel) | Gold, freie Taschenplätze, Rüstungszustand und GearScore in einem kleinen Rahmen | `/gold` |
|
||||||
|
| [**Halbklick**](#halbklick) | Klick-Zauber auf den Rahmen von Grid2 wie Clique, getrennt nach linker und rechter Rahmenhälfte | `/hk` |
|
||||||
|
| [**Leistenabstand**](#leistenabstand) | Symbolabstand der Aktionsleisten unter 2, auch 0 oder negativ | `/abstand` |
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. **[WoW-Forever-Addons.zip herunterladen](https://git.micw.org/mike/wow-forever-addons/raw/branch/master/WoW-Forever-Addons.zip)**
|
||||||
|
2. Die ZIP in den AddOns-Ordner von **Forever** entpacken, nicht in den von Classic oder Retail:
|
||||||
|
- Windows: `C:\Program Files (x86)\World of Warcraft\_forever_\Interface\AddOns\`
|
||||||
|
- macOS: `/Applications/World of Warcraft/_forever_/Interface/AddOns/`
|
||||||
|
|
||||||
|
Danach liegen dort die Ordner `ForeverScale`, `Goldbeutel`, `Halbklick` und `Leistenabstand`. Wer nur einzelne Addons möchte, lässt die anderen Ordner einfach weg.
|
||||||
|
3. WoW **komplett neu starten**. Neue Addons erkennt der Client nicht per `/reload`.
|
||||||
|
|
||||||
|
> **Als „veraltet“ markiert?** Nach einem Patch kann das passieren. Gib im Chat `/dump select(4, GetBuildInfo())` ein und trage die angezeigte Zahl in die Zeile `## Interface:` der `.toc`-Datei des Addons ein.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. UI-Skalierung in WoW Forever
|
## ForeverScale
|
||||||
|
|
||||||
**Mike:** wow forever scale ui
|
Blizzards Regler für die UI-Skalierung (Esc → Optionen → System → Grafik) endet bei **0,64**. Auf großen oder hochauflösenden Bildschirmen ist das oft noch zu groß. Ein `/run UIParent:SetScale(0.5333)` wirkt zwar sofort, ist aber beim nächsten Logout wieder weg.
|
||||||
|
|
||||||
**Claude:**
|
ForeverScale speichert deinen Wert für den ganzen Account und setzt ihn nach jedem Login, Reload und Auflösungswechsel wieder. Ändert Blizzard die Skalierung zurück, stellt ForeverScale deinen Wert wieder her.
|
||||||
|
|
||||||
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.
|
| Befehl | Wirkung |
|
||||||
|
|---|---|
|
||||||
|
| `/fscale 0.5333` | feste Skalierung setzen, 0.30 bis 1.50 (mit Punkt) |
|
||||||
|
| `/fscale pixel` | pixelgenau: 768 ÷ Bildschirmhöhe, wird bei jedem Auflösungswechsel neu berechnet |
|
||||||
|
| `/fscale reset` | ForeverScale abschalten, danach `/reload` |
|
||||||
|
| `/fscale` | aktuellen Wert und Hilfe anzeigen |
|
||||||
|
|
||||||
**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:
|
**Pixelgenaue Werte** (das macht `/fscale pixel` automatisch):
|
||||||
|
|
||||||
```
|
| Bildschirmhöhe | Skalierung |
|
||||||
/console useUiScale 1
|
|---|---|
|
||||||
/console uiScale 0.75
|
| 1080 (Full HD) | 0.7111 |
|
||||||
```
|
| 1440 (WQHD) | 0.5333 |
|
||||||
|
| 2160 (4K) | 0.3556 |
|
||||||
|
| 2880 (5K) | 0.2667 |
|
||||||
|
|
||||||
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.
|
**Gut zu wissen**
|
||||||
|
|
||||||
**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:
|
- Im Kampf ändert ForeverScale nichts. Die neue Skalierung gilt dann ab Kampfende.
|
||||||
|
- Nutze nur **ein** Skalierungs-Addon, sonst überschreiben sie sich gegenseitig. Auch Blizzards eigenen Regler setzt ForeverScale wieder zurück, solange es aktiv ist.
|
||||||
- **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.
|
- `pixel` ist nicht auf 0,30 begrenzt. Auf 5K- und 6K-Bildschirmen liegt der Wert darunter, sonst wäre die Darstellung nicht mehr pixelgenau.
|
||||||
- **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
|
## Goldbeutel
|
||||||
|
|
||||||
**Mike:** cool, kannDu mir auch ein Aden schreiben das meinen Goldstand in einem kleinen beweglichen Rahmen anzeigt
|
Ein kleiner, verschiebbarer Rahmen mit allem, was man unterwegs im Blick haben will:
|
||||||
|
|
||||||
**Claude:**
|
<img src="docs/goldbeutel.png" width="400" alt="Goldbeutel im Spiel: 2 Gold 36 Silber 13 Kupfer, 42 freie Taschenplätze, Rüstung 100 %, GS 193">
|
||||||
|
|
||||||
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.
|
| Anzeige | Bedeutung | Farbe |
|
||||||
|
|---|---|---|
|
||||||
|
| 2 36 13 | dein Gold mit Gold-, Silber- und Kupfermünzen | – |
|
||||||
|
| 42 | freie Plätze im Rucksack und in den vier normalen Taschen | gelb bei 5 oder weniger, rot bei 0 |
|
||||||
|
| 100% | Zustand des am stärksten beschädigten Ausrüstungsteils | gelb unter 50 %, rot unter 20 % |
|
||||||
|
| GS 193 | GearScore der angelegten Ausrüstung, derselbe Wert wie bei [GearScore Forever](https://www.curseforge.com/wow/addons/gearscore-forever) in der Charakteransicht | in dessen Farbskala (grau, weiß, grün, blau, lila, orange) |
|
||||||
|
|
||||||
|
Spezialtaschen wie Köcher, Kräuter- oder Reagenzientaschen zählen nicht zu den freien Plätzen, weil dort nicht alles hineinpasst. Trägst du nichts mit Haltbarkeit, fällt die Prozentanzeige weg.
|
||||||
|
|
||||||
|
Den **GearScore** rechnet Goldbeutel selbst aus, mit derselben Formel wie GearScore Forever (übernommen von GearScoreLite). Die Punkte eines Gegenstands hängen nur von Gegenstandsstufe, Qualität und Platz ab. Hemd und Wappenrock zählen nicht, bei Jägern zählt die Fernkampfwaffe mehr als die Nahkampfwaffen. GearScore Forever muss dafür nicht installiert sein. Ist es installiert, übernimmt Goldbeutel auch dessen Farbskala: Sie wächst mit dem höchsten GearScore, den das Addon je gesehen hat, auch bei inspizierten Spielern.
|
||||||
|
|
||||||
|
**Tooltip** (Maus über den Rahmen):
|
||||||
|
|
||||||
|
- freie und gesamte Taschenplätze, Spezialtaschen extra
|
||||||
|
- Gesamtzustand der Rüstung und das am stärksten beschädigte Teil
|
||||||
|
- GearScore und durchschnittliche Gegenstandsstufe, beide wie in der Charakteransicht von GearScore Forever
|
||||||
|
- Gold gewonnen (grün) oder verloren (rot) in dieser Sitzung. Ein `/reload` setzt das nicht zurück, erst ein neuer Login.
|
||||||
|
- alle deine Charaktere auf dem Realm, in Klassenfarbe und nach Gold sortiert, mit Gesamtsumme. Ein Charakter erscheint, sobald du dich einmal mit ihm eingeloggt hast.
|
||||||
|
|
||||||
**Bedienung**
|
**Bedienung**
|
||||||
|
|
||||||
- **Linke Maustaste gedrückt halten und ziehen:** Rahmen verschieben. Die Position wird gespeichert.
|
| Aktion | Wirkung |
|
||||||
- **Rechtsklick:** Rahmen sperren oder entsperren, damit du ihn nicht aus Versehen verschiebst.
|
|---|---|
|
||||||
- **Maus über den Rahmen:** Ein Tooltip zeigt:
|
| Linke Maustaste ziehen | Rahmen verschieben, die Position wird gespeichert |
|
||||||
- wie viel Gold du in dieser Sitzung gewonnen (grün) oder verloren (rot) hast
|
| Rechtsklick | Rahmen sperren oder entsperren |
|
||||||
- alle deine Charaktere auf dem Realm, in Klassenfarbe und nach Gold sortiert
|
| `/gold` | Rahmen aus- oder einblenden |
|
||||||
- die Gesamtsumme
|
| `/gold lock` | sperren oder entsperren |
|
||||||
|
| `/gold reset` | Position zurücksetzen und Rahmen einblenden |
|
||||||
|
| `/gold forget <Name>` | gelöschten Charakter aus der Liste entfernen |
|
||||||
|
|
||||||
Andere Charaktere erscheinen erst in der Liste, nachdem du dich einmal mit ihnen eingeloggt hast.
|
`/goldbeutel` funktioniert genauso wie `/gold`. Der Rahmen hängt am normalen Interface und wird mit ForeverScale automatisch mitskaliert.
|
||||||
- **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
|
## Halbklick
|
||||||
|
|
||||||
**Mike:** bei Aktionsleisten kann ich den Symbolabstand nicht kleiner 2 einstellen
|
Klick-Zauber für die Rahmen von [Grid2](https://www.curseforge.com/wow/addons/grid2), wie bei [Clique](https://www.curseforge.com/wow/addons/clique): Ein Klick auf einen Grid2-Rahmen wirkt einen Zauber direkt auf diese Einheit, ohne sie vorher ins Ziel zu nehmen. Zusätzlich kann jede Belegung nur für die **linke** oder nur für die **rechte Hälfte** des Rahmens gelten. So passen zwei Zauber auf dieselbe Maustaste, zum Beispiel:
|
||||||
|
|
||||||
**Claude:**
|
| Klick | linke Hälfte | rechte Hälfte |
|
||||||
|
|---|---|---|
|
||||||
|
| Linksklick | Erneuerung | Ziel auswählen (wie bisher) |
|
||||||
|
| Shift + Linksklick | Blitzheilung | Große Heilung |
|
||||||
|
| Rechtsklick | Reinigen | Menü (wie bisher) |
|
||||||
|
|
||||||
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**.
|
**Einrichten:** `/hk` öffnet das Fenster. Oben stehen alle Belegungen, unten legst du eine neue an. Im Bild liegen auf Links- und Rechtsklick je zwei Zauber, einer pro Hälfte:
|
||||||
|
|
||||||
**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.
|
<img src="docs/halbklick.png" width="520" alt="Halbklick-Fenster im Spiel: Linksklick links Geringes Heilen, rechts Heilen; Rechtsklick links Machtwort: Schild, rechts Erneuerung">
|
||||||
|
|
||||||
**Befehle**
|
1. **Klick:** Ins Klickfeld mit der gewünschten Maustaste klicken. Shift, Strg oder Alt dabei gedrückt halten, wenn sie dazugehören sollen. Maustaste 4 und 5 gehen auch.
|
||||||
|
2. **Bereich:** ganzer Rahmen, linke Hälfte oder rechte Hälfte
|
||||||
|
3. **Einheit:** alle, nur freundliche oder nur feindliche, wie die Klick-Sets „friend“ und „enemy“ bei Clique
|
||||||
|
4. **Aktion:** Zauber, Makro, Ziel auswählen, Fokus setzen oder Menü öffnen
|
||||||
|
5. Bei **Zauber** den Namen eintragen oder den Zauber aus dem Zauberbuch ins Feld ziehen. Ein **Makro** kannst du eintippen oder aus der Makroliste hineinziehen.
|
||||||
|
6. **Hinzufügen**
|
||||||
|
|
||||||
- `/abstand` zeigt den Status.
|
Ein Klick auf eine Zeile lädt die Belegung zum Ändern, das X löscht sie. Speicherst du eine Kombination, die es schon gibt, ersetzt die neue Belegung die alte.
|
||||||
- `/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**
|
**Welche Belegung gilt?** Bei jedem Klick sucht Halbklick in dieser Reihenfolge und nimmt den ersten Treffer:
|
||||||
|
|
||||||
- **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.
|
1. die Hälfte, in die du geklickt hast, mit „nur freundlich“ oder „nur feindlich“
|
||||||
- **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.
|
2. die Hälfte, für alle Einheiten
|
||||||
|
3. der ganze Rahmen, mit „nur freundlich“ oder „nur feindlich“
|
||||||
|
4. der ganze Rahmen, für alle Einheiten
|
||||||
|
|
||||||
**Getestet:** Ich habe es in einer nachgebauten Umgebung mit echtem Ankersystem durchgespielt:
|
Passt nichts, bleibt der Klick, wie er ist: Linksklick wählt das Ziel, Rechtsklick öffnet das Menü. Legst du also Linksklick nur auf eine Hälfte, kannst du mit der anderen Hälfte weiter ganz normal anwählen.
|
||||||
|
|
||||||
- waagerechte, senkrechte und mehrreihige Leisten, auch nach links oder unten wachsend
|
| Befehl | Wirkung |
|
||||||
- 125 % Symbolgröße
|
|---|---|
|
||||||
- Änderungen im Edit Mode
|
| `/hk` | Fenster öffnen oder schließen |
|
||||||
- Kampf
|
| `/hk liste` | alle Belegungen im Chat |
|
||||||
- wiederholtes Anwenden ohne Verrutschen
|
| `/hk status` | wie viele Rahmen angemeldet sind und ob etwas auf das Kampfende wartet |
|
||||||
|
|
||||||
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.
|
`/halbklick` funktioniert genauso wie `/hk`.
|
||||||
|
|
||||||
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.
|
**Welche Rahmen?** Nur die Rahmen von **Grid2**, also alles, was Grid2 anzeigt: Gruppe, Schlachtzug, Begleiter und eigene Layouts. Blizzards Rahmen (Spieler, Ziel, Gruppe, Schlachtzug) und Rahmen anderer Addons bleiben unberührt, dort klickst du wie gewohnt. Ohne Grid2 macht Halbklick nichts und sagt das beim Login.
|
||||||
|
|
||||||
*Datei: Leistenabstand.zip (Quellcode im Anhang C)*
|
**Gut zu wissen**
|
||||||
|
|
||||||
|
- Die Belegungen gelten **pro Charakter**.
|
||||||
|
- **Im Kampf** lässt Blizzard keine Änderungen an Klick-Belegungen zu. Du kannst trotzdem speichern, die Änderung wirkt dann ab Kampfende. Die Hälften selbst funktionieren im Kampf ganz normal.
|
||||||
|
- **Makros** wirken nicht von selbst auf die angeklickte Einheit. Schreib `[@mouseover]` dazu, zum Beispiel `/cast [@mouseover] Erneuerung`.
|
||||||
|
- Ob beim **Drücken** oder beim **Loslassen** der Maustaste ausgelöst wird, bestimmt Grid2 mit seiner eigenen Einstellung dafür. Standard ist Loslassen.
|
||||||
|
- Belegst du dieselbe Kombination auch in Blizzards eigenem Klick-Zaubern (Click Casting), gewinnt auf Grid2-Rahmen Halbklick. Alle anderen Kombinationen von Blizzard funktionieren weiter.
|
||||||
|
- Verwende **nur ein Klick-Zauber-Addon**. Clique, Clique Forever, ForeverClick, HealingForever und RankClick vertragen sich nicht mit Halbklick, beim Login erscheint dann eine Warnung.
|
||||||
|
- Was Clique außerdem kann, fehlt hier: Tastatur-Belegungen über Rahmen („Hovercast“), Belegungen nur außerhalb des Kampfes, Profile und Talent-Sets.
|
||||||
|
|
||||||
|
**So funktioniert es**
|
||||||
|
|
||||||
|
Grid2 meldet jeden seiner Rahmen über `Grid2Frame:RegisterFrame` an. Dort hängt sich Halbklick ein, zusätzlich sucht es die Rahmen über Grid2s Rahmenliste und über die Namen (`Grid2LayoutHeader1UnitButton1` usw.). Die Clique-Schnittstelle `ClickCastFrames` reicht nicht: Grid2 nutzt sie nur für seine eigenen Header, nicht für die von Blizzard. Grid2 legt alle Rahmen schon außerhalb des Kampfes an, deshalb sind sie im Kampf bereits eingerichtet.
|
||||||
|
|
||||||
|
Jeder Grid2-Rahmen bekommt über `WrapScript` einen geschützten Vorab-Handler für Klicks. Der läuft auch im Kampf. Er liest mit `GetMousePosition()` die Mausposition im Rahmen (0 = linker, 1 = rechter Rand, die Grenze liegt bei 0,5), dazu die Modifikatortasten und ob die Einheit freundlich oder feindlich ist. Findet er eine passende Belegung, stellt er Aktion und Einheit am unsichtbaren Button `HalbklickProxy` ein und leitet den Klick dorthin weiter. Der Umweg ist nötig, weil Blizzards eigene Rahmen „Ziel auswählen“ und „Menü“ nur auf den Tasten zulassen, die in Blizzards Klick-Zaubern dafür eingestellt sind.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Quellen
|
## Leistenabstand
|
||||||
|
|
||||||
- [Master Scale – CurseForge](https://www.curseforge.com/wow/addons/master-scale)
|
Im Bearbeitungsmodus (Edit Mode) lässt sich der Symbolabstand der Aktionsleisten nicht unter **2** einstellen. Leistenabstand erlaubt jeden Wert von **-4 bis 10**. Nach der Installation stehen alle Leisten auf **0**.
|
||||||
- [UI scaling – Warcraft Wiki](https://warcraft.wiki.gg/wiki/UI_scaling)
|
|
||||||
- [Scale'thas – CurseForge](https://www.curseforge.com/wow/addons/scalethas)
|
| Befehl | Wirkung |
|
||||||
|
|---|---|
|
||||||
|
| `/abstand` | Status und Hilfe |
|
||||||
|
| `/abstand 0` | Abstand für alle Leisten, auch Kommazahlen wie `-0,5` |
|
||||||
|
| `/abstand 3 1` | Abstand nur für Aktionsleiste 3 |
|
||||||
|
| `/abstand 3 aus` | Leiste 3 wieder Blizzard überlassen, danach `/reload` |
|
||||||
|
| `/abstand aus` | alles ausschalten, danach `/reload` |
|
||||||
|
| `/abstand rahmen` | Leistenrahmen mit verkleinern, an oder aus (experimentell) |
|
||||||
|
|
||||||
|
Als Leiste gehen `1` bis `8` (Aktionsleisten), `haltung` (Haltungsleiste) und `pet` (Begleiterleiste). Negative Werte lassen die Ränder der Symbole überlappen. `/leistenabstand` funktioniert genauso wie `/abstand`.
|
||||||
|
|
||||||
|
**So funktioniert es**
|
||||||
|
|
||||||
|
Blizzards Abstandswert (`buttonPadding`) direkt zu ändern, führt zu Taint: Der Edit Mode und anderer Blizzard-Code lesen diesen Wert, und dann erscheinen Meldungen wie „Aktion blockiert“. Leistenabstand lässt den Wert deshalb in Ruhe. Jedes Mal, wenn Blizzard eine Leiste neu anordnet, setzt es danach nur die Positionen der einzelnen Buttons neu, und zwar nie im Kampf.
|
||||||
|
|
||||||
|
Position, Reihen, Symbolgröße und Anzahl der Symbole stellst du weiter im Edit Mode ein. Nur den Abstandsregler dort übergeht das Addon. Leere Plätze behalten ihre Lücke, auch wenn „Immer Buttons anzeigen“ aus ist.
|
||||||
|
|
||||||
|
**Einschränkungen**
|
||||||
|
|
||||||
|
- **Rahmen im Edit Mode:** Ohne `rahmen` bleibt der Markierungsrahmen einer Leiste so groß wie bei Abstand 2. Rastest du eine zweite Leiste daneben ein, bleibt eine Lücke. Mit `rahmen` passt er genau, das geht aber über die bewährte Methode hinaus. Kommen Meldungen wie „Aktion blockiert“, schalte es wieder aus.
|
||||||
|
- **Kampf:** Ordnet Blizzard eine Leiste mitten im Kampf neu an (selten), gelten bis Kampfende wieder die alten Abstände. Vorher darf kein Addon die Buttons anfassen.
|
||||||
|
- **Leistennamen:** Die Namen der Leisten stammen aus dem Retail-Client. Meldet `/abstand` bei einer Leiste „Nicht gefunden“, heißt sie in Forever anders.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Entwicklung
|
||||||
|
|
||||||
|
```
|
||||||
|
ForeverScale/ ForeverScale.toc, ForeverScale.lua
|
||||||
|
Goldbeutel/ Goldbeutel.toc, Goldbeutel.lua
|
||||||
|
Halbklick/ Halbklick.toc, Halbklick.lua
|
||||||
|
Leistenabstand/ Leistenabstand.toc, Leistenabstand.lua
|
||||||
|
tests/ Tests gegen eine nachgebaute WoW-Umgebung
|
||||||
|
docs/ Bilder für dieses README
|
||||||
|
make-zip.sh baut WoW-Forever-Addons.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
**Tests** laufen mit [LuaJIT](https://luajit.org) und spielen die Addons gegen eine nachgebaute WoW-API durch. Bei einem Fehler endet das Skript mit Exit-Code 1.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
luajit tests/test_leistenabstand.lua
|
||||||
|
luajit tests/test_goldbeutel_foreverscale.lua
|
||||||
|
luajit tests/test_halbklick.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Der Halbklick-Test führt die geschützten Snippets wirklich aus, in einer eigenen Umgebung mit denselben Verboten wie bei Blizzard (kein `{`, `}` und kein `function`). Die Weiterleitung danach bildet er nach Blizzards `SecureTemplates.lua` aus dem Forever-Client nach.
|
||||||
|
|
||||||
|
**Download aktualisieren:** Nach Änderungen an einem Addon `./make-zip.sh` ausführen und die neue ZIP mit committen. Sonst bietet der Download-Link noch die alte Version an.
|
||||||
|
|
||||||
|
**Status:** Alle vier Addons sind gegen die nachgebaute Umgebung getestet, aber noch nicht im echten Forever-Client. Wenn dort etwas nicht funktioniert, hilft die genaue Fehlermeldung oder die Ausgabe von `/abstand` bzw. `/hk status` am meisten.
|
||||||
|
|
||||||
|
## Alternativen und Hintergrund
|
||||||
|
|
||||||
|
- [Master Scale](https://www.curseforge.com/wow/addons/master-scale) und [Scale'thas](https://www.curseforge.com/wow/addons/scalethas): fertige Skalierungs-Addons statt ForeverScale. Master Scale unterstützt Forever, reicht von 0,50 bis 1,50 und wird unter Esc → Optionen → AddOns eingestellt.
|
||||||
|
- [McAwesome Action Bars](https://www.curseforge.com/wow/addons/mcawesome-action-bars): ersetzt die Aktionsleisten in Forever komplett, mit eigenem Symbolabstand pro Leiste.
|
||||||
|
- [UI scaling – Warcraft Wiki](https://warcraft.wiki.gg/wiki/UI_scaling): Hintergrund zur UI-Skalierung und zur 768-Formel.
|
||||||
- [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)
|
- [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)
|
- [How to modify padding for MainMenuBar 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): warum man `buttonPadding` nicht direkt ändern sollte.
|
||||||
- [McAwesome Action Bars – CurseForge](https://www.curseforge.com/wow/addons/mcawesome-action-bars)
|
- [Clique](https://www.curseforge.com/wow/addons/clique), [ForeverClick](https://www.curseforge.com/wow/addons/foreverclick) und [Clique Forever](https://github.com/orbit0r/Clique-Forever): Klick-Zauber-Addons ohne Unterscheidung der Rahmenhälften. Clique Forever leitet Klicks ebenfalls über eigene Proxy-Buttons.
|
||||||
|
- [Blizzards UI-Quelltext für Forever](https://github.com/Gethe/wow-ui-source/tree/forever): `RestrictedFrames.lua` (dort steht `GetMousePosition`), `SecureHandlers.lua` und `SecureTemplates.lua`, auf denen Halbklick aufbaut.
|
||||||
---
|
|
||||||
|
|
||||||
## 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, worked out
|
|
||||||
-- again whenever the resolution changes. Not limited to
|
|
||||||
-- 0.30 - 1.50, so on 5K/6K screens it goes below 0.30.
|
|
||||||
-- /fscale reset stop overriding (then /reload)
|
|
||||||
|
|
||||||
local ADDON = ...
|
|
||||||
local f = CreateFrame("Frame")
|
|
||||||
|
|
||||||
-- the scale to enforce, or nil if there is no override
|
|
||||||
local function target()
|
|
||||||
local db = ForeverScaleDB
|
|
||||||
if not db then return end
|
|
||||||
if db.pixel then
|
|
||||||
local _, h = GetPhysicalScreenSize()
|
|
||||||
if h and h > 0 then return 768 / h end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
return db.scale
|
|
||||||
end
|
|
||||||
|
|
||||||
local function apply()
|
|
||||||
local s = target()
|
|
||||||
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, ForeverScaleDB.pixel = nil, nil
|
|
||||||
print("ForeverScale: override cleared. /reload to return to Blizzard's scale.")
|
|
||||||
return
|
|
||||||
elseif msg == "pixel" then
|
|
||||||
ForeverScaleDB.scale, ForeverScaleDB.pixel = nil, true
|
|
||||||
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, ForeverScaleDB.pixel = v, nil
|
|
||||||
end
|
|
||||||
|
|
||||||
apply()
|
|
||||||
print(string.format("ForeverScale: scale set to %.4f%s%s", target() or UIParent:GetScale(),
|
|
||||||
ForeverScaleDB.pixel and " (pixel, follows your resolution)" or "",
|
|
||||||
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
|
|
||||||
|
|
||||||
-- string.lower kennt nur A-Z. Fuer Namen wie "Ärger" auch À-Þ (UTF-8 C3 80-9E,
|
|
||||||
-- ausser ×) in Kleinbuchstaben umwandeln.
|
|
||||||
local function lower(s)
|
|
||||||
return (s:lower():gsub("\195([\128-\158])", function(c)
|
|
||||||
if c ~= "\151" then return "\195" .. string.char(c:byte() + 32) end
|
|
||||||
end))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Felder aktualisieren statt den Eintrag zu ersetzen, damit der
|
|
||||||
-- Sitzungsstart (session) erhalten bleibt
|
|
||||||
local function record()
|
|
||||||
local chars = db.chars[realm]
|
|
||||||
local me = chars[player] or {}
|
|
||||||
chars[player] = me
|
|
||||||
local _, class = UnitClass("player")
|
|
||||||
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)
|
|
||||||
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:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
||||||
ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
|
||||||
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_ENTERING_WORLD" then
|
|
||||||
-- PLAYER_LOGIN kommt auch bei /reload. Erst hier steht fest, ob es nur ein
|
|
||||||
-- Reload war (arg2 = isReloadingUi); dann zaehlt die Sitzung weiter.
|
|
||||||
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
|
|
||||||
local me = db.chars[realm][player]
|
|
||||||
if arg2 and me.session then
|
|
||||||
sessionStart = me.session
|
|
||||||
else
|
|
||||||
me.session = sessionStart
|
|
||||||
end
|
|
||||||
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, want = db.chars[realm], lower(arg)
|
|
||||||
for name in pairs(chars) do
|
|
||||||
if lower(name) == want 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 },
|
|
||||||
-- 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 = {}
|
|
||||||
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
|
|
||||||
|
|
||||||
-- 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)
|
|
||||||
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, grid)
|
|
||||||
local l, r, t, b
|
|
||||||
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
|
|
||||||
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 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 = grid[1]
|
|
||||||
for i = 1, anchor:GetNumPoints() do
|
|
||||||
local _, rel = anchor:GetPoint(i)
|
|
||||||
for _, b in ipairs(grid) 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(grid) 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, #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, grid) 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
|
|
||||||
```
|
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 648 KiB |
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Baut WoW-Forever-Addons.zip mit den drei Addon-Ordnern auf oberster Ebene,
|
# Baut WoW-Forever-Addons.zip mit den vier Addon-Ordnern auf oberster Ebene,
|
||||||
# damit man sie direkt nach World of Warcraft/_forever_/Interface/AddOns/ entpacken kann.
|
# damit man sie direkt nach World of Warcraft/_forever_/Interface/AddOns/ entpacken kann.
|
||||||
# Nach Aenderungen an den Addons erneut ausfuehren und die ZIP mit committen.
|
# Nach Aenderungen an den Addons erneut ausfuehren und die ZIP mit committen.
|
||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
rm -f WoW-Forever-Addons.zip
|
rm -f WoW-Forever-Addons.zip
|
||||||
zip -q -X -r WoW-Forever-Addons.zip ForeverScale Goldbeutel Leistenabstand -x '*.DS_Store'
|
zip -q -X -r WoW-Forever-Addons.zip ForeverScale Goldbeutel Halbklick Leistenabstand -x '*.DS_Store'
|
||||||
unzip -l WoW-Forever-Addons.zip
|
unzip -l WoW-Forever-Addons.zip
|
||||||
@@ -8,7 +8,25 @@ local noop = function() end
|
|||||||
local function obj(t) return setmetatable(t or {}, {__index = function() return noop end}) end
|
local function obj(t) return setmetatable(t or {}, {__index = function() return noop end}) end
|
||||||
|
|
||||||
---------------------------------------------------------------- Goldbeutel
|
---------------------------------------------------------------- Goldbeutel
|
||||||
local money, ev, lines
|
local money, ev, lines, shownText, gtimers
|
||||||
|
-- Ausgangszustand fuer Taschen, Ruestung und Ausruestung (in Tests veraenderbar)
|
||||||
|
-- bags[i] = { Plaetze, frei, Taschentyp }; Index 0 = Rucksack, 5 = Reagenzientasche
|
||||||
|
-- gear[Platz] = { Qualitaet, Gegenstandsstufe, Ausruestungsplatz }
|
||||||
|
local bags, dura, gear, gclass, uncached
|
||||||
|
local function defaultGear()
|
||||||
|
bags = { [0] = {16, 5, 0}, {20, 10, 0}, {16, 16, 1}, {0, 0, 0}, {20, 8, 0}, {36, 30, 0} }
|
||||||
|
dura = { [1] = {45, 100}, [5] = {100, 100}, [7] = {80, 80} } -- Kopf, Brust, Beine
|
||||||
|
gear = {
|
||||||
|
[1] = {4, 66, "INVTYPE_HEAD"}, [2] = {3, 60, "INVTYPE_NECK"}, [3] = {4, 66, "INVTYPE_SHOULDER"},
|
||||||
|
[4] = {1, 1, "INVTYPE_BODY"}, [5] = {4, 66, "INVTYPE_ROBE"}, [6] = {3, 58, "INVTYPE_WAIST"},
|
||||||
|
[7] = {4, 66, "INVTYPE_LEGS"}, [8] = {3, 58, "INVTYPE_FEET"}, [9] = {3, 58, "INVTYPE_WRIST"},
|
||||||
|
[10] = {4, 66, "INVTYPE_HAND"}, [11] = {3, 60, "INVTYPE_FINGER"}, [12] = {3, 60, "INVTYPE_FINGER"},
|
||||||
|
[13] = {3, 60, "INVTYPE_TRINKET"}, [14] = {3, 60, "INVTYPE_TRINKET"}, [15] = {3, 60, "INVTYPE_CLOAK"},
|
||||||
|
[16] = {4, 77, "INVTYPE_2HWEAPON"}, [18] = {3, 60, "INVTYPE_RANGEDRIGHT"}, [19] = {1, 1, "INVTYPE_TABARD"},
|
||||||
|
}
|
||||||
|
gclass, uncached = "MAGE", {}
|
||||||
|
end
|
||||||
|
defaultGear()
|
||||||
local function startGold(name, db)
|
local function startGold(name, db)
|
||||||
GoldbeutelDB = db
|
GoldbeutelDB = db
|
||||||
print = noop
|
print = noop
|
||||||
@@ -16,8 +34,23 @@ local function startGold(name, db)
|
|||||||
strtrim = function(s) return (s:gsub("^%s+",""):gsub("%s+$","")) end
|
strtrim = function(s) return (s:gsub("^%s+",""):gsub("%s+$","")) end
|
||||||
GetRealmName = function() return "Blackmoore" end
|
GetRealmName = function() return "Blackmoore" end
|
||||||
UnitName = function() return name end
|
UnitName = function() return name end
|
||||||
UnitClass = function() return "Magier", "MAGE" end
|
UnitClass = function() return "Klasse", gclass end
|
||||||
GetMoney = function() return money end
|
GetMoney = function() return money end
|
||||||
|
NUM_BAG_SLOTS, NUM_TOTAL_EQUIPPED_BAG_SLOTS, INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED = 4, 5, 1, 19
|
||||||
|
C_Container = {
|
||||||
|
GetContainerNumSlots = function(b) return bags[b] and bags[b][1] or 0 end,
|
||||||
|
GetContainerNumFreeSlots = function(b) if bags[b] then return bags[b][2], bags[b][3] end return 0, 0 end,
|
||||||
|
}
|
||||||
|
GetInventoryItemDurability = function(s) if dura[s] then return dura[s][1], dura[s][2] end end
|
||||||
|
GetInventoryItemLink = function(_, s) if gear[s] then return "[Item" .. s .. "]" end end
|
||||||
|
GetInventoryItemID = function(_, s) if gear[s] then return 1000 + s end end
|
||||||
|
C_Item = { GetItemInfo = function(link)
|
||||||
|
local s = tonumber(link:match("%d+")); local g = gear[s]
|
||||||
|
if g and not uncached[s] then return "Name", link, g[1], g[2], 1, "Ruestung", "Stoff", 1, g[3] end
|
||||||
|
end }
|
||||||
|
GearscoreForeverDB = nil
|
||||||
|
gtimers = {}
|
||||||
|
C_Timer = { After = function(_, fn) gtimers[#gtimers + 1] = fn end }
|
||||||
UIParent = obj{ GetHeight = function() return 800 end }
|
UIParent = obj{ GetHeight = function() return 800 end }
|
||||||
lines = {}
|
lines = {}
|
||||||
GameTooltip = obj{ AddDoubleLine = function(_, l, r) lines[l] = r end, IsOwned = function() return false end }
|
GameTooltip = obj{ AddDoubleLine = function(_, l, r) lines[l] = r end, IsOwned = function() return false end }
|
||||||
@@ -28,7 +61,8 @@ local function startGold(name, db)
|
|||||||
GetCenter = function() return 500, 300 end,
|
GetCenter = function() return 500, 300 end,
|
||||||
SetShown = function(self, v) self.shown = v end,
|
SetShown = function(self, v) self.shown = v end,
|
||||||
IsShown = function(self) return self.shown end,
|
IsShown = function(self) return self.shown end,
|
||||||
CreateFontString = function() return obj{ GetStringWidth = function() return 80 end, GetStringHeight = function() return 12 end } end }
|
CreateFontString = function() return obj{ SetText = function(_, t) shownText = t end,
|
||||||
|
GetStringWidth = function() return 80 end, GetStringHeight = function() return 12 end } end }
|
||||||
frames[#frames + 1] = f
|
frames[#frames + 1] = f
|
||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
@@ -68,6 +102,83 @@ SlashCmdList.GOLDBEUTEL("forget ÉLODIE"); check("ÉLODIE -> Élodie entfernt",
|
|||||||
SlashCmdList.GOLDBEUTEL("forget öx×y"); check("öx×y -> Öx×y entfernt (× unveraendert)", chars["Öx×y"] == 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)
|
SlashCmdList.GOLDBEUTEL("forget testmagier"); check("Eigener Charakter bleibt", chars.Testmagier ~= nil)
|
||||||
|
|
||||||
|
out("Goldbeutel: Taschen, Ruestung, GearScore")
|
||||||
|
local function flush() while #gtimers > 0 do table.remove(gtimers, 1)() end end
|
||||||
|
-- Liest Escape-Sequenzen wie der Client von links nach rechts: "||" ist ein |,
|
||||||
|
-- |cAARRGGBB und |r sind Farben, |T...|t eine Textur. Liefert den sichtbaren Text
|
||||||
|
-- und die Zahl der am Ende noch offenen Farben (muss 0 sein).
|
||||||
|
local function render(s)
|
||||||
|
local res, open, i = {}, 0, 1
|
||||||
|
while i <= #s do
|
||||||
|
local c, n = s:sub(i, i), s:sub(i + 1, i + 1)
|
||||||
|
if c ~= "|" then res[#res + 1] = c; i = i + 1
|
||||||
|
elseif n == "|" then res[#res + 1] = "|"; i = i + 2
|
||||||
|
elseif n == "c" and s:sub(i + 2, i + 9):match("^%x+$") and i + 9 <= #s then open = open + 1; i = i + 10
|
||||||
|
elseif n == "r" then open = open - 1; i = i + 2
|
||||||
|
elseif n == "T" then i = (s:find("|t", i, true) or #s) + 2
|
||||||
|
else res[#res + 1] = c; i = i + 1 end
|
||||||
|
end
|
||||||
|
return table.concat(res), open
|
||||||
|
end
|
||||||
|
local function plain(s) return (render(s)) end
|
||||||
|
local function tooltip() lines = {}; fr.scripts.OnEnter(fr); return lines end
|
||||||
|
-- Sollwerte (Punkte, iLvl, Farbe) stammen aus dem Originalcode von GearScore Forever 1.3.0
|
||||||
|
defaultGear(); money = 1234567
|
||||||
|
fr = startGold("Testmagier", nil); ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", true, false); flush()
|
||||||
|
check("Rahmen: eine Zeile mit allen vier Werten",
|
||||||
|
plain(shownText) == "123 45 67 | 23 | 45% | GS 856")
|
||||||
|
check("Jede Farbe wird wieder geschlossen (grauer Trenner ohne sichtbares 'r')",
|
||||||
|
select(2, render(shownText)) == 0 and shownText:find("|cff666666|||r", 1, true) ~= nil)
|
||||||
|
check("Spezialtaschen (Koecher, Reagenzientasche) nicht im Rahmen mitgezaehlt", plain(shownText):find("| 23 |", 1, true))
|
||||||
|
check("45% gelb (unter 50)", shownText:find("|cffffd10045%|r", 1, true) ~= nil)
|
||||||
|
check("23 freie Plaetze ohne Warnfarbe", shownText:find("|||r 23 ", 1, true) ~= nil)
|
||||||
|
check("GS 856 lila wie in GearScore Forever", shownText:find("|cffb44aea856|r", 1, true) ~= nil)
|
||||||
|
tooltip()
|
||||||
|
check("Tooltip: Taschen frei 23 / 56", lines["Taschen frei:"] == "23 / 56")
|
||||||
|
check("Tooltip: Spezialtaschen frei 46 / 52", lines["Spezialtaschen frei:"] == "46 / 52")
|
||||||
|
check("Tooltip: Ruestung gesamt 80% (225/280)", lines["Rüstung gesamt:"] == "80%")
|
||||||
|
check("Tooltip: am staerksten beschaedigtes Teil (Kopf) mit 45%", plain(lines[" [Item1]"] or "") == "45%")
|
||||||
|
check("Tooltip: GearScore 856", plain(lines["GearScore:"] or "") == "856")
|
||||||
|
check("Tooltip: Gegenstandsstufe 62 (ohne Hemd und Wappenrock)", lines["Gegenstandsstufe:"] == 62)
|
||||||
|
|
||||||
|
bags[0][2], bags[1][2], bags[4][2] = 0, 3, 0; dura[1][1] = 10
|
||||||
|
for _ = 1, 3 do ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED") end
|
||||||
|
ev.scripts.OnEvent(ev, "UPDATE_INVENTORY_DURABILITY")
|
||||||
|
check("Mehrere Ereignisse -> nur eine Aktualisierung", #gtimers == 1)
|
||||||
|
flush()
|
||||||
|
check("3 freie Plaetze gelb", shownText:find("|cffffd1003|r", 1, true) ~= nil)
|
||||||
|
check("10% rot", shownText:find("|cffff333310%|r", 1, true) ~= nil)
|
||||||
|
bags[1][2] = 0; ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED"); flush()
|
||||||
|
check("0 freie Plaetze rot", shownText:find("|cffff33330|r", 1, true) ~= nil)
|
||||||
|
|
||||||
|
out("Goldbeutel: GearScore wie in GearScore Forever")
|
||||||
|
ev.scripts.OnEvent(ev, "GET_ITEM_INFO_RECEIVED"); check("Alles geladen: GET_ITEM_INFO_RECEIVED loest nichts aus", #gtimers == 0)
|
||||||
|
GearscoreForeverDB = { maxScoreSeen = 1800 }; ev.scripts.OnEvent(ev, "PLAYER_MONEY"); flush()
|
||||||
|
check("Groessere Skala aus GearScore Forever (1800 gesehen): 856 gruen", shownText:find("|cff18e535856|r", 1, true) ~= nil)
|
||||||
|
GearscoreForeverDB = nil
|
||||||
|
gclass = "HUNTER"; ev.scripts.OnEvent(ev, "PLAYER_EQUIPMENT_CHANGED"); flush()
|
||||||
|
check("Jaeger: Nahkampfwaffe zaehlt wenig, Zauberstab viel -> 818", plain(tooltip()["GearScore:"] or "") == "818")
|
||||||
|
gclass = "MAGE"; gear[17] = {4, 77, "INVTYPE_2HWEAPON"}
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_EQUIPMENT_CHANGED"); flush()
|
||||||
|
check("Titanengriff: zwei Zweihaender je zur Haelfte -> 856, iLvl 63",
|
||||||
|
plain(tooltip()["GearScore:"] or "") == "856" and lines["Gegenstandsstufe:"] == 63)
|
||||||
|
gear[17] = nil; uncached[1] = true
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_EQUIPMENT_CHANGED"); flush()
|
||||||
|
check("Kopf noch nicht geladen: vorlaeufig 781", plain(shownText):find("GS 781", 1, true) ~= nil)
|
||||||
|
uncached[1] = nil; ev.scripts.OnEvent(ev, "GET_ITEM_INFO_RECEIVED")
|
||||||
|
check("GET_ITEM_INFO_RECEIVED rechnet neu, solange Daten fehlen", #gtimers == 1)
|
||||||
|
flush()
|
||||||
|
check("Danach vollstaendig: 856", plain(shownText):find("GS 856", 1, true) ~= nil)
|
||||||
|
|
||||||
|
gear, dura = {}, {}; ev.scripts.OnEvent(ev, "PLAYER_EQUIPMENT_CHANGED"); flush()
|
||||||
|
check("Ohne Ausruestung nur Gold und Taschen", plain(shownText) == "123 45 67 | 0")
|
||||||
|
tooltip()
|
||||||
|
check("Tooltip ohne Ruestungs- und GearScore-Zeilen",
|
||||||
|
lines["Rüstung gesamt:"] == nil and lines["GearScore:"] == nil and lines["Gegenstandsstufe:"] == nil)
|
||||||
|
defaultGear(); dura = { [1] = {50, 50} }; ev.scripts.OnEvent(ev, "UPDATE_INVENTORY_DURABILITY"); flush()
|
||||||
|
tooltip()
|
||||||
|
check("Alles heil: keine Zeile fuer beschaedigtes Teil", lines[" [Item1]"] == nil and lines["Rüstung gesamt:"] == "100%")
|
||||||
|
|
||||||
---------------------------------------------------------------- ForeverScale
|
---------------------------------------------------------------- ForeverScale
|
||||||
local scale, h, combat, timers, f
|
local scale, h, combat, timers, f
|
||||||
local function startScale(db)
|
local function startScale(db)
|
||||||
|
|||||||
@@ -0,0 +1,590 @@
|
|||||||
|
-- Aufruf aus dem Repo-Wurzelverzeichnis oder von ueberall: luajit tests/test_halbklick.lua
|
||||||
|
-- Testet Halbklick in einer nachgebauten WoW-Umgebung (Mock), nicht im echten Client.
|
||||||
|
-- Die geschuetzten Snippets laufen wirklich: in einer eigenen Umgebung wie bei
|
||||||
|
-- Blizzard (RestrictedExecution.lua), mit derselben Pruefung auf "{", "}" und
|
||||||
|
-- "function". Die Weiterleitung danach bildet SecureTemplates.lua aus dem
|
||||||
|
-- Forever-Client nach (Attributsuche mit Modifikatoren, Aktion "click",
|
||||||
|
-- useOnKeyDown beim Proxy).
|
||||||
|
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
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Zustand der Welt
|
||||||
|
local mods = "" -- gedrueckte Modifikatoren, z. B. "shift-" oder "alt-ctrl-"
|
||||||
|
local mouseX -- Mausposition im Rahmen, 0 = links, 1 = rechts, nil = ausserhalb
|
||||||
|
local combat = false
|
||||||
|
local reaction = { party1 = "help", party2 = "help", player = "help", target = "harm", raid3 = "help" }
|
||||||
|
local log = {} -- was beim Klick passiert ist
|
||||||
|
local cursor -- { "spell", ... } am Mauszeiger
|
||||||
|
local printed = {}
|
||||||
|
local frames = {} -- alle erzeugten Rahmen in Reihenfolge
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Rahmen
|
||||||
|
local noop = function() end
|
||||||
|
local Frame = {}
|
||||||
|
-- Unbekannte Methoden (gross geschrieben) tun nichts, Datenfelder bleiben nil
|
||||||
|
local FrameMT = { __index = function(_, k)
|
||||||
|
local v = Frame[k]
|
||||||
|
if v ~= nil then return v end
|
||||||
|
if type(k) == "string" and k:match("^%u") then return noop end
|
||||||
|
end }
|
||||||
|
|
||||||
|
-- Blizzards Suche nach "modifizierten" Attributen (SecureButton_GetModifiedAttribute)
|
||||||
|
local SUFFIX = { LeftButton = "1", RightButton = "2", MiddleButton = "3" }
|
||||||
|
for n = 4, 31 do SUFFIX["Button" .. n] = tostring(n) end
|
||||||
|
local function modifiedAttr(f, name, button)
|
||||||
|
local suffix = SUFFIX[button] or ("-" .. button)
|
||||||
|
for _, k in ipairs({ mods .. name .. suffix, "*" .. name .. suffix, mods .. name .. "*", "*" .. name .. "*", name }) do
|
||||||
|
local v = f.attrs[k]
|
||||||
|
if v ~= nil then
|
||||||
|
if v == "" then return nil end -- ATTRIBUTE_NOOP
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- SecureUnitButton_OnClick (vereinfacht): Aktion "click" an den Delegaten weiterreichen
|
||||||
|
local function unitOnClick(self, button, down)
|
||||||
|
local t = modifiedAttr(self, "type", button)
|
||||||
|
if t == "click" then
|
||||||
|
local d = modifiedAttr(self, "clickbutton", button)
|
||||||
|
if d then d:Click(button) end
|
||||||
|
else
|
||||||
|
log[#log + 1] = { kind = "standard", type = t, unit = self.attrs.unit }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- SecureActionButton_OnClick: ohne Tastendruck-Angabe zaehlt useOnKeyDown
|
||||||
|
-- (Standard aus dem CVar ActionButtonUseKeyDown = 1)
|
||||||
|
local function actionOnClick(self, button, down)
|
||||||
|
local useOnKeyDown = self.attrs.useOnKeyDown
|
||||||
|
if useOnKeyDown == nil then useOnKeyDown = true end
|
||||||
|
if not ((down and useOnKeyDown) or (not down and not useOnKeyDown)) then
|
||||||
|
log[#log + 1] = { kind = "nichts" }
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local unit = modifiedAttr(self, "unit", button)
|
||||||
|
local suffix = modifiedAttr(self, "unitsuffix", button)
|
||||||
|
if unit and suffix then unit = unit .. suffix end
|
||||||
|
log[#log + 1] = {
|
||||||
|
kind = "proxy", type = modifiedAttr(self, "type", button), unit = unit,
|
||||||
|
spell = modifiedAttr(self, "spell", button), macrotext = modifiedAttr(self, "macrotext", button),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function newFrame(kind, name, parent, template)
|
||||||
|
template = template or ""
|
||||||
|
local f = setmetatable({ kind = kind, name = name, parent = parent, template = template,
|
||||||
|
attrs = {}, scripts = {}, shown = true, events = {} }, FrameMT)
|
||||||
|
f.protected = template:find("Secure") ~= nil
|
||||||
|
if template:find("SecureUnitButtonTemplate") then f.scripts.OnClick = unitOnClick end
|
||||||
|
if template:find("SecureActionButtonTemplate") then f.scripts.OnClick = actionOnClick end
|
||||||
|
if template:find("UIRadioButtonTemplate") then f.text = newFrame("FontString") end
|
||||||
|
if name then _G[name] = f end
|
||||||
|
frames[#frames + 1] = f
|
||||||
|
return f
|
||||||
|
end
|
||||||
|
|
||||||
|
function Frame:GetName() return self.name end
|
||||||
|
function Frame:GetParent() return self.parent end
|
||||||
|
function Frame:SetAttribute(k, v)
|
||||||
|
assert(not (combat and self.protected), "SetAttribute an geschuetztem Rahmen im Kampf: " .. tostring(k))
|
||||||
|
self.attrs[k] = v
|
||||||
|
end
|
||||||
|
function Frame:GetAttribute(k) return self.attrs[k] end
|
||||||
|
function Frame:SetScript(n, fn) self.scripts[n] = fn end
|
||||||
|
function Frame:GetScript(n) return self.scripts[n] end
|
||||||
|
function Frame:HookScript(n, fn)
|
||||||
|
local old = self.scripts[n]
|
||||||
|
self.scripts[n] = function(...) if old then old(...) end; fn(...) end
|
||||||
|
end
|
||||||
|
function Frame:HasScript(n) return n ~= "OnClick" or self.kind == "Button" or self.kind == "CheckButton" end
|
||||||
|
function Frame:IsForbidden() return self.forbidden or false end
|
||||||
|
function Frame:IsProtected() return self.protected, self.protected end
|
||||||
|
function Frame:Show() self.shown = true; if self.scripts.OnShow then self.scripts.OnShow(self) end end
|
||||||
|
function Frame:Hide() self.shown = false end
|
||||||
|
function Frame:SetShown(s) if s then self:Show() else self:Hide() end end
|
||||||
|
function Frame:IsShown() return self.shown end
|
||||||
|
function Frame:SetText(t) self.textValue = t end
|
||||||
|
function Frame:GetText() return self.textValue end
|
||||||
|
function Frame:SetChecked(c) self.checked = c end
|
||||||
|
function Frame:GetChecked() return self.checked end
|
||||||
|
function Frame:LockHighlight() self.locked = true end
|
||||||
|
function Frame:UnlockHighlight() self.locked = false end
|
||||||
|
function Frame:RegisterEvent(e) self.events[e] = true end
|
||||||
|
function Frame:UnregisterEvent(e) self.events[e] = nil end
|
||||||
|
function Frame:CreateFontString() return newFrame("FontString", nil, self) end
|
||||||
|
function Frame:CreateTexture() return newFrame("Texture", nil, self) end
|
||||||
|
function Frame:Click(button, down)
|
||||||
|
if self.scripts.OnClick then self.scripts.OnClick(self, button or "LeftButton", down or false) end
|
||||||
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Geschuetzte Umgebung
|
||||||
|
local handles = setmetatable({}, { __mode = "k" })
|
||||||
|
local handle
|
||||||
|
local function unwrapValue(v)
|
||||||
|
if type(v) == "table" and v.__frame then return v.__frame end
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
function handle(f)
|
||||||
|
if not f then return nil end
|
||||||
|
if handles[f] then return handles[f] end
|
||||||
|
local h = { __frame = f }
|
||||||
|
function h:GetAttribute(name)
|
||||||
|
if type(name) ~= "string" or name:match("^_") then return end
|
||||||
|
local v = f.attrs[name]
|
||||||
|
if type(v) == "table" and getmetatable(v) == FrameMT then return handle(v) end
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
function h:SetAttribute(name, value)
|
||||||
|
assert(type(name) == "string" and not name:match("^_"), "Invalid attribute name")
|
||||||
|
f.attrs[name] = unwrapValue(value) -- im Kampf erlaubt: geschuetzter Code
|
||||||
|
end
|
||||||
|
function h:GetFrameRef(label) return handle(f.attrs["frameref-" .. label]) end
|
||||||
|
-- wie SecureButton_GetModifiedAttribute: faellt mit "useparent-..." auf den Elternrahmen zurueck
|
||||||
|
function h:GetEffectiveAttribute(name)
|
||||||
|
local v = f.attrs[name]
|
||||||
|
if v == nil and (f.attrs["useparent-" .. name] or f.attrs["useparent*"]) and f.parent then
|
||||||
|
v = f.parent.attrs[name]
|
||||||
|
end
|
||||||
|
if type(v) == "table" and getmetatable(v) == FrameMT then return handle(v) end
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
function h:GetMousePosition() if mouseX then return mouseX, 0.5 end end
|
||||||
|
handles[f] = h
|
||||||
|
return h
|
||||||
|
end
|
||||||
|
|
||||||
|
local envs = {}
|
||||||
|
local function restrictedEnv(header)
|
||||||
|
if not envs[header] then
|
||||||
|
envs[header] = {
|
||||||
|
IsAltKeyDown = function() return mods:find("alt-", 1, true) ~= nil end,
|
||||||
|
IsControlKeyDown = function() return mods:find("ctrl-", 1, true) ~= nil end,
|
||||||
|
IsShiftKeyDown = function() return mods:find("shift-", 1, true) ~= nil end,
|
||||||
|
PlayerCanAttack = function(u) return reaction[u] == "harm" end,
|
||||||
|
PlayerCanAssist = function(u) return reaction[u] == "help" end,
|
||||||
|
newtable = function(...) return { ... } end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return envs[header]
|
||||||
|
end
|
||||||
|
|
||||||
|
local snippetsCompiled = 0
|
||||||
|
local function compile(body, signature, env)
|
||||||
|
-- dieselben Verbote wie in BuildRestrictedClosure
|
||||||
|
assert(not body:match("function"), "Snippet enthaelt das Wort 'function'")
|
||||||
|
assert(not body:match("[{}]"), "Snippet enthaelt { oder }")
|
||||||
|
local def = assert(loadstring("return function (" .. signature .. ") " .. body .. "\nend"))
|
||||||
|
setfenv(def, {})
|
||||||
|
local fn = def()
|
||||||
|
setfenv(fn, env)
|
||||||
|
snippetsCompiled = snippetsCompiled + 1
|
||||||
|
return fn
|
||||||
|
end
|
||||||
|
|
||||||
|
local function makeHeader(f)
|
||||||
|
function f:SetFrameRef(label, ref)
|
||||||
|
assert(not combat, "SetFrameRef im Kampf")
|
||||||
|
self.attrs["frameref-" .. label] = ref
|
||||||
|
end
|
||||||
|
function f:Execute(body)
|
||||||
|
assert(not combat, "Execute im Kampf")
|
||||||
|
compile(body, "self", restrictedEnv(self))(handle(self))
|
||||||
|
end
|
||||||
|
function f:WrapScript(frame, script, preBody)
|
||||||
|
assert(not combat, "WrapScript im Kampf")
|
||||||
|
assert(script == "OnClick")
|
||||||
|
local header = self
|
||||||
|
local orig = frame.scripts.OnClick
|
||||||
|
local pre = compile(preBody, "self,button,down", restrictedEnv(header))
|
||||||
|
frame.unwrapped = frame.unwrapped or {}
|
||||||
|
frame.unwrapped[#frame.unwrapped + 1] = orig
|
||||||
|
frame.scripts.OnClick = function(fr, button, down)
|
||||||
|
if not combat or fr.protected then
|
||||||
|
local newbutton = pre(handle(fr), button, down)
|
||||||
|
if newbutton == false then return end
|
||||||
|
if newbutton then button = tostring(newbutton) end
|
||||||
|
end
|
||||||
|
if orig then orig(fr, button, down) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function f:UnwrapScript(frame, script)
|
||||||
|
assert(not combat, "UnwrapScript im Kampf")
|
||||||
|
frame.scripts[script] = table.remove(frame.unwrapped)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------------------- WoW-API
|
||||||
|
local ev
|
||||||
|
local nGrid = 0
|
||||||
|
local function installApi()
|
||||||
|
frames, printed, log = {}, {}, {}
|
||||||
|
mods, mouseX, combat, cursor = "", nil, false, nil
|
||||||
|
for _, n in ipairs({ "HalbklickHeader", "HalbklickProxy", "HalbklickFrame", "HalbklickWert",
|
||||||
|
"HalbklickKlickfeld", "HalbklickListe", "PlayerFrame", "TargetFrame", "CompactRaidFrame1",
|
||||||
|
"NamePlate1UnitFrame", "PartyFrame", "ClickCastFrames", "HalbklickDB" }) do _G[n] = nil end
|
||||||
|
CreateFrame = function(kind, name, parent, template)
|
||||||
|
local f = newFrame(kind, name, parent, template)
|
||||||
|
if (template or ""):find("SecureHandlerBaseTemplate") then makeHeader(f) end
|
||||||
|
return f
|
||||||
|
end
|
||||||
|
UIParent = newFrame("Frame", "UIParent")
|
||||||
|
InCombatLockdown = function() return combat end
|
||||||
|
hooksecurefunc = function(a, b, c)
|
||||||
|
local tbl, name, fn = _G, a, b
|
||||||
|
if type(a) == "table" then tbl, name, fn = a, b, c end
|
||||||
|
local orig = tbl[name]
|
||||||
|
tbl[name] = function(...) local r = orig(...); fn(...); return r end
|
||||||
|
end
|
||||||
|
-- Grid2: meldet jeden Rahmen ueber RegisterFrame an und fuehrt eine Liste
|
||||||
|
Grid2Frame = { registeredFrames = {} }
|
||||||
|
function Grid2Frame:RegisterFrame(frame)
|
||||||
|
if self.registeredFrames then self.registeredFrames[frame:GetName()] = frame end
|
||||||
|
end
|
||||||
|
for k in pairs(_G) do
|
||||||
|
if type(k) == "string" and k:find("^Grid2LayoutHeader") then _G[k] = nil end
|
||||||
|
end
|
||||||
|
nGrid = 0
|
||||||
|
CompactUnitFrame_SetUnit = function(frame, unit) frame:SetAttribute("unit", unit) end
|
||||||
|
IsAltKeyDown = function() return mods:find("alt-", 1, true) ~= nil end
|
||||||
|
IsControlKeyDown = function() return mods:find("ctrl-", 1, true) ~= nil end
|
||||||
|
IsShiftKeyDown = function() return mods:find("shift-", 1, true) ~= nil end
|
||||||
|
GetCursorInfo = function() if cursor then return unpack(cursor) end end
|
||||||
|
ClearCursor = function() cursor = nil end
|
||||||
|
C_Spell = { GetSpellName = function(id) return ({ [2061] = "Blitzheilung", [139] = "Erneuerung" })[id] end }
|
||||||
|
GetMacroInfo = function(i) if i == 7 then return "Heil", 1, "/cast [@mouseover] Erneuerung\n" end end
|
||||||
|
C_AddOns = { IsAddOnLoaded = function(n) return n == "Clique" end }
|
||||||
|
strtrim = function(s) return (s:gsub("^%s+", ""):gsub("%s+$", "")) end
|
||||||
|
tinsert = table.insert
|
||||||
|
UISpecialFrames = {}
|
||||||
|
SlashCmdList = {}
|
||||||
|
print = function(s) printed[#printed + 1] = s end
|
||||||
|
unpack = unpack or table.unpack
|
||||||
|
end
|
||||||
|
|
||||||
|
local function loadAddon(db, before)
|
||||||
|
installApi()
|
||||||
|
HalbklickDB = db
|
||||||
|
if before then before() end
|
||||||
|
assert(loadfile(ROOT .. "Halbklick/Halbklick.lua"))("Halbklick")
|
||||||
|
for _, f in ipairs(frames) do
|
||||||
|
if f.kind == "Frame" and not f.name and f.scripts.OnEvent then ev = f; break end
|
||||||
|
end
|
||||||
|
ev.scripts.OnEvent(ev, "ADDON_LOADED", "Halbklick")
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_LOGIN")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function unitFrame(unit, name)
|
||||||
|
local f = CreateFrame("Button", name, UIParent, "SecureUnitButtonTemplate")
|
||||||
|
f.attrs["*type1"] = "target"
|
||||||
|
f.attrs["*type2"] = "menu"
|
||||||
|
f.attrs.unit = unit
|
||||||
|
return f
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Grid2-Rahmen wie aus Blizzards SecureGroupHeader, mit Grid2s Attributen.
|
||||||
|
-- register = false: Grid2 hat ihn angelegt, aber (noch) nicht gemeldet.
|
||||||
|
local function gridFrame(unit, register)
|
||||||
|
local hdr = _G.Grid2LayoutHeader1 or CreateFrame("Frame", "Grid2LayoutHeader1", UIParent, "SecureGroupHeaderTemplate")
|
||||||
|
hdr.attrs.toggleForVehicle = true
|
||||||
|
nGrid = nGrid + 1
|
||||||
|
local f = CreateFrame("Button", "Grid2LayoutHeader1UnitButton" .. nGrid, hdr, "SecureUnitButtonTemplate")
|
||||||
|
f.attrs["*type1"] = "target"
|
||||||
|
f.attrs["*type2"] = "togglemenu"
|
||||||
|
f.attrs["useparent-toggleForVehicle"] = true
|
||||||
|
f.attrs["useparent-unitsuffix"] = true
|
||||||
|
f.attrs.unit = unit
|
||||||
|
if register ~= false then Grid2Frame:RegisterFrame(f) end
|
||||||
|
return f
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Klick simulieren: Maustaste, Modifikatoren, Position (0..1 oder nil = Maus ausserhalb)
|
||||||
|
local function click(f, button, m, x)
|
||||||
|
mods, mouseX, log = m or "", x, {}
|
||||||
|
f:Click(button, false)
|
||||||
|
mods = ""
|
||||||
|
return log[1] or { kind = "kein Klick" }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function bind(button, m, area, react, action, value)
|
||||||
|
return { button = button, mods = m or "", area = area or "A", reaction = react or "any", action = action, value = value }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function isCast(r, spell, unit)
|
||||||
|
return r.kind == "proxy" and r.type == "spell" and r.spell == spell and r.unit == unit
|
||||||
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------------------- Tests
|
||||||
|
out("A: Shift-Linksklick nur auf der linken Haelfte")
|
||||||
|
loadAddon({ bindings = { bind("LeftButton", "shift-", "L", "any", "spell", "Blitzheilung") } })
|
||||||
|
local p1 = gridFrame("party1")
|
||||||
|
check("Rahmen hat Weiterleitung auf den Proxy", p1.attrs["*type31"] == "click"
|
||||||
|
and p1.attrs["*clickbutton31"] == HalbklickProxy)
|
||||||
|
check("Proxy reagiert auf Click() ohne down (useOnKeyDown = false)", HalbklickProxy.attrs.useOnKeyDown == false)
|
||||||
|
check("links + Shift: Blitzheilung auf party1", isCast(click(p1, "LeftButton", "shift-", 0.2), "Blitzheilung", "party1"))
|
||||||
|
local r = click(p1, "LeftButton", "shift-", 0.8)
|
||||||
|
check("rechts + Shift: normaler Klick (Ziel)", r.kind == "standard" and r.type == "target")
|
||||||
|
r = click(p1, "LeftButton", "", 0.2)
|
||||||
|
check("links ohne Shift: normaler Klick (Ziel)", r.kind == "standard" and r.type == "target")
|
||||||
|
r = click(p1, "RightButton", "", 0.3)
|
||||||
|
check("Rechtsklick links: Menue wie bisher", r.kind == "standard" and r.type == "togglemenu")
|
||||||
|
check("genau an der Grenze (0,5) zaehlt rechts", click(p1, "LeftButton", "shift-", 0.5).kind == "standard")
|
||||||
|
check("Hinweis: Clique laeuft auch", printed[1] and printed[1]:find("Clique") ~= nil)
|
||||||
|
r = click(p1, "Button31", "shift-", 0.2)
|
||||||
|
check("echter, unbelegter Button31-Klick wird verworfen", r.kind == "kein Klick")
|
||||||
|
|
||||||
|
out("B: Ganzer Rahmen plus eine Haelfte auf derselben Taste")
|
||||||
|
loadAddon({ bindings = {
|
||||||
|
bind("LeftButton", "", "A", "any", "spell", "Erneuerung"),
|
||||||
|
bind("LeftButton", "", "R", "any", "spell", "Gebet der Heilung"),
|
||||||
|
} })
|
||||||
|
p1 = gridFrame("party1")
|
||||||
|
check("links: ganzer Rahmen greift (Erneuerung)", isCast(click(p1, "LeftButton", "", 0.1), "Erneuerung", "party1"))
|
||||||
|
check("rechts: Haelfte gewinnt (Gebet der Heilung)", isCast(click(p1, "LeftButton", "", 0.9), "Gebet der Heilung", "party1"))
|
||||||
|
check("Maus ausserhalb (z. B. /click): ganzer Rahmen", isCast(click(p1, "LeftButton", "", nil), "Erneuerung", "party1"))
|
||||||
|
|
||||||
|
out("C: Freundlich / feindlich")
|
||||||
|
loadAddon({ bindings = {
|
||||||
|
bind("RightButton", "", "A", "help", "spell", "Heilung"),
|
||||||
|
bind("RightButton", "", "A", "harm", "spell", "Blitzschlag"),
|
||||||
|
bind("MiddleButton", "alt-ctrl-shift-", "L", "harm", "focus"),
|
||||||
|
} })
|
||||||
|
p1 = gridFrame("party1")
|
||||||
|
local tf = gridFrame("target")
|
||||||
|
local npc = gridFrame("party4") -- weder Freund noch Feind
|
||||||
|
check("Freund: Heilung", isCast(click(p1, "RightButton", "", 0.5), "Heilung", "party1"))
|
||||||
|
check("Feind: Blitzschlag", isCast(click(tf, "RightButton", "", 0.5), "Blitzschlag", "target"))
|
||||||
|
r = click(npc, "RightButton", "", 0.5)
|
||||||
|
check("neutral: normales Menue", r.kind == "standard" and r.type == "togglemenu")
|
||||||
|
r = click(tf, "MiddleButton", "alt-ctrl-shift-", 0.1)
|
||||||
|
check("Alt+Strg+Shift-Mittelklick links auf Feind: Fokus", r.kind == "proxy" and r.type == "focus" and r.unit == "target")
|
||||||
|
check("... rechts nicht", click(tf, "MiddleButton", "alt-ctrl-shift-", 0.9).kind == "standard")
|
||||||
|
check("... auf Freund nicht", click(p1, "MiddleButton", "alt-ctrl-shift-", 0.1).kind == "standard")
|
||||||
|
|
||||||
|
out("D: Vorrang: Haelfte vor freundlich/feindlich")
|
||||||
|
loadAddon({ bindings = {
|
||||||
|
bind("LeftButton", "", "L", "any", "spell", "Haelfte"),
|
||||||
|
bind("LeftButton", "", "A", "help", "spell", "Freund"),
|
||||||
|
bind("LeftButton", "", "R", "harm", "spell", "Feind rechts"),
|
||||||
|
} })
|
||||||
|
p1 = gridFrame("party1")
|
||||||
|
tf = gridFrame("target")
|
||||||
|
check("Freund links: Haelfte", isCast(click(p1, "LeftButton", "", 0.2), "Haelfte", "party1"))
|
||||||
|
check("Freund rechts: Freund", isCast(click(p1, "LeftButton", "", 0.7), "Freund", "party1"))
|
||||||
|
check("Feind rechts: Feind rechts", isCast(click(tf, "LeftButton", "", 0.7), "Feind rechts", "target"))
|
||||||
|
check("Feind links: Haelfte", isCast(click(tf, "LeftButton", "", 0.2), "Haelfte", "target"))
|
||||||
|
|
||||||
|
out("E: Ziel, Menue, Makro mit Sonderzeichen")
|
||||||
|
local tricky = '/say "{rt1} function" \\ end\n/cast [@mouseover] Erneuerung'
|
||||||
|
loadAddon({ bindings = {
|
||||||
|
bind("LeftButton", "ctrl-", "L", "any", "target"),
|
||||||
|
bind("LeftButton", "ctrl-", "R", "any", "menu"),
|
||||||
|
bind("Button4", "", "A", "any", "macro", tricky),
|
||||||
|
} })
|
||||||
|
p1 = gridFrame("party2")
|
||||||
|
r = click(p1, "LeftButton", "ctrl-", 0.1)
|
||||||
|
check("Strg-Linksklick links: Ziel ueber den Proxy", r.kind == "proxy" and r.type == "target" and r.unit == "party2")
|
||||||
|
r = click(p1, "LeftButton", "ctrl-", 0.9)
|
||||||
|
check("Strg-Linksklick rechts: Menue (togglemenu)", r.kind == "proxy" and r.type == "togglemenu")
|
||||||
|
check("... und kein alter Zaubername am Proxy", r.spell == nil and r.macrotext == nil)
|
||||||
|
r = click(p1, "Button4", "", 0.5)
|
||||||
|
check("Makrotext kommt unveraendert an", r.kind == "proxy" and r.type == "macro" and r.macrotext == tricky)
|
||||||
|
|
||||||
|
out("F: Im Kampf")
|
||||||
|
loadAddon({ bindings = {} })
|
||||||
|
combat = true
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_REGEN_DISABLED")
|
||||||
|
p1 = gridFrame("party1") -- Grid2 legt im Kampf einen Rahmen an (selten)
|
||||||
|
check("im Kampf noch nicht angemeldet", p1.attrs["*type31"] == nil)
|
||||||
|
SlashCmdList.HALBKLICK("")
|
||||||
|
mods = "shift-"
|
||||||
|
HalbklickKlickfeld:Click("RightButton")
|
||||||
|
mods = ""
|
||||||
|
HalbklickWert:SetText("Blitzheilung")
|
||||||
|
local saveBtn
|
||||||
|
for _, f in ipairs(frames) do if f.kind == "Button" and f.textValue == "Hinzufügen" then saveBtn = f end end
|
||||||
|
saveBtn:Click()
|
||||||
|
check("Speichern im Kampf landet in der Datenbank", #HalbklickDB.bindings == 1)
|
||||||
|
local statusText
|
||||||
|
for _, f in ipairs(frames) do if f.textValue == "Gespeichert. Wirkt nach dem Kampf." then statusText = f end end
|
||||||
|
check("... und meldet: wirkt nach dem Kampf", statusText ~= nil)
|
||||||
|
combat = false
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_REGEN_ENABLED")
|
||||||
|
check("nach dem Kampf angemeldet", p1.attrs["*type31"] == "click")
|
||||||
|
check("nach dem Kampf wirkt die Belegung", isCast(click(p1, "RightButton", "shift-", 0.5), "Blitzheilung", "party1"))
|
||||||
|
combat = true
|
||||||
|
check("im Kampf funktioniert der Klick", isCast(click(p1, "RightButton", "shift-", 0.5), "Blitzheilung", "party1"))
|
||||||
|
combat = false
|
||||||
|
|
||||||
|
out("G: /reload mitten im Kampf")
|
||||||
|
loadAddon({ bindings = { bind("LeftButton", "", "L", "any", "spell", "Erneuerung") } }, function() combat = true end)
|
||||||
|
p1 = gridFrame("party1")
|
||||||
|
check("im Kampf geladen: nichts angefasst", HalbklickProxy.attrs.useOnKeyDown == nil and p1.attrs["*type31"] == nil)
|
||||||
|
combat = false
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_REGEN_ENABLED")
|
||||||
|
check("nach dem Kampf alles eingerichtet", isCast(click(p1, "LeftButton", "", 0.1), "Erneuerung", "party1"))
|
||||||
|
|
||||||
|
out("H: Nur Grid2-Rahmen")
|
||||||
|
local early
|
||||||
|
loadAddon({ bindings = { bind("LeftButton", "", "L", "any", "spell", "Erneuerung") } }, function()
|
||||||
|
early = gridFrame("party3") -- Grid2 war schneller als Halbklick
|
||||||
|
end)
|
||||||
|
check("vorher angelegter Grid2-Rahmen uebernommen", isCast(click(early, "LeftButton", "", 0.1), "Erneuerung", "party3"))
|
||||||
|
local g = gridFrame("raid3")
|
||||||
|
check("neuer Grid2-Rahmen ueber RegisterFrame", isCast(click(g, "LeftButton", "", 0.1), "Erneuerung", "raid3"))
|
||||||
|
check("toggleForVehicle vom Grid2-Header geerbt", HalbklickProxy.attrs.toggleForVehicle == true)
|
||||||
|
Grid2LayoutHeader1.attrs.unitsuffix = "pet"
|
||||||
|
check("unitsuffix vom Grid2-Header geerbt", isCast(click(g, "LeftButton", "", 0.1), "Erneuerung", "raid3pet"))
|
||||||
|
Grid2LayoutHeader1.attrs.unitsuffix = nil
|
||||||
|
local pf = unitFrame("player", "PlayerFrame")
|
||||||
|
local crf = unitFrame(nil, "CompactRaidFrame1")
|
||||||
|
CompactUnitFrame_SetUnit(crf, "raid3")
|
||||||
|
ClickCastFrames = ClickCastFrames or {} -- ein anderes Rahmen-Addon meldet sich wie bei Clique an
|
||||||
|
local other = unitFrame("party2", "ElvUF_PartyGroup1UnitButton1")
|
||||||
|
ClickCastFrames[other] = true
|
||||||
|
ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD")
|
||||||
|
ev.scripts.OnEvent(ev, "GROUP_ROSTER_UPDATE")
|
||||||
|
check("Blizzards Spielerrahmen bleibt unberuehrt", pf.attrs["*type31"] == nil
|
||||||
|
and click(pf, "LeftButton", "", 0.1).kind == "standard")
|
||||||
|
check("Blizzards Schlachtzugsrahmen bleibt unberuehrt", crf.attrs["*type31"] == nil)
|
||||||
|
check("Rahmen anderer Addons bleiben unberuehrt", other.attrs["*type31"] == nil
|
||||||
|
and click(other, "LeftButton", "", 0.1).kind == "standard")
|
||||||
|
check("erneutes Suchen wickelt nicht doppelt ein", #g.unwrapped == 1 and #early.unwrapped == 1)
|
||||||
|
local plain = CreateFrame("Button", "Grid2LayoutHeader1UnitButton99", Grid2LayoutHeader1) -- nicht geschuetzt
|
||||||
|
Grid2Frame:RegisterFrame(plain)
|
||||||
|
check("ungeschuetzter Rahmen wird nicht angemeldet", plain.attrs["*type31"] == nil)
|
||||||
|
|
||||||
|
out("H2: Grid2 ohne Rahmenliste, und ganz ohne Grid2")
|
||||||
|
loadAddon({ bindings = { bind("LeftButton", "", "R", "any", "spell", "Erneuerung") } }, function()
|
||||||
|
Grid2Frame.registeredFrames = nil
|
||||||
|
end)
|
||||||
|
g = gridFrame("party1", false)
|
||||||
|
ev.scripts.OnEvent(ev, "GROUP_ROSTER_UPDATE")
|
||||||
|
check("Grid2-Rahmen ueber den Namen gefunden", isCast(click(g, "LeftButton", "", 0.9), "Erneuerung", "party1"))
|
||||||
|
loadAddon({ bindings = {} }, function() Grid2Frame = nil end)
|
||||||
|
local warned = false
|
||||||
|
for _, s in ipairs(printed) do if s:find("Grid2 ist nicht aktiv", 1, true) then warned = true end end
|
||||||
|
check("ohne Grid2 erscheint ein Hinweis", warned)
|
||||||
|
|
||||||
|
out("I: Fenster")
|
||||||
|
loadAddon({ bindings = {
|
||||||
|
bind("LeftButton", "", "A", "any", "spell", "Erneuerung"),
|
||||||
|
{ button = "LeftButton", mods = "", area = "X", reaction = "any", action = "spell", value = "kaputt" },
|
||||||
|
bind("RightButton", "", "A", "any", "spell", ""),
|
||||||
|
"Unsinn",
|
||||||
|
} })
|
||||||
|
check("kaputte Eintraege beim Laden verworfen", #HalbklickDB.bindings == 1)
|
||||||
|
p1 = gridFrame("party1")
|
||||||
|
SlashCmdList.HALBKLICK("")
|
||||||
|
check("/hk oeffnet das Fenster", HalbklickFrame:IsShown())
|
||||||
|
local function findRadio(text)
|
||||||
|
for _, f in ipairs(frames) do
|
||||||
|
if f.kind == "CheckButton" and f.text:GetText() == text then return f end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function findButton(text)
|
||||||
|
for _, f in ipairs(frames) do
|
||||||
|
if f.kind == "Button" and f.textValue == text then return f end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function rowsShown()
|
||||||
|
local list = {}
|
||||||
|
for _, f in ipairs(frames) do
|
||||||
|
if f.index and f.del and f.shown then list[f.index] = f end
|
||||||
|
end
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
mods = "alt-"
|
||||||
|
HalbklickKlickfeld:Click("Button5")
|
||||||
|
mods = ""
|
||||||
|
check("Klickfeld merkt sich Alt + Maustaste 5", HalbklickKlickfeld.textValue == "Alt + Maustaste 5")
|
||||||
|
findRadio("rechte Hälfte"):Click()
|
||||||
|
findRadio("feindlich"):Click()
|
||||||
|
check("Auswahl rechts/feindlich angehakt", findRadio("rechte Hälfte").checked and findRadio("feindlich").checked
|
||||||
|
and not findRadio("ganzer Rahmen").checked)
|
||||||
|
cursor = { "spell", 12, "spell", 2061 }
|
||||||
|
HalbklickWert.scripts.OnReceiveDrag()
|
||||||
|
check("Zauber aus dem Zauberbuch gezogen", HalbklickWert.textValue == "Blitzheilung" and cursor == nil)
|
||||||
|
findButton("Hinzufügen"):Click()
|
||||||
|
local b2 = HalbklickDB.bindings[2]
|
||||||
|
check("Belegung gespeichert", b2 and b2.button == "Button5" and b2.mods == "alt-" and b2.area == "R"
|
||||||
|
and b2.reaction == "harm" and b2.action == "spell" and b2.value == "Blitzheilung")
|
||||||
|
check("Editor danach leer", HalbklickKlickfeld.textValue:find("^Hier") ~= nil and HalbklickWert.textValue == "")
|
||||||
|
local rws = rowsShown()
|
||||||
|
check("Liste zeigt beide Belegungen", rws[1] and rws[2] and rws[2].text:GetText():find("Alt %+ Maustaste 5") ~= nil
|
||||||
|
and rws[2].text:GetText():find("rechte Hälfte, feindlich") ~= nil)
|
||||||
|
tf = gridFrame("target")
|
||||||
|
check("neue Belegung wirkt sofort", isCast(click(tf, "Button5", "alt-", 0.9), "Blitzheilung", "target"))
|
||||||
|
|
||||||
|
-- Makro aus der Makroliste ziehen, Ziel-Aktion ohne Wert
|
||||||
|
findRadio("Makro"):Click()
|
||||||
|
cursor = { "macro", 7 }
|
||||||
|
HalbklickWert.scripts.OnReceiveDrag()
|
||||||
|
check("Makro gezogen", HalbklickWert.textValue == "/cast [@mouseover] Erneuerung")
|
||||||
|
mods = "ctrl-"; HalbklickKlickfeld:Click("LeftButton"); mods = ""
|
||||||
|
findButton("Hinzufügen"):Click()
|
||||||
|
check("Makro gespeichert", #HalbklickDB.bindings == 3)
|
||||||
|
|
||||||
|
-- Bearbeiten: erste Zeile laden, auf linke Haelfte aendern
|
||||||
|
rws = rowsShown()
|
||||||
|
rws[1]:Click()
|
||||||
|
check("Zeile laedt in den Editor", HalbklickKlickfeld.textValue == "Linksklick" and HalbklickWert.textValue == "Erneuerung"
|
||||||
|
and findButton("Ändern") ~= nil and rws[1].locked)
|
||||||
|
findRadio("linke Hälfte"):Click()
|
||||||
|
findButton("Ändern"):Click()
|
||||||
|
check("geaendert statt neu", #HalbklickDB.bindings == 3 and HalbklickDB.bindings[1].area == "L")
|
||||||
|
check("rechts jetzt normaler Klick", click(p1, "LeftButton", "", 0.9).kind == "standard")
|
||||||
|
check("links weiter Erneuerung", isCast(click(p1, "LeftButton", "", 0.1), "Erneuerung", "party1"))
|
||||||
|
|
||||||
|
-- Gleiche Kombination noch einmal: ersetzt die alte
|
||||||
|
HalbklickKlickfeld:Click("LeftButton")
|
||||||
|
findRadio("linke Hälfte"):Click()
|
||||||
|
findRadio("Zauber"):Click()
|
||||||
|
HalbklickWert:SetText(" Gebet\nder Heilung ")
|
||||||
|
findButton("Hinzufügen"):Click()
|
||||||
|
check("gleiche Kombination ersetzt", #HalbklickDB.bindings == 3)
|
||||||
|
check("Zeilenumbruch im Zaubernamen entfernt", isCast(click(p1, "LeftButton", "", 0.1), "Gebet der Heilung", "party1"))
|
||||||
|
|
||||||
|
-- Fehler: kein Klick festgelegt, kein Zauber
|
||||||
|
findButton("Neu"):Click()
|
||||||
|
findButton("Hinzufügen"):Click()
|
||||||
|
check("ohne Klick nichts gespeichert", #HalbklickDB.bindings == 3)
|
||||||
|
HalbklickKlickfeld:Click("RightButton")
|
||||||
|
findButton("Hinzufügen"):Click()
|
||||||
|
check("ohne Zauber nichts gespeichert", #HalbklickDB.bindings == 3)
|
||||||
|
findRadio("Ziel auswählen"):Click()
|
||||||
|
check("Ziel braucht kein Wertefeld", HalbklickWert.parent.shown == false)
|
||||||
|
findButton("Hinzufügen"):Click()
|
||||||
|
check("Rechtsklick -> Ziel gespeichert", #HalbklickDB.bindings == 4)
|
||||||
|
|
||||||
|
-- Loeschen
|
||||||
|
local before = #HalbklickDB.bindings
|
||||||
|
for _, row in pairs(rowsShown()) do
|
||||||
|
if row.text:GetText():find("Gebet der Heilung") then row.del:Click() end
|
||||||
|
end
|
||||||
|
check("Zeile geloescht", #HalbklickDB.bindings == before - 1)
|
||||||
|
r = click(p1, "LeftButton", "", 0.1)
|
||||||
|
check("geloeschte Belegung wirkt nicht mehr", r.kind == "standard")
|
||||||
|
local stale = 0
|
||||||
|
for k in pairs(HalbklickHeader.attrs) do if k:find("Gebet", 1, true) or k:find("^hkt:LeftButton:L") then stale = stale + 1 end end
|
||||||
|
check("keine alten Attribute am Kopf-Frame", stale == 0)
|
||||||
|
|
||||||
|
out("J: Befehle")
|
||||||
|
printed = {}
|
||||||
|
SlashCmdList.HALBKLICK("liste")
|
||||||
|
check("/hk liste zeigt alle Belegungen", #printed == #HalbklickDB.bindings)
|
||||||
|
printed = {}
|
||||||
|
SlashCmdList.HALBKLICK("status")
|
||||||
|
check("/hk status", printed[1] and printed[1]:find("Rahmen angemeldet") ~= nil)
|
||||||
|
printed = {}
|
||||||
|
SlashCmdList.HALBKLICK("quatsch")
|
||||||
|
check("unbekannter Befehl zeigt Hilfe", printed[1] and printed[1]:find("/hk liste") ~= nil)
|
||||||
|
check("Snippets wurden wirklich uebersetzt", snippetsCompiled > 0)
|
||||||
|
|
||||||
|
out(fails == 0 and "\nAlle Tests bestanden." or ("\n" .. fails .. " Test(s) fehlgeschlagen."))
|
||||||
|
os.exit(fails == 0 and 0 or 1)
|
||||||
Reference in new issue
Block a user