diff --git a/TomTom.lua b/TomTom.lua index f97b9f3..9ebdfc6 100755 --- a/TomTom.lua +++ b/TomTom.lua @@ -113,7 +113,9 @@ function TomTom:ADDON_LOADED(event, addon) }, feeds = { coords = false, + coords_throttle = 0.3, arrow = false, + arrow_throttle = 0.1, }, }, } @@ -158,7 +160,12 @@ function TomTom:ADDON_LOADED(event, addon) }) local coordFeedFrame = CreateFrame("Frame") - local throttle, counter = 0.5, 0 + local throttle, counter = self.db.profile.feeds.coords_throttle, 0 + + function TomTom:UpdateCoordFeedThrottle() + throttle = self.db.profile.feeds.coords_throttle + end + coordFeedFrame:SetScript("OnUpdate", function(self, elapsed) counter = counter + elapsed if counter < throttle then diff --git a/TomTom_Config.lua b/TomTom_Config.lua index 609a6a7..5bd0de9 100644 --- a/TomTom_Config.lua +++ b/TomTom_Config.lua @@ -40,6 +40,10 @@ local function createconfig() TomTom:ReloadWaypoints() elseif info.arg == "minimap.enable" or info.arg == "worldmap.enable" then TomTom:ReloadWaypoints() + elseif info.arg == "feeds.coords_throttle" then + TomTom:UpdateCoordFeedThrottle() + elseif info.arg == "feeds.arrow_throttle" then + TomTom:UpdateArrowFeedThrottle() end end @@ -497,13 +501,31 @@ local function createconfig() width = "double", arg = "feeds.coords", }, + coords_throttle = { + type = "range", + order = 3, + name = L["Coordinate feed throttle"], + desc = L["Controls the frequency of updates for the coordinate LDB feed."], + width = "double", + min = 0, max = 2.0, step = 0.05, + arg = "feeds.coords_throttle", + }, arrow = { type = "toggle", order = 3, name = L["Provide a LDB data source for the crazy-arrow"], width = "double", arg = "feeds.arrow", - } + }, + arrow_throttle = { + type = "range", + order = 3, + name = L["Crazy Arrow feed throttle"], + desc = L["Controls the frequency of updates for the crazy arrow LDB feed."], + width = "double", + min = 0, max = 2.0, step = 0.05, + arg = "feeds.arrow_throttle", + }, }, } diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua index 059dd8b..aed19d0 100644 --- a/TomTom_CrazyArrow.lua +++ b/TomTom_CrazyArrow.lua @@ -129,6 +129,7 @@ local last_distance = 0 local tta_throttle = 0 local speed = 0 local speed_count = 0 + local function OnUpdate(self, elapsed) if not active_point then self:Hide() @@ -349,13 +350,17 @@ local function init_dropdown(self, level) end end -wayframe:RegisterForClicks("RightButtonUp") -wayframe:SetScript("OnClick", function(self, button) - if TomTom.db.profile.arrow.menu then - UIDropDownMenu_Initialize(TomTom.dropdown, init_dropdown) - ToggleDropDownMenu(1, nil, TomTom.dropdown, "cursor", 0, 0) +local function WayFrame_OnClick(self, button) + if active_point then + if TomTom.db.profile.arrow.menu then + UIDropDownMenu_Initialize(TomTom.dropdown, init_dropdown) + ToggleDropDownMenu(1, nil, TomTom.dropdown, "cursor", 0, 0) + end end -end) +end + +wayframe:RegisterForClicks("RightButtonUp") +wayframe:SetScript("OnClick", WayFrame_OnClick) local function getCoords(column, row) local xstart = (column * 56) / 512 @@ -366,7 +371,8 @@ local function getCoords(column, row) end local texcoords = setmetatable({}, {__index = function(t, k) - local col,row = k:match("(%d):(%d)") + local col,row = k:match("(%d+):(%d+)") + col,row = tonumber(col), tonumber(row) local obj = {getCoords(col, row)} rawset(t, k, obj) return obj @@ -392,11 +398,17 @@ wayframe:SetScript("OnEvent", function(self, event, arg1, ...) tooltip:AddLine(sformat(L["%d yards"], dist), 1, 1, 1) end end, + OnClick = WayFrame_OnClick, }) local crazyFeedFrame = CreateFrame("Frame") - local throttle = 0.5 + local throttle = TomTom.db.profile.feeds.arrow_throttle local counter = 0 + + function TomTom:UpdateArrowFeedThrottle() + throttle = TomTom.db.profile.feeds.arrow_throttle + end + crazyFeedFrame:SetScript("OnUpdate", function(self, elapsed) counter = counter + elapsed if counter < throttle then @@ -404,7 +416,7 @@ wayframe:SetScript("OnEvent", function(self, event, arg1, ...) end counter = 0 - + local angle = TomTom:GetDirectionToWaypoint(active_point) local player = GetPlayerBearing() if not angle or not player then