Neues Addon: Belegungen gelten für den ganzen Einheitenrahmen oder nur für die linke oder rechte Hälfte, wahlweise nur für freundliche oder feindliche Einheiten. Ein geschützter OnClick-Vorab-Handler liest GetMousePosition() und leitet belegte Klicks über Button31 an einen eigenen Proxy-Button weiter. Fenster mit /hk, Tests gegen nachgebaute Secure-Umgebung, ZIP neu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
543 lines
25 KiB
Lua
543 lines
25 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
|
|
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 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(name, fn)
|
|
local orig = _G[name]
|
|
_G[name] = function(...) local r = orig(...); fn(...); return r end
|
|
end
|
|
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
|
|
|
|
-- 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 = unitFrame("party1")
|
|
ClickCastFrames[p1] = true
|
|
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 == "menu")
|
|
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 = unitFrame("party1"); ClickCastFrames[p1] = true
|
|
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 = unitFrame("party1"); ClickCastFrames[p1] = true
|
|
local tf = unitFrame("target", "TargetFrame"); ClickCastFrames[tf] = true
|
|
local npc = unitFrame("party4"); ClickCastFrames[npc] = true -- 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 == "menu")
|
|
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 = unitFrame("party1"); ClickCastFrames[p1] = true
|
|
tf = unitFrame("target"); ClickCastFrames[tf] = true
|
|
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 = unitFrame("party2"); ClickCastFrames[p1] = true
|
|
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 = {} })
|
|
p1 = unitFrame("party1")
|
|
combat = true
|
|
ev.scripts.OnEvent(ev, "PLAYER_REGEN_DISABLED")
|
|
ClickCastFrames[p1] = true
|
|
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"))
|
|
ClickCastFrames[p1] = nil
|
|
check("Abmelden im Kampf wartet", p1.attrs["*type31"] == "click")
|
|
combat = false
|
|
ev.scripts.OnEvent(ev, "PLAYER_REGEN_ENABLED")
|
|
check("nach dem Kampf abgemeldet", p1.attrs["*type31"] == nil and p1.scripts.OnClick == unitOnClick)
|
|
check("abgemeldet: normaler Klick", click(p1, "RightButton", "shift-", 0.5).kind == "standard")
|
|
|
|
out("G: /reload mitten im Kampf")
|
|
loadAddon({ bindings = { bind("LeftButton", "", "L", "any", "spell", "Erneuerung") } }, function() combat = true end)
|
|
p1 = unitFrame("party1"); ClickCastFrames[p1] = true
|
|
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: Blizzard-Rahmen und andere Addons")
|
|
loadAddon({ bindings = { bind("LeftButton", "", "L", "any", "spell", "Erneuerung") } }, function()
|
|
ClickCastFrames = {}
|
|
ClickCastFrames[unitFrame("party3", "FruehAngemeldet")] = true
|
|
end)
|
|
check("vor dem Laden angemeldeter Rahmen uebernommen", FruehAngemeldet.attrs["*type31"] == "click")
|
|
local pf = unitFrame("player", "PlayerFrame")
|
|
ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD")
|
|
check("PlayerFrame angemeldet", isCast(click(pf, "LeftButton", "", 0.1), "Erneuerung", "player"))
|
|
local crf = unitFrame(nil, "CompactRaidFrame1")
|
|
CompactUnitFrame_SetUnit(crf, "raid3")
|
|
check("Schlachtzugsrahmen nach SetUnit angemeldet", isCast(click(crf, "LeftButton", "", 0.1), "Erneuerung", "raid3"))
|
|
local plate = unitFrame(nil, "NamePlate1UnitFrame")
|
|
CompactUnitFrame_SetUnit(plate, "nameplate1")
|
|
check("Namensschild bleibt aussen vor", plate.attrs["*type31"] == nil)
|
|
local forb = unitFrame(nil, "CompactRaidFrame2"); forb.forbidden = true
|
|
CompactUnitFrame_SetUnit(forb, "raid4")
|
|
check("verbotener Rahmen bleibt aussen vor", forb.attrs["*type31"] == nil)
|
|
local plain = CreateFrame("Button", nil, UIParent) -- nicht geschuetzt
|
|
ClickCastFrames[plain] = true
|
|
check("ungeschuetzter Rahmen wird nicht angemeldet", plain.attrs["*type31"] == nil)
|
|
ClickCastFrames[pf] = true
|
|
check("doppelt anmelden wickelt nicht doppelt ein", #pf.unwrapped == 1)
|
|
|
|
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 = unitFrame("party1"); ClickCastFrames[p1] = true
|
|
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 = unitFrame("target"); ClickCastFrames[tf] = true
|
|
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)
|