- DucielPerf addon embedded in the DLL (always served, listed in the addon list): minimap button and /ducielperf (/dperf) open a window with Performance, Diagnostics, Features (module switches, world markers on me/target/clear, interact key bindings, loot all corpses) and Status tabs. - settings.cpp: one table of every ducielperf.cfg setting with live apply where possible; DucielPerf_SettingInfo / GetSetting / SetSetting. config_set_int writes ducielperf.cfg keeping comments and other keys. - Live switches: decompression, file cache, Lua strings, SavedVariables buffering, frame raising and clickthrough keep their hooks and call the client's code while off. New keys: inflate, filecache, luastrings, alloctrack, worldmarkers, interact, clickthrough, transmogfix, exitfix, minimap, minimap_angle. - Tests: test_config (cfg writing), test_addon (the addon on a mock WoW API in Lua 5.0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
4.5 KiB
Lua
101 lines
4.5 KiB
Lua
-- Mock of the WoW 1.12 frame API and the DLL functions, enough to run
|
|
-- assets/addons/DucielPerf/DucielPerf.lua in plain Lua 5.0 (tests/run_tests.sh).
|
|
function setglobal(n, v) _G[n] = v end
|
|
function getglobal(n) return _G[n] end
|
|
-- Minimal WoW 1.12 API mock to run DucielPerf.lua in plain Lua 5.0.
|
|
calls = {}
|
|
function log(s) table.insert(calls, s) end
|
|
|
|
-- Generic widget: any unknown method is a no-op returning nil, scripts stored.
|
|
local Widget = {}
|
|
local function newWidget(kind, name, parent)
|
|
local w = { _kind = kind, _scripts = {}, _shown = true, _checked = nil, _text = "", _name = name }
|
|
setmetatable(w, { __index = function(t, k)
|
|
if Widget[k] then return Widget[k] end
|
|
return function() return nil end
|
|
end })
|
|
if name then setglobal(name, w) end
|
|
return w
|
|
end
|
|
function Widget.SetScript(self, k, f) self._scripts[k] = f end
|
|
function Widget.GetScript(self, k) return self._scripts[k] end
|
|
function Widget.Show(self) self._shown = true; self:_fire("OnShow") end
|
|
function Widget.Hide(self) self._shown = false end
|
|
function Widget.IsShown(self) return self._shown end
|
|
function Widget.SetChecked(self, v) self._checked = v and 1 or false end
|
|
function Widget.GetChecked(self) return self._checked or nil end
|
|
function Widget.SetText(self, t) self._text = t end
|
|
function Widget.GetText(self) return self._text end
|
|
function Widget.GetCenter(self) return 500, 500 end
|
|
function Widget.GetEffectiveScale(self) return 1 end
|
|
function Widget.CreateTexture(self) return newWidget("Texture") end
|
|
function Widget.CreateFontString(self) return newWidget("FontString") end
|
|
function Widget._fire(self, k, a1)
|
|
local f = self._scripts[k]
|
|
if f then
|
|
local old, olda = this, arg1
|
|
this = self; arg1 = a1
|
|
f()
|
|
this = old; arg1 = olda
|
|
end
|
|
end
|
|
|
|
function CreateFrame(kind, name, parent, template)
|
|
local w = newWidget(kind, name, parent)
|
|
w._shown = true
|
|
if template == "UICheckButtonTemplate" and name then newWidget("FontString", name .. "Text") end
|
|
return w
|
|
end
|
|
|
|
UIParent = newWidget("Frame", "UIParent")
|
|
Minimap = newWidget("Frame", "Minimap")
|
|
GameTooltip = newWidget("GameTooltip", "GameTooltip")
|
|
DEFAULT_CHAT_FRAME = { AddMessage = function(self, m) log("chat: " .. m) end }
|
|
UISpecialFrames = {}
|
|
SlashCmdList = {}
|
|
tinsert = table.insert
|
|
|
|
function gcinfo() return 61234, 80000 end
|
|
function GetCursorPosition() return 580, 420 end
|
|
function GetBindingKey(b) if b == "Interact" then return "F" end end
|
|
function ReloadUI() log("reload") end
|
|
function LoadAddOn() end
|
|
function ShowUIPanel() end
|
|
|
|
-- DLL functions
|
|
local S = {
|
|
{ "inflate", "Faster MPQ decompression", "perf", 1, 1, 1, 1, 0, 1, 1, 1, nil, "help" },
|
|
{ "strbuf", "Garbage-free string building", "perf", 1, 1, 1, 1, 0, 1, nil, 1, nil, "help" },
|
|
{ "gcdefer_mb", "Combat GC limit (MB)", "perf", nil, 128, 128, 128, 8, 512, 1, 1, nil, "help" },
|
|
{ "watchdog", "Freeze watchdog", "diag", 1, 0, 0, 0, 0, 1, 1, 1, nil, "help" },
|
|
{ "worldmarkers", "World markers", "features", 1, 1, 0, 1, 0, 1, nil, 1, 1, "help" },
|
|
{ "interact", "Interact", "features", 1, 1, 1, 1, 0, 1, nil, nil, nil, "help" },
|
|
{ "minimap", "Minimap button", "ui", 1, 1, 1, 1, 0, 1, 1, 1, nil, "" },
|
|
{ "minimap_angle", "Minimap pos", "ui", nil, 225, 225, 225, 0, 359, 1, 1, nil, "" },
|
|
}
|
|
function DucielPerf_SettingInfo(i)
|
|
local s = S[i]
|
|
if not s then return nil end
|
|
return unpack(s)
|
|
end
|
|
local function findS(key) for _, s in ipairs(S) do if s[1] == key then return s end end end
|
|
function DucielPerf_GetSetting(key) local s = findS(key); return s[5], s[6], s[12] end
|
|
function DucielPerf_SetSetting(key, v)
|
|
log("set " .. key .. "=" .. tostring(v))
|
|
local s = findS(key); s[6] = v; if s[10] then s[5] = v end
|
|
return s[5], nil
|
|
end
|
|
function GetWeirdUtilsVersion() return "0.9.0" end
|
|
function DucielPerf_GetGCStats(t) t.cycles = 3; t.totalMs = 300; t.lastMs = 100; t.maxMs = 120; t.deferOn = 1
|
|
t.deferring = 0; t.deferred = 2; t.deferredFights = 1; t.deferCapHits = 0; return 3, 300 end
|
|
function DucielPerf_GetFrameLevelStats() return 32, 0, 19890, 20, 1.99, 16874 end
|
|
function DucielPerf_GetStringBufferStats() return 1000, 3, 2000000, 0 end
|
|
function DucielPerf_Watchdog() return 1, 150, 4 end
|
|
function DucielPerf_FrameStats() return 1 end
|
|
function DucielPerf_AllocTracking() return nil end
|
|
WorldMarkers = { UI_WorldMarker = function(i, u) log("marker " .. i .. " " .. tostring(u)) end,
|
|
UI_ClearWorldMarker = function(i) log("clear " .. tostring(i)) end }
|
|
function GetWorldMarker(i) if i == 2 then return 1, 2, 3, 4 end end
|
|
function InteractNearest() end
|
|
function LootAllCorpses() log("lootall") end
|