Quantcast

Fixed a crash when loaded on a non shaman character.

Taracque [01-07-13 - 14:17]
Fixed a crash when loaded on a non shaman character.
Filename
Change_log.txt
Ele_GUI.lua
Elementarist.lua
Elementarist.toc
modules/elemental.lua
diff --git a/Change_log.txt b/Change_log.txt
index b6d49f8..9313822 100755
--- a/Change_log.txt
+++ b/Change_log.txt
@@ -1,3 +1,6 @@
+**v3.1.1**
+* Fixed: Crash if loaded while not playing with Shaman
+
 **v3.1.0**
 * Added: More resto function added, each talent has it's own config panel
 * Fixed: Elemental rotation fixed to match Totemspot's description
diff --git a/Ele_GUI.lua b/Ele_GUI.lua
index 20a98cd..22d4bb8 100755
--- a/Ele_GUI.lua
+++ b/Ele_GUI.lua
@@ -225,6 +225,15 @@ function Elementarist:CreateConfig()
 	if (Elementarist.configPanel ~= nil) then
 		return;
 	end
+	if (not ElementaristDB.version) then
+		ElementaristDB.version = Elementarist.versionNumber;
+		if (not ElementaristDB.modules) then
+			ElementaristDB.modules = {}
+		end
+		ElementaristDB.modules.elemental = true;
+		ElementaristDB.modules.restoration = not ElementaristDB.disableIfNotEle;
+	end
+
 	Elementarist.configPanel = CreateFrame( "Frame", "ElementaristConfigPanel", UIParent );
 	-- Register in the Interface Addon Options GUI
 	-- Set the name for the Category for the Options Panel
@@ -233,14 +242,11 @@ function Elementarist:CreateConfig()
 	local EnableBtn = Elementarist:CreateCheckButton(L.CONFIG_ENABLED, Elementarist.configPanel, ElementaristDB, "enabled", false)
 	EnableBtn:SetPoint('TOPLEFT', 10, -8)

-	local EnableEleBtn = Elementarist:CreateCheckButton(L.CONFIG_ONLY_ON_ELE, Elementarist.configPanel, ElementaristDB, "disableIfNotEle", false)
-	EnableEleBtn:SetPoint('TOPLEFT', 40, -28)
-
 	local DisableMini = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_MINI, Elementarist.configPanel, ElementaristDB, "disableMini", false)
-	DisableMini:SetPoint('TOPLEFT', 40, -48)
+	DisableMini:SetPoint('TOPLEFT', 40, -38)

 	local LockBtn = Elementarist:CreateCheckButton(L.CONFIG_LOCK_FRAMES, Elementarist.configPanel, ElementaristDB, "locked", false)
-	LockBtn:SetPoint('TOPLEFT', 10, -78)
+	LockBtn:SetPoint('TOPLEFT', 10, -68)

 	local Scale = Elementarist:CreateSlider(L.CONFIG_SPELL_ADV_SCALE, Elementarist.configPanel, .25, 3, .1)
 	Scale:SetScript('OnShow', function(self)
@@ -256,7 +262,7 @@ function Elementarist:CreateConfig()
 			Elementarist.displayFrame:SetScale(value)
 		end
 	end)
-	Scale:SetPoint("TOPLEFT",10,-118)
+	Scale:SetPoint("TOPLEFT",10,-108)
 	Scale:Show()

 	local Alpha = Elementarist:CreateSlider(L.CONFIG_SPELL_ADV_ALPHA, Elementarist.configPanel, .0, 1, .1)
@@ -272,11 +278,11 @@ function Elementarist:CreateConfig()
 			Elementarist.displayFrame:SetAlpha(value)
 		end
 	end)
-	Alpha:SetPoint("TOPLEFT",200,-118)
+	Alpha:SetPoint("TOPLEFT",200,-108)
 	Alpha:Show()

 	local DebuffDisableBtn = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_DEBUFF_TRACKER, Elementarist.configPanel, ElementaristDB, "debuffdisabled", false)
-	DebuffDisableBtn:SetPoint('TOPLEFT', 10, -178)
+	DebuffDisableBtn:SetPoint('TOPLEFT', 10, -168)

 	local DebuffScale = Elementarist:CreateSlider(L.CONFIG_DEBUFF_TRACKER_SCALE, Elementarist.configPanel, .25, 3, .1)
 	DebuffScale:SetScript('OnShow', function(self)
@@ -291,7 +297,7 @@ function Elementarist:CreateConfig()
 			Elementarist.debuffTracker:SetScale(value)
 		end
 	end)
-	DebuffScale:SetPoint("TOPLEFT",10,-158)
+	DebuffScale:SetPoint("TOPLEFT",10,-148)
 	DebuffScale:Show()

 	local DebuffAlpha = Elementarist:CreateSlider(L.CONFIG_DEBUFF_TRACKER_ALPHA, Elementarist.configPanel, .0, 1, .1)
