diff --git a/TomTom.lua b/TomTom.lua index 370b07f..cf8ac5f 100755 --- a/TomTom.lua +++ b/TomTom.lua @@ -120,6 +120,10 @@ function TomTom:ADDON_LOADED(event, addon) arrow = false, arrow_throttle = 0.1, }, + poi = { + enable = true, + modifier = "C", + }, }, } @@ -196,7 +200,7 @@ function TomTom:ReloadOptions() self:ShowHideWorldCoords() self:ShowHideCoordBlock() self:ShowHideCrazyArrow() - + self:EnableDisablePOIIntegration() end function TomTom:ReloadWaypoints() @@ -1097,5 +1101,3 @@ SlashCmdList["TOMTOM_WAY"] = function(msg) return usage() end end - --- Fix for curseforge fingerprinting diff --git a/TomTom.toc b/TomTom.toc index ef97744..44ca822 100755 --- a/TomTom.toc +++ b/TomTom.toc @@ -31,5 +31,6 @@ TomTom.lua TomTom_Waypoints.lua TomTom_CrazyArrow.lua TomTom_Corpse.lua +TomTom_POIIntegration.lua TomTom_Config.lua diff --git a/TomTom_Config.lua b/TomTom_Config.lua index 13d16d0..f8b3015 100644 --- a/TomTom_Config.lua +++ b/TomTom_Config.lua @@ -36,6 +36,8 @@ local function createconfig() TomTom:ShowHideWorldCoords() elseif ns == "arrow" then TomTom:ShowHideCrazyArrow() + elseif ns == "poi" then + TomTom:EnableDisablePOIIntegration() elseif opt == "otherzone" then TomTom:ReloadWaypoints() elseif info.arg == "minimap.enable" or info.arg == "worldmap.enable" then @@ -611,9 +613,49 @@ local function createconfig() }, } - options.args.profile = { + options.args.poi = { type = "group", order = 6, + name = L["Quest Objectives"], + desc = L["Options that alter quest objective integration"], + get = get, + set = set, + args = { + desc = { + order = 1, + type = "description", + name = L["TomTom can be configured to set waypoints for the quest objectives that are shown in the watch frame and on the world map. These options can be used to configure these options."], + }, + enable = { + order = 2, + type = "toggle", + name = L["Enable quest objective integration"], + desc = L["Enables the setting of waypoints when modified-clicking on quest objectives"], + width = "double", + arg = "poi.enable", + }, + modifier = { + type = "select", + order = 3, + name = L["set waypoint modifier"], + desc = L["This setting changes the modifier used by TomTom when right-clicking on a quest objective POI to create a waypoint"], + values = { + ["A"] = "Alt", + ["C"] = "Ctrl", + ["S"] = "Shift", + ["AC"] = "Alt-Ctrl", + ["AS"] = "Alt-Shift", + ["CS"] = "Ctrl-Shift", + ["ACS"] = "Alt-Ctrl-Shift", + }, + arg = "poi.modifier", + }, + }, + } -- End POI Integration settings + + options.args.profile = { + type = "group", + order = 7, name = L["Profile Options"], args = { desc = { @@ -682,6 +724,9 @@ local function createBlizzOptions() config:RegisterOptionsTable("TomTom-Feeds", options.args.feeds) dialog:AddToBlizOptions("TomTom-Feeds", options.args.feeds.name, "TomTom") + -- POI Options + config:RegisterOptionsTable("TomTom-POI", options.args.poi) + dialog:AddToBlizOptions("TomTom-POI", options.args.poi.name, "TomTom") -- Profile Options local p_options = options.args.profile.args.options diff --git a/TomTom_POIIntegration.lua b/TomTom_POIIntegration.lua new file mode 100644 index 0000000..529b0af --- /dev/null +++ b/TomTom_POIIntegration.lua @@ -0,0 +1,83 @@ +local function POIAnchorToCoord(poiframe) + local point, relto, relpoint, x, y = poiframe:GetPoint() + local frame = WorldMapDetailFrame + local width = frame:GetWidth() + local height = frame:GetHeight() + local scale = frame:GetEffectiveScale() + local cx = (x / scale) / width + local cy = (-y / scale) / height + + if cx < 0 or cx > 1 or cy < 0 or cy > 1 then + return nil, nil + end + + return cx * 100, cy * 100 +end + +local modTbl = { + C = IsControlKeyDown, + A = IsAltKeyDown, + S = IsShiftKeyDown, +} + +local hookEnabled = true; +local modifier; + +-- desc, persistent, minimap, world, custom_callbacks, silent, crazy) +local function poi_OnClick(self, button) + -- Are we enabled? + if not hookEnabled then + return + end + + -- Is this the right button/modifier? + if button == "RightButton" then + for i = 1, #modifier do + local mod = modifier:sub(i, i) + local func = modTbl[mod] + if not func() then + return + end + end + else + return + end + + if self.parentName == "WatchFrameLines" then + local questFrame = _G["WorldMapQuestFrame"..self.questLogIndex]; + local selected = WorldMapQuestScrollChildFrame.selected + local poiIcon = selected.poiIcon; + self = poiIcon + end + + local c, z = GetCurrentMapContinent(), GetCurrentMapZone(); + local x, y = POIAnchorToCoord(self) + + local qid = self.questId + + local title; + if self.quest.questLogIndex then + title = GetQuestLogTitle(self.quest.questLogIndex) + else + title = "Quest #" .. qid .. " POI" + end + + local uid = TomTom:AddZWaypoint(c, z, x, y, title) +end + +local hooked = {} +hooksecurefunc("QuestPOI_DisplayButton", function(parentName, buttonType, buttonIndex, questId) + local buttonName = "poi"..tostring(parentName)..tostring(buttonType).."_"..tostring(buttonIndex); + local poiButton = _G[buttonName]; + + if not hooked[buttonName] then + poiButton:HookScript("OnClick", poi_OnClick) + poiButton:RegisterForClicks("AnyUp") + hooked[buttonName] = true + end +end) + +function TomTom:EnableDisablePOIIntegration() + hookEnabled = TomTom.profile.poi.enable + modifier = TomTom.profile.poi.modifier +end