Started adding map pins for front doors

Chinmay Patil [07-02-20 - 23:06]
Started adding map pins for front doors
Filename
AAGroupTool.txt
ADGroupTool.lua
SettingsMenu.lua
diff --git a/AAGroupTool.txt b/AAGroupTool.txt
index 482a8f6..47e8e10 100644
--- a/AAGroupTool.txt
+++ b/AAGroupTool.txt
@@ -3,7 +3,7 @@
 ## Description: A toolset for groups in cyrodil
 ## Author: |c0DC1CF@M0R_Gaming|r
 ## SavedVariables: ADVars
-## DependsOn: LibAddonMenu-2.0
+## DependsOn: LibAddonMenu-2.0 LibMapPins-1.0>=10027 LibMapPing

 ADGroupTool.lua
 SettingsMenu.lua
diff --git a/ADGroupTool.lua b/ADGroupTool.lua
index 52b8344..56b3904 100644
--- a/ADGroupTool.lua
+++ b/ADGroupTool.lua
@@ -14,7 +14,7 @@ ADGroupTool.DefaultSettings = {
 	offCrownTimerMin = 10,
 	discordLink = "[Insert Discord Link Here]",
 	discordInvite = "Come join us in discord! Even if you don't have a mic, it still helps us coordinate attacks! Come join us at",
-	radius = 25500
+	radius = 25500,
 }

 -- The range of a forward camp is 25500 units
@@ -41,10 +41,6 @@ end



-
-
-
-
 function ADGroupTool.sendDiscord()
 	local channel = CHAT_CHANNEL_PARTY
 	local target = nil
@@ -53,6 +49,10 @@ function ADGroupTool.sendDiscord()
 end


+
+
+
+
 function ADGroupTool.startTimer()
 	if ADGroupTool.adgttToggle then
 		EVENT_MANAGER:UnregisterForUpdate("AD Group Tool SOC") --milliseconds
@@ -85,7 +85,6 @@ SLASH_COMMANDS["/adsetdiscordinv"] = ADGroupTool.setDiscordInv



-
 function ADGroupTool.groupTimer()

 	local crown = GetGroupLeaderUnitTag()
@@ -148,6 +147,107 @@ end



