Skip to content

Commit

Permalink
Fix GUID parsing for GameObjects and enable Profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
widxwer committed May 13, 2024
1 parent a56e232 commit 5208645
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 52 deletions.
80 changes: 37 additions & 43 deletions Compat/Compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,43 @@ function QuestieCompat.GetQuestTagInfo(questId)
end
end

-- Returns the ID of the displayed quest at a quest giver.
-- https://wowpedia.fandom.com/wiki/API_GetQuestID
function QuestieCompat.GetQuestID(questStarter, title)
local title = title or GetTitleText()
local guid = QuestieCompat.UnitGUID("npc")

return QuestieDB.GetQuestIDFromName(title, guid, questStarter)
end

-- https://wowwiki-archive.fandom.com/wiki/API_UnitGUID?oldid=2368080
local GUIDType = {
[0]="Player",
[1]="GameObject",
[3]="Creature",
[4]="Pet",
[5]="Vehicle"
}

-- Returns the GUID of the unit.
-- https://wowpedia.fandom.com/wiki/GUID
-- Patch 6.0.2 (2014-10-14): Changed to a new format
function QuestieCompat.UnitGUID(unit)
local guid = UnitGUID(unit)
if guid then
local type = tonumber(guid:sub(5,5), 16) % 8
if type and (type == 1 or type == 3 or type == 5) then
local id = tonumber(guid:sub(6, 12), 16)
-- Creature-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]
return string.format("%s-0-4170-0-41-%d-00000F4B37", GUIDType[type], id)
end
end
end

function QuestieCompat.GetMaxPlayerLevel()
return (Questie.IsWotlk and 80) or (Questie.IsTBC and 70) or (Questie.IsClassic and 60)
end

-- https://wowpedia.fandom.com/wiki/API_UnitAura?oldid=2681338
-- Returns the buffs/debuffs for the unit.
-- an alias for UnitAura(unit, index, "HELPFUL"), returning only buffs.
Expand All @@ -506,10 +543,6 @@ function QuestieCompat.UnitBuff(unit, index)
return name, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
end

function QuestieCompat.GetMaxPlayerLevel()
return (Questie.IsWotlk and 80) or (Questie.IsTBC and 70) or (Questie.IsClassic and 60)
end

-- Returns the race of the unit.
-- https://wowpedia.fandom.com/wiki/API_UnitRace
function QuestieCompat.UnitRace(unit)
Expand Down Expand Up @@ -575,44 +608,6 @@ function QuestieCompat.GetHomePartyInfo(homePlayers)
end
end

-- https://wowpedia.fandom.com/wiki/API_UnitGUID?oldid=2507049
local GUIDType = {
[0]="Player",
[1]="GameObject",
[3]="Creature",
[4]="Pet",
[5]="Vehicle"
}

-- Returns the GUID of the unit.
-- https://wowpedia.fandom.com/wiki/GUID
-- Patch 6.0.2 (2014-10-14): Changed to a new format
function QuestieCompat.UnitGUID(unit)
local guid = UnitGUID(unit)
if guid then
local type = tonumber(guid:sub(5,5), 16) % 8
if type and (type == 1 or type == 3 or type == 5) then
local id = tonumber(guid:sub(9, 12), 16)
-- Creature-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]
return string.format("%s-0-4170-0-41-%d-00000F4B37", GUIDType[type], id)
end
end
end

-- Returns the ID of the displayed quest at a quest giver.
-- https://wowpedia.fandom.com/wiki/API_GetQuestID
function QuestieCompat.GetQuestID(questStarter, title)
local title = title or GetTitleText()
local guid = QuestieCompat.UnitGUID("target")

local questID = QuestieDB.GetQuestIDFromName(title, guid or QuestieCompat.UnitGUID("npc"), questStarter)
if questID == 0 then
return QuestieDB.GetQuestIDFromName(title, guid or QuestieCompat.UnitGUID("npc"), not questStarter)
end

return questID
end

-- Gets a list of the auction house item classes.
-- https://wowpedia.fandom.com/wiki/API_GetAuctionItemClasses?oldid=1835520
local itemClass = {GetAuctionItemClasses()}
Expand Down Expand Up @@ -1257,7 +1252,6 @@ function QuestieCompat:ADDON_LOADED(event, addon)
"QuestieDebugOffer",
"SeasonOfDiscovery",
"QuestieDBMIntegration",
"Profiler",
}) do
local module = QuestieLoader:ImportModule(moduleName)
setmetatable(module, QuestieCompat.NOOP_MT)
Expand Down
14 changes: 13 additions & 1 deletion Modules/Journey/QuestieSearchResults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,19 @@ function QuestieSearchResults:ItemDetailsFrame(f, itemId)
itemLink = select(2, GetItemInfo(itemId))
end
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
GameTooltip:SetHyperlink(itemLink)
if itemLink then
GameTooltip:SetHyperlink(itemLink)
elseif QuestieCompat.Is335 then
-- I don't know if this applies to private servers, but let's assume it does.
GameTooltip:AddLine("Item Unavailable", 1, 0, 0)
GameTooltip:AddLine("This item is unsafe. To view this item without the risk of disconnection, you need to have first seen it in the game world. This is a restriction enforced by Blizzard since Patch 1.10.", nil, nil, nil, 1)
GameTooltip:AddLine(" ");
GameTooltip:AddLine("You can |cffFFFFFFLEFT-CLICK|r to attempt to query the server. You may be disconnected.", .75, .75, .75, 1)

