Quantcast

Added a button to remove all parses to config.

Peter Eliasson [08-05-16 - 20:45]
Added a button to remove all parses to config.
Filename
src/main.lua
src/options.lua
diff --git a/src/main.lua b/src/main.lua
index fc85eda..98b0e74 100644
--- a/src/main.lua
+++ b/src/main.lua
@@ -122,6 +122,13 @@ function addon:IsInMyGuild(playerName)
 	end
 end

+-- Creates the "database" via AceDB
+function addon:SetupDatabase()
+	self.db = LibStub("AceDB-3.0"):New("GuildSkadaHighScoreDB", addon.dbDefaults, true)
+	-- Make sure db version is in sync
+	self.migrate:DoMigration();
+end
+
 -- Method called when ENCOUNTER_END was called and the success
 -- status was true.
 -- This method uses the parse module to get a list of all valid
@@ -193,10 +200,7 @@ function addon:ZONE_CHANGED_NEW_AREA(evt)
 end

 function addon:OnInitialize()
-	self.db = LibStub("AceDB-3.0"):New("GuildSkadaHighScoreDB", addon.dbDefaults, true)
-
-	-- Make sure db version is in sync
-	self.migrate:DoMigration();
+	self:SetupDatabase();
 end

 function addon:OnEnable()
diff --git a/src/options.lua b/src/options.lua
index e10ac2f..8a25bf8 100644
--- a/src/options.lua
+++ b/src/options.lua
@@ -40,6 +40,30 @@ local function createOptionsTable()
 				name = format("Version: %s", addon.versionName),
 				width = "Full",
 			},
+			actions = {
+				name = "Actions",
+				type = "group",
+				inline = true,
+				order = 10,
+				args = {
+					RemoveParses = {
+						order = 10,
+						type = 'execute',
+						name = 'Remove All Parses',
+						desc = 'Removes ALL stored parses.',
+						confirm = function()
+							return 'Are you sure you want to remove ALL stored parses?'
+								.. ' This cannot be undone!';
+						end,
+						func = function()
+							local highscoreDb = addon.highscore:GetDB();
+							highscoreDb = nil;
+							addon:SetupDatabase();
+							addon:Print("All parses have been removed.");
+						end,
+					},
+				},
+			},
 			purgeSettings = {
 				name = "Purge Settings",
 				type = "group",