Skip to content

Commit

Permalink
Revised a lot of logic for DisplayID into a Model.lua file (potential…
Browse files Browse the repository at this point in the history
…ly temporary until Classic uses NPC.lua). This allows the same DisplayID blocking to be done in one place for both Model preview and row icons

DisplayID calculation is now cached for the respective data
Game Tooltip now uses a priority function chain to assign a Model from a reference since Retail & Classic support different tooltip functions
Followers can once again show their model
Retail: Scrollbar changes now only cause the respective ATT window to refresh once per game frame (there were some situations where dragging a scrollbar would refresh the window multiple times with different scroll amounts in one game frame)
  • Loading branch information
ImUnicke committed Sep 4, 2024
1 parent f4b1a66 commit 8118494
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 155 deletions.
35 changes: 3 additions & 32 deletions AllTheThings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ local IsRetrieving = app.Modules.RetrievingData.IsRetrieving;
local GetProgressColorText = app.Modules.Color.GetProgressColorText;
local TryColorizeName = app.TryColorizeName;
local DESCRIPTION_SEPARATOR = app.DESCRIPTION_SEPARATOR;
local GetDisplayID = app.GetDisplayID
local ATTAccountWideData;

-- Color Lib
Expand Down Expand Up @@ -247,37 +248,6 @@ local function GetMoneyString(amount)
end
return amount
end
local function GetDisplayID(data)
-- don't create a displayID for groups with a sourceID/itemID/difficultyID/mapID
if data.sourceID or data.itemID or data.difficultyID or data.mapID then return end
local displayID = data.displayID
if displayID then
return displayID
end
local npcID = data.npcID or data.creatureID
if npcID then
displayID = app.NPCDisplayIDFromID[npcID]
if displayID then
return displayID
end
end

local qgs = data.qgs
if qgs and #qgs > 0 then
return app.NPCDisplayIDFromID[qgs[1]]
end

local providers = data.providers
if providers and #providers > 0 then
local lookup = app.NPCDisplayIDFromID
for _,v in ipairs(providers) do
-- if one of the providers is an NPC, we should show its texture regardless of other providers
if v[1] == "n" then
return lookup[v[2]]
end
end
end
end
local function GetIconFromProviders(group)
if group.providers then
local icon;
Expand Down Expand Up @@ -7783,7 +7753,8 @@ end
local function OnScrollBarValueChanged(self, value)
if self.CurrentValue ~= value then
self.CurrentValue = value;
self:GetParent():Refresh();
local window = self:GetParent()
Callback(window.Refresh, window)
end
end
local function ProcessGroup(data, object)
Expand Down
1 change: 1 addition & 0 deletions AllTheThings.toc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ src\Modules\Costs.lua
src\Modules\Events.lua
src\Modules\Filter.lua
src\Modules\Inventory.lua
src\Modules\Model.lua
src\Modules\Social.lua
src\Modules\Tooltip.lua
src\Modules\Upgrade.lua
Expand Down
1 change: 1 addition & 0 deletions AllTheThings_Cata.toc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ src\Modules\Color.lua
# src\Modules\Costs.lua
src\Modules\Events.lua
src\Modules\Filter.lua
src\Modules\Model.lua
src\Modules\Social.lua
src\Modules\Tooltip.lua
# src\Modules\Upgrade.lua
Expand Down
1 change: 1 addition & 0 deletions AllTheThings_TBC.legacytoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ src\Modules\Color.lua
# src\Modules\Costs.lua
src\Modules\Events.lua
src\Modules\Filter.lua
src\Modules\Model.lua
src\Modules\Social.lua
src\Modules\Tooltip.lua
# src\Modules\Upgrade.lua
Expand Down
1 change: 1 addition & 0 deletions AllTheThings_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ src\Modules\Color.lua
# src\Modules\Costs.lua
src\Modules\Events.lua
src\Modules\Filter.lua
src\Modules\Model.lua
src\Modules\Social.lua
src\Modules\Tooltip.lua
# src\Modules\Upgrade.lua
Expand Down
1 change: 1 addition & 0 deletions AllTheThings_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ src\Modules\Color.lua
# src\Modules\Costs.lua
src\Modules\Events.lua
src\Modules\Filter.lua
src\Modules\Model.lua
src\Modules\Social.lua
src\Modules\Tooltip.lua
# src\Modules\Upgrade.lua
Expand Down
24 changes: 1 addition & 23 deletions classic/ATT-Classic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,29 +297,7 @@ app.IsComplete = function(o)
if o.collectible then return o.collected; end
if o.trackable then return o.saved; end
end
local function GetDisplayID(data)
if data.displayID then
return data.displayID;
elseif data.creatureID then
local displayID = app.NPCDisplayIDFromID[data.creatureID];
if displayID then
return displayID;
end
end

