diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e43b0f9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_Store
diff --git a/GroupLeader.lua b/GroupLeader.lua
index 1cabe54..cbce7c4 100755
--- a/GroupLeader.lua
+++ b/GroupLeader.lua
@@ -14,30 +14,26 @@ local colors = {
['Green'] = "g.dds",
['Blue'] = "b.dds",
}
-local textureKeys = GetTableKeys(textures)
-local colorKeys = GetTableKeys(colors)
+local textureKeys = GroupLeader.GetTableKeys(textures)
+local colorKeys = GroupLeader.GetTableKeys(colors)
local mapPinType = "GroupLeaderMap"
local compassPinType = "GroupLeaderCompass"
-- Addon data storage
-local leaderTag = nil
-local leaderName = nil
-local leaderX = nil
-local leaderY = nil
-local playerName = nil
local nameToUnitTagMap = {}
-local customLeaderTag = nil
-local customLeaderName = nil
+local playerName = nil
+local trackers = {
+ ['leader'] = {tag=nil, name=nil, symbol=nil, color=nil, X=0, Y=0},
+ }
-- Defaults for settings
local defaults = {
- trackingEnabled = true,
compassEnabled = true,
mapEnabled = true,
+ leaderEnabled = true,
leaderSymbol = 'Star',
+ leaderColor = 'White',
compassMaxDistance = 1.0,
- compassColor = 'White',
- mapColor = 'White',
}
-- Misc functions
@@ -62,16 +58,18 @@ end
-- Tooltip creator
local pinTooltipCreator = {
creator = function(pin)
- InformationTooltip:AddLine("Leader: " .. leaderName)
+ --TODO
+ --InformationTooltip:AddLine("Tracking" .. leaderName)
end,
tooltip = InformationTooltip,
}
-- Compass and map callbacks
local function MapCallback(pinManager)
- if not db or not db.trackingEnabled or not db.mapEnabled then
+ 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
@@ -84,9 +82,10 @@ local function CompassPinCallback(pinManager)
if COMPASS.container:IsHidden() then
return
end
- if not db or not db.trackingEnabled or not db.compassEnabled then
+ 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
@@ -107,38 +106,134 @@ local function AddMapPin(pinType, pinTypeAddCallback, pinTypeOnResizeCallback, p
end
-- Slash command handlers
-local function SetLeader(text)
- MapNamesToUnitTags()
- if text ~= nil and string.len(text) > 0 then
+local function CommandHandler(text)
+ -- Display help
+ if text == nil or string.len(text) <= 0 or string.lower(text) == "help" then
+ GroupLeader.ChatMessage("GroupLeader Help:")
+ GroupLeader.ChatMessage("/gl : display help.")
+ GroupLeader.ChatMessage(" aliases: /groupleader, /gl help")
+ GroupLeader.ChatMessage("/gl leader : toggle leader tracking")
+ GroupLeader.ChatMessage("/gl map : toggle map tracking")
+ GroupLeader.ChatMessage("/gl compass : toggle compass tracking")
+ GroupLeader.ChatMessage("/gl add [name] -symbol -color : add a custom tracker")
+ GroupLeader.ChatMessage(" -symbol and -color are optional")
+ GroupLeader.ChatMessage(" e.g., /gl add adein -circle -red")
+ GroupLeader.ChatMessage("/gl del [name] : delete a custom tracker")
+ GroupLeader.ChatMessage("/gl clear : clear all custom trackers")
+ elseif text ~= nil and string.len(text) > 0 then
+ MapNamesToUnitTags()
local input = string.lower(text)
- local newLeaderTag = nameToUnitTagMap[input]
- if newLeaderTag then
- customLeaderTag = newLeaderTag
- customLeaderName = input
- ChatMessage("Now tracking " .. text)
+ local params = GroupLeader.SplitString(input)
+ local paramCount = table.getn(params)
+ if params[1] == "leader" then
+ db.leaderEnabled = not db.leaderEnabled
+ local status = nil
+ if db.leaderEnabled then
+ status = "enabled"
+ else
+ status = "disabled"
+ end
+ GroupLeader.ChatMessage("Tracking group leader " .. status)
+ elseif params[1] == "map" then
+ db.mapEnabled = not db.mapEnabled
+ local status = nil
+ if db.mapEnabled then
+ status = "enabled"
+ else
+ status = "disabled"
+ end
+ GroupLeader.ChatMessage("Map tracking " .. status)
+ elseif params[1] == "compass" then
+ db.compassEnabled = not db.compassEnabled
+ local status = nil
+ if db.compassEnabled then
+ status = "enabled"
+ else
+ status = "disabled"
+ end
+ GroupLeader.ChatMessage("Compass tracking " .. status)
+ elseif params[1] == "add" then
+ local name = nil
+ local symbol = nil
+ local color = nil
+ for paramCounter = 2, paramCounter, 1 do
+ param = params[paramCounter]
+ if string.sub(param, 1, string.len("-"))=="-" then
+ local paramNoDash = string.sub(param, 2, -1)
+ if not symbol then
+ for tex in textureKeys do
+ if paramNoDash == tex then
+ symbol = tex
+ break
+ end
+ end
+ if not color then
+ for col in colorKeys do
+ if paramNoDash == col then
+ color = col
+ break
+ end
+ end
+ else
+ if not name then
+ name = param
+ else
+ name = name .. " " .. param
+ end
+ end
+ end
+ local unitTag = nameToUnitTagMap[name]
+ if unitTag then
+ table.insert(trackers, {tag=unitTag, name=name, symbol=symbol, color=color, X=0, Y=0})
+ GroupLeader.ChatMessage("Now tracking " .. name)
+ else
+ GroupLeader.ChatMessage("Player not found in group!")
+ end
+ elseif params[1] == "del" then
+ local name = nil
+ for paramCounter = 2, paramCounter, 1 do
+ param = params[paramCounter]
+ if not name then
+ name = param
+ else
+ name = name .. " " .. param
+ end
+ end
+ deleted = false
+ for k, v in pairs(trackers) do
+ if v.name == name then
+ table.remove(trackers, k)
+ deleted = true
+ end
+ end
+ if deleted then
+ GroupLeader.ChatMessage("Deleted " .. name .. " from tracking list")
+ else
+ GroupLeader.ChatMessage("Player not found in tracking list!")
+ end
+ elseif params[1] == "clear" then
+ GroupLeader.ChatMessage("Clearing custom trackers")
+ local trackerCount = table.getn(trackers) - 1
+ for trackerCounter = 1, trackerCount, 1 do
+ table.remove(trackerCounter)
+ end
else
- ChatMessage("Player not found in group!")
+ GroupLeader.ChatMessage("Unknown GroupLeader command!")
end
- else
- ChatMessage("Clearing custom leader tracking")
- customLeaderTag = nil
end
end
-- Event handlers
-- Called when the group is disbanded
local function Disbanded()
- leaderTag = nil
- customLeaderTag = nil
- customLeaderName = nil
- leaderX = nil
- leaderY = nil
- leaderName = nil
+ trackers = {
+ ['leader'] = {tag=nil, name=nil, symbol=nil, color=nil, X=0, Y=0},
+ }
end
-- Called when the group leader changes
local function LeaderUpdate()
- leaderTag = GetGroupLeaderUnitTag()
+ trackers['leader'].tag = GetGroupLeaderUnitTag()
end
-- Called when someone joins the group
@@ -149,13 +244,13 @@ end
-- Called when someone leaves the group
local function MemberLeft()
LeaderUpdate()
- if customLeaderTag then
- MapNamesToUnitTags()
- local newLeaderTag = nameToUnitTagMap[customLeaderName]
- if newLeaderTag then
- customLeaderTag = newLeaderTag
+ MapNamesToUnitTags()
+ for k, v in pairs(trackers) do
+ local newUnitTag = nameToUnitTagMap[v.name]
+ if newUnitTag then
+ trackers[k].tag = newUnitTag
else
- Disbanded()
+ table.remove(trackers, k)
end
end
end
@@ -167,6 +262,7 @@ 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]
@@ -174,10 +270,11 @@ local function UpdateTexture()
end
-- Called on game UI updates
-function OnGroupLeaderUpdate(time)
+function GroupLeader.OnGroupLeaderUpdate(time)
+ -- TODO
local unitTag = nil
- if customLeaderTag then
- unitTag = customLeaderTag
+ if customLeader1Tag then
+ unitTag = customLeader1Tag
elseif leaderTag then
unitTag = leaderTag
end
@@ -197,6 +294,7 @@ 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")
@@ -261,14 +359,11 @@ local function AddonSetup(eventCode, addOnName)
return
end
- leaderTag = nil
- leaderName = nil
- leaderX = nil
- leaderY = nil
- playerName = nil
nameToUnitTagMap = {}
- customLeaderTag = nil
- customLeaderName = nil
+ playerName = nil
+ trackers = {
+ ['leader'] = {tag=nil, name=nil, symbol=nil, color=nil, X=0, Y=0},
+ }
-- Populate the settings DB
Group_LeaderDB = Group_LeaderDB or {}
@@ -282,6 +377,7 @@ local function AddonSetup(eventCode, addOnName)
playerName = GetUnitName('player')
LeaderUpdate()
+ -- TODO
local mapPinLayout = {
level = 200,
texture = textures[db.leaderSymbol] .. colors[db.mapColor],
@@ -296,7 +392,8 @@ local function AddonSetup(eventCode, addOnName)
AddMapPin(mapPinType, MapCallback, nil, mapPinLayout, pinTooltipCreator)
COMPASS_PINS:AddCustomPin(compassPinType, CompassPinCallback, compassPinLayout)
- SLASH_COMMANDS["/leader"] = SetLeader
+ SLASH_COMMANDS["/groupleader"] = CommandHandler
+ SLASH_COMMANDS["/gl"] = CommandHandler
EVENT_MANAGER:RegisterForEvent("GroupLeaderDisbanded", EVENT_GROUP_DISBANDED, Disbanded)
EVENT_MANAGER:RegisterForEvent("GroupLeaderLeaderUpdate", EVENT_LEADER_UPDATE, LeaderUpdate)
diff --git a/GroupLeader.xml b/GroupLeader.xml
index 76cff9e..7170d0c 100755
--- a/GroupLeader.xml
+++ b/GroupLeader.xml
@@ -2,7 +2,7 @@
<Controls>
<TopLevelControl name="GroupLeader">
<OnUpdate>
- OnGroupLeaderUpdate(time)
+ GroupLeader.OnGroupLeaderUpdate(time)
</OnUpdate>
</TopLevelControl>
</Controls>
diff --git a/Util.lua b/Util.lua
index 7d63f00..4d626bf 100755
--- a/Util.lua
+++ b/Util.lua
@@ -1,5 +1,5 @@
-- Get a list of the keys from a table
-function GetTableKeys(aTable)
+function GroupLeader.GetTableKeys(aTable)
local keys = {}
local n = 0
for k, v in pairs(aTable) do
@@ -10,13 +10,23 @@ function GetTableKeys(aTable)
end
-- Add a message to the chat window
-function ChatMessage(message)
- CHAT_SYSTEM:AddMessage(message)
+function GroupLeader.ChatMessage(message)
+ CHAT_SYSTEM:AddMessage(message)
end
-function RGBPercToHex(r, g, b)
- r = r <= 1 and r >= 0 and r or 0
- g = g <= 1 and g >= 0 and g or 0
- b = b <= 1 and b >= 0 and b or 0
- return string.format("%02x%02x%02x", r*255, g*255, b*255)
+function GroupLeader.RGBPercToHex(r, g, b)
+ r = r <= 1 and r >= 0 and r or 0
+ g = g <= 1 and g >= 0 and g or 0
+ b = b <= 1 and b >= 0 and b or 0
+ return string.format("%02x%02x%02x", r*255, g*255, b*255)
end
+
+function GroupLeader.SplitString(input)
+ local result = {}
+ local counter = 1
+ for s in string.gmatch(input, "%S+") do
+ result[counter] = s
+ counter = counter + 1
+ end
+ return result
+end
\ No newline at end of file