Added a settings menu

Chinmay Patil [06-21-20 - 23:27]
Added a settings menu
Fixed a bug where saved variables would not be created.
Filename
AAGroupTool.txt
ADGroupTool.lua
SettingsMenu.lua
changelog.txt
diff --git a/AAGroupTool.txt b/AAGroupTool.txt
index 23b0afb..482a8f6 100644
--- a/AAGroupTool.txt
+++ b/AAGroupTool.txt
@@ -3,6 +3,8 @@
 ## Description: A toolset for groups in cyrodil
 ## Author: |c0DC1CF@M0R_Gaming|r
 ## SavedVariables: ADVars
+## DependsOn: LibAddonMenu-2.0

 ADGroupTool.lua
+SettingsMenu.lua
 bindings.xml
\ No newline at end of file
diff --git a/ADGroupTool.lua b/ADGroupTool.lua
index b89dc67..52b8344 100644
--- a/ADGroupTool.lua
+++ b/ADGroupTool.lua
@@ -1,22 +1,11 @@
 ADGroupTool = {}

 -- Written by M0R_Gaming
---> For AD, by AD

-ADGroupTool.name = "ADGroupTool"
+ADGroupTool.name = "AAGroupTool"
 ADGroupTool.groupList = {}
 ADGroupTool.adgttToggle = false
 ADGroupTool.varversion = 1
