Compare commits
6
Commits
3b4f25d87c
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60e6b9fa1a | ||
|
|
d4b1e270b7 | ||
|
|
ef00f123ec | ||
|
|
b1598a7701 | ||
|
|
759617543b | ||
|
|
014db940dd |
No files matched your search
+149
-28
@@ -1,8 +1,8 @@
|
|||||||
-- Goldbeutel: zeigt Gold, freie Taschenplaetze, Ruestungszustand und
|
-- Goldbeutel: zeigt Gold, freie Taschenplaetze, Ruestungszustand und
|
||||||
-- Gegenstandsstufe in einem kleinen, verschiebbaren Rahmen.
|
-- GearScore in einem kleinen, verschiebbaren Rahmen.
|
||||||
-- Linksziehen verschieben
|
-- Linksziehen verschieben
|
||||||
-- Rechtsklick sperren / entsperren
|
-- Rechtsklick sperren / entsperren
|
||||||
-- Mauszeiger drauf Details zu Taschen, Ruestung und Gegenstandsstufe,
|
-- Mauszeiger drauf Details zu Taschen, Ruestung, GearScore und Gegenstandsstufe,
|
||||||
-- Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
|
-- Gewinn/Verlust dieser Sitzung + alle Charaktere des Realms
|
||||||
-- /gold ein-/ausblenden
|
-- /gold ein-/ausblenden
|
||||||
-- /gold lock sperren / entsperren
|
-- /gold lock sperren / entsperren
|
||||||
@@ -15,7 +15,7 @@ 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 " -- "||" ist ein woertliches |
|
local SEP = " |cff666666|||r " -- grauer Strich: "||" ist ein woertliches |, dann "|r"
|
||||||
local LABEL = "|cffaaaaaa" -- Beschriftungen im Rahmen
|
local LABEL = "|cffaaaaaa" -- Beschriftungen im Rahmen
|
||||||
local YELLOW = "|cffffd100"
|
local YELLOW = "|cffffd100"
|
||||||
local RED = "|cffff3333"
|
local RED = "|cffff3333"
|
||||||
@@ -56,11 +56,6 @@ local function formatMoney(c)
|
|||||||
return string.format("%d%s", k, COPPER)
|
return string.format("%d%s", k, COPPER)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 245.34 -> "245,3"
|
|
||||||
local function decimal(x)
|
|
||||||
return (string.format("%.1f", x):gsub("%.", ","))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function paint(s, color)
|
local function paint(s, color)
|
||||||
if color then return color .. s .. "|r" end
|
if color then return color .. s .. "|r" end
|
||||||
return s
|
return s
|
||||||
@@ -125,26 +120,150 @@ local function durability()
|
|||||||
if low then return low, lowSlot, cur / max * 100 end
|
if low then return low, lowSlot, cur / max * 100 end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Durchschnittliche Gegenstandsstufe wie im Charakterfenster: angelegt und mit
|
-- GearScore genau wie im Addon "GearScore Forever" (Daeler), das die Formel von
|
||||||
-- der besten Ausruestung aus den Taschen. nil, solange der Client sie nicht kennt.
|
-- GearScoreLite uebernimmt. Das Addon bietet keine Schnittstelle nach aussen,
|
||||||
local function itemLevel()
|
-- deshalb ist die Rechnung hier nachgebaut. So stimmt der Wert mit der
|
||||||
if not GetAverageItemLevel then return end
|
-- Charakteransicht ueberein, und Goldbeutel braucht das Addon nicht.
|
||||||
local best, equipped = GetAverageItemLevel()
|
-- Die Punkte eines Gegenstands haengen nur von Stufe, Qualitaet und Platz ab.
|
||||||
if equipped and equipped > 0 then return equipped, best end
|
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
|
end
|
||||||
|
|
||||||
-- Eine Zeile: Gold | Taschen 23 | 87% | iLvl 245
|
-- 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 function frameText()
|
||||||
local parts = { formatMoney(GetMoney()) }
|
local parts = { formatMoney(GetMoney()) }
|
||||||
local free = bagSpace()
|
local free = bagSpace()
|
||||||
parts[#parts + 1] = LABEL .. "Taschen|r " .. paint(free, freeColor(free))
|
parts[#parts + 1] = paint(free, freeColor(free))
|
||||||
local low = durability()
|
local low = durability()
|
||||||
if low then
|
if low then
|
||||||
parts[#parts + 1] = paint(math.floor(low) .. "%", pctColor(low))
|
parts[#parts + 1] = paint(math.floor(low) .. "%", pctColor(low))
|
||||||
end
|
end
|
||||||
local ilvl = itemLevel()
|
local gs = gearScore()
|
||||||
if ilvl then
|
if gs > 0 then
|
||||||
parts[#parts + 1] = LABEL .. "iLvl|r " .. math.floor(ilvl)
|
parts[#parts + 1] = LABEL .. "GS|r " .. paint(gs, gsColor(gs))
|
||||||
end
|
end
|
||||||
return table.concat(parts, SEP)
|
return table.concat(parts, SEP)
|
||||||
end
|
end
|
||||||
@@ -178,12 +297,10 @@ local function addStatusLines()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ilvl, best = itemLevel()
|
local gs, ilvl = gearScore()
|
||||||
if ilvl then
|
if gs > 0 then
|
||||||
GameTooltip:AddDoubleLine("Gegenstandsstufe:", decimal(ilvl), 1, 0.82, 0, 1, 1, 1)
|
GameTooltip:AddDoubleLine("GearScore:", paint(gs, gsColor(gs)), 1, 0.82, 0, 1, 1, 1)
|
||||||
if best and best - ilvl >= 0.05 then
|
GameTooltip:AddDoubleLine("Gegenstandsstufe:", ilvl, 1, 0.82, 0, 1, 1, 1)
|
||||||
GameTooltip:AddDoubleLine("Beste Ausrüstung:", decimal(best), 1, 0.82, 0, 0.6, 0.6, 0.6)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -321,9 +438,9 @@ 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, Gegenstandsstufe. pcall, falls ein Client eines davon nicht kennt.
|
-- Taschen, Ruestung, GearScore. pcall, falls ein Client eines davon nicht kennt.
|
||||||
for _, e in ipairs({ "BAG_UPDATE_DELAYED", "UPDATE_INVENTORY_DURABILITY",
|
for _, e in ipairs({ "BAG_UPDATE_DELAYED", "UPDATE_INVENTORY_DURABILITY",
|
||||||
"PLAYER_EQUIPMENT_CHANGED", "PLAYER_AVG_ITEM_LEVEL_UPDATE" }) do
|
"PLAYER_EQUIPMENT_CHANGED", "GET_ITEM_INFO_RECEIVED" }) do
|
||||||
pcall(ev.RegisterEvent, ev, e)
|
pcall(ev.RegisterEvent, ev, e)
|
||||||
end
|
end
|
||||||
ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
||||||
@@ -353,8 +470,12 @@ ev:SetScript("OnEvent", function(self, event, arg1, arg2)
|
|||||||
queueUpdate()
|
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
|
else
|
||||||
-- PLAYER_MONEY und die Ereignisse fuer Taschen, Ruestung und Gegenstandsstufe
|
-- PLAYER_MONEY und die Ereignisse fuer Taschen, Ruestung und Ausruestung
|
||||||
queueUpdate()
|
queueUpdate()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
## Interface: 16001
|
## Interface: 16001
|
||||||
## Title: Goldbeutel
|
## Title: Goldbeutel
|
||||||
## Notes: Zeigt Gold, freie Taschenplätze, Rüstungszustand und Gegenstandsstufe 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,11 +1,12 @@
|
|||||||
# WoW Forever Addons
|
# WoW Forever Addons
|
||||||
|
|
||||||
Drei kleine, voneinander unabhängige Addons für **World of Warcraft: Forever**. Jedes Addon besteht aus einer einzigen Lua-Datei und braucht keine weiteren Bibliotheken.
|
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.
|
||||||
|
|
||||||
| Addon | Wozu | Befehl |
|
| Addon | Wozu | Befehl |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| [**ForeverScale**](#foreverscale) | UI-Skalierung auch unter Blizzards Minimum von 0,64, dauerhaft gespeichert | `/fscale` |
|
| [**ForeverScale**](#foreverscale) | UI-Skalierung auch unter Blizzards Minimum von 0,64, dauerhaft gespeichert | `/fscale` |
|
||||||
| [**Goldbeutel**](#goldbeutel) | Gold, freie Taschenplätze, Rüstungszustand und Gegenstandsstufe in einem kleinen Rahmen | `/gold` |
|
| [**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` |
|
| [**Leistenabstand**](#leistenabstand) | Symbolabstand der Aktionsleisten unter 2, auch 0 oder negativ | `/abstand` |
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -15,7 +16,7 @@ Drei kleine, voneinander unabhängige Addons für **World of Warcraft: Forever**
|
|||||||
- Windows: `C:\Program Files (x86)\World of Warcraft\_forever_\Interface\AddOns\`
|
- Windows: `C:\Program Files (x86)\World of Warcraft\_forever_\Interface\AddOns\`
|
||||||
- macOS: `/Applications/World of Warcraft/_forever_/Interface/AddOns/`
|
- macOS: `/Applications/World of Warcraft/_forever_/Interface/AddOns/`
|
||||||
|
|
||||||
Danach liegen dort die Ordner `ForeverScale`, `Goldbeutel` und `Leistenabstand`. Wer nur einzelne Addons möchte, lässt die anderen Ordner einfach weg.
|
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`.
|
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.
|
> **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.
|
||||||
@@ -56,26 +57,24 @@ ForeverScale speichert deinen Wert für den ganzen Account und setzt ihn nach je
|
|||||||
|
|
||||||
Ein kleiner, verschiebbarer Rahmen mit allem, was man unterwegs im Blick haben will:
|
Ein kleiner, verschiebbarer Rahmen mit allem, was man unterwegs im Blick haben will:
|
||||||
|
|
||||||
```
|
<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">
|
||||||
┌─────────────────────────────────────────────────────┐
|
|
||||||
│ 12.345g 67s 89c | Taschen 23 | 87% | iLvl 245 │
|
|
||||||
└─────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
| Anzeige | Bedeutung | Warnfarbe |
|
| Anzeige | Bedeutung | Farbe |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Gold | dein Gold mit Gold-, Silber- und Kupfermünzen | – |
|
| 2 36 13 | dein Gold mit Gold-, Silber- und Kupfermünzen | – |
|
||||||
| Taschen | freie Plätze im Rucksack und in den vier normalen Taschen | gelb bei 5 oder weniger, rot bei 0 |
|
| 42 | freie Plätze im Rucksack und in den vier normalen Taschen | gelb bei 5 oder weniger, rot bei 0 |
|
||||||
| 87% | Zustand des am stärksten beschädigten Ausrüstungsteils | gelb unter 50 %, rot unter 20 % |
|
| 100% | Zustand des am stärksten beschädigten Ausrüstungsteils | gelb unter 50 %, rot unter 20 % |
|
||||||
| iLvl | durchschnittliche Gegenstandsstufe der angelegten Ausrüstung, wie im Charakterfenster | – |
|
| 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.
|
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):
|
**Tooltip** (Maus über den Rahmen):
|
||||||
|
|
||||||
- freie und gesamte Taschenplätze, Spezialtaschen extra
|
- freie und gesamte Taschenplätze, Spezialtaschen extra
|
||||||
- Gesamtzustand der Rüstung und das am stärksten beschädigte Teil
|
- Gesamtzustand der Rüstung und das am stärksten beschädigte Teil
|
||||||
- Gegenstandsstufe mit Nachkommastelle und, falls höher, der Wert mit der besten Ausrüstung aus deinen Taschen
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
@@ -94,6 +93,66 @@ Spezialtaschen wie Köcher, Kräuter- oder Reagenzientaschen zählen nicht zu de
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Halbklick
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
| 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) |
|
||||||
|
|
||||||
|
**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:
|
||||||
|
|
||||||
|
<img src="docs/halbklick.png" width="520" alt="Halbklick-Fenster im Spiel: Linksklick links Geringes Heilen, rechts Heilen; Rechtsklick links Machtwort: Schild, rechts Erneuerung">
|
||||||
|
|
||||||
|
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**
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
**Welche Belegung gilt?** Bei jedem Klick sucht Halbklick in dieser Reihenfolge und nimmt den ersten Treffer:
|
||||||
|
|
||||||
|
1. die Hälfte, in die du geklickt hast, mit „nur freundlich“ oder „nur feindlich“
|
||||||
|
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
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
| Befehl | Wirkung |
|
||||||
|
|---|---|
|
||||||
|
| `/hk` | Fenster öffnen oder schließen |
|
||||||
|
| `/hk liste` | alle Belegungen im Chat |
|
||||||
|
| `/hk status` | wie viele Rahmen angemeldet sind und ob etwas auf das Kampfende wartet |
|
||||||
|
|
||||||
|
`/halbklick` funktioniert genauso wie `/hk`.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Leistenabstand
|
## Leistenabstand
|
||||||
|
|
||||||
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**.
|
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**.
|
||||||
@@ -128,8 +187,10 @@ Position, Reihen, Symbolgröße und Anzahl der Symbole stellst du weiter im Edit
|
|||||||
```
|
```
|
||||||
ForeverScale/ ForeverScale.toc, ForeverScale.lua
|
ForeverScale/ ForeverScale.toc, ForeverScale.lua
|
||||||
Goldbeutel/ Goldbeutel.toc, Goldbeutel.lua
|
Goldbeutel/ Goldbeutel.toc, Goldbeutel.lua
|
||||||
|
Halbklick/ Halbklick.toc, Halbklick.lua
|
||||||
Leistenabstand/ Leistenabstand.toc, Leistenabstand.lua
|
Leistenabstand/ Leistenabstand.toc, Leistenabstand.lua
|
||||||
tests/ Tests gegen eine nachgebaute WoW-Umgebung
|
tests/ Tests gegen eine nachgebaute WoW-Umgebung
|
||||||
|
docs/ Bilder für dieses README
|
||||||
make-zip.sh baut WoW-Forever-Addons.zip
|
make-zip.sh baut WoW-Forever-Addons.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -138,11 +199,14 @@ make-zip.sh baut WoW-Forever-Addons.zip
|
|||||||
```sh
|
```sh
|
||||||
luajit tests/test_leistenabstand.lua
|
luajit tests/test_leistenabstand.lua
|
||||||
luajit tests/test_goldbeutel_foreverscale.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.
|
**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 drei 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` am meisten.
|
**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
|
## Alternativen und Hintergrund
|
||||||
|
|
||||||
@@ -151,3 +215,5 @@ luajit tests/test_goldbeutel_foreverscale.lua
|
|||||||
- [UI scaling – Warcraft Wiki](https://warcraft.wiki.gg/wiki/UI_scaling): Hintergrund zur UI-Skalierung und zur 768-Formel.
|
- [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 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.
|
- [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.
|
||||||
|
- [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.
|
||||||
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
|
||||||
@@ -9,13 +9,22 @@ local function obj(t) return setmetatable(t or {}, {__index = function() return
|
|||||||
|
|
||||||
---------------------------------------------------------------- Goldbeutel
|
---------------------------------------------------------------- Goldbeutel
|
||||||
local money, ev, lines, shownText, gtimers
|
local money, ev, lines, shownText, gtimers
|
||||||
-- Ausgangszustand fuer Taschen, Ruestung und Gegenstandsstufe (in Tests veraenderbar)
|
-- Ausgangszustand fuer Taschen, Ruestung und Ausruestung (in Tests veraenderbar)
|
||||||
-- bags[i] = { Plaetze, frei, Taschentyp }; Index 0 = Rucksack, 5 = Reagenzientasche
|
-- bags[i] = { Plaetze, frei, Taschentyp }; Index 0 = Rucksack, 5 = Reagenzientasche
|
||||||
local bags, dura, ilvl
|
-- gear[Platz] = { Qualitaet, Gegenstandsstufe, Ausruestungsplatz }
|
||||||
|
local bags, dura, gear, gclass, uncached
|
||||||
local function defaultGear()
|
local function defaultGear()
|
||||||
bags = { [0] = {16, 5, 0}, {20, 10, 0}, {16, 16, 1}, {0, 0, 0}, {20, 8, 0}, {36, 30, 0} }
|
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
|
dura = { [1] = {45, 100}, [5] = {100, 100}, [7] = {80, 80} } -- Kopf, Brust, Beine
|
||||||
ilvl = {247.14, 245.34} -- beste, angelegt
|
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
|
end
|
||||||
defaultGear()
|
defaultGear()
|
||||||
local function startGold(name, db)
|
local function startGold(name, db)
|
||||||
@@ -25,7 +34,7 @@ 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
|
NUM_BAG_SLOTS, NUM_TOTAL_EQUIPPED_BAG_SLOTS, INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED = 4, 5, 1, 19
|
||||||
C_Container = {
|
C_Container = {
|
||||||
@@ -33,8 +42,13 @@ local function startGold(name, db)
|
|||||||
GetContainerNumFreeSlots = function(b) if bags[b] then return bags[b][2], bags[b][3] end return 0, 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
|
GetInventoryItemDurability = function(s) if dura[s] then return dura[s][1], dura[s][2] end end
|
||||||
GetInventoryItemLink = function(_, s) return "[Item" .. s .. "]" end
|
GetInventoryItemLink = function(_, s) if gear[s] then return "[Item" .. s .. "]" end end
|
||||||
GetAverageItemLevel = function() return ilvl[1], ilvl[2] 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 = {}
|
gtimers = {}
|
||||||
C_Timer = { After = function(_, fn) gtimers[#gtimers + 1] = fn end }
|
C_Timer = { After = function(_, fn) gtimers[#gtimers + 1] = fn end }
|
||||||
UIParent = obj{ GetHeight = function() return 800 end }
|
UIParent = obj{ GetHeight = function() return 800 end }
|
||||||
@@ -88,23 +102,44 @@ 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, Gegenstandsstufe")
|
out("Goldbeutel: Taschen, Ruestung, GearScore")
|
||||||
local function flush() while #gtimers > 0 do table.remove(gtimers, 1)() end end
|
local function flush() while #gtimers > 0 do table.remove(gtimers, 1)() end end
|
||||||
local function plain(s) return (s:gsub("|T.-|t", ""):gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):gsub("||", "|")) 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
|
defaultGear(); money = 1234567
|
||||||
fr = startGold("Testmagier", nil); ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", true, false); flush()
|
fr = startGold("Testmagier", nil); ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", true, false); flush()
|
||||||
check("Rahmen: eine Zeile mit allen vier Werten",
|
check("Rahmen: eine Zeile mit allen vier Werten",
|
||||||
plain(shownText) == "123 45 67 | Taschen 23 | 45% | iLvl 245")
|
plain(shownText) == "123 45 67 | 23 | 45% | GS 856")
|
||||||
check("Spezialtaschen (Koecher, Reagenzientasche) nicht im Rahmen mitgezaehlt", plain(shownText):find("Taschen 23", 1, true))
|
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("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("23 freie Plaetze ohne Warnfarbe", shownText:find("|||r 23 ", 1, true) ~= nil)
|
||||||
lines = {}; fr.scripts.OnEnter(fr)
|
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: Taschen frei 23 / 56", lines["Taschen frei:"] == "23 / 56")
|
||||||
check("Tooltip: Spezialtaschen frei 46 / 52", lines["Spezialtaschen frei:"] == "46 / 52")
|
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: 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: am staerksten beschaedigtes Teil (Kopf) mit 45%", plain(lines[" [Item1]"] or "") == "45%")
|
||||||
check("Tooltip: Gegenstandsstufe 245,3", lines["Gegenstandsstufe:"] == "245,3")
|
check("Tooltip: GearScore 856", plain(lines["GearScore:"] or "") == "856")
|
||||||
check("Tooltip: beste Ausruestung 247,1", lines["Beste Ausrüstung:"] == "247,1")
|
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
|
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
|
for _ = 1, 3 do ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED") end
|
||||||
@@ -116,14 +151,33 @@ check("10% rot", shownText:find("|cffff333310%|r", 1, true) ~= nil)
|
|||||||
bags[1][2] = 0; ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED"); flush()
|
bags[1][2] = 0; ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED"); flush()
|
||||||
check("0 freie Plaetze rot", shownText:find("|cffff33330|r", 1, true) ~= nil)
|
check("0 freie Plaetze rot", shownText:find("|cffff33330|r", 1, true) ~= nil)
|
||||||
|
|
||||||
dura = {}; ilvl = {0, 0}; ev.scripts.OnEvent(ev, "PLAYER_EQUIPMENT_CHANGED"); flush()
|
out("Goldbeutel: GearScore wie in GearScore Forever")
|
||||||
check("Ohne Haltbarkeit und ohne iLvl nur Gold und Taschen", plain(shownText) == "123 45 67 | Taschen 0")
|
ev.scripts.OnEvent(ev, "GET_ITEM_INFO_RECEIVED"); check("Alles geladen: GET_ITEM_INFO_RECEIVED loest nichts aus", #gtimers == 0)
|
||||||
lines = {}; fr.scripts.OnEnter(fr)
|
GearscoreForeverDB = { maxScoreSeen = 1800 }; ev.scripts.OnEvent(ev, "PLAYER_MONEY"); flush()
|
||||||
check("Tooltip ohne Ruestungs- und iLvl-Zeilen", lines["Rüstung gesamt:"] == nil and lines["Gegenstandsstufe:"] == nil)
|
check("Groessere Skala aus GearScore Forever (1800 gesehen): 856 gruen", shownText:find("|cff18e535856|r", 1, true) ~= nil)
|
||||||
dura = { [1] = {50, 50} }; ilvl = {245.34, 245.34}; ev.scripts.OnEvent(ev, "PLAYER_AVG_ITEM_LEVEL_UPDATE"); flush()
|
GearscoreForeverDB = nil
|
||||||
lines = {}; fr.scripts.OnEnter(fr)
|
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%")
|
check("Alles heil: keine Zeile fuer beschaedigtes Teil", lines[" [Item1]"] == nil and lines["Rüstung gesamt:"] == "100%")
|
||||||
check("Beste = angelegt: keine Zeile 'Beste Ausruestung'", lines["Beste Ausrüstung:"] == nil)
|
|
||||||
|
|
||||||
---------------------------------------------------------------- ForeverScale
|
---------------------------------------------------------------- ForeverScale
|
||||||
local scale, h, combat, timers, f
|
local scale, h, combat, timers, f
|
||||||
|
|||||||
@@ -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