Quantcast

Added a "reset switch."

pschifferer [01-23-09 - 01:08]
Added a "reset switch."
Filename
Cauldron/Bindings.xml
Cauldron/CauldronMain.lua
Cauldron/Locale/Cauldron-enUS.lua
diff --git a/Cauldron/Bindings.xml b/Cauldron/Bindings.xml
index 8ffa73d..6ba0f4c 100644
--- a/Cauldron/Bindings.xml
+++ b/Cauldron/Bindings.xml
@@ -3,6 +3,9 @@
 	<Binding name="TOGGLE_CAULDRONSHOPPINGLIST" header="CAULDRON">
        	Cauldron:ShoppingList_Toggle();
 	</Binding>
+	<Binding name="CAULDRONRESET">
+       	Cauldron:Reset();
+	</Binding>
 	<!--
 	<Binding name="TOGGLE_CAULDRONCONFIG">
        	Cauldron:Config_Toggle();
diff --git a/Cauldron/CauldronMain.lua b/Cauldron/CauldronMain.lua
index d7ef1a9..c9702b4 100644
--- a/Cauldron/CauldronMain.lua
+++ b/Cauldron/CauldronMain.lua
@@ -10,6 +10,7 @@ Cauldron.date = string.sub("$Date$", 8, 17);
 -- key binding names
 BINDING_HEADER_CAULDRON = "Cauldron";
 BINDING_NAME_TOGGLE_CAULDRONSHOPPINGLIST = "Toggle Shopping List Window";
+BINDING_NAME_CAULDRONRESET = "Reset Cauldron";
 -- BINDING_NAME_TOGGLE_CAULDRONCONFIG = "Toggle Config Window";

 Cauldron.options = {};
@@ -57,6 +58,12 @@ function Cauldron:OnInitialize()
 				type = 'execute',
 				func = function() self:DisplayVersion() end,
 			},
+			reset = {
+				name = L["Reset"],
+				desc = L["Resets Cauldron to a fresh state"],
+				type = 'execute',
+				func = function() self:Reset() end,
+			},
 --			debug = LibStub('LibLogDebug-1.0'):GetAce3OptionTable(self, 110),
 		},
 	}
@@ -686,3 +693,22 @@ end
 	},

 --]]
+
+function Cauldron:Reset()
+	self:Print("Resetting data structures...");
+
+	-- close the window
+	Cauldron:Frame_Hide();
+
+	-- reset the shopping list
+	self.db.realm.shopping = CauldronShopping:NewList();
+
+	-- reset the skills for each character
+	for toon, info in pairs(self.db.realm.userdata) do
+		self.db.realm.userdata[toon] = {};
+		self.db.realm.userdata[toon].skills = {};
+		self.db.realm.userdata[toon].queue = CauldronQueue:NewQueue();
+	end
+
+	self:Print("Reset complete.");
+end
diff --git a/Cauldron/Locale/Cauldron-enUS.lua b/Cauldron/Locale/Cauldron-enUS.lua
index 1fdbc28..e2b80df 100644
--- a/Cauldron/Locale/Cauldron-enUS.lua
+++ b/Cauldron/Locale/Cauldron-enUS.lua
@@ -18,6 +18,8 @@ L["Menu"] = true
 L["Show Cauldron UI"] = true
 L["Shopping list"] = true
 L["Open shopping list window"] = true
+L["Reset"] = true
+L["Resets Cauldron to a fresh state"] = true

 L["Player known"] = true
 L["Player can learn"] = true