Skip to content

Commit

Permalink
Formatting pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Justw8 committed Oct 30, 2024
1 parent 3d4d97d commit 41af74d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
20 changes: 10 additions & 10 deletions Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local defaultsDB = {
hearthstone = "none",
reverseMageFlyouts = false,
buttonText = true,
showOnlySeasonalHerosPath = false,
showOnlySeasonalHerosPath = false
}

-- Get all options and verify them
Expand All @@ -35,12 +35,11 @@ local function resetOptions()
end

local function OnSettingChanged(_, setting, value)
local variable = setting:GetVariable()
TeleportMenuDB[variable] = value
local variable = setting:GetVariable()
TeleportMenuDB[variable] = value
tpm:ReloadFrames()
end


local optionsCategory = Settings.RegisterVerticalLayoutCategory(ADDON_NAME)

function tpm:GetOptionsCategory()
Expand Down Expand Up @@ -84,8 +83,8 @@ function tpm:LoadOptions()
local setting = Settings.RegisterProxySetting(optionsCategory, "IconSize_Slider", type(defaultsDB[optionsKey]), "Icon Size", defaultsDB[optionsKey], GetValue, SetValue)

local function Formatter(value)
return label:format(value)
end
return label:format(value)
end
options:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right, Formatter)

Settings.CreateSlider(optionsCategory, setting, options, tooltip)
Expand All @@ -98,11 +97,11 @@ function tpm:LoadOptions()
local function GetOptions()
local container = Settings.CreateControlTextContainer()
container:Add("none", L["None"])
container:Add("rng", "|T1669494:16:16:0:0:64:64:4:60:4:60|t "..L["Random"])
container:Add("rng", "|T1669494:16:16:0:0:64:64:4:60:4:60|t " .. L["Random"])
local startOption = 2
local hearthstones = tpm:GetAvailableHearthstoneToys()
for id, hearthstoneInfo in pairs(hearthstones) do
container:Add(tostring(id), "|T"..hearthstoneInfo.texture..":16:16:0:0:64:64:4:60:4:60|t "..hearthstoneInfo.name)
container:Add(tostring(id), "|T" .. hearthstoneInfo.texture .. ":16:16:0:0:64:64:4:60:4:60|t " .. hearthstoneInfo.name)
end
return container:GetData()
end
Expand All @@ -123,10 +122,11 @@ function tpm:LoadOptions()
do
local optionsKey = "showOnlySeasonalHerosPath"
local tooltip = L["Seasonal Teleports Toggle Tooltip"]
local setting = Settings.RegisterAddOnSetting(optionsCategory, "ShowOnlySeasonalHerosPath_Checkbox", optionsKey, db, type(defaultsDB[optionsKey]), L["Seasonal Teleports"], defaultsDB[optionsKey])
local setting =
Settings.RegisterAddOnSetting(optionsCategory, "ShowOnlySeasonalHerosPath_Checkbox", optionsKey, db, type(defaultsDB[optionsKey]), L["Seasonal Teleports"], defaultsDB[optionsKey])
Settings.SetOnValueChangedCallback("ShowOnlySeasonalHerosPath_Checkbox", OnSettingChanged)
Settings.CreateCheckbox(optionsCategory, setting, tooltip)
end

Settings.RegisterAddOnCategory(optionsCategory)
Settings.RegisterAddOnCategory(optionsCategory)
end
33 changes: 21 additions & 12 deletions TeleportMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,39 @@ local hearthstoneToys = {
[172179] = true, -- Eternal Traveler's Hearthstone
[180290] = function()
-- Night Fae Hearthstone
if GetCovenantData(3) then return true end
if GetCovenantData(3) then
return true
end
local covenantID = C_Covenants.GetActiveCovenantID()
if covenantID == 3 then
return true
end
end,
[182773] = function()
-- Necrolord Hearthstone
if GetCovenantData(2) then return true end
if GetCovenantData(2) then
return true
end
local covenantID = C_Covenants.GetActiveCovenantID()
if covenantID == 4 then
return true
end
end,
[183716] = function()
-- Venthyr Sinstone
if GetCovenantData(4) then return true end
if GetCovenantData(4) then
return true
end
local covenantID = C_Covenants.GetActiveCovenantID()
if covenantID == 2 then
return true
end
end,
[184353] = function()
-- Kyrian Hearthstone
if GetCovenantData(1) then return true end
if GetCovenantData(1) then
return true
end
local covenantID = C_Covenants.GetActiveCovenantID()
if covenantID == 1 then
return true
Expand Down Expand Up @@ -192,7 +200,6 @@ local shortNames = {
[445444] = L["Priory of the Sacred Flame"],
[445417] = L["Ara-Kara, City of Echoes"],
[445441] = L["Darkflame Cleft"],

-- Mage teleports
[3561] = L["Stormwind"],
[3562] = L["Ironforge"],
Expand Down Expand Up @@ -221,7 +228,6 @@ local shortNames = {
[344587] = L["Oribos"],
[395277] = L["Valdrakken"],
[446540] = L["Dornogal"],

-- Mage portals
[10059] = L["Stormwind"],
[11416] = L["Ironforge"],
Expand All @@ -248,7 +254,7 @@ local shortNames = {
[281402] = L["Dazar'alor"],
[344597] = L["Oribos"],
[395289] = L["Valdrakken"],
[446534] = L["Dornogal"],
[446534] = L["Dornogal"]
}

local tpTable = {
Expand Down Expand Up @@ -379,7 +385,9 @@ local function createCooldownFrame(frame)
cooldownFrame:SetAllPoints()

function cooldownFrame:CheckCooldown(id, type)
if not id then return end
if not id then
return
end
local start, duration, enabled
if type == "toy" or type == "item" then
start, duration, enabled = C_Item.GetItemCooldown(id)
Expand Down Expand Up @@ -483,7 +491,7 @@ local function createFlyOutFrame()
if next(flyOutFramesPool) then
flyOutFrame = table.remove(flyOutFramesPool)
else
flyOutFrame = CreateFrame("Frame", "FlyOutFrame"..#flyOutFrames+1, TeleportMeButtonsFrame)
flyOutFrame = CreateFrame("Frame", "FlyOutFrame" .. #flyOutFrames + 1, TeleportMeButtonsFrame)
table.insert(flyOutFrames, flyOutFrame)
end

Expand Down Expand Up @@ -603,8 +611,10 @@ end

function tpm:GetIconText(spellId)
local text = shortNames[spellId]
if text then return text end
print(APPEND .. "No short name found for spellID " .. id ..", please report this on GitHub")
if text then
return text
end
print(APPEND .. "No short name found for spellID " .. id .. ", please report this on GitHub")
end

function tpm:GetAvailableHearthstoneToys()
Expand Down Expand Up @@ -760,7 +770,6 @@ function tpm:CreateSeasonalTeleportFlyout()
local xOffset = globalWidth * flyoutsCreated
flyOutButton:SetPoint("RIGHT", flyOutFrame, "LEFT", globalWidth + xOffset, 0)
end

end
flyOutFrame:SetSize(globalWidth + (globalWidth * flyoutsCreated), globalHeight)

Expand Down

0 comments on commit 41af74d

Please sign in to comment.