From a2a7e7fe70a11a928af5f3bf37049efe771f90b5 Mon Sep 17 00:00:00 2001 From: Mokulu Date: Wed, 26 Aug 2020 23:30:52 -0700 Subject: [PATCH] Added icon scale config. Fixed rare draw on load issue. --- Locale/enUS.lua | 4 +++ Settings.lua | 38 ++++++++++++++++++++++---- TownsfolkTracker.lua | 35 +++++++++++++++++++++++- TownsfolkTracker.toc | 4 +-- changehistory.md | 64 -------------------------------------------- changelog.md | 8 +++--- 6 files changed, 77 insertions(+), 76 deletions(-) delete mode 100644 changehistory.md diff --git a/Locale/enUS.lua b/Locale/enUS.lua index 7c66eca..36843ea 100644 --- a/Locale/enUS.lua +++ b/Locale/enUS.lua @@ -1671,3 +1671,7 @@ L["Toggles the display of dungeons and raids on the fully zoomed out world map." L["Reset Tracking"] = true L["Tracking menu bugged after an update? Click here to reset it to the default."] = true L["Tracking list reset."] = true +L["World Map Tracker Scale"] = true +L["Changes the scale of townsfolk icons on the world map."] = true +L["Minimap Tracker Scale"] = true +L["Changes the scale of townsfolk icons on the minimap."] = true diff --git a/Settings.lua b/Settings.lua index 5fc1c40..32d8878 100644 --- a/Settings.lua +++ b/Settings.lua @@ -60,10 +60,36 @@ TF_SETTINGS_MENU = { set = "ToggleShowAllClassTrainers", order = 2, }, + mapScale = { + type = "range", + name = L["World Map Tracker Scale"], + desc = L["Changes the scale of townsfolk icons on the world map."], + min = 0.5, + max = 2, + step = 0.01, + bigStep = 0.1, + get = "GetMapIconScale", + set = "SetMapIconScale", + isPercent = true, + order = 3, + }, + minimapScale = { + type = "range", + name = L["Minimap Tracker Scale"], + desc = L["Changes the scale of townsfolk icons on the minimap."], + min = 0.5, + max = 2, + step = 0.01, + bigStep = 0.1, + get = "GetMinimapIconScale", + set = "SetMinimapIconScale", + isPercent = true, + order = 4, + }, worldDesc = { name = L["WorldMapDescription"], type = "description", - order = 3, + order = 5, }, useWorldMap = { type = "toggle", @@ -72,7 +98,7 @@ TF_SETTINGS_MENU = { width = "full", get = "IsUseWorldMap", set = "ToggleUseWorldMap", - order = 4, + order = 6, }, showMapButton = { type = "toggle", @@ -84,7 +110,7 @@ TF_SETTINGS_MENU = { disabled = function() return not TownsfolkTracker.db.profile.useWorldMap end, - order = 5, + order = 7, }, showInstancesOnWorld = { type = "toggle", @@ -96,14 +122,14 @@ TF_SETTINGS_MENU = { disabled = function() return not TownsfolkTracker.db.profile.useWorldMap end, - order = 6, + order = 8, }, resetTracking = { type = "execute", name = L["Reset Tracking"], desc = L["Tracking menu bugged after an update? Click here to reset it to the default."], func = "ResetTracking", - order = 7, + order = 9, } }, } @@ -117,5 +143,7 @@ TF_SETTINGS_DEFAULTS = { showInstanceOnWorldMap = true, minimapPos = 315, useWorldMap = true, + mapScale = 1.0, + minimapScale = 1.0, }, } diff --git a/TownsfolkTracker.lua b/TownsfolkTracker.lua index 8ebe319..267fed7 100644 --- a/TownsfolkTracker.lua +++ b/TownsfolkTracker.lua @@ -51,6 +51,8 @@ SlashCmdList["TOWNSFOLK"] = function(msg) InterfaceOptionsFrame_OpenToCategory("Townsfolk Tracker") end +TownsfolkTracker.iconsCreated = false + -- Initialize addon function TownsfolkTracker:OnInitialize() -- Register options @@ -128,6 +130,26 @@ function TownsfolkTracker:ResetTracking(info) self:DrawMapIcons() end +function TownsfolkTracker:GetMapIconScale(info) + return self.db.profile.mapScale +end + +function TownsfolkTracker:SetMapIconScale(info, value) + self.db.profile.mapScale = value + TownsfolkTracker:CreateIcons() + self:DrawMapIcons() +end + +function TownsfolkTracker:GetMinimapIconScale(info) + return self.db.profile.minimapScale +end + +function TownsfolkTracker:SetMinimapIconScale(info, value) + self.db.profile.minimapScale = value + TownsfolkTracker:CreateIcons() + self:DrawMapIcons() +end + -- On Enable of addon function TownsfolkTracker:OnEnable() -- Register minimap icon @@ -274,21 +296,25 @@ function TownsfolkTracker:CreateMapMarker(iconType, point, townsfolk, folktype, -- marker size if (iconType == TF_ATLAS_ICON) then + -- world map local size = 10 if (point.iconSize) then size = size * point.iconSize elseif (townsfolk.iconSize) then size = size * townsfolk.iconSize end + size = size * TownsfolkTracker:GetMapIconScale(); marker:SetWidth(size) marker:SetHeight(size) else + -- minimap local size = 12 if (point.iconSize) then size = size * point.iconSize elseif (townsfolk.iconSize) then size = size * townsfolk.iconSize end + size = size * TownsfolkTracker:GetMinimapIconScale(); marker:SetWidth(size) marker:SetHeight(size) end @@ -363,6 +389,8 @@ function TownsfolkTracker:CreateIcons() end end end + + self.iconsCreated = true end function TownsfolkTracker:DrawMapIcons() @@ -426,6 +454,11 @@ local INSTANCE_DISTANCE = 0.025 -- runs when player changes maps function TownsfolkTracker:DrawDungeonMinimapIcons(mapId) + -- don't try to draw icons before they're created + if not self.iconsCreated then + return + end + local x, y = Maps:GetPlayerZonePosition() Pins:RemoveAllMinimapIcons("TownsfolkTrackerInternal") for folktype, townsfolk in pairs(TOWNSFOLK) do @@ -436,7 +469,7 @@ function TownsfolkTracker:DrawDungeonMinimapIcons(mapId) if (point.entrance and mapId == point.entrance.zone) then -- find the distance local distance, deltaX, deltaY = Maps:GetWorldDistance(mapId, x, y, point.entrance.x, point.entrance.y) - if (distance <= INSTANCE_DISTANCE) then + if (distance <= INSTANCE_DISTANCE and point.entranceNode) then Pins:AddMinimapIconMap("TownsfolkTrackerInternal", point.entranceNode, point.entrance.zone, point.entrance.x, point.entrance.y, true, true) end end diff --git a/TownsfolkTracker.toc b/TownsfolkTracker.toc index f3024cb..b43d039 100644 --- a/TownsfolkTracker.toc +++ b/TownsfolkTracker.toc @@ -1,8 +1,8 @@ -## Interface: 11302 +## Interface: 11305 ## Title: Townsfolk Tracker ## Notes: Allows tracking of townsfolk NPCs on the map and minimap. ## Author: Mokulu -## Version: 1.0.7 +## Version: 1.0.8 ## SavedVariables: TownsfolkTrackerDB ## SavedVariablesPerCharacter: tfTrackingList diff --git a/changehistory.md b/changehistory.md deleted file mode 100644 index ecfc924..0000000 --- a/changehistory.md +++ /dev/null @@ -1,64 +0,0 @@ -## Townsfolk Tracker v1 - -[See the latest version's changes here.](https://bitbucket.org/jsiebert9/townsfolk-tracker/src/master/changelog.md) - -### v1.0.6 (Sept. 24, 2019) -* Added a slash command to open the addon's interface options: /townsfolktracker, /townsfolk, /tt -* Tentatively fixed the taint issue with various unit frames (CompactRaidFrame, etc.). -* Fixed display conflicts of the Map button with other addons. -* Updated Chinese localization up to version 1.0.5; translations by [急云](https://www.curseforge.com/members/q09q09) -* Added Traditional Chinese localization up to version 1.0.5, not including NPC names; translations by [急云](https://www.curseforge.com/members/q09q09) - - -### v1.0.5 (Sept. 21, 2019) -* Added Swamp of Sorrows NPCs -* Added The Hinterlands NPCs -* Added Western Plaguelands NPCs -* Added Blasted Lands NPCs -* Added Stonetalon Peak, Stonetalon Mountains NPCs -* Added Brackenwall Village, Dustwallow Marsh NPCs -* Added Bloodvenom Post, Felwood NPCs -* Added a few missing NPCs in: - * Thunderbluff - * Desolace (Horde) - * Tirisfal Glades - * Sun Rock Retreat, Stonetalon Mountains -* Fixed the doubled mailbox in Theramore Isle -* Updated Chinese localization up to version 1.0.4; translations by [急云](https://www.curseforge.com/members/q09q09) - -### v1.0.4 (Sept. 17, 2019) -* Added Alterac Mountains NPCs -* Added Alliance Hillsbrad Foothills NPCs -* Added Alliance Arathi Highlands NPCs -* Added Shadowprey Village, Desolace NPCs (Horde) -* Added remaining Azshara NPCs (Horde, neutrals) -* Added a few missing Elwynn Forest NPCs -* Added Chinese localization up to version 1.0.3; translations by [急云](https://www.curseforge.com/members/q09q09) - -### v1.0.3 (Sept. 15, 2019) -* Added Darkshore NPCs -* Added Redridge Mountains NPCs -* Added Duskwood NPCs -* Added Alliance Ashenvale NPCs -* Added Alliance Azshara NPCs -* Added Theramore Isle, Dustwallow Marsh NPCs -* Added Alliance Arathi Highlands NPCs -* Added several missing NPCs to Stranglethorn Vale -* Added several missing NPCs to Wetlands -* Minor NPC fixes in Stormwind, Darnassus - -### v1.0.2 (Sept. 13, 2019) -* Added Thousand Needles NPCs -* Added Camp Mojache, Feralas NPCs -* Added Tanaris NPCs -* Added Elwynn Forest NPCs -* Added Westfall NPCs -* Added a few missing Stormwind NPCs -* Minor locale fixes - -### v1.0.1 (Sept. 12, 2019) -* Fixes to enable standalone usage -* Curse packaging modifications - -### v1.0 (Sept. 11, 2019) -* Initial release diff --git a/changelog.md b/changelog.md index 171625d..409a734 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ -### v1.0.7 (Oct. 12, 2019) -* Fixed the SoundKit issue with the dropdown menu. -* Added a few missing NPCs to Orgrimmar and Silverpine Forest. +### v1.0.8 (Aug. 26, 2020) +* Added world map and minimap icon scale configuration. +* Fixed an issue if PlayerZoneChanged (draw icons) fired before Player_Entering_World (create icons). -[See past changes here.](https://bitbucket.org/jsiebert9/townsfolk-tracker/src/master/changehistory.md) +[See past changes here.](https://github.com/Mokulu/Townsfolk-Tracker/releases)