---[[
-ADGroupTool.guildID = 341929
-
-ADGroupTool.offCrownTimerMin = 10
-
-ADGroupTool.offCrownTimer = 60*ADGroupTool.offCrownTimerMin --in seconds
-
-ADGroupTool.inviteToggle = false
-ADGroupTool.discord = ""
-]]


 ADGroupTool.DefaultSettings = {
@@ -28,30 +17,8 @@ ADGroupTool.DefaultSettings = {
 	radius = 25500
 }

-
-ZO_CreateStringId("SI_BINDING_NAME_ADGROUPTOOL_TOGGLE_SOC", "Toggle [Stay On Crown] Module")
-ZO_CreateStringId("SI_BINDING_NAME_ADGROUPTOOL_POST_DISCORD", "Send Discord Message")
-
-
-
 -- The range of a forward camp is 25500 units

-
-function ADGroupTool.startTimer()
-	if ADGroupTool.adgttToggle then
-		EVENT_MANAGER:UnregisterForUpdate("AD Group Tool SOC") --milliseconds
-		EVENT_MANAGER:UnregisterForEvent("AD Group Tool SOC DC", EVENT_GROUP_MEMBER_LEFT)
-		d("|cFFD700AD Group Tool|r: [Stay On Crown] module |cFF0000deactivated|r.")
-		ADGroupTool.adgttToggle = false
-		ADGroupTool.groupList = {}
-	else
-		EVENT_MANAGER:RegisterForUpdate("AD Group Tool SOC", 1000, ADGroupTool.groupTimer) --milliseconds
-		EVENT_MANAGER:RegisterForEvent("AD Group Tool SOC DC", EVENT_GROUP_MEMBER_LEFT, ADGroupTool.SOCDC)
-		d("|cFFD700AD Group Tool|r: [Stay On Crown] module |c00FF00activated|r.")
-		ADGroupTool.adgttToggle = true
-	end
-end
-
 function ADGroupTool.setTimer(minutes)
 	if not minutes then
 		d("Please provide a valid amount of time (in minutes)")
@@ -61,21 +28,6 @@ function ADGroupTool.setTimer(minutes)
 		d("Pugs will be kicked after "..minutes.." minutes of not being on crown")
 	end
 end
---[[
-function ADGroupTool.startInvite(discord)
-	if ADGroupTool.inviteToggle then
-		EVENT_MANAGER:UnregisterForEvent("AD Group Tool INV", EVENT_GROUP_MEMBER_JOINED)
-		ADGroupTool.inviteToggle = false
-		d("|cFFD700AD Group Tool|r: [Auto Discord Invite] module |cFF0000deactivated|r.")
-	else
-		EVENT_MANAGER:RegisterForEvent("AD Group Tool INV", EVENT_GROUP_MEMBER_JOINED, ADGroupTool.InvDiscord)
-		ADGroupTool.inviteToggle = true
-		ADGroupTool.discord = discord
-		d("Discord link set: "..ADGroupTool.discord)
-		d("|cFFD700AD Group Tool|r: [Auto Discord Invite] module |c00FF00activated|r.")
-	end
-end
-]]

 function ADGroupTool.setDiscord(discord)
 	ADGroupTool.vars.discordLink = discord
@@ -87,6 +39,12 @@ function ADGroupTool.setDiscordInv(discord)
 	d("Discord Invite Message set: "..ADGroupTool.vars.discordInvite)
 end

+
+
+
+
+
+
 function ADGroupTool.sendDiscord()
 	local channel = CHAT_CHANNEL_PARTY
 	local target = nil
@@ -94,9 +52,30 @@ function ADGroupTool.sendDiscord()
 	CHAT_SYSTEM:StartTextEntry(message, channel, target)
 end

+
+function ADGroupTool.startTimer()
+	if ADGroupTool.adgttToggle then
+		EVENT_MANAGER:UnregisterForUpdate("AD Group Tool SOC") --milliseconds
+		EVENT_MANAGER:UnregisterForEvent("AD Group Tool SOC DC", EVENT_GROUP_MEMBER_LEFT)
+		d("|cFFD700AD Group Tool|r: [Stay On Crown] module |cFF0000deactivated|r.")
+		ADGroupTool.adgttToggle = false
+		ADGroupTool.groupList = {}
+	else
+		EVENT_MANAGER:RegisterForUpdate("AD Group Tool SOC", 1000, ADGroupTool.groupTimer) --milliseconds
+		EVENT_MANAGER:RegisterForEvent("AD Group Tool SOC DC", EVENT_GROUP_MEMBER_LEFT, ADGroupTool.SOCDC)
+		d("|cFFD700AD Group Tool|r: [Stay On Crown] module |c00FF00activated|r.")
+		ADGroupTool.adgttToggle = true
+	end
+end
+
+
+
+-- Setting up Keybinds and Commands --
+
+ZO_CreateStringId("SI_BINDING_NAME_ADGROUPTOOL_TOGGLE_SOC", "Toggle [Stay On Crown] Module")
+ZO_CreateStringId("SI_BINDING_NAME_ADGROUPTOOL_POST_DISCORD", "Send Discord Message")
 SLASH_COMMANDS["/stayoncrown"] = ADGroupTool.startTimer
 SLASH_COMMANDS["/adtimerset"] = ADGroupTool.setTimer
---SLASH_COMMANDS["/addiscord"] = ADGroupTool.startInvite
 SLASH_COMMANDS["/addiscord"] = ADGroupTool.sendDiscord
 SLASH_COMMANDS["/adsetdiscord"] = ADGroupTool.setDiscord
 SLASH_COMMANDS["/adsetdiscordinv"] = ADGroupTool.setDiscordInv
@@ -169,54 +148,6 @@ end



-
-
-
-
-
---[[
-function ADGroupTool.InvDiscord(eventCode, characterName, displayName, isLocalPlayer)
-	d("User "..displayName.." has joined the group")
-	if GetGuildMemberIndexFromDisplayName(ADGroupTool.guildID, displayName) == nil then
-		local channel = CHAT_CHANNEL_PARTY
-		local target = nil
-		local message = "Come join us in discord! Even if you don't have a mic, it still helps us coordinate attacks! Come join us at "..ADGroupTool.discord
-		CHAT_SYSTEM:StartTextEntry(message, channel, target)
-		d("A new player has joined the group.")
-		d("Press |cFFFFFF[Enter]|r twice to send a discord link.")
-	end
-end
-]]
--- 341929
--- GetGuildMemberIndexFromDisplayName(
-
-
-
-
---[[
-
-
--- the following code was receieved ESOUI's wiki
-function ADGroupTool.OnAddOnLoaded(event, addonName)
-	d(addonName)
-  	if addonName == ADGroupTool.name then
-    	ADGroupTool:Initialize()
- 	end
-end
-function ADGroupTool:Initialize(self)
-	-- init function (Not nessicary rn)
-	d("Init")
-	ADGroupTool.vars = ZO_SavedVars:NewAccountWide("ADVars", ADGroupTool.varversion, nil, ADGroupTool.DefaultSettings)
-end
-
--- EVENTS --
--- Finally, we'll register our event handler function to be called when the proper event occurs.
-EVENT_MANAGER:RegisterForEvent(ADGroupTool.name, EVENT_ADD_ON_LOADED, ADGroupTool.OnAddOnLoaded)
---EVENT_MANAGER:RegisterForUpdate("AD Group Tool Timer", 1000, ADGroupTool.groupTimer) --milliseconds
-
-]]
-
-
 -- The following was adapted from https://wiki.esoui.com/Circonians_Stamina_Bar_Tutorial#lua_Structure

 -------------------------------------------------------------------------------------------------
@@ -233,7 +164,8 @@ end
 -------------------------------------------------------------------------------------------------
 function ADGroupTool:Initialize()
 	ADGroupTool.vars = ZO_SavedVars:NewAccountWide("ADVars", ADGroupTool.varversion, nil, ADGroupTool.DefaultSettings)
-
+	ADGroupTool.createSettings()
+
 	EVENT_MANAGER:UnregisterForEvent(ADGroupTool.name, EVENT_ADD_ON_LOADED)
 end

diff --git a/SettingsMenu.lua b/SettingsMenu.lua
new file mode 100644
index 0000000..ef0a02d
--- /dev/null
+++ b/SettingsMenu.lua
@@ -0,0 +1,89 @@
+function ADGroupTool.createSettings()
+
+	local vars = ADGroupTool.vars
+
+	local panelName = "ADGroupToolSettingsPanel"
+	local panelData = {
+		type = "panel",
+		name = "|cFFD700Artaeum Group Tool|r",
+		author = "|c0DC1CF@M0R_Gaming|r",
+		slashCommand = "/ad"
+	}
+
+	local optionsTable = {
+
+		-- STAY ON CROWN MODULE
+
+		{
+			type = "header",
+			name = "|cFFD700[Stay On Crown Module]|r"
+		},
+		{
+			type = "editbox",
+			name = "Discord Invite Link",
+			tooltip = "Time before pugs will be kicked (in minutes).",
+			getFunc = function() return vars.offCrownTimerMin end,
+			setFunc = function(value) ADGroupTool.setTimer(value) end,
+			isMultiline = false
+		},
+		{
+			type = "editbox",
+			name = "Radius",
+			tooltip = "If pugs are this much away, the timer will start counting for them. A forward camp radius is 25500 units.",
+			getFunc = function() return vars.radius end,
+			setFunc = function(value) vars.radius = value end,
+			isMultiline = false
+		},
+		{
+			type = "button",
+			name = "Toggle Module",
+			tooltip = "Click here to toggle [Stay on Crown].",
+			func = function() ADGroupTool.startTimer() end
+		},
+		{
+			type = "divider"
+		},
+
+
+		-- DISCORD MODULE
+
+
+		{
+			type = "header",
+			name = "|cFFD700[Discord Module]|r"
+		},
+		{
+			type = "editbox",
+			name = "Discord Invite Link",
+			tooltip = "Please add your discord invite link here.",
+			getFunc = function() return ADGroupTool.vars.discordLink end,
+			setFunc = function(value) ADGroupTool.vars.discordLink = value end,
+			isMultiline = false	--boolean
+		},
+		{
+			type = "editbox",
+			name = "Discord Invite Message",
+			tooltip = "Please add your discord invite message here.",
+			getFunc = function() return ADGroupTool.vars.discordInvite end,
+			setFunc = function(value) ADGroupTool.vars.discordInvite = value end,
+			isMultiline = true	--boolean
+		},
+		{
+			type = "button",
+			name = "Send Discord Invite",
+			tooltip = "Click here to send a discord invite!",
+			func = function() ADGroupTool.sendDiscord() end
+		},
+		{
+			type = "divider"
+		},
+
+
+
+	}
+
+
+	local panel = LibAddonMenu2:RegisterAddonPanel(panelName, panelData)
+	LibAddonMenu2:RegisterOptionControls(panelName, optionsTable)
+
+end
\ No newline at end of file
diff --git a/changelog.txt b/changelog.txt
index 99d9951..70b2e9f 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,20 @@
+Version 1.3
+----------
+Added a settings menu
+Fixed a bug where saved variables would not be created.
+
+
+Version 1.2.2
+----------
+Made the switch to using esoui's git to store code
+
+
+Bugfix 1.2.1
+-----------
+Attempted to fix bug where addon no longer shows up on minion
+
+
+
 Version 1.2
 -----------
 Renamed Addon to Artaeum Group Tool (AD Group Tool) after parting ways with AA.