Skip to content

Commit

Permalink
TOC Update
Browse files Browse the repository at this point in the history
first Fix deployed
maybe need some rework after TomTom is fixed
  • Loading branch information
fuba82 committed Jul 25, 2024
1 parent 0856a07 commit 9b360ac
Showing 1 changed file with 104 additions and 94 deletions.
198 changes: 104 additions & 94 deletions IPAInstancePortalPinTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function IPAInstancePortalMapDataProviderMixin:RefreshAllData(fromOnShow)

if (isContinent and trackOnContinents) or (not isContinent and trackOnZones) then
if (isWhitelisted) then
self:GetMap():AcquirePin("IPAInstancePortalPinTemplate", entranceInfo);
local pin = self:GetMap():AcquirePin("IPAInstancePortalPinTemplate", entranceInfo);
pin.dataProvider = self;
end
end
end
Expand All @@ -78,8 +79,18 @@ function IPAInstancePortalMapDataProviderMixin:RefreshAllData(fromOnShow)
end

-- local function for "Add Waypoints" with the feature to "force" Built-In Waypoint System, just set "useTomTom" to false or leave it blank
local function AddWaypoint(mapID, x, y, title, useTomTom)
if (useTomTom == true) and TomTom then
local function AddNativeWaypoint(mapID, x, y)
if C_Map.CanSetUserWaypointOnMap(mapID) then
local vector = CreateVector2D(x, y)
local mapPoint = UiMapPoint.CreateFromVector2D(mapID, vector)
C_Map.SetUserWaypoint(mapPoint)
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
PlaySound(SOUNDKIT.UI_MAP_WAYPOINT_SUPER_TRACK_ON);
end
end

local function AddTomTomWaypoint(mapID, x, y, title)
if TomTom then
title = title or "Waypoint"
TomTom:AddWaypoint(mapID, x, y, {
title = title,
Expand All @@ -88,14 +99,6 @@ local function AddWaypoint(mapID, x, y, title, useTomTom)
world = true,
from = addonName or "InstancePortalsAdvanced"
})
else -- if TomTom is not installed or useTomTom is false you the Built-In Waypoint System
if C_Map.CanSetUserWaypointOnMap(mapID) then
local vector = CreateVector2D(x, y)
local mapPoint = UiMapPoint.CreateFromVector2D(mapID, vector)
C_Map.SetUserWaypoint(mapPoint)
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
PlaySound(SOUNDKIT.UI_MAP_WAYPOINT_SUPER_TRACK_ON);
end
end
end

