Quantcast

- added defaults for checkbox and dropdown lists

Sidoine De Wispelaere [10-13-09 - 19:53]
- added defaults for checkbox and dropdown lists
- fixed bug with visibility
- fixed localization bug
- added TargetDeadIn() and OtherDebuffPresent() functions

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@120 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Condition.lua
Locale-enUS.lua
Locale-frFR.lua
Ovale.lua
Ovale.toc
OvaleCompile.lua
defaut/Chevalier.lua
defaut/Demoniste.lua
defaut/Druide.lua
defaut/Guerrier.lua
defaut/Paladin.lua
embeds.xml
diff --git a/Condition.lua b/Condition.lua
index d5c8157..24cf62f 100644
--- a/Condition.lua
+++ b/Condition.lua
@@ -34,6 +34,7 @@ local stunSpellIdList =
 	853, -- Hammer of Justice
 	408, -- Kidney Shot
 	12798, -- Revenge Stun
+	46968, -- Shockwave
 }
 local stunSpellList = nil

@@ -209,6 +210,32 @@ local function GetTargetAura(condition, filter, target)
 	return timeLeft, stacksLeft
 end

+local lastSaved
+local savedHealth
+local targetGUID
+local lastSPD=0.0001
+
+local function getTargetDead()
+	local second = math.floor(Ovale.maintenant)
+	if targetGUID~=UnitGUID("target") then
+		lastSaved = nil
+		targetGUID = UnitGUID("target")
+		savedHealth = {}
+	end
+	local newHealth = UnitHealth("target")
+	if second~=lastSaved then
+		lastSaved = second
+		local mod10 = second % 10
+		local prevHealth = savedHealth[mod10]
+		savedHealth[mod10] = newHealth
+		if prevHealth then
+			lastSPD = 10/(newHealth-prevHealth)
+		end
+	end
+	-- Rough estimation
+	return newHealth * lastSPD
+end
+
 Ovale.conditions=
 {
 	-- Test if a white hit just occured
@@ -460,6 +487,18 @@ Ovale.conditions=
 			return minTime
 		end
 	end,
+	OtherDebuffPresent = function(condition)
+		Ovale:EnableOtherDebuffs()
+		local otherDebuff = Ovale.otherDebuffs[GetSpellInfo(condition[1])]
+		if otherDebuff then
+			for target,expireTime in pairs(otherDebuff) do
+				if target~=UnitGUID("target") and expireTime>Ovale.maintenant then
+					return 0
+				end
+			end
+		end
+		return nil
+	end,
 	-- Test if any player pet is present (or not)
 	-- 1 : "yes" or "no"
 	PetPresent = function(condition)
@@ -565,6 +604,9 @@ Ovale.conditions=
 		end
 		return nil
 	end,
+	TargetDeadIn = function(condition)
+		return compare(getTargetDead(), condition[1], condition[2])
+	end,
 	-- Test if a debuff will expire on the target after a given time, or if there is less than the
 	-- given number of stacks (if stackable)
 	-- 1 : buff spell id
diff --git a/Locale-enUS.lua b/Locale-enUS.lua
index 404a84e..cd86911 100644
--- a/Locale-enUS.lua
+++ b/Locale-enUS.lua
@@ -25,4 +25,5 @@ L["Si cible uniquement"] = "If has target"
 L["Verrouiller position"] = "Lock position"
 L["Vertical"] = true
 L["Marge entre deux icônes"] = "Margin between icons"
-L["Focus"] = true
\ No newline at end of file
+L["Focus"] = true
+L["Apparence"] = "Appearance"
\ No newline at end of file
diff --git a/Locale-frFR.lua b/Locale-frFR.lua
index 2309ad0..f5b3aa6 100644
--- a/Locale-frFR.lua
+++ b/Locale-frFR.lua
@@ -25,4 +25,5 @@ L["Si cible uniquement"] = true
 L["Verrouiller position"] = true
 L["Vertical"] = true
 L["Marge entre deux icônes"] = true
-L["Focus"] = true
\ No newline at end of file
+L["Focus"] = true
+L["Apparence"] = true
\ No newline at end of file
diff --git a/Ovale.lua b/Ovale.lua
index 49c957b..607e5fc 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -47,7 +47,7 @@ local options =
 	{
 		apparence =
 		{
-			name = "Apparence",
+			name = L["Apparence"],
 			type = "group",
 			args =
 			{
@@ -204,7 +204,7 @@ local options =
 					guiHidden = true,
 					func = function()
 						Ovale.db.profile.display = true
-						Ovale.frame:Show()
+						Ovale:UpdateVisibility()
 					end
 				},
 				hide =
@@ -335,13 +335,7 @@ end
 ]]

 function Ovale:PLAYER_TARGET_CHANGED()
-	if (Ovale.db.profile.apparence.avecCible) then
-		if not UnitExists("target") then
-			self.frame:Hide()
-		else
-			self.frame:Show()
-		end
-	end
+	self:UpdateVisibility()
 end

 function Ovale:UNIT_AURA(event, unit)
@@ -513,9 +507,7 @@ end

 function Ovale:PLAYER_REGEN_ENABLED()
 	self.enCombat = false
-	if (Ovale.db.profile.apparence.enCombat and not Ovale.enCombat) then
-		self.frame:Hide()
-	end
+	self:UpdateVisibility()
 	-- if self.maxScore and self.maxScore > 0 then
 	-- 	self:Print((self.score/self.maxScore*100).."%")
 	-- end
@@ -526,10 +518,7 @@ function Ovale:PLAYER_REGEN_DISABLED()
 	self.score = 0
 	self.maxScore = 0

-	if (Ovale.db.profile.apparence.enCombat and not Ovale.enCombat) then
-		self.frame:Show()
-	end
-
+	self:UpdateVisibility()
 end

 function Ovale:OnDisable()
@@ -1226,6 +1215,11 @@ function Ovale:ToggleOptions()
 end

 function Ovale:UpdateVisibility()
+	if not Ovale.db.profile.display then
+		self.frame:Hide()
+		return
+	end
+
 	self.frame:Show()

 	if (Ovale.db.profile.apparence.avecCible and not UnitExists("target")) then
@@ -1246,10 +1240,13 @@ function Ovale:UpdateFrame()

 	self.checkBoxes = {}

-	for k,v in pairs(self.casesACocher) do
+	for k,checkBox in pairs(self.casesACocher) do
 		self.checkBoxes[k] = LibStub("AceGUI-3.0"):Create("CheckBox");
 		self.frame:AddChild(self.checkBoxes[k])
-		self.checkBoxes[k]:SetLabel(v)
+		self.checkBoxes[k]:SetLabel(checkBox.text)
+		if self.db.profile.check[k]==nil then
+			self.db.profile.check[k] = checkBox.checked
+		end
 		if (self.db.profile.check[k]) then
 			self.checkBoxes[k]:SetValue(self.db.profile.check[k]);
 		end
@@ -1260,9 +1257,12 @@ function Ovale:UpdateFrame()
 	self.dropDowns = {}

 	if (self.listes) then
-		for k,v in pairs(self.listes) do
+		for k,list in pairs(self.listes) do
 			self.dropDowns[k] = LibStub("AceGUI-3.0"):Create("Dropdown");
-			self.dropDowns[k]:SetList(v)
+			self.dropDowns[k]:SetList(list.items)
+			if not self.db.profile.list[k] then
+				self.db.profile.list[k] = list.default
+			end
 			if (self.db.profile.list[k]) then
 				self.dropDowns[k]:SetValue(self.db.profile.list[k]);
 			end
diff --git a/Ovale.toc b/Ovale.toc
index d3731c9..1fe956a 100644
--- a/Ovale.toc
+++ b/Ovale.toc
@@ -3,7 +3,7 @@
 ## Notes: Show the icon of the next spell to cast
 ## Notes-frFR: Affiche l'icône du prochain sort à lancer
 ## Author: Sidoine
-## Version: 3.2.11
+## Version: 3.2.12
 ## OptionalDeps: Ace3, ButtonFacade, Recount
 ## SavedVariables: OvaleDB
 ## SavedVariablesPerCharacter: OvaleDBPC
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 0f6bc6b..8da8a35 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -151,16 +151,22 @@ local function subtest(text, pattern, func)
 	return text
 end

-local function ParseAddListItem(list,item,text)
+local function ParseAddListItem(list,item,text, default)
 	if (not Ovale.listes[list]) then
-		Ovale.listes[list] = {}
+		Ovale.listes[list] = {items={},default=nil}
+	end
+	Ovale.listes[list].items[item] = text
+	if default == "default" then
+		Ovale.listes[list].default=item
 	end
-	Ovale.listes[list][item] = text
 	return ""
 end

-local function ParseAddCheckBox(item, text)
-	Ovale.casesACocher[item] = text
+local function ParseAddCheckBox(item, text, checked)
+	Ovale.casesACocher[item] = {text = text}
+	if checked=="checked" then
+		Ovale.casesACocher[item].checked = true
+	end
 	return ""
 end

@@ -212,9 +218,11 @@ end
 function Ovale:CompileInputs(text)
 	self.casesACocher = {}
 	self.listes = {}
+	self.defaultListes = {}
+	self.defaultCheck = {}

-	text = string.gsub(text, "AddListItem%s*%(%s*(%w+)%s+(%w+)%s+\"(.-)\"%s*%)", ParseAddListItem)
-	text = string.gsub(text, "AddCheckBox%s*%(%s*(%w+)%s+\"(.-)\"%s*%)", ParseAddCheckBox)
+	text = string.gsub(text, "AddListItem%s*%(%s*(%w+)%s+(%w+)%s+\"(.-)\"%s*(.-)%s*%)", ParseAddListItem)
+	text = string.gsub(text, "AddCheckBox%s*%(%s*(%w+)%s+\"(.-)\"%s*(.-)%s*%)", ParseAddCheckBox)
 	return text
 end

diff --git a/defaut/Chevalier.lua b/defaut/Chevalier.lua
index 6c0015f..e46bd40 100644
--- a/defaut/Chevalier.lua
+++ b/defaut/Chevalier.lua
@@ -34,6 +34,7 @@ Define(TALENTABOMINATIONMIGHT 2105)
 Define(RAISEDEAD 46584)

 AddCheckBox(rolldes SpellName(GLYPHDISEASE))
+
 SpellAddTargetDebuff(ICYTOUCH FROSTFEVER=15)
 SpellAddTargetDebuff(PLAGUESTRIKE BLOODPLAGUE=15)
 SpellInfo(ICYTOUCH frost=-1 forcecd=DEATHCOIL)
diff --git a/defaut/Demoniste.lua b/defaut/Demoniste.lua
index 85a6726..f7ecaed 100644
--- a/defaut/Demoniste.lua
+++ b/defaut/Demoniste.lua
@@ -29,7 +29,7 @@ Define(DECIMATION 63167)
 Define(CHAOSBOLT 50796)

 AddListItem(curse elements SpellName(CURSEELEMENTS))
-AddListItem(curse agony SpellName(CURSEAGONY))
+AddListItem(curse agony SpellName(CURSEAGONY) default)
 AddListItem(curse doom SpellName(CURSEDOOM))
 AddListItem(curse tongues SpellName(CURSETONGUES))
 AddListItem(curse weakness SpellName(CURSEWEAKNESS))
diff --git a/defaut/Druide.lua b/defaut/Druide.lua
index 07786ab..695643a 100644
--- a/defaut/Druide.lua
+++ b/defaut/Druide.lua
@@ -27,9 +27,9 @@ Define(CLAW 16827)
 Define(STARFALL 48505)

 AddCheckBox(multi L(AOE))
-AddCheckBox(mangle SpellName(MANGLECAT))
-AddCheckBox(demo SpellName(DEMOROAR))
-AddCheckBox(lucioles SpellName(FAERIEFIRE))
+AddCheckBox(mangle SpellName(MANGLECAT) default)
+AddCheckBox(demo SpellName(DEMOROAR) default)
+AddCheckBox(lucioles SpellName(FAERIEFIRE) default)
 AddCheckBox(wrath SpellName(WRATH))

 ScoreSpells(FAERIEFERAL DEMOROAR MANGLEBEAR LACERATE SAVAGEROAR RIP
@@ -42,17 +42,17 @@ AddIcon
 {
 	if Stance(1) # bear
 	{
+		Spell(MANGLEBEAR)
+
+		if Mana(more 10) and TargetDebuffExpires(LACERATE 4 stacks=5)
+			Spell(LACERATE)
+
 		if CheckBoxOn(lucioles) and TargetDebuffExpires(FAERIEFERAL 2)
 			Spell(FAERIEFERAL)

 		if CheckBoxOn(demo) and TargetDebuffExpires(DEMOROAR 2)
 			Spell(DEMOROAR)

-		Spell(MANGLEBEAR)
-
-		if Mana(more 10) and TargetDebuffExpires(LACERATE 4 stacks=5)
-			Spell(LACERATE)
-
 		if CheckBoxOn(multi)
 			Spell(SWIPE)
 	}
diff --git a/defaut/Guerrier.lua b/defaut/Guerrier.lua
index 6937e53..c2aae4b 100644
--- a/defaut/Guerrier.lua
+++ b/defaut/Guerrier.lua
@@ -36,8 +36,8 @@ Define(CURSEOFWEAKNESS 50511)

 AddCheckBox(multi L(AOE))
 AddCheckBox(demo SpellName(DEMOSHOUT))
-AddCheckBox(whirlwind SpellName(WHIRLWIND))
-AddCheckBox(sunder SpellName(SUNDER))
+AddCheckBox(whirlwind SpellName(WHIRLWIND) default)
+AddCheckBox(sunder SpellName(SUNDER) default)
 AddListItem(shout none L(None))
 AddListItem(shout battle SpellName(BATTLESHOUT))
 AddListItem(shout command SpellName(COMMANDSHOUT))
@@ -141,7 +141,10 @@ AddIcon
      }

      if CheckBoxOn(sunder) and TargetDebuffExpires(SUNDER 5 stacks=5)
+     {
+		Spell(DEVASTATE)
         Spell(SUNDER)
+     }
 }

 AddIcon
diff --git a/defaut/Paladin.lua b/defaut/Paladin.lua
index c43a3b1..972c211 100644
--- a/defaut/Paladin.lua
+++ b/defaut/Paladin.lua
@@ -22,11 +22,11 @@ Define(HOLYWRATH 2812)

 AddListItem(sceau piete SpellName(SEALRIGHTEOUSNESS))
 AddListItem(sceau autorite SpellName(SEALCOMMAND))
-AddListItem(sceau vengeance SpellName(SEALVENGEANCE))
+AddListItem(sceau vengeance SpellName(SEALVENGEANCE) default)
 AddListItem(jugement lumiere SpellName(JUDGELIGHT))
-AddListItem(jugement sagesse SpellName(JUDGEWISDOM))
-AddCheckBox(consecration SpellName(CONSECRATE))
-AddCheckBox(tempete SpellName(DIVINESTORM))
+AddListItem(jugement sagesse SpellName(JUDGEWISDOM) default)
+AddCheckBox(consecration SpellName(CONSECRATE) checked)
+AddCheckBox(tempete SpellName(DIVINESTORM) checked)
 AddCheckBox(coleredivine SpellName(HOLYWRATH))
 ScoreSpells(SEALRIGHTEOUSNESS SEALCOMMAND SEALVENGEANCE SEALCORRUPTION HOLYSHIELD HAMMEROFTHERIGHTEOUS CRUSADERSTRIKE
 	HAMMEROFWRATH JUDGELIGHT JUDGEWISDOM DIVINESTORM CONSECRATE EXORCISM HOLYWRATH HOLYSHOCK SHIELDOFRIGHTEOUSNESS)
diff --git a/embeds.xml b/embeds.xml
index fe03baa..d0c5838 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -12,5 +12,4 @@
   <Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml" />
   <Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml" />
   <Include file="Libs\LibBabble-CreatureType-3.0\lib.xml" />
-  <Include file="Libs\LibBabble-CreatureType-3.0\lib.xml" />
 </Ui>