Blizzard-Rahmen und die ClickCastFrames-Schnittstelle fallen weg. Halbklick hängt sich an Grid2Frame:RegisterFrame, liest Grid2Frame.registeredFrames und sucht ersatzweise über die Rahmennamen. Grid2 meldet Rahmen aus Blizzards SecureGroupHeader nur bei Clique an, nicht über ClickCastFrames. Einheit, unitsuffix und toggleForVehicle kommen jetzt über GetEffectiveAttribute, weil Grid2-Rahmen sie per useparent vom Header erben. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
591 lines
27 KiB
Lua
591 lines
27 KiB
Lua
-- 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)
|