Expand All @@ -106,42 +109,47 @@ IPAInstancePortalProviderPinMixin = BaseMapPoiPinMixin:CreateSubPin("PIN_FRAME_L
function IPAInstancePortalProviderPinMixin:OnAcquired(dungeonEntranceInfo) -- override
BaseMapPoiPinMixin.OnAcquired(self, dungeonEntranceInfo);

local poiInfo = self:GetPoiInfo();
self.poiInfo = poiInfo;
self:SetDataProvider(poiInfo.dataProvider);

self.hub = dungeonEntranceInfo.hub
self.tier = dungeonEntranceInfo.tier;
self.journalInstanceID = dungeonEntranceInfo.journalInstanceID;
self.isRaid = select(11, EJ_GetInstanceInfo(self.journalInstanceID));
end

function IPAInstancePortalProviderPinMixin:OnClick(button)
function IPAInstancePortalProviderPinMixin:OnMouseClickAction(button)
if (not button) then return end

local useWaypoints = true
local useTomTom = true
if IPASettings and IPASettings.options then
useWaypoints = IPASettings.options.useWaypoints
useTomTom = IPASettings.options.useTomTom and (TomTom ~= nil) or false
end
if (button == "LeftButton") then
local useWaypoints = true
local useTomTom = true
if IPASettings and IPASettings.options then
useWaypoints = IPASettings.options.useWaypoints
useTomTom = IPASettings.options.useTomTom and (TomTom ~= nil) or false
end

local wp_mapid, wp_x, wp_y, wp_name
IPAUIPrintDebug("IPAInstancePortalProviderPinMixin:OnClick, button: "..button)
IPAUIPrintDebug("IPAInstancePortalProviderPinMixin:OnClick, self.hub: "..self.hub)
local wp_mapid, wp_x, wp_y, wp_name
IPAUIPrintDebug("IPAInstancePortalProviderPinMixin:OnMouseClickAction, button: "..tostring(button))
IPAUIPrintDebug("IPAInstancePortalProviderPinMixin:OnMouseClickAction, self.hub: "..tostring(self.hub))

if self.hub == 0 then
if (button == "LeftButton" and IsShiftKeyDown() and useWaypoints == true) then
local uiMapID = self:GetMap():GetMapID();
if self.hub == 0 then
local uiMapID = self:GetMap():GetMapID();
IPAUIPrintDebug("uiMapID: "..uiMapID)
if not uiMapID then return end
if not uiMapID then return end

local journalInstanceID = self.journalInstanceID
IPAUIPrintDebug("self.journalInstanceID: "..journalInstanceID)
if not journalInstanceID then return end
if not journalInstanceID then return end

-- function C_Map.GetMapChildrenInfo(uiMapID, optional mapType, optional allDescendants)
local mapChildren = C_Map.GetMapChildrenInfo(uiMapID, Enum.UIMapType.Zone) -- get current map children
if ( (type(mapChildren) ~= 'table') or (#mapChildren < 1) ) then return end -- mapChildren is not table or empty
local mapChildren = C_Map.GetMapChildrenInfo(uiMapID, Enum.UIMapType.Zone) -- get current map children
if ( (type(mapChildren) ~= 'table') or (#mapChildren < 1) ) then return end -- mapChildren is not table or empty

if journalInstanceID == 1179 then -- special case "The Eternal Palace"
if (journalInstanceID == 1179) then -- special case "The Eternal Palace"
local name = EJ_GetInstanceInfo(1179) or "The Eternal Palace"

wp_mapid = 1355
wp_x = (0.50369811058044)
wp_y = (0.12483072280884)
Expand All @@ -168,7 +176,7 @@ function IPAInstancePortalProviderPinMixin:OnClick(button)
end

-- if anything is missing, TRY to use Pin itself as Source
if (not wp_mapid) or (not wp_x) or (not wp_y) or (not wp_name) then
if (not wp_mapid) or (not wp_x) or (not wp_y) or (not wp_name) then
IPAUIPrintDebug("Waypoint Info is missing, try to use PIN as Source")
if (not wp_mapid) then IPAUIPrintDebug("Missing: wp_mapid") end
if (not wp_x) then IPAUIPrintDebug("Missing: wp_x") end
Expand All @@ -179,80 +187,82 @@ function IPAInstancePortalProviderPinMixin:OnClick(button)
wp_x, wp_y = self:GetPosition()
wp_name = self.name or "Waypoint"
end
else -- not ""LeftButton" and IsShiftKeyDown()" or "useWaypoints == false" then open Encounter Journal
if ( not EncounterJournal ) then
EncounterJournal_LoadUI();
end
EncounterJournal_OpenJournal(nil, self.journalInstanceID)
_G.EncounterJournal:SetScript("OnShow", nil)
end
else -- if self.hub ~= 0, try to use Map Pin itself as Source
if (button == "LeftButton" and IsShiftKeyDown() and useWaypoints == true) then
wp_mapid = self:GetMap():GetMapID();
wp_x, wp_y = self:GetPosition()
wp_name = self.name or "Waypoint"
end
end

-- check for all needed Variables and Add Waypoint if all Variables are present
if (button == "LeftButton" and IsShiftKeyDown() and useWaypoints == true) and wp_mapid and wp_x and wp_y and wp_name then
else -- if self.hub ~= 0, try to use Map Pin itself as Source
wp_mapid = self:GetMap():GetMapID();
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")
AddWaypoint(wp_mapid, wp_x, wp_y, wp_name, useTomTom)
end
end

-- Waypoint Function for Blizzard Dungeon Entrance Pins
local function WaypointDungeonEntrancePinMixin(self, button)
if (not self) or (not button) then return end
if useTomTom ~= true then
AddNativeWaypoint(wp_mapid, wp_x, wp_y)
else
AddTomTomWaypoint(wp_mapid, wp_x, wp_y, wp_name)
end

local useWaypoints = true
local useTomTom = true
if IPASettings and IPASettings.options then
useWaypoints = IPASettings.options.useWaypoints
useTomTom = IPASettings.options.useTomTom and (TomTom ~= nil) or false
elseif (button == "RightButton") then
EncounterJournal_LoadUI();
EncounterJournal_OpenJournal(nil, self.journalInstanceID);
end

local wp_mapid, wp_x, wp_y, wp_name
if (button == "LeftButton" and IsShiftKeyDown() and useWaypoints == true) then
local uiMapID = self:GetMap():GetMapID();
local journalInstanceID = self.journalInstanceID

local dungeonEntrances = C_EncounterJournal.GetDungeonEntrancesForMap(uiMapID);
for i, dungeonEntranceInfo in ipairs(dungeonEntrances) do
if dungeonEntranceInfo.journalInstanceID == journalInstanceID then
IPAUIPrintDebug("InstanceID: "..journalInstanceID)
wp_mapid = uiMapID
wp_x = dungeonEntranceInfo.position.x
wp_y = dungeonEntranceInfo.position.y
wp_name = dungeonEntranceInfo.name or "Waypoint"
end
end
end

-- if anything is missing, TRY to use Pin itself as Source
if (not wp_mapid) or (not wp_x) or (not wp_y) or (not wp_name) then
IPAUIPrintDebug("Waypoint Info is missing, try to use PIN as Source")
if (not wp_mapid) then IPAUIPrintDebug("Missing: wp_mapid") end
if (not wp_x) then IPAUIPrintDebug("Missing: wp_x") end
if (not wp_y) then IPAUIPrintDebug("Missing: wp_y") end
if (not wp_name) then IPAUIPrintDebug("Missing: wp_name") end

wp_mapid = self:GetMap():GetMapID();
wp_x, wp_y = self:GetPosition()
wp_name = self.name or "Waypoint"
end
-- temporary disabled until tomtom is fixed and not need for "new" Native Supertracked POI's
--[[
-- Waypoint Function for Blizzard Dungeon Entrance Pins
local function WaypointDungeonEntrancePinMixin(self, button)
if (not self) or (not button) then return end
else -- not ""LeftButton" and IsShiftKeyDown()" or "useWaypoints == false" then open Encounter Journal
if ( not EncounterJournal ) then
EncounterJournal_LoadUI();
if (button == "LeftButton") then
local useWaypoints = true
local useTomTom = true
if IPASettings and IPASettings.options then
useWaypoints = IPASettings.options.useWaypoints
useTomTom = IPASettings.options.useTomTom and (TomTom ~= nil) or false
end
EncounterJournal_OpenJournal(nil, self.journalInstanceID)
_G.EncounterJournal:SetScript("OnShow", nil)
end
if (useTomTom ~= true) then
SuperTrackablePinMixin.OnMouseClickAction(self, button);
else
local wp_mapid, wp_x, wp_y, wp_name
if (button == "LeftButton" and IsShiftKeyDown() and useWaypoints == true) then
local uiMapID = self:GetMap():GetMapID();
local journalInstanceID = self.journalInstanceID
local dungeonEntrances = C_EncounterJournal.GetDungeonEntrancesForMap(uiMapID);
for i, dungeonEntranceInfo in ipairs(dungeonEntrances) do
if dungeonEntranceInfo.journalInstanceID == journalInstanceID then
IPAUIPrintDebug("InstanceID: "..journalInstanceID)
wp_mapid = uiMapID
wp_x = dungeonEntranceInfo.position.x
wp_y = dungeonEntranceInfo.position.y
wp_name = dungeonEntranceInfo.name or "Waypoint"
end
end
if (button == "LeftButton" and IsShiftKeyDown() and useWaypoints == true) and wp_mapid and wp_x and wp_y and wp_name then
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")
AddWaypoint(wp_mapid, wp_x, wp_y, wp_name, useTomTom)
-- if anything is missing, TRY to use Pin itself as Source
if (not wp_mapid) or (not wp_x) or (not wp_y) or (not wp_name) then
IPAUIPrintDebug("Waypoint Info is missing, try to use PIN as Source")
if (not wp_mapid) then IPAUIPrintDebug("Missing: wp_mapid") end
if (not wp_x) then IPAUIPrintDebug("Missing: wp_x") end
if (not wp_y) then IPAUIPrintDebug("Missing: wp_y") end
if (not wp_name) then IPAUIPrintDebug("Missing: wp_name") end
wp_mapid = self:GetMap():GetMapID();
wp_x, wp_y = self:GetPosition()
wp_name = self.name or "Waypoint"
end
end
AddTomTomWaypoint(wp_mapid, wp_x, wp_y, wp_name)
end
elseif button == "RightButton" then
EncounterJournal_LoadUI();
EncounterJournal_OpenJournal(nil, self.journalInstanceID);
end
end
_G.DungeonEntrancePinMixin.OnMouseClickAction = WaypointDungeonEntrancePinMixin
_G.DungeonEntrancePinMixin.OnMouseClickAction = WaypointDungeonEntrancePinMixin
]]

0 comments on commit 9b360ac

Please sign in to comment.