Quantcast

- bug fix with "unless"

Sidoine De Wispelaere [02-03-09 - 20:23]
- bug fix with "unless"
- added some tolerance when comparing two CD
- added before keyword
- some options added

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@15 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Locale-enUS.lua
Locale-frFR.lua
Ovale.lua
Ovale.toc
OvaleCompile.lua
OvaleFrame.lua
OvaleIcone.lua
defaut/Chasseur.lua
defaut/Demoniste.lua
diff --git a/Locale-enUS.lua b/Locale-enUS.lua
index fda0142..a45ea89 100644
--- a/Locale-enUS.lua
+++ b/Locale-enUS.lua
@@ -20,4 +20,7 @@ L["Melee"] = true
 L["Raccourcis clavier"] = "Keyboard shortcuts"
 L["Afficher les raccourcis clavier dans le coin inférieur gauche des icônes"] = "Show keyboard shortcuts in the icon bottom-left corner"
 L["Affichage numérique"] = "Numeric display"
-L["Affiche le temps de recharge sous forme numérique"] = "Show the remaining time in numerical form"
\ No newline at end of file
+L["Affiche le temps de recharge sous forme numérique"] = "Show the remaining time in numerical form"
+L["Si cible uniquement"] = "If has target"
+L["Verrouiller position"] = "Lock position"
+L["Vertical"] = true
\ No newline at end of file
diff --git a/Locale-frFR.lua b/Locale-frFR.lua
index ec07a23..b5c4b91 100644
--- a/Locale-frFR.lua
+++ b/Locale-frFR.lua
@@ -20,4 +20,7 @@ L["Melee"] = "Corps-à-corps"
 L["Raccourcis clavier"] = true
 L["Afficher les raccourcis clavier dans le coin inférieur gauche des icônes"] = true
 L["Affichage numérique"] = true
-L["Affiche le temps de recharge sous forme numérique"] = true
\ No newline at end of file
+L["Affiche le temps de recharge sous forme numérique"] = true
+L["Si cible uniquement"] = true
+L["Verrouiller position"] = true
+L["Vertical"] = true
\ No newline at end of file
diff --git a/Ovale.lua b/Ovale.lua
index e482fe7..acf600b 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -23,6 +23,7 @@ Ovale.checkBoxes = {}
 Ovale.dropDowns = {}
 Ovale.masterNodes = nil
 Ovale.bug = false
+Ovale.enCombat = false

 Ovale.arbre = {}

@@ -54,6 +55,19 @@ local options =
 					end,
 					width = full
 				},
+				targetOnly =
+				{
+					order = 1.5,
+					type = "toggle",
+					name = L["Si cible uniquement"],
+					get = function(info)
+						return Ovale.db.profile.apparence.avecCible
+					end,
+					set = function(info, v)
+						Ovale.db.profile.apparence.avecCible = v
+					end,
+					width = full
+				},
 				iconWidth =
 				{
 					order = 2,
@@ -111,7 +125,24 @@ local options =
 					desc = L["Affiche le temps de recharge sous forme numérique"],
 					get = function(info) return Ovale.db.profile.apparence.numeric end,
 					set = function(info, value) Ovale.db.profile.apparence.numeric = value end
-				}
+				},
+				verrouille =
+				{
+					order = 8,
+					type = "toggle",
+					name = L["Verrouiller position"],
+					get = function(info) return Ovale.db.profile.apparence.verrouille end,
+					set = function(info, value) Ovale.db.profile.apparence.verrouille = value end
+				},
+				vertical =
+				{
+					order = 9,
+					type = "toggle",
+					name = L["Vertical"],
+					get = function(info) return Ovale.db.profile.apparence.vertical end,
+					set = function(info, value) Ovale.db.profile.apparence.vertical = value; Ovale:UpdateFrame() end
+				},
+
 			}
 		},
 		code =
@@ -248,15 +279,11 @@ function Ovale:OnEnable()
 end

 function Ovale:PLAYER_REGEN_ENABLED()
-	if (self.db.profile.apparence.enCombat) then
-		self.frame:Hide()
-	end
+	self.enCombat = false
 end

 function Ovale:PLAYER_REGEN_DISABLED()
-	if (self.db.profile.apparence.enCombat) then
-		self.frame:Show()
-	end
+	self.enCombat = true
 end

 function Ovale:OnDisable()
@@ -549,6 +576,18 @@ function Ovale:CalculerMeilleureAction(element)
 			end
 	 		return temps
 		end
+	elseif (element.type == "before") then
+		if (Ovale.trace) then
+			self:Print(element.time.."s before")
+		end
+		local tempsA = Ovale:CalculerMeilleureAction(element.a)
+		if (tempsA==nil) then
+			return nil
+		end
+		if (tempsA<element.time) then
+			return 0
+		end
+		return tempsA - element.time
 	elseif (element.type == "and" or element.type == "if") then
 		if (Ovale.trace) then
 			self:Print(element.type)
@@ -587,7 +626,7 @@ function Ovale:CalculerMeilleureAction(element)

 		local tempsA = Ovale:CalculerMeilleureAction(element.a)
 		local tempsB = Ovale:CalculerMeilleureAction(element.b)
