Commit Graph
2 Commits
Author SHA1 Message Date
8e721237f6 feat(addons): zhCN localization for ClassicAPI_DebugTools and 6 missing globals fix (#141)
* feat(debugtools): add zhCN localization for ClassicAPI_DebugTools

* fix(locales): add 6 missing global strings to zhCN

* feat(debugtools): clean up slash command dispatch and add help subcommand

* fix(debugtools): use %s instead of %d in PROFILER_CALLS_FORMAT

ns.Count() always returns a string (either a formatted number or '-'),
never a number. Feeding it to %d causes format() to throw. Change the
locale template to %s so both '-', '1,234', etc. render correctly.

* fix(debugtools): repair regressions from the localization pass

- XML labels: 1.12's Button/FontString loader passes the text attribute
  verbatim to FrameScript_GetText (0x703BF0), which reads the global of
  exactly that name and falls back to the raw value. Nothing strips
  "$...$", so text="$TI_SHOW$" rendered as literal "$TI_SHOW$". Use the
  bare global name, as stock FrameXML does.
- Tabs: ns.AddTab(name, label) keeps a fixed English key for ns.ShowIn
  and a separate localized button label. Keying tabs by the translated
  name made ShowIn("Globals") return nil and error on a zhCN client.
- Frames tab state: restore visible / "shown, parent hidden" / hidden.
  The inverted branch reported a shown frame under a hidden parent as
  hidden and made the third state unreachable.
- /profiler: unknown or incomplete subcommands print the usage again
  instead of doing nothing.
- Deep Tracking / CPU Profiling buttons: split the label from ON/OFF so
  the state keeps its accent / grey colour.
- Restore the gap between owner and CPU time in the frame-stack and
  Frames-tab tooltips, and the leading space of " (replaced)".
- zhCN: ADDON_OPTIONS titles the shared Interface Options panel and the
  game-menu button, not ClassicAPI's own settings; revert to 插件设置.

---------

Co-authored-by: jilinge <jilinge@users.noreply.github.com>
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
2026-11-13 10:33:01 -06:00
Brues f19f13d44c feat(debugtools): fold pfDebug in as /profiler
pfDebug was a separate addon that profiled through ClassicAPI's own
APIs: GetAddOnMemoryUsage and GetAddOnCPUUsage, GetFrameCPUUsage,
GetFunctionCPUUsage, GetEventCPUUsage, and the intrinsic precall and
postcall script hooks. Its code now lives in ClassicAPI_DebugTools
under Profiler/, with its MIT notice (Copyright (c) 2018 Shagu). The
analyzer tabs (Addons, Frames, Events, Globals) and the widget are
pfDebug's, with the frame and template names renamed to
ClassicAPIProfiler*.

/profiler and /prof load DebugTools on demand through the same stub as
/dump, then toggle the analyzer. The subcommands widget, reset and
profile on|off are pfDebug's.

What changed in the move:

- The sampler starts only when the widget or the analyzer first opens,
  so a load for /dump costs nothing. It first takes every counter as it
  is, so the first CPU/s and KB/s cover one second, not the session.
- Whether profiling runs is probed, not read from the cvar: a function
  is called once and GetFunctionCPUUsage must count that call. The
  scriptProfile cvar can already hold the next session's value.
- A frame record starts at the frame's current CPU time and call count,
  and opening the analyzer takes every frame and event counter again,
  because the frame totals and the deep hooks keep counting while it is
  closed. pfDebug started records at 0, so the first scan and each
  reopen showed a frame's whole session as one second.
- The /fstack lines (owner, OnUpdate and OnEvent owner and CPU, all
  scripts, deep allocations) are added at the end of
  FrameStackTooltip_OnTooltipSetFrameStack, not by hooking
  OnTooltipSetFrameStack.
- No pfUI skin and no SavedVariables. The plain backdrop is pfDebug's
  own fallback. The widget no longer opens at login, because that would
  load DebugTools at login.

README's Debug tools table gains /profiler and the new /fstack lines.
2026-10-31 23:16:01 -05:00