@@ -307,11 +313,11 @@ function Elementarist:CreateConfig()
 			Elementarist.debuffTracker:SetAlpha(value)
 		end
 	end)
-	DebuffAlpha:SetPoint("TOPLEFT",200,-158)
+	DebuffAlpha:SetPoint("TOPLEFT",200,-148)
 	DebuffAlpha:Show()

 	local ShieldDisableBtn = Elementarist:CreateCheckButton(L.CONFIG_DISABLE_SHIELD_TRACKER, Elementarist.configPanel, ElementaristDB, "shielddisabled", false)
-	ShieldDisableBtn:SetPoint('TOPLEFT', 10, -238)
+	ShieldDisableBtn:SetPoint('TOPLEFT', 10, -228)

 	local ShieldScale = Elementarist:CreateSlider(L.CONFIG_SHIELD_TRACKER_SCALE, Elementarist.configPanel, .25, 3, .1)
 	ShieldScale:SetScript('OnShow', function(self)
@@ -326,7 +332,7 @@ function Elementarist:CreateConfig()
 			Elementarist.shieldTracker:SetScale(value)
 		end
 	end)
-	ShieldScale:SetPoint("TOPLEFT",10,-218)
+	ShieldScale:SetPoint("TOPLEFT",10,-208)
 	ShieldScale:Show()

 	local ShieldAlpha = Elementarist:CreateSlider(L.CONFIG_SHIELD_TRACKER_ALPHA, Elementarist.configPanel, .0, 1, .1)
@@ -342,14 +348,14 @@ function Elementarist:CreateConfig()
 			Elementarist.shieldTracker:SetAlpha(value)
 		end
 	end)
-	ShieldAlpha:SetPoint("TOPLEFT",200,-218)
+	ShieldAlpha:SetPoint("TOPLEFT",200,-208)
 	ShieldAlpha:Show()

 	local ThreatWarnBtn = Elementarist:CreateCheckButton(L.CONFIG_THREAT_WARNING, Elementarist.configPanel, ElementaristDB, "ThreatWarning", false)
-	ThreatWarnBtn:SetPoint('TOPLEFT', 10, -268)
+	ThreatWarnBtn:SetPoint('TOPLEFT', 10, -258)

 	local EleLayout = Elementarist:CreateDropDownMenu(L.CONFIG_LAYOUT, Elementarist.configPanel, ElementaristDB, "Layout", {{text = Elementarist.EleLayout["1"]}, {text = Elementarist.EleLayout["2"]}},200)
-	EleLayout:SetPoint('TOPLEFT', 10, -298)
+	EleLayout:SetPoint('TOPLEFT', 10, -288)

 	local ResetBtn = Elementarist:CreateButton(L.CONFIG_RESET_POSITIONS, Elementarist.configPanel)
 	ResetBtn:SetWidth(160)
@@ -357,7 +363,7 @@ function Elementarist:CreateConfig()
 	ResetBtn:SetScript('OnClick', function()
 		Elementarist:ResetPosition()
 	end)
-	ResetBtn:SetPoint("TOPLEFT",10,-328)
+	ResetBtn:SetPoint("TOPLEFT",10,-318)
 	ResetBtn:Show()

 	Elementarist.configPanel.okay = function()
@@ -375,7 +381,6 @@ function Elementarist:CreateConfig()
 		ElementaristDB.shieldscale = 1
 		ElementaristDB.locked = false
 		ElementaristDB.enabled = true
-		ElementaristDB.disableIfNotEle = true
 		ElementaristDB.disableMini = false
 		ElementaristDB.debuffdisabled = false
 		ElementaristDB.shielddisabled = false
@@ -386,6 +391,7 @@ function Elementarist:CreateConfig()
 		ElementaristDB.EnableEQ = false
 		ElementaristDB.ThreatWarning = true
 		ElementaristDB.Layout = Elementarist.EleLayout["1"]
+		ElementaristDB.version = Elementarist.versionNumber;
 		Elementarist:ResetPosition()
 	end

@@ -408,10 +414,22 @@ function Elementarist:CreateConfig()

 	if (Elementarist.modules) then
 		for i,v in pairs(Elementarist.modules) do
-			local vposition = -40;
+			local vposition = -20;
 			if (Elementarist[i].Configuration) then
 				local childPanel = CreateFrame( "Frame", "ElementaristConfigPanel" .. i, Elementarist.configPanel );
 				childPanel.name = i:gsub("^%l", string.upper);
