diff --git a/GroupLeader.lua b/GroupLeader.lua
index cbce7c4..c5c6274 100755
--- a/GroupLeader.lua
+++ b/GroupLeader.lua
@@ -19,13 +19,6 @@ local colorKeys = GroupLeader.GetTableKeys(colors)
local mapPinType = "GroupLeaderMap"
local compassPinType = "GroupLeaderCompass"
--- Addon data storage
-local nameToUnitTagMap = {}
-local playerName = nil
-local trackers = {
- ['leader'] = {tag=nil, name=nil, symbol=nil, color=nil, X=0, Y=0},
- }
-
-- Defaults for settings
local defaults = {
compassEnabled = true,
@@ -36,6 +29,13 @@ local defaults = {
compassMaxDistance = 1.0,
}
+-- Addon data storage
+local nameToUnitTagMap = {}
+local playerName = nil
+local trackers = {
+ ['leader'] = {tag=nil, name=nil, symbol='Circle', color='Red', X=0, Y=0},
+ }
+
-- Misc functions
-- Map group member names to unit tags in a table
local function MapNamesToUnitTags()
@@ -69,13 +69,15 @@ local function MapCallback(pinManager)
if not db or not db.mapEnabled then
return
end
- -- TODO
- if not leaderName or not leaderX or not leaderY then
- return
- elseif leaderName == playerName then
- return
- end
- pinManager:CreatePin(_G[mapPinType], leaderName, leaderX, leaderY)
+ for k, v in pairs(trackers) do
+ if v.tag and v.name and v.symbol and v.color and not (v.X == 0 and v.Y == 0) then
+ if k == 'leader' and db.leaderEnabled and v.name ~= playerName then
+ pinManager:CreatePin(_G[mapPinType .. v.symbol .. v.color], v.name, v.X, v.Y)
+ else
+ pinManager:CreatePin(_G[mapPinType .. v.symbol .. v.color], v.name, v.X, v.Y)
+ end
+ end
+ end
end
local function CompassPinCallback(pinManager)
@@ -85,13 +87,15 @@ local function CompassPinCallback(pinManager)
if not db or not db.compassEnabled then
return
end
- -- TODO
- if not leaderName or not leaderX or not leaderY then
- return
- elseif leaderName == playerName then
- return
- end
- pinManager:CreatePin(compassPinType, leaderName, leaderX, leaderY)
+ for k, v in pairs(trackers) do
+ if v.tag and v.name and v.symbol and v.color and not (v.X == 0 and v.Y == 0) then
+ if k == 'leader' and db.leaderEnabled and v.name ~= playerName then
+ pinManager:CreatePin(compassPinType .. v.symbol .. v.color, v.name, v.X, v.Y)
+ else
+ pinManager:CreatePin(compassPinType .. v.symbol .. v.color, v.name, v.X, v.Y)
+ end
+ end
+ end
end
-- Map specific functions
@@ -102,7 +106,7 @@ end
local function AddMapPin(pinType, pinTypeAddCallback, pinTypeOnResizeCallback, pinLayoutData, pinTooltipCreator)
ZO_WorldMap_AddCustomPin(pinType, pinTypeAddCallback, pinTypeOnResizeCallback, pinLayoutData, pinTooltipCreator)
ZO_WorldMap_SetCustomPinEnabled(_G[pinType], true)
- RefreshMapPins(pinType)
+ --RefreshMapPins(pinType)
end
-- Slash command handlers
@@ -154,8 +158,8 @@ local function CommandHandler(text)
GroupLeader.ChatMessage("Compass tracking " .. status)
elseif params[1] == "add" then
local name = nil
- local symbol = nil
- local color = nil
+ local symbol = 'Circle'
+ local color = 'Red'
for paramCounter = 2, paramCounter, 1 do
param = params[paramCounter]
if string.sub(param, 1, string.len("-"))=="-" then
@@ -184,6 +188,12 @@ local function CommandHandler(text)
end
local unitTag = nameToUnitTagMap[name]
if unitTag then
+ for k, v in pairs(trackers) do
+ if v.tag == unitTag then
+ GroupLeader.ChatMessage("Already tracking that player!")
+ return
+ end
+ end
table.insert(trackers, {tag=unitTag, name=name, symbol=symbol, color=color, X=0, Y=0})
GroupLeader.ChatMessage("Now tracking " .. name)
else
@@ -261,93 +271,85 @@ local function ConnectedStatus()
end
-- Refresh the compass and map with the chosen texture
-local function UpdateTexture()
- -- TODO
- ZO_MapPin.PIN_DATA[_G[mapPinType]].texture = textures[db.leaderSymbol] .. colors[db.mapColor]
- RefreshMapPins(mapPinType)
- COMPASS_PINS.pinLayouts[compassPinType].texture = textures[db.leaderSymbol] .. colors[db.compassColor]
+local function RefreshAllPins()
+ RefreshMapPins(mapPinType .. 'StarWhite')
+ RefreshMapPins(mapPinType .. 'StarBlack')
+ RefreshMapPins(mapPinType .. 'StarRed')
+ RefreshMapPins(mapPinType .. 'StarGreen')
+ RefreshMapPins(mapPinType .. 'StarBlue')
+ RefreshMapPins(mapPinType .. 'PlusWhite')
+ RefreshMapPins(mapPinType .. 'PlusBlack')
+ RefreshMapPins(mapPinType .. 'PlusRed')
+ RefreshMapPins(mapPinType .. 'PlusGreen')
+ RefreshMapPins(mapPinType .. 'PlusBlue')
+ RefreshMapPins(mapPinType .. 'CircleWhite')
+ RefreshMapPins(mapPinType .. 'CircleBlack')
+ RefreshMapPins(mapPinType .. 'CircleRed')
+ RefreshMapPins(mapPinType .. 'CircleGreen')
+ RefreshMapPins(mapPinType .. 'CircleBlue')
COMPASS_PINS:RefreshPins()
end
-- Called on game UI updates
function GroupLeader.OnGroupLeaderUpdate(time)
- -- TODO
- local unitTag = nil
- if customLeader1Tag then
- unitTag = customLeader1Tag
- elseif leaderTag then
- unitTag = leaderTag
+ for k, v in pairs(trackers) do
+ if v.tag then
+ v.X, v.Y = GetMapPlayerPosition(v.tag)
+ v.name = GetUnitName(v.tag)
+ else
+ v.X = nil
+ v.Y = nil
+ v.name = nil
+ end
end
- if unitTag then
- leaderX, leaderY = GetMapPlayerPosition(unitTag)
- leaderName = GetUnitName(unitTag)
- else
- leaderX = nil
- leaderY = nil
- leaderName = nil
- end
-
- COMPASS_PINS:RefreshPins()
- RefreshMapPins(mapPinType)
+ RefreshAllPins()
end
-- Create the settings menu
local function CreateSettings()
- -- TODO
local LAM = LibStub("LibAddonMenu-1.0")
local panel = LAM:CreateControlPanel("GROUP_LEADER_SETTINGS", "Group Leader")
LAM:AddHeader(panel, "GROUP_LEADER_SETTINGS_GENERAL", "General Settings")
- LAM:AddCheckbox(panel, "Group_Leader_Tracking_Enabled", "Enable Tracking", "If enabled, the location of the group leader (or custom target using /leader name) will be tracked",
- function() return db.trackingEnabled end, --getFunc
+ LAM:AddCheckbox(panel, "Group_Leader_Map_Enabled", "Enable Map Tracking", "If enabled, the location of the group leader (or custom targets) will be tracked on the map",
+ function() return db.mapEnabled end, --getFunc
function() --setFunc
- db.trackingEnabled = not db.trackingEnabled
- end)
- LAM:AddDropdown(panel, "Group_Leader_Symbol", "Select Tracking Symbol", "Select the symbol to use for tracking the leader",
- textureKeys,
- function() return db.leaderSymbol end, --getFunc
- function(text) --setFunc
- db.leaderSymbol = text
- UpdateTexture()
- end, --setFunc
- false,
- nil)
-
- LAM:AddHeader(panel, "GROUP_LEADER_SETTINGS_COMPASS", "Compass Settings")
- LAM:AddCheckbox(panel, "Group_Leader_Compass_Enabled", "Enable Compass Tracking", "If enabled, the location of the group leader (or custom target using /leader name) will be tracked on the compass",
+ db.mapEnabled = not db.mapEnabled
+ end)
+ LAM:AddCheckbox(panel, "Group_Leader_Compass_Enabled", "Enable Compass Tracking", "If enabled, the location of the group leader (or custom targets) will be tracked on the compass",
function() return db.compassEnabled end, --getFunc
function() --setFunc
db.compassEnabled = not db.compassEnabled
end)
- LAM:AddSlider(panel, "Group_Leader_Compass_MaxDistance", "Max Distance", "The maximum distance (in normalized map units) to show the group leader", 1, 100, 1,
+ LAM:AddSlider(panel, "Group_Leader_Compass_MaxDistance", "Max Distance", "The maximum distance (in normalized map units) to show the tracked players", 1, 100, 1,
function() return db.compassMaxDistance * 100 end,
function(maxDistance)
db.compassMaxDistance = maxDistance / 100
COMPASS_PINS.pinLayouts[compassPinType].maxDistance = maxDistance / 100
COMPASS_PINS:RefreshPins()
end)
- LAM:AddDropdown(panel, "Group_Leader_Compass_Color", "Select Tracking Color", "Select the color to use for the symbol used for tracking the leader",
- colorKeys,
- function() return db.compassColor end, --getFunc
+
+ LAM:AddHeader(panel, "GROUP_LEADER_SETTINGS_LEADER", "Leader Settings")
+ LAM:AddCheckbox(panel, "Group_Leader_Tracking_Enabled", "Enable Tracking", "If enabled, the location of the group leader will be tracked",
+ function() return db.leaderEnabled end, --getFunc
+ function() --setFunc
+ db.leaderEnabled = not db.leaderEnabled
+ end)
+ LAM:AddDropdown(panel, "Group_Leader_Symbol", "Select Tracking Symbol", "Select the symbol to use for tracking the leader",
+ textureKeys,
+ function() return db.leaderSymbol end, --getFunc
function(text) --setFunc
- db.compassColor = text
- UpdateTexture()
+ db.leaderSymbol = text
+ RefreshAllPins()
end, --setFunc
false,
nil)
-
- LAM:AddHeader(panel, "GROUP_LEADER_SETTINGS_MAP", "Map Settings")
- LAM:AddCheckbox(panel, "Group_Leader_Map_Enabled", "Enable Map Tracking", "If enabled, the location of the group leader (or custom target using /leader name) will be tracked on the map",
- function() return db.mapEnabled end, --getFunc
- function() --setFunc
- db.mapEnabled = not db.mapEnabled
- end)
- LAM:AddDropdown(panel, "Group_Leader_Map_Color", "Select Tracking Color", "Select the color to use for the symbol used for tracking the leader",
+ LAM:AddDropdown(panel, "Group_Leader_Color", "Select Tracking Color", "Select the color to use for the symbol used for tracking the leader",
colorKeys,
- function() return db.mapColor end, --getFunc
+ function() return db.leaderColor end, --getFunc
function(text) --setFunc
- db.mapColor = text
- UpdateTexture()
+ db.leaderColor = text
+ RefreshAllPins()
end, --setFunc
false,
nil)
@@ -362,7 +364,7 @@ local function AddonSetup(eventCode, addOnName)
nameToUnitTagMap = {}
playerName = nil
trackers = {
- ['leader'] = {tag=nil, name=nil, symbol=nil, color=nil, X=0, Y=0},
+ ['leader'] = {tag=nil, name=nil, symbol='Circle', color='Red', X=0, Y=0},
}
-- Populate the settings DB
@@ -377,21 +379,192 @@ local function AddonSetup(eventCode, addOnName)
playerName = GetUnitName('player')
LeaderUpdate()
- -- TODO
- local mapPinLayout = {
+ trackers['leader'].symbol = db.leaderSymbol
+ trackers['leader'].color = db.leaderColor
+
+ local mapPinLayout = nil
+ local compassPinLayout = nil
+
+ mapPinLayout = {
level = 200,
- texture = textures[db.leaderSymbol] .. colors[db.mapColor],
+ texture = textures['Star'] .. colors['White'],
size = 40,
}
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Star'] .. colors['White'],
+ }
+ AddMapPin(mapPinType .. 'StarWhite', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'StarWhite', CompassPinCallback, compassPinLayout)
- local compassPinLayout = {
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Star'] .. colors['Black'],
+ size = 40,
+ }
+ compassPinLayout = {
maxDistance = db.compassMaxDistance,
- texture = textures[db.leaderSymbol] .. colors[db.compassColor],
+ texture = textures['Star'] .. colors['Black'],
}
-
- AddMapPin(mapPinType, MapCallback, nil, mapPinLayout, pinTooltipCreator)
- COMPASS_PINS:AddCustomPin(compassPinType, CompassPinCallback, compassPinLayout)
+ AddMapPin(mapPinType .. 'StarBlack', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'StarBlack', CompassPinCallback, compassPinLayout)
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Star'] .. colors['Red'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Star'] .. colors['Red'],
+ }
+ AddMapPin(mapPinType .. 'StarRed', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'StarRed', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Star'] .. colors['Green'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Star'] .. colors['Green'],
+ }
+ AddMapPin(mapPinType .. 'StarGreen', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'StarGreen', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Star'] .. colors['Blue'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Star'] .. colors['Blue'],
+ }
+ AddMapPin(mapPinType .. 'StarBlue', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'StarBlue', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Plus'] .. colors['White'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Plus'] .. colors['White'],
+ }
+ AddMapPin(mapPinType .. 'PlusWhite', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'PlusWhite', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Plus'] .. colors['Black'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Plus'] .. colors['Black'],
+ }
+ AddMapPin(mapPinType .. 'PlusBlack', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'PlusBlack', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Plus'] .. colors['Red'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Plus'] .. colors['Red'],
+ }
+ AddMapPin(mapPinType .. 'PlusRed', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'PlusRed', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Plus'] .. colors['Green'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Plus'] .. colors['Green'],
+ }
+ AddMapPin(mapPinType .. 'PlusGreen', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'PlusGreen', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Plus'] .. colors['Blue'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Plus'] .. colors['Blue'],
+ }
+ AddMapPin(mapPinType .. 'PlusBlue', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'PlusBlue', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Circle'] .. colors['White'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Circle'] .. colors['White'],
+ }
+ AddMapPin(mapPinType .. 'CircleWhite', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'CircleWhite', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Circle'] .. colors['Black'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Circle'] .. colors['Black'],
+ }
+ AddMapPin(mapPinType .. 'CircleBlack', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'CircleBlack', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Circle'] .. colors['Red'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Circle'] .. colors['Red'],
+ }
+ AddMapPin(mapPinType .. 'CircleRed', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'CircleRed', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Circle'] .. colors['Green'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Circle'] .. colors['Green'],
+ }
+ AddMapPin(mapPinType .. 'CircleGreen', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'CircleGreen', CompassPinCallback, compassPinLayout)
+
+ mapPinLayout = {
+ level = 200,
+ texture = textures['Circle'] .. colors['Blue'],
+ size = 40,
+ }
+ compassPinLayout = {
+ maxDistance = db.compassMaxDistance,
+ texture = textures['Circle'] .. colors['Blue'],
+ }
+ AddMapPin(mapPinType .. 'CircleBlue', MapCallback, nil, mapPinLayout, pinTooltipCreator)
+ COMPASS_PINS:AddCustomPin(compassPinType .. 'CircleBlue', CompassPinCallback, compassPinLayout)
+
SLASH_COMMANDS["/groupleader"] = CommandHandler
SLASH_COMMANDS["/gl"] = CommandHandler