if data.providers and #data.providers > 0 then
for k,v in pairs(data.providers) do
-- if one of the providers is an NPC, we should show its texture regardless of other providers
if v[1] == "n" then
return app.NPCDisplayIDFromID[v[2]];
end
end
end

if data.qgs and #data.qgs > 0 then
return app.NPCDisplayIDFromID[data.qgs[1]];
end
end
local GetDisplayID = app.GetDisplayID
local function GetIconFromProviders(group)
if group.providers then
local icon;
Expand Down
3 changes: 0 additions & 3 deletions src/Classes/Header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ do
icon = function(t)
return cache.GetCachedField(t, "icon", CacheInfo) or 4555017;
end,
displayID = function(t)
return cache.GetCachedField(t, "displayID", CacheInfo);
end,
},
"WithQuest", {
trackable = function(t)
Expand Down
3 changes: 0 additions & 3 deletions src/Classes/NPC.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ do
title = function(t)
return NPCTitlesFromID[t[KEY]]
end,
displayID = function(t)
return NPCDisplayIDFromID[t[KEY]]
end,
icon = function(t)
local vendorParent = t.parent and t.parent.headerID == app.HeaderConstants.VENDORS
if vendorParent then
Expand Down
2 changes: 1 addition & 1 deletion src/Expansions/Warlords.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ do
return cache.GetCachedField(t, "title", CacheInfo);
end,
displayID = function(t)
-- return cache.GetCachedField(t, "displayID", CacheInfo);
return cache.GetCachedField(t, "displayID", CacheInfo);
end,
link = function(t)
return cache.GetCachedField(t, "link", CacheInfo);
Expand Down
66 changes: 66 additions & 0 deletions src/Modules/Model.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
-- App locals
local _, app = ...;

-- Globals
local ipairs
= ipairs

-- returns the input key unless it's blocked by being set to 0
local BlockedDisplayID = {
[11686] = 0, -- empty blue thing
[16925] = 0, -- nothing
[21072] = 0, -- empty blue thing
[23767] = 0, -- empty blue thing
[27823] = 0, -- empty blue thing
[28016] = 0, -- empty blue thing
[52318] = 0, -- generic bunny
[56187] = 0, -- generic bunny
[64062] = 0, -- generic bunny
[110046] = 0, -- nothing
[112684] = 0, -- nothing
}
local AllowedDisplayID = setmetatable({}, {
__index = function(t, key)
if BlockedDisplayID[key] then
return false
end
-- app.PrintDebug("DisplayID",key)
return key;
end
});

local function GetDisplayID(data)
-- don't create a displayID for groups with a sourceID/itemID/difficultyID/mapID
if data.sourceID or data.difficultyID or data.mapID or data.itemID then return false end

local npcID = data.npcID or data.creatureID
if npcID then return app.NPCDisplayIDFromID[npcID] end

local qgs = data.qgs
if qgs and #qgs > 0 then return app.NPCDisplayIDFromID[qgs[1]] end

local providers = data.providers
if providers and #providers > 0 then
local lookup = app.NPCDisplayIDFromID
for _,v in ipairs(providers) do
-- if one of the providers is an NPC, we should show its texture regardless of other providers
if v[1] == "n" then
return lookup[v[2]]
end
end
end
return false
end

-- TODO: This really should just be in NPC.lua, but Classic doesn't use that yet
-- Determines an allowed DisplayID for the provided data group based on NPC data
-- or returns an existing displayID of the group
app.GetDisplayID = function(data)
local id = data.displayID
-- app.PrintDebug("old.displayID",id)
if id ~= nil then return id end
id = AllowedDisplayID[GetDisplayID(data)]
-- app.PrintDebug("new.displayID",id)
data.displayID = id
return id
end
4 changes: 2 additions & 2 deletions src/UI/Classic Window Logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ local function SetPortraitIcon(self, data, x)
if app.Settings:GetTooltipSetting("IconPortraits") then
local extraSetting = IconPortraitTooltipExtraSettings[data.key];
if not extraSetting or app.Settings:GetTooltipSetting(extraSetting) then
local displayID = CalculateRowDisplayID(data);
local displayID = app.GetDisplayID(data);
if displayID then
SetPortraitTextureFromDisplayID(self, type(displayID) == "number" and displayID or displayID[1]);
SetPortraitTextureFromDisplayID(self, displayID);
self:SetWidth(self:GetHeight());
self:SetTexCoord(0, 1, 0, 1);
return true;
Expand Down
Loading

0 comments on commit 8118494

Please sign in to comment.