Skip to content

Commit

Permalink
Linked InstancePortalAdvanced Pin visibility on Continent Maps to the…
Browse files Browse the repository at this point in the history
… Native "Show Dungeon Entrace" CVar

We can now toogle Dungeon Entrances with Blizzard's internal Settings
  • Loading branch information
fuba82 committed Jul 29, 2024
1 parent 82454b2 commit 9ed7c3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 75 deletions.
68 changes: 0 additions & 68 deletions IPACore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,79 +37,11 @@ function InstancePortalAdvUI_OnLoad(self)

IPAUIPrintDebug("InstancePortalAdvUI_OnLoad()")
WorldMapFrame:AddDataProvider(CreateFromMixins(IPAInstancePortalMapDataProviderMixin));
--hooksecurefunc("ToggleDropDownMenu", IPAUIDropDownInit)

end

function InstancePortalAdvUI_OnEvent(event, arg1)
if event == "ADDON_LOADED" then
--[[
if IPAUITrackInstancePortals == nil then
IPAUIPrintDebug("IPUISetDefaults()")
IPAUITrackInstancePortals = true
IPAUITrackInstancePortalsOnContinents = true
end
]]

IPAUIPrintDebug("ADDON_LOADED()")

IPAUITrackInstancePortals = true
IPAUITrackInstancePortalsOnContinents = true

RegisterCVar("IPAUITrackInstancePortals")
RegisterCVar("IPAUITrackInstancePortalsOnContinents")
end
end

function IPAUIDropDownInit(_, _, dropDownFrame, _, _, _, _, clickedButton)
local trackingOptionsFrame = WorldMapFrame.overlayFrames[2]
local trackingOptionsMenu = trackingOptionsFrame.DropDown

IPAUIPrintDebug("IPAUIDropDownInit")

local function OnSelection(button)
if button.value == "IPAUITrackInstancePortals" then
IPAUITrackInstancePortals = button.checked
else
IPAUITrackInstancePortalsOnContinents = button.checked
end

SetCVar(button.value, button.checked and "1" or "0", "INSTANCE_PORTAL_REFRESH");
WorldMapFrame:RefreshAllDataProviders()
end

if dropDownFrame == trackingOptionsMenu then

local info = UIDropDownMenu_CreateInfo();

UIDropDownMenu_AddSeparator();
info.isTitle = true;
info.notCheckable = true;
info.text = DUNGEONS.." / "..RAIDS;
info.isNotRadio = true;
UIDropDownMenu_AddButton(info);

info = UIDropDownMenu_CreateInfo();
info.isTitle = nil;
info.notCheckable = nil;
info.text = "Show on Zone Map"; --BATTLEFIELD_MINIMAP
info.isNotRadio = true;
info.checked = IPAUITrackInstancePortals;
info.func = OnSelection;
info.keepShownOnClick = true;
info.value = "IPAUITrackInstancePortals";
--UIDropDownMenu_AddButton(info);

info = UIDropDownMenu_CreateInfo();
info.isTitle = nil;
info.notCheckable = nil;
info.text = "Show on Continent Map"; --WORLD_MAP
info.isNotRadio = true;
info.checked = IPAUITrackInstancePortalsOnContinents;
info.func = OnSelection;
info.keepShownOnClick = true;
info.value = "IPAUITrackInstancePortalsOnContinents";
UIDropDownMenu_AddButton(info);
end
end

Expand Down
13 changes: 6 additions & 7 deletions IPAInstancePortalPinTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
function IPAInstancePortalMapDataProviderMixin:OnEvent(event, ...)
if event == "CVAR_UPDATE" then
local eventName, value = ...;
if eventName == "INSTANCE_PORTAL_REFRESH" then
if eventName == "showDungeonEntrancesOnMap" then
self:RefreshAllData();
end
end
Expand All @@ -26,8 +26,7 @@ function IPAInstancePortalMapDataProviderMixin:RefreshAllData(fromOnShow)
self:RemoveAllData();
IPAUIPrintDebug("IPAInstancePortalMapDataProviderMixin:RefreshAllData")

local trackOnZones = IPAUITrackInstancePortals
local trackOnContinents = IPAUITrackInstancePortalsOnContinents
local showDungeonEntrancesOnMap = C_CVar and C_CVar.GetCVarBool("showDungeonEntrancesOnMap") or false

local mapID = self:GetMap():GetMapID();
IPAUIPrintDebug("Map ID = "..mapID)
Expand Down Expand Up @@ -66,7 +65,7 @@ function IPAInstancePortalMapDataProviderMixin:RefreshAllData(fromOnShow)
isWhitelisted = false
end

if (isContinent and trackOnContinents) or (not isContinent and trackOnZones) then
if showDungeonEntrancesOnMap then
if (isWhitelisted) then
local pin = self:GetMap():AcquirePin("IPAInstancePortalPinTemplate", entranceInfo);
pin.dataProvider = self;
Expand Down Expand Up @@ -216,9 +215,9 @@ local function WaypointDungeonEntrancePinMixin(self, button)
local useTomTom = true
if IPASettings and IPASettings.options then
useTomTom = IPASettings.options.useTomTom and (TomTom ~= nil) or false
end
end
IPAUIPrintDebug("useTomTom: "..tostring(useTomTom))

if (useTomTom == true) then
local wp_mapid, wp_x, wp_y, wp_name
local uiMapID = self:GetMap():GetMapID();
Expand Down Expand Up @@ -247,7 +246,7 @@ local function WaypointDungeonEntrancePinMixin(self, button)
wp_x, wp_y = self:GetPosition()
wp_name = self.name or "Waypoint"
end

IPAUIPrintDebug("\nWaypoint Info:\n MapID: "..wp_mapid.."\n X: "..wp_x.."\n Y: "..wp_y.."\n Name: "..wp_name.."\n System: "..(useTomTom and "TomTom" or "Blizzard").."\n")
AddTomTomWaypoint(wp_mapid, wp_x, wp_y, wp_name)
else
Expand Down

0 comments on commit 9ed7c3d

Please sign in to comment.