Skip to content

Commit

Permalink
API update
Browse files Browse the repository at this point in the history
  • Loading branch information
p3lim committed Nov 29, 2024
1 parent 33ebf02 commit 80257c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 61 deletions.
61 changes: 5 additions & 56 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,65 +58,14 @@ local settings = {
tooltip = L['Hold this key to temporarily hide all world quests'],
default = 'ALT',
options = {
NEVER = NEVER,
ALT = ALT_KEY,
CTRL = CTRL_KEY,
SHIFT = SHIFT_KEY,
{value='NEVER', label=NEVER},
{value='ALT', label=ALT_KEY},
{value='CTRL', label=CTRL_KEY},
{value='SHIFT', label=SHIFT_KEY},
},
},
}

addon:RegisterSettings('BetterWorldQuestsDB', settings)
addon:RegisterSettingsSlash('/betterworldquests', '/bwq')

-- custom menu element for a slider
-- since the slider needs to be quite wide in order to be functional it's added to a sub-menu
local function createSlider(root, name, getter, setter, minValue, maxValue, steps, formatter)
local element = root:CreateButton(name):CreateFrame()
element:AddInitializer(function(frame)
local slider = frame:AttachTemplate('MinimalSliderWithSteppersTemplate')
slider:SetPoint('TOPLEFT', 0, -1)
slider:SetSize(150, 25)
slider:RegisterCallback('OnValueChanged', setter, frame)
slider:Init(getter(), minValue, maxValue, (maxValue - minValue) / steps, {
[MinimalSliderWithSteppersMixin.Label.Right] = formatter
})

-- there's no way to properly reset an element from the menu, so we'll need to use
-- a dummy element we can hook OnHide onto, and also to increase the total width
-- of the element so the right label doesn't go out of the bounds of the menu.
-- see https://github.com/Stanzilla/WoWUIBugs/issues/652
local dummy = frame:AttachFrame('Frame')
dummy:SetPoint('TOPLEFT', slider)
dummy:SetPoint('BOTTOMLEFT', slider)
dummy:SetWidth(180)
dummy:SetScript('OnHide', function()
slider:UnregisterCallback('OnValueChanged', frame)
slider:Release()
end)
end)

return element
end

-- inject some of the settings into the tracking menu
Menu.ModifyMenu('MENU_WORLD_MAP_TRACKING', function(_, root)
root:CreateDivider()
root:CreateTitle((addonName:gsub('(%l)(%u)', '%1 %2')) .. HEADER_COLON)

for _, setting in next, settings do
if setting.type == 'toggle' then
root:CreateCheckbox(setting.title, function()
return addon:GetOption(setting.key)
end, function()
addon:SetOption(setting.key, not addon:GetOption(setting.key))
end)
elseif setting.type == 'slider' then
createSlider(root, setting.title, function()
return addon:GetOption(setting.key)
end, function(_, value)
addon:SetOption(setting.key, value)
end, setting.minValue, setting.maxValue, setting.valueStep, setting.valueFormat)
end
end
end)
addon:RegisterMapSettings('BetterWorldQuestsDB', settings)
7 changes: 2 additions & 5 deletions storms.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local _, addon = ...
local HBD = LibStub('HereBeDragons-2.0')

local DRAGON_ISLES_MAPS = {
Expand All @@ -7,18 +8,14 @@ local DRAGON_ISLES_MAPS = {
[2025] = true, -- Thaldraszus
}

local function startsWith(str, start)
return string.sub(str, 1, string.len(start)) == start
end

local function updatePOIs(self)
local map = self:GetMap()
local mapID = map:GetMapID()
if mapID == 1978 then -- Dragon Isles
for childMapID in next, DRAGON_ISLES_MAPS do
for _, poiID in next, C_AreaPoiInfo.GetAreaPOIForMap(childMapID) do
local info = C_AreaPoiInfo.GetAreaPOIInfo(childMapID, poiID)
if info and startsWith(info.atlasName, 'ElementalStorm') then
if info and addon:startswith(info.atlasName, 'ElementalStorm') then
local x, y = info.position:GetXY()
info.dataProvider = self
info.position:SetXY(HBD:TranslateZoneCoordinates(x, y, childMapID, mapID))
Expand Down

0 comments on commit 80257c8

Please sign in to comment.