Skip to content

Commit

Permalink
Move 3 hearthstones to a special hearthstone bag as they don't share …
Browse files Browse the repository at this point in the history
…cooldown with others.
  • Loading branch information
Justw8 committed Aug 26, 2024
1 parent e48dd66 commit e344b04
Showing 1 changed file with 108 additions and 5 deletions.
113 changes: 108 additions & 5 deletions TeleportMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ local _, tpm = ...

local APPEND = "\124cFFFF0000TeleportMenu:\124r "
local availableHearthstones = {}
local validHearthstoneToys = {
local hearthstoneToys = {
[54452] = true, -- Ethereal Portal
[64488] = true, -- The Innkeeper's Daughter
[93672] = true, -- Dark Portal
[142542] = true, -- Tome of Town Portal
[162973] = true, -- Greatfather Winter's Hearthstone
[163045] = true, -- Headless Horseman's Hearthstone
[163206] = true, -- Weary Spirit Binding
Expand Down Expand Up @@ -41,6 +40,11 @@ local validHearthstoneToys = {
[206195] = true, -- Path of the Naaru
[208704] = true, -- Deepdweller's Earthen Hearthstone
[209035] = true, -- Hearthstone of the Flame
}

local availableBonusHearthstones = {}
local bonusHearthstones = {
[142542] = true, -- Tome of Town Portal
[210455] = function() -- Draenic Hologem (Draenei and Lightforged Draenei only)
local _, _, raceId = UnitRace("player")
if raceId == 11 or raceId == 30 then return true end
Expand Down Expand Up @@ -68,6 +72,7 @@ local wormholes = {
local tpTable = {
-- Hearthstones
{id = 6948, type = "item", hearthstone = true}, -- Hearthstone
{type = "bonusheartsones", iconId = 5524917}, -- Bonus Heartstones
{id = 556, type = "spell"}, -- Astral Recall (Shaman)
{id = 110560, type = "toy", quest={34378, 34586}}, -- Garrison Hearthstone
{id = 140192, type = "toy", quest={44184, 44663}}, -- Dalaran Hearthstone
Expand Down Expand Up @@ -99,7 +104,7 @@ local tpTable = {

function tpm:updateAvailableHearthstones()
availableHearthstones = {}
for id, usable in pairs(validHearthstoneToys) do
for id, usable in pairs(hearthstoneToys) do
if PlayerHasToy(id) then
if type(usable) == "function" and usable() then
table.insert(availableHearthstones, id)
Expand All @@ -110,6 +115,19 @@ function tpm:updateAvailableHearthstones()
end
end

function tpm:updateAvailableBonusHeartstones()
availableBonusHearthstones = {}
for id, usable in pairs(bonusHearthstones) do
if PlayerHasToy(id) then
if type(usable) == "function" and usable() then
table.insert(availableBonusHearthstones, id)
elseif usable == true then
table.insert(availableBonusHearthstones, id)
end
end
end
end

function tpm:updateAvailableWormholes()
for _, id in ipairs(wormholes) do
if PlayerHasToy(id) and C_ToyBox.IsToyUsable(id) then
Expand Down Expand Up @@ -283,6 +301,81 @@ function tpm:CreateWormholeFlyout(iconId)
return button
end

function tpm:CreateBonusHearthstoneFlyout(iconId)
if #availableBonusHearthstones == 0 then return end
local button = CreateFrame("Button", nil, TeleportMeButtonsFrame, "SecureActionButtonTemplate")
local yOffset = -40 * TeleportMeButtonsFrame:GetButtonAmount()
button:SetSize(40, 40)
button:SetNormalTexture(iconId)
button:SetPoint("TOPLEFT", TeleportMeButtonsFrame, "TOPRIGHT", 0, yOffset)
button:EnableMouse(true)
button:RegisterForClicks("AnyDown", "AnyUp")
button:SetFrameStrata("HIGH")
button:SetFrameLevel(101)
button:SetScript("OnEnter", function(self)
if InCombatLockdown() then
tpm:setCombatTooltip(self)
return
end
tpm:setToolTip(self, "bonusheartsones")
self.flyOutFrame:Show()
end)
button:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)

local flyOutFrame = CreateFrame("Frame", nil, TeleportMeButtonsFrame)
flyOutFrame:SetPoint("TOPLEFT", TeleportMeButtonsFrame, "TOPRIGHT", 0, yOffset)
flyOutFrame:SetFrameStrata("HIGH")
flyOutFrame:SetFrameLevel(103)
flyOutFrame:SetPropagateMouseClicks(true)
flyOutFrame:SetPropagateMouseMotion(true)
flyOutFrame.mainButton = button
flyOutFrame:SetScript("OnLeave", function(self)
GameTooltip:Hide()
if not InCombatLockdown() then
self:Hide()
end
end)
flyOutFrame:Hide()
button.flyOutFrame = flyOutFrame

local flyOutButtons = {}
local flyoutsCreated = 0
for _, toyId in ipairs(availableBonusHearthstones) do
local flyOutButton = CreateFrame("Button", nil, flyOutFrame," SecureActionButtonTemplate")
local _, name, iconId = C_ToyBox.GetToyInfo(toyId)
local xOffset = 40 + (40 * flyoutsCreated)
flyOutButton:SetSize(40, 40)
flyOutButton:SetNormalTexture(iconId)
flyOutButton:SetAttribute("type", "toy")
flyOutButton:SetAttribute("toy", toyId)
flyOutButton:SetPoint("RIGHT", flyOutFrame, "LEFT", 40 + xOffset, 0)
flyOutButton:EnableMouse(true)
flyOutButton:RegisterForClicks("AnyDown", "AnyUp")
flyOutButton:SetFrameStrata("HIGH")
flyOutButton:SetFrameLevel(102)
flyOutButton:SetScript("OnEnter", function(self)
tpm:setToolTip(self, "toy", toyId)
end)
flyOutButton:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
flyOutButton.cooldownFrame = tpm:createCooldownFrame(flyOutButton)
flyOutButton.cooldownFrame:CheckCooldown(toyId, "toy")
flyOutButton:SetScript("OnShow", function(self)
self.cooldownFrame:CheckCooldown(toyId, "toy")
end)
table.insert(flyOutButtons, flyOutButton)
flyoutsCreated = flyoutsCreated + 1
end
flyOutFrame:SetSize(40 + (40 * flyoutsCreated), 40)

button.flyOutButtons = flyOutButtons
return button
end


function tpm:setCombatTooltip(self)
GameTooltip:SetOwner(self, "ANCHOR_NONE")
GameTooltip:SetPoint("BOTTOMLEFT", TeleportMeButtonsFrame, "TOPRIGHT", 0, 0)
Expand Down Expand Up @@ -313,6 +406,10 @@ function tpm:setToolTip(self, type, id, hs)
if professionInfo then
GameTooltip:SetText(professionInfo.professionName, 1, 1, 1)
end
elseif type == "bonusheartsones" then
GameTooltip:SetText("Bonus Hearthstones", 1, 1, 1)
GameTooltip:AddLine("\124cFF34B7EBThese Hearthstones do not share cooldown with the other toys.\124r", 1, 1, 1)
GameTooltip:Show()
end
GameTooltip:Show()
end
Expand Down Expand Up @@ -506,6 +603,11 @@ local function createAnchors()
if created then
TeleportMeButtonsFrame:IncrementButtons()
end
elseif teleport.type == "bonusheartsones" then
local created = tpm:CreateBonusHearthstoneFlyout(teleport.iconId)
if created then
TeleportMeButtonsFrame:IncrementButtons()
end
elseif teleport.type == "flyout" then
local created = tpm:CreateHerosPathFlyout(teleport.id, teleport.iconId)
if created then
Expand Down Expand Up @@ -541,7 +643,7 @@ SlashCmdList["TPMENU"] = function(msg)

if msg == "list" then
print(APPEND.."Available Hearthstone toys: [id - name]")
for id, _ in pairs(validHearthstoneToys) do
for id, _ in pairs(hearthstoneToys) do
if PlayerHasToy(id) then
local _, name = C_ToyBox.GetToyInfo(id)
print(id.." - "..name)
Expand All @@ -562,7 +664,7 @@ SlashCmdList["TPMENU"] = function(msg)
end

local id = tonumber(msg)
if id and validHearthstoneToys[id] and PlayerHasToy(id) then
if id and hearthstoneToys[id] and PlayerHasToy(id) then
local _, name = C_ToyBox.GetToyInfo(id)
TeleportMenuDB.hearthstone = id
updateHearthstone()
Expand All @@ -579,6 +681,7 @@ end

function tpm:Setup()
tpm:updateAvailableHearthstones()
tpm:updateAvailableBonusHeartstones()
tpm:updateAvailableWormholes()
createAnchors()
hooksecurefunc("ToggleGameMenu", createAnchors)
Expand Down

0 comments on commit e344b04

Please sign in to comment.