Add GameTooltip:SetEquipmentSet with localized output

Registers `SetEquipmentSet` on the GameTooltip method registry,
mirroring the 4.3.4 implementation at 0x0046E690. Builds a tooltip
with header + counts (equipped / in inventory / ignored) + one line
per missing item.

Storage format now persists itemID alongside GUID per slot
(`slot N guid=0xHEX item=ID`), so missing items can be looked up by
name in the item cache even when the live CGItem is no longer in the
client's object map. Backward compat: pre-itemID files load fine and
fall back to a `%d missing` summary line for those slots.

Adds `Game::Lua::PushLocalizedString` and `PushLocalizedFormatInt`
helpers — generic lookup of `_G[name]` with a C-string fallback for
servers stripped of standard GlobalStrings. The tooltip uses these
for the four count lines via Blizzard's `ITEMS_VARIABLE_QUANTITY`,
`ITEMS_EQUIPPED`, `ITEMS_IN_INVENTORY`, `ITEM_SLOTS_IGNORED` keys,
and for the per-missing-item line via `ITEM_MISSING`.

AddOn side: a `GlobalStrings.lua` companion provides English defaults
for those five keys plus a `ShowEquipmentSet()` test helper in
Constants.lua.

First implementation passed `nargs=4` to `lua_call` where the stack
needed 5 (self + text + r + g + b for `tooltip:SetText`) — Lua then
treated `self` as the function, surfacing as
`<in C code>: in function 'SetEquipmentSet'` with no Lua frame above.
Fixed before this commit.
This commit is contained in:
Brues
2026-05-18 15:13:36 -05:00
parent 084cc81ca8
commit 5982b85c75
8 changed files with 388 additions and 10 deletions
+24
View File
@@ -174,6 +174,30 @@ void SetGlobalNumber(void *L, const char *name, double value) {
PushNumber(L, value);
RawSet(L, GLOBALS_INDEX);
}
void PushLocalizedString(void *L, const char *globalName, const char *fallback) {
PushString(L, globalName);
GetTable(L, GLOBALS_INDEX);
if (Type(L, -1) != TYPE_STRING) {
// Replace the non-string at top with the fallback so callers
// always see exactly one string at -1.
SetTop(L, GetTop(L) - 1);
PushString(L, fallback);
}
}
void PushLocalizedFormatInt(void *L, const char *globalName,
const char *fallback, int n) {
// Resolve `string.format` from _G. The engine ships it as both a
// global and as `string.format`; the global is faster (one
// gettable instead of two) and equally available across builds.
PushString(L, "format");
GetTable(L, GLOBALS_INDEX);
PushLocalizedString(L, globalName, fallback);
PushNumber(L, static_cast<double>(n));
Call(L, 2, 1); // format(fmt, n) → string
}
} // namespace Lua
namespace {