-		if (tempsB==nil or tempsB>tempsA) then
+		if (tempsB==nil or (tempsA~=nil and tempsB>tempsA)) then
 			return tempsA
 		else
 			return tempsB
@@ -626,7 +665,7 @@ function Ovale:CalculerMeilleureAction(element)
 						-- que si il se lance au moins 1,5s avant
 						maxEcart = -self.gcd
 					else
-						maxEcart = 0
+						maxEcart = -0.01
 					end
 					if (nouveauTemps-meilleurTempsFils < maxEcart) then
 						remplacer = true
@@ -666,7 +705,8 @@ function Ovale:ChargerDefaut()
 			check = {},
 			list = {},
 			apparence = {enCombat=false, iconWidth = 64, iconHeight = 64,
-				smallIconWidth=32, smallIconHeight=32, raccourcis=true, numeric=false}
+				smallIconWidth=32, smallIconHeight=32, raccourcis=true, numeric=false, avecCible = false,
+				verrouille = false, vertical = false}
 		}
 	})
 end
diff --git a/Ovale.toc b/Ovale.toc
index a2b0b9e..f33cc25 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.0.1
+## Version: 3.0.2
 ## OptionalDeps: Ace3
 ## SavedVariables: OvaleDB
 ## SavedVariablesPerCharacter: OvaleDBPC
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 7d90187..093125e 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -48,6 +48,12 @@ local function ParseAnd(a,b)
 	return "node"..#node
 end