itemIcon:SetCallback("OnClick", function()
GameTooltip:SetHyperlink("item:"..itemId..":0:0:0:0:0:0:0")
end)
end
GameTooltip:Show()
end)
itemIcon:SetCallback("OnLeave", function()
Expand Down
8 changes: 5 additions & 3 deletions Modules/QuestieProfiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local QuestieProfiler = QuestieLoader:CreateModule("Profiler")

--- COMPATIBILITY ---
local C_Timer = QuestieCompat.C_Timer
local BackdropTemplateMixin = not QuestieCompat.Is335 and BackdropTemplateMixin

QuestieProfiler.hooks = {}
QuestieProfiler.alreadyHooked = {}
Expand Down Expand Up @@ -144,7 +145,7 @@ function QuestieProfiler:CreateUI()
})

local scrollFrameTemplete
if Questie.IsWotlk then
if Questie.IsWotlk and (not QuestieCompat.Is335) then
scrollFrameTemplete = "ScrollFrameTemplate"
else
scrollFrameTemplete = "UIPanelScrollFrameTemplate"
Expand All @@ -154,6 +155,7 @@ function QuestieProfiler:CreateUI()
base.scrollFrame:SetFrameStrata("TOOLTIP")
base.scrollFrame:SetPoint("TOPLEFT", base, 0, -40)
base.scrollFrame:SetPoint("BOTTOMRIGHT", base, 0, 30)
base.scrollFrame.ScrollBar = _G[base.scrollFrame:GetName() .. "ScrollBar"]
base.scrollFrame.ScrollBar:Hide()

base.scrollContainer = CreateFrame("Frame")
Expand Down Expand Up @@ -453,9 +455,9 @@ function QuestieProfiler:CreateUI()
end
search:SetAutoFocus(false)
search:SetScript("OnEscapePressed", clearFocus)
search:HookScript("OnKeyUp", function()
search:HookScript(QuestieCompat.Is335 and "OnTextChanged" or "OnKeyUp", function(self, userInput)
local txt = string.lower(search:GetText())
if string.len(txt) == 0 then
if string.len(txt) == 0 or userInput == false then
txt = nil
end
QuestieProfiler.searchFilter = txt
Expand Down
3 changes: 2 additions & 1 deletion Modules/Tracker/TrackerBaseFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local l10n = QuestieLoader:ImportModule("l10n")

--- COMPATIBILITY ---
local C_Timer = QuestieCompat.C_Timer
local BackdropTemplateMixin = not QuestieCompat.Is335 and BackdropTemplateMixin

local WatchFrame = QuestWatchFrame or WatchFrame
local baseFrame, sizer, sizerSetPoint, sizerSetPointY, sizerLine1, sizerLine2, sizerLine3
Expand All @@ -29,7 +30,7 @@ TrackerBaseFrame.isMoving = false
local _OnEnter, _SetSizerTooltip

function TrackerBaseFrame.Initialize()
baseFrame = CreateFrame("Frame", "Questie_BaseFrame", UIParent, not QuestieCompat.Is335 and (BackdropTemplateMixin and "BackdropTemplate"))
baseFrame = CreateFrame("Frame", "Questie_BaseFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
baseFrame:SetClampedToScreen(true) -- We don't want this frame to be able to move off screen at all!
baseFrame:SetFrameStrata("MEDIUM")
baseFrame:SetFrameLevel(0)
Expand Down
5 changes: 4 additions & 1 deletion Modules/Tutorial/ChooseObjectiveType.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ local QuestieOptionsUtils = QuestieLoader:ImportModule("QuestieOptionsUtils")
---@type QuestieLib
local QuestieLib = QuestieLoader:ImportModule("QuestieLib");

--- COMPATIBILITY ---
local BackdropTemplateMixin = not QuestieCompat.Is335 and BackdropTemplateMixin

---@return Frame
function Tutorial.CreateChooseObjectiveTypeFrame()
local baseFrame = CreateFrame("Frame", "QuestieTutorialChooseObjectiveType", UIParent, not QuestieCompat.Is335 and (BackdropTemplateMixin and "BackdropTemplate"))
local baseFrame = CreateFrame("Frame", "QuestieTutorialChooseObjectiveType", UIParent, BackdropTemplateMixin and "BackdropTemplate")
baseFrame:SetSize(740, 358)
baseFrame:SetPoint("CENTER", 0, 50)
baseFrame:SetFrameStrata("HIGH")
Expand Down
2 changes: 1 addition & 1 deletion Questie-335-Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Modules\Options\TrackerTab\QuestieOptionsTracker.lua
Modules\QuestieCleanup.lua

# Profiler
#Modules\QuestieProfiler.lua
Modules\QuestieProfiler.lua

# Main
Questie.lua
2 changes: 1 addition & 1 deletion Questie-335-TBC.toc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Modules\Options\TrackerTab\QuestieOptionsTracker.lua
Modules\QuestieCleanup.lua

# Profiler
#Modules\QuestieProfiler.lua
Modules\QuestieProfiler.lua

# Main
Questie.lua
2 changes: 1 addition & 1 deletion Questie-335.toc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Modules\Options\TrackerTab\QuestieOptionsTracker.lua
Modules\QuestieCleanup.lua

# Profiler
#Modules\QuestieProfiler.lua
Modules\QuestieProfiler.lua

# Main
Questie.lua

0 comments on commit 5208645

Please sign in to comment.