Skip to content

Commit a9c1829

Browse files
committed
minimap: a tooltip for the tracking button, and no 3.x icon on a 1.12 interface
Two faults on the same button, either of which was enough to make hovering it do nothing useful. GameTooltip:SetTrackingSpell was in neither the method table nor the no-op allowlist, so the lookup answered nil. 1.12's Minimap.xml opens the tracking frame's OnEnter with SetOwner and that call, so the handler raised on its second line with the tooltip already owned by a frame that then wrote nothing into it. It is the spell's own tooltip now, through SetSpellByID, because "Track Humanoids" is a title with nothing under it saying what that does. And GetTrackingTexture answered Interface\Minimap\Tracking\None for nothing tracked, which is 3.x's art. A 1.12 client has no Interface\Minimap\Tracking folder at all - interface.MPQ, patch.MPQ and patch-2.MPQ hold nothing under that path - and its Minimap.xml hides the tracking frame outright when this answers nil. So the frame was shown with a missing texture in it rather than hidden. Only 1.12 changes: the dropdown and its None entry are 2.x's. The spell id the tooltip needs comes from __WoweeActiveTrackingSpell rather than from a fifth value on GetTrackingInfo, which is 4.x's own - it says whether an entry nests under the one above it, and a spell id would have been read as that. Reported in #132
1 parent aa89e1d commit a9c1829

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

src/addons/lua_engine.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7108,6 +7108,27 @@ void LuaEngine::registerCoreAPI() {
71087108
" self:AddLine(string.format('%.0f sec remaining', duration), 1, 1, 1)\n"
71097109
" end\n"
71107110
"end\n"
7111+
// What the minimap's tracking button is showing. 1.12's Minimap.xml
7112+
// opens the tracking frame's OnEnter with SetOwner and this, and it was
7113+
// in neither the method table nor the no-op allowlist - so the lookup
7114+
// answered nil, the call raised, and the OnEnter it was the second line
7115+
// of took the tooltip's owner with it. Reported in #132.
7116+
//
7117+
// The spell's own tooltip where SetSpellByID can render one, because
7118+
// "Track Humanoids" is a title without the line under it saying what
7119+
// that does. The id comes from this client rather than from
7120+
// GetTrackingInfo, whose fifth value is 4.x's own.
7121+
"function __WoweeFrameMT:SetTrackingSpell()\n"
7122+
" self:ClearLines()\n"
7123+
" local spellId = __WoweeActiveTrackingSpell()\n"
7124+
" if spellId and self.SetSpellByID then\n"
7125+
" return self:SetSpellByID(spellId)\n"
7126+
" end\n"
7127+
" for i = 1, GetNumTrackingTypes() do\n"
7128+
" local name, _, active = GetTrackingInfo(i)\n"
7129+
" if active and name then return self:SetText(name, 1, 1, 1) end\n"
7130+
" end\n"
7131+
"end\n"
71117132
"function __WoweeFrameMT:SetTrainerService(index)\n"
71127133
" self:ClearLines()\n"
71137134
" if not index then return end\n"

src/addons/lua_system_api.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,19 @@ static int lua_GetTrackingTexture(lua_State* L) {
22882288
const std::string icon = gh->getSpellIconPath(sid);
22892289
if (!icon.empty()) { lua_pushstring(L, icon.c_str()); return 1; }
22902290
}
2291+
// Nothing tracked, and what a stock client shows for that is not the same
2292+
// picture in every expansion. 3.x has a button whose art is empty in the
2293+
// XML and a magnifying glass to fill it with. 1.12 has neither: its
2294+
// Minimap.xml hides the tracking frame outright when this answers nil, and
2295+
// the 1.12 archives carry no Interface\Minimap\Tracking folder at all -
2296+
// interface.MPQ, patch.MPQ and patch-2.MPQ hold nothing under that path. So
2297+
// on turtle the answer named a file that does not exist, and the frame was
2298+
// shown with an empty icon in it rather than hidden.
2299+
//
2300+
// Only 1.12 changes. The tracking dropdown and its None entry are 2.x's and
2301+
// nothing here has been checked against a 2.4.3 tree, so every other
2302+
// interface keeps the answer it already had.
2303+
if (interfaceVersion(L) < 20000) return luaReturnNil(L);
22912304
lua_pushstring(L, "Interface\\Minimap\\Tracking\\None");
22922305
return 1;
22932306
}
@@ -2302,6 +2315,12 @@ static int lua_GetNumTrackingTypes(lua_State* L) {
23022315
///
23032316
/// "spell" for the category, because these are spell icons and the menu uses
23042317
/// that to crop the icon's border - the same trim the action bar gives them.
2318+
///
2319+
/// Four values and not five. The spell id would have been useful to
2320+
/// GameTooltip:SetTrackingSpell and belongs in none of them: 4.x defines a
2321+
/// fifth of its own - whether the entry nests under the one above it - and a
2322+
/// number in that position would be read as that. __WoweeActiveTrackingSpell
2323+
/// carries it instead, under a name no interface will ever call.
23052324
static int lua_GetTrackingInfo(lua_State* L) {
23062325
auto* gh = getGameHandler(L);
23072326
const int index = static_cast<int>(luaL_optnumber(L, 1, 0));
@@ -2315,6 +2334,21 @@ static int lua_GetTrackingInfo(lua_State* L) {
23152334
return 4;
23162335
}
23172336

2337+
/// __WoweeActiveTrackingSpell() → the spell id of the tracking now running.
2338+
///
2339+
/// This client's own and not an interface function: GameTooltip:SetTrackingSpell
2340+
/// needs the id to render the spell's own tooltip, and every real API that
2341+
/// could have carried it is a shape some expansion has already defined.
2342+
static int lua_ActiveTrackingSpell(lua_State* L) {
2343+
auto* gh = getGameHandler(L);
2344+
for (uint32_t sid : trackingSpells(gh)) {
2345+
if (!trackingActive(gh, sid)) continue;
2346+
lua_pushnumber(L, static_cast<lua_Number>(sid));
2347+
return 1;
2348+
}
2349+
return luaReturnNil(L);
2350+
}
2351+
23182352
/// SetTracking(index) - casting the spell is how tracking is turned on; there
23192353
/// is no separate message for it. A nil index is the menu's "None" entry,
23202354
/// which in a stock client cancels the running tracking aura. Cancelling a
@@ -6433,6 +6467,7 @@ void registerSystemLuaAPI(lua_State* L) {
64336467
{"GetTrackingTexture", lua_GetTrackingTexture},
64346468
{"GetNumTrackingTypes", lua_GetNumTrackingTypes},
64356469
{"GetTrackingInfo", lua_GetTrackingInfo},
6470+
{"__WoweeActiveTrackingSpell", lua_ActiveTrackingSpell},
64366471
{"SetTracking", lua_SetTracking},
64376472
{"GetZoneText", lua_GetZoneText},
64386473
{"GetRealZoneText", lua_GetZoneText},

0 commit comments

Comments
 (0)