+local function ParseBefore(a,b)
+	local newNode = {type="before", time=tonumber(a), a=node[tonumber(b)]}
+	node[#node+1] = newNode
+	return "node"..#node
+end
+
 local function ParseOr(a,b)
 	local newNode = {type="or", a=node[tonumber(a)], b=node[tonumber(b)]}
 	node[#node+1] = newNode
@@ -108,6 +114,7 @@ local function ParseAddIcon(params, text)
 	text = string.gsub(text, "(%w+)%s*%((.-)%)", ParseFunction)
 	text = subtest(text, "node(%d+)%s+and%s+node(%d+)", ParseAnd)
 	text = subtest(text, "node(%d+)%s+or%s+node(%d+)", ParseOr)
+	text = subtest(text, "(%d+.?%d*)s%s+before%s+node(%d+)", ParseBefore)

 	text = subtest(text, "{([^{}]*)}", ParseGroup)

diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index 8423b54..9624721 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -27,17 +27,17 @@ do
 		this.obj:Hide()
 	end

-	local function frameOnMouseDown(this)
-		this:StartMoving()
-		AceGUI:ClearFocus()
-	end

-	local function titleOnMouseDown(this)
-		AceGUI:ClearFocus()
+	local function frameOnMouseDown(this)
+		if (not Ovale.db.profile.apparence.verrouille) then
+			this:StartMoving()
+			AceGUI:ClearFocus()
+		end
 	end

 	local function frameOnMouseUp(this)
 		this:StopMovingOrSizing()
+
 		if (Ovale.db.profile.left~=this:GetLeft() or Ovale.db.profile.top ~=this:GetTop()) then
 			Ovale.db.profile.left = this:GetLeft()
 			Ovale.db.profile.top = this:GetTop()
@@ -65,44 +65,6 @@ do
 		--this.obj.content:Hide()
 	end

-	local function titleOnMouseUp(this)
-		--[[ local frame = this:GetParent()
-		frame:StopMovingOrSizing()
-		local self = frame.obj
-		local status = self.status or self.localstatus
-		status.width = frame:GetWidth()
-		status.height = frame:GetHeight()
-		status.top = frame:GetTop()
-		status.left = frame:GetLeft() ]]--
-	end
-
-	local function sizerseOnMouseDown(this)
-		this:GetParent():StartSizing("BOTTOMRIGHT")
-		AceGUI:ClearFocus()
-	end
-
-	local function sizersOnMouseDown(this)
-		this:GetParent():StartSizing("BOTTOM")
-		AceGUI:ClearFocus()
-	end
-
-	local function sizereOnMouseDown(this)
-		this:GetParent():StartSizing("RIGHT")
-		AceGUI:ClearFocus()
-	end
-
-	local function sizerOnMouseUp(this)
-		this:GetParent():StopMovingOrSizing()
-	end
-
-	local function SetTitle(self,title)
-		self.titletext:SetText(title)
-	end
-
-	local function SetStatusText(self,text)
-		self.statustext:SetText(text)
-	end
-
 	local function Hide(self)
 		self.frame:Hide()
 	end
@@ -113,34 +75,9 @@ do

 	local function OnAcquire(self)
 		self.frame:SetParent(UIParent)
-		self:ApplyStatus()
 	end

 	local function OnRelease(self)
-		self.status = nil
-		for k in pairs(self.localstatus) do
-			self.localstatus[k] = nil
-		end
-	end
-
-	-- called to set an external table to store status in
-	local function SetStatusTable(self, status)
-		assert(type(status) == "table")
-		self.status = status
-		self:ApplyStatus()
-	end
-
-	local function ApplyStatus(self)
-		local status = self.status or self.localstatus
-		local frame = self.frame
-		self:SetWidth(status.width or 700)
-		self:SetHeight(status.height or 500)
-		if status.top and status.left then
-			frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
-			frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
-		else
-			frame:SetPoint("CENTER",UIParent,"CENTER")
-		end
 	end

 	local function OnWidthSet(self, width)
@@ -201,7 +138,11 @@ do
 				top = 0
 				left = maxWidth
 			end
-			self.icone[k]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",left,-top)
+			if (Ovale.db.profile.apparence.vertical) then
+				self.icone[k]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",top,-left)
+			else
+				self.icone[k]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",left,-top)
+			end
 			self.icone[k]:SetWidth(width)
 			self.icone[k]:SetHeight(height)
 			self.icone[k]:Show();
@@ -213,9 +154,15 @@ do
 				maxWidth = left + width
 			end
 		end
-		self.frame:SetWidth(maxWidth)
-		self.frame:SetHeight(maxHeight)
-		self.content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",maxWidth,0)
+		if (Ovale.db.profile.apparence.vertical) then
+			self.frame:SetWidth(maxHeight)
+			self.frame:SetHeight(maxWidth)
+			self.content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",maxHeight,0)
+		else
+			self.frame:SetWidth(maxWidth)
+			self.frame:SetHeight(maxHeight)
+			self.content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",maxWidth,0)
+		end
 	end

 	local function Constructor()
@@ -228,14 +175,9 @@ do

 		self.Hide = Hide
 		self.Show = Show
-		self.SetTitle =  SetTitle
 		self.OnRelease = OnRelease
 		self.OnAcquire = OnAcquire
-		self.SetStatusText = SetStatusText
-		self.SetStatusTable = SetStatusTable
 		self.ApplyStatus = ApplyStatus
-	--	self.OnWidthSet = OnWidthSet
-	--	self.OnHeightSet = OnHeightSet
 		self.LayoutFinished = OnLayoutFinished
 		self.UpdateIcons = UpdateIcons

@@ -252,7 +194,6 @@ do
 		--frame:SetResizable(true)
 		frame:SetFrameStrata("BACKGROUND")
 		frame:SetScript("OnMouseDown", frameOnMouseDown)
-		-- title:SetScript("OnMouseDown",titleOnMouseDown)
 		frame:SetScript("OnMouseUp", frameOnMouseUp)
 		frame:SetScript("OnEnter", frameOnEnter)
 		frame:SetScript("OnLeave", frameOnLeave)
diff --git a/OvaleIcone.lua b/OvaleIcone.lua
index 247b654..9ad61fd 100644
--- a/OvaleIcone.lua
+++ b/OvaleIcone.lua
@@ -17,6 +17,14 @@
 		Ovale.trace = true
 	end

+	if (Ovale.db.profile.apparence.avecCible and not UnitExists("target")) then
+		minAttente = nil
+	end
+
+	if (Ovale.db.profile.apparence.enCombat and not Ovale.enCombat) then
+		minAttente = nil
+	end
+
 	if (self.masterNode.params.nocd == 1 and minAttente>1.5) then
 		minAttente = nil
 	end
diff --git a/defaut/Chasseur.lua b/defaut/Chasseur.lua
index f116855..7f87d63 100644
--- a/defaut/Chasseur.lua
+++ b/defaut/Chasseur.lua
@@ -16,10 +16,10 @@ AddCheckBox(multi SpellName(MULTISHOT))
 AddIcon
 {
 	if TargetDebuffExpires(SERPENTSTING 0) Spell(SERPENTSTING)
+	Spell(EXPLOSIVESHOT)
 	Spell(ARCANESHOT)
 	#Spell(AIMEDSHOT)
 	if CheckBoxOn(multi) Spell(MULTISHOT)
-	Spell(EXPLOSIVESHOT)
 	if TargetLifePercent(less 20) Spell(KILLSHOT)
 	Spell(STEADYSHOT)
 }
diff --git a/defaut/Demoniste.lua b/defaut/Demoniste.lua
index 3e2c968..098e1ea 100644
--- a/defaut/Demoniste.lua
+++ b/defaut/Demoniste.lua
@@ -22,6 +22,7 @@ Define(CONFLAGRATE 17962)
 Define(DRAINSOUL 47855)
 Define(SHADOWEMBRACE 32391)
 Define(TALENTSHADOWEMBRACE 1763)
+Define(METAMORPHOSIS 47241)

 AddListItem(curse recklessness SpellName(CURSERECKLESSNESS))
 AddListItem(curse elements SpellName(CURSEELEMENTS))
@@ -52,4 +53,9 @@ if TargetLifePercent(less 25) and Level(more 76) Spell(DRAINSOUL)
 if TalentPoints(TALENTEMBERSTORM more 0) Spell(SOULFIRE)
 Spell(SHADOWBOLT)
 }
+
+AddIcon
+{
+	Spell(METAMORPHOSIS)
+}
 ]]