Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
Added icon scale config.
Browse files Browse the repository at this point in the history
Fixed rare draw on load issue.
  • Loading branch information
Mokulu committed Aug 27, 2020
1 parent 2556ce9 commit a2a7e7f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 76 deletions.
4 changes: 4 additions & 0 deletions Locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 33 additions & 5 deletions Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -72,7 +98,7 @@ TF_SETTINGS_MENU = {
width = "full",
get = "IsUseWorldMap",
set = "ToggleUseWorldMap",
order = 4,
order = 6,
},
showMapButton = {
type = "toggle",
Expand All @@ -84,7 +110,7 @@ TF_SETTINGS_MENU = {
disabled = function()
return not TownsfolkTracker.db.profile.useWorldMap
end,
order = 5,
order = 7,
},
showInstancesOnWorld = {
type = "toggle",
Expand All @@ -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,
}
},
}
Expand All @@ -117,5 +143,7 @@ TF_SETTINGS_DEFAULTS = {
showInstanceOnWorldMap = true,
minimapPos = 315,
useWorldMap = true,
mapScale = 1.0,
minimapScale = 1.0,
},
}
35 changes: 34 additions & 1 deletion TownsfolkTracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ SlashCmdList["TOWNSFOLK"] = function(msg)
InterfaceOptionsFrame_OpenToCategory("Townsfolk Tracker")
end

TownsfolkTracker.iconsCreated = false

-- Initialize addon
function TownsfolkTracker:OnInitialize()
-- Register options
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -363,6 +389,8 @@ function TownsfolkTracker:CreateIcons()
end
end
end

self.iconsCreated = true
end

function TownsfolkTracker:DrawMapIcons()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions TownsfolkTracker.toc
Original file line number Diff line number Diff line change
@@ -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

Expand Down
64 changes: 0 additions & 64 deletions changehistory.md

This file was deleted.

8 changes: 4 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a2a7e7f

Please sign in to comment.