+
+
+
+
+-- Map Pins Module, some of the base code was taken from the sample code in LibMapPins-1.0.lua
+
+--local fd = {}
+local LMP = LibMapPins
+
+local fds = {
+	{name="Castle Bloodmayne",x=0.57472223043442,y=0.76157778501511},
+	{name="Castle Black Boot",x=0.40770667791367,y=0.76615333557129},
+	{name="Castle Faregyl",x=0.49927777051926,y=0.67549556493759},
+	{name="Castle Alessia",x=0.57074224948883,y=0.557148873806},
+	{name="Castle Roebeck",x=0.41256666183472,y=0.56352001428604},
+	{name="Castle Brindle",x=0.23523999750614,y=0.56775331497192},
+	{name="Fort Ash",x=0.33939111232758,y=0.4275244474411},
+	{name="Fort Aleswell",x=0.40584889054298,y=0.28369554877281},
+	{name="Drakelow Keep",x=0.76734441518784,y=0.58292669057846},
+}
+
+
+local function setRally(pin)
+	local _, pinTag = pin:GetPinTypeAndTag()
+	local x = pinTag.x
+	local y = pinTag.y
+	LibMapPing:SetMapPing(MAP_PIN_TYPE_RALLY_POINT,MAP_TYPE_LOCATION_CENTERED,x,y)
+end
+
+
+local LMB_handler = {
+	{
+		name = "Set Rally to Front Door",
+		callback = setRally,
+		show = function(pin) return true end,
+	}
+}
+
+
+--sample layout
+local pinLayoutData  = {
+   level = 5,
+   texture = "esoui/art/icons/mapkey/mapkey_ava_milegate_passable.dds",
+   size = 10,
+}
+
+--tooltip creator
+local pinTooltipCreator = {
+	creator = function(pin)
+		local _, pinTag = pin:GetPinTypeAndTag()
+		InformationTooltip:AddLine(pinTag.name.." Front Door")
+	end,
+	tooltip = ZO_MAP_TOOLTIP_MODE.INFORMATION,
+}
+
+
+function ADGroupTool.disableDoors()
+	LibMapPins:Disable("Front Doors")
+end
+EVENT_MANAGER:RegisterForEvent("Cyro Transis Active FD", EVENT_START_FAST_TRAVEL_KEEP_INTERACTION, ADGroupTool.disableDoors)
+
+
+function ADGroupTool.enableDoors()
+	LibMapPins:Enable("Front Doors")
+end
+EVENT_MANAGER:RegisterForEvent("Cyro Transis Deactive FD", EVENT_END_FAST_TRAVEL_KEEP_INTERACTION, ADGroupTool.enableDoors)
+
+
+
+local function createDoors()
+	for _, pinInfo in ipairs(fds) do
+		LMP:CreatePin("Front Doors", pinInfo, pinInfo.x, pinInfo.y)
+	end
+end
+
+
+local function fdcallback()
+	if not LMP:IsEnabled("Front Doors") then return end
+	local zone, subzone = LMP:GetZoneAndSubzone()
+	if not (zone == "cyrodiil") then return end
+	if not (subzone == "ava_whole") then return end
+	--d("IN CYRO!")
+	createDoors()
+end
+
+
+
+function ADGroupTool.getCoords(Name)
+	local channel = CHAT_CHANNEL_PARTY
+	local target = nil
+	local x, y, map = GetMapPlayerPosition('player')
+	local message = "{name=\""..Name.."\",x="..x..",y="..y.."},"
+	CHAT_SYSTEM:StartTextEntry(message, channel, target)
+end
+
+SLASH_COMMANDS["/getcoords"] = ADGroupTool.getCoords
+
+--LMP:AddPinFilter(FDPinType)
+
+
+
 -- The following was adapted from https://wiki.esoui.com/Circonians_Stamina_Bar_Tutorial#lua_Structure

 -------------------------------------------------------------------------------------------------
@@ -166,6 +266,10 @@ function ADGroupTool:Initialize()
 	ADGroupTool.vars = ZO_SavedVars:NewAccountWide("ADVars", ADGroupTool.varversion, nil, ADGroupTool.DefaultSettings)
 	ADGroupTool.createSettings()

+	LibMapPins:AddPinType("Front Doors", fdcallback, nil, pinLayoutData, pinTooltipCreator)
+	LibMapPins:AddPinFilter("Front Doors")
+	LibMapPins:SetClickHandlers("Front Doors", LMB_handler)
+
 	EVENT_MANAGER:UnregisterForEvent(ADGroupTool.name, EVENT_ADD_ON_LOADED)
 end

diff --git a/SettingsMenu.lua b/SettingsMenu.lua
index ef0a02d..f3782ed 100644
--- a/SettingsMenu.lua
+++ b/SettingsMenu.lua
@@ -20,7 +20,7 @@ function ADGroupTool.createSettings()
 		},
 		{
 			type = "editbox",
-			name = "Discord Invite Link",
+			name = "Time to Kick",
 			tooltip = "Time before pugs will be kicked (in minutes).",
 			getFunc = function() return vars.offCrownTimerMin end,
 			setFunc = function(value) ADGroupTool.setTimer(value) end,
@@ -35,6 +35,14 @@ function ADGroupTool.createSettings()
 			isMultiline = false
 		},
 		{
+			type = "editbox",
+			name = "Guild ID",
+			tooltip = "Enter your whitelist Guild ID in here (-1 for no whitelist)",
+			getFunc = function() return vars.guildID end,
+			setFunc = function(value) vars.guildID = value end,
+			isMultiline = false
+		},
+		{
 			type = "button",
 			name = "Toggle Module",
 			tooltip = "Click here to toggle [Stay on Crown].",