+
+				if (not ElementaristDB.modules) then
+					ElementaristDB.modules = {};
+				end
+				if (not ElementaristDB.modules[i]) then
+					ElementaristDB.modules[i] = {};
+					ElementaristDB.modules[i].enabled = true;
+				end
+				local checkBox = Elementarist:CreateCheckButton(childPanel.name .. " enabled", childPanel, ElementaristDB.modules, i, false);
+				checkBox:SetPoint('TOPLEFT', 10, vposition);
+				vposition = vposition - 40;
+
 				for i2,v2 in pairs(Elementarist[i].Configuration) do
 					if (v2.type == "DropDown") then
 						local dropDown = Elementarist:CreateDropDownMenu(v2.label, childPanel, ElementaristDB, i2, v2.options, 200);
diff --git a/Elementarist.lua b/Elementarist.lua
index 0f038fb..dea0ff5 100755
--- a/Elementarist.lua
+++ b/Elementarist.lua
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Elementarist 3.1.0
+-- Elementarist 3.1.1
 --
 -- Shows the advised spell for an elemental shaman for optimal DPS output.
 -------------------------------------------------------------------------------
@@ -8,7 +8,8 @@ Elementarist = {Locals = {}}

 local L = Elementarist.Locals

-Elementarist.versionNumber = '3.1.0'
+Elementarist.versionNumber = '3.1.1';
+Elementarist.enabled = true;
 Elementarist.playerName = UnitName("player")
 Elementarist.playerGUID = UnitGUID("player")
 Elementarist.targetGUID = nil
@@ -193,11 +194,6 @@ function Elementarist.events.ADDON_LOADED(addon)
 		Elementarist.SpellFlash = _G['SpellFlashAddon']
 	end
 	if addon ~= "Elementarist" then return end
-	local _,playerClass = UnitClass("player")
-	if playerClass ~= "SHAMAN" then
-		Elementarist.eventFrame:UnregisterEvent("PLAYER_ALIVE")
-		return
-	end

 	-- load defaults, if first start
 	Elementarist:InitSettings()
@@ -290,9 +286,16 @@ end

 function Elementarist:detectTalent()
 	local spec = GetSpecialization()
-	local _
+	local _,playerClass;
 	local talent = "";

+	_,playerClass = UnitClass("player")
+
+	if playerClass ~= "SHAMAN" then
+		talent = "";
+		Elementarist.enabled = false;
+		return;
+	end
 	if (spec == 1) then
 		talent = "elemental"
 	end
@@ -306,7 +309,7 @@ function Elementarist:detectTalent()
 	_, Elementarist.tier6Talent = GetTalentRowSelectionInfo(6)

 	if (talent ~= "") and (talent ~= Elementarist.talent) then
-		if ((Elementarist.modules[talent]) and (Elementarist[talent].Initialize)) then
+		if ((Elementarist.modules[talent]) and (ElementaristDB.modules[talent]) and (Elementarist[talent].Initialize)) then
 			Elementarist.callbacks = {};
 			Elementarist[talent]:Initialize();
 		end;
@@ -564,9 +567,9 @@ function Elementarist:isEnabled()
 		Elementarist:detectTalent()
 	end
 	return (
-		ElementaristDB.enabled and (
-			(not ElementaristDB.disableIfNotEle) or (Elementarist.talent == "elemental")
-		)
+		Elementarist.enabled and
+		ElementaristDB.enabled and
+		ElementaristDB.modules[Elementarist.talent]
 	)
 end

@@ -778,7 +781,10 @@ function Elementarist:FlashSpell(spell,spelltype)
 end

 function Elementarist:DecideSpells()
-
+	if (not Elementarist.enabled) then
+		return;
+	end
+
 	Elementarist.timeSinceLastUpdate = 0;
 	local currentTime = GetTime()

diff --git a/Elementarist.toc b/Elementarist.toc
index 1e2ebc1..8904423 100755
--- a/Elementarist.toc
+++ b/Elementarist.toc
@@ -2,7 +2,7 @@
 ## Title: Elementarist
 ## Notes: Elemental shaman spell rotation helper
 ## Author: Taracque, Felmosórongy of Arathor
-## Version: 3.1.0
+## Version: 3.1.1
 ## SavedVariables: ElementaristDB
 ## OptionalDeps: OmniCC, SpellFlash
 ## Dependencies:
diff --git a/modules/elemental.lua b/modules/elemental.lua
index 733cb03..48a8a3f 100755
--- a/modules/elemental.lua
+++ b/modules/elemental.lua
@@ -4,7 +4,7 @@ Elementarist:RegisterModule("elemental");

 Elementarist.elemental = {
 	["Configuration"] = {
-		["Behvaior"] = {
+		["Behavior"] = {
 			["type"]	= "DropDown",
 			["label"]	=	L.CONFIG_BEHAVIOR,
 			["options"]	= {