From 5da69961a562079b552ec327592fb0e159f49344 Mon Sep 17 00:00:00 2001 From: Sidoine De Wispelaere Date: Sun, 5 Jul 2009 11:06:05 +0000 Subject: [PATCH] - display an action even if it is not in the action bar (do not work well for "on next action" spells) git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@80 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- Ovale.lua | 111 +++++++++++++++++++++++++++++++++++++------------------- OvaleIcone.lua | 25 ++++++------- 2 files changed, 86 insertions(+), 50 deletions(-) diff --git a/Ovale.lua b/Ovale.lua index a6644be..291a254 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -13,8 +13,6 @@ Ovale.talentNameToId = {} Ovale.firstInit = false Ovale.Inferieur = 1 Ovale.Superieur = 2 -Ovale.retourPriorite = 0 -Ovale.retourAction = nil Ovale.listeTalentsRemplie = false Ovale.frame = nil Ovale.checkBoxes = {} @@ -673,10 +671,7 @@ function Ovale:CalculerMeilleureAction(element) if (not element) then return nil end - - self.retourAction = nil - self.retourPriorite = nil - + if (element.type=="function")then if (element.func == "Spell" or element.func=="Macro" or element.func=="Item") then local action @@ -688,31 +683,57 @@ function Ovale:CalculerMeilleureAction(element) elseif (element.func=="Item") then action = self.actionObjet[element.params[1]] end - if (not action) then + local actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut, actionIsCurrent, actionEnable + + if (action) then + actionTexture = GetActionTexture(action) + actionInRange = IsActionInRange(action, "target") + actionCooldownStart, actionCooldownDuration, actionEnable = GetActionCooldown(action) + actionUsable = IsUsableAction(action) + actionShortcut = self.shortCut[action] + actionIsCurrent = IsCurrentAction(action) + end + if (not actionTexture and element.func == "Spell") then + local sort = self:GetSpellInfoOrNil(element.params[1]) + actionTexture = GetSpellTexture(sort) + actionInRange = IsSpellInRange(sort, "target") + actionCooldownStart, actionCooldownDuration, actionEnable = GetSpellCooldown(sort) + actionUsable = IsUsableSpell(sort) + actionShortcut = nil + local casting = UnitCastingInfo("player") + if (casting == sort) then + actionIsCurrent = 1 + else + actionIsCurrent = nil + end + -- not quite the same as IsCurrentAction. Why did they remove IsCurrentCast? + end + + if (not actionTexture) then if (Ovale.trace) then self:Print("Action "..element.params[1].." not found") end return nil end - if (element.params.usable==1 and not IsUsableAction(action)) then + if (element.params.usable==1 and not actionUsable) then if (Ovale.trace) then self:Print("Action "..element.params[1].." not usable") end return nil end - if (element.params.doNotRepeat==1 and IsCurrentAction(action)) then + if (element.params.doNotRepeat==1 and actionIsCurrent) then if (Ovale.trace) then self:Print("Action "..element.params[1].." is current action") end return nil end - local start, duration, enable = GetActionCooldown(action) - local restant - if (enable>0) then - if (not duration or start==0) then + if (actionEnable>0) then + local restant + if (not actionCooldownDuration or actionCooldownStart==0) then restant = 0 else - restant = duration - (self.maintenant - start); + restant = actionCooldownDuration - (self.maintenant - actionCooldownStart); end if (restanttempsA) then - return tempsB + return tempsB, priorite, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut else - return tempsA + return tempsA, priorite, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut end elseif (element.type == "unless") then if (Ovale.trace) then @@ -791,9 +812,11 @@ function Ovale:CalculerMeilleureAction(element) if (tempsA==0) then return nil end - local tempsB = Ovale:CalculerMeilleureAction(element.b) + local tempsB, priorite, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut = Ovale:CalculerMeilleureAction(element.b) if (tempsA==nil or tempsA>tempsB) then - return tempsB + return tempsB, priorite, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut else return nil end @@ -815,17 +838,26 @@ function Ovale:CalculerMeilleureAction(element) local meilleurFils local meilleurTempsFils local meilleurePrioriteFils + local bestActionInRange + local bestActionCooldownStart + local bestActionCooldownDuration + local bestActionUsable + local bestActionShortCut if (Ovale.trace) then self:Print(element.type) end for k, v in ipairs(element.nodes) do - local nouveauTemps = Ovale:CalculerMeilleureAction(v) - local action = self.retourAction - local priorite = self.retourPriorite + local nouveauTemps, priorite, action, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut = Ovale:CalculerMeilleureAction(v) if (nouveauTemps) then local remplacer + if (not action) then + self:Print("Internal error: "..v.type.." returned nouveauTemps="..nouveauTemps.." and action=nil") + self.bug = true + return nil + end if (not meilleurTempsFils) then remplacer = true else @@ -833,7 +865,7 @@ function Ovale:CalculerMeilleureAction(element) local maxEcart if (priorite and not meilleurePrioriteFils) then self.bug = true - self:Print("meilleurePrioriteFils nil and priorite not nil") + self:Print("Internal error: meilleurePrioriteFils=nil and priorite="..priorite) return nil end if (priorite and priorite > meilleurePrioriteFils) then @@ -855,6 +887,11 @@ function Ovale:CalculerMeilleureAction(element) meilleurTempsFils = nouveauTemps meilleurFils = action meilleurePrioriteFils = priorite + bestActionInRange = actionInRange + bestActionCooldownStart = actionCooldownStart + bestActionCooldownDuration = actionCooldownDuration + bestActionUsable = actionUsable + bestActionShortCut = actionShortcut end end end @@ -863,14 +900,14 @@ function Ovale:CalculerMeilleureAction(element) if (Ovale.trace) then self:Print("Best action "..meilleurFils.." remains "..meilleurTempsFils) end - self.retourPriorite = meilleurePrioriteFils - self.retourAction = meilleurFils - return meilleurTempsFils + return meilleurTempsFils,meilleurePrioriteFils, meilleurFils, bestActionInRange, bestActionCooldownStart, + bestActionCooldownDuration, bestActionUsable, bestActionShortCut else if (Ovale.trace) then printTime(nil) end return nil end end + return nil end function Ovale:ChargerDefaut() diff --git a/OvaleIcone.lua b/OvaleIcone.lua index 6fe7796..c5be895 100644 --- a/OvaleIcone.lua +++ b/OvaleIcone.lua @@ -6,8 +6,8 @@ end Ovale:InitCalculerMeilleureAction() - local minAttente = Ovale:CalculerMeilleureAction(self.masterNode) - local meilleureAction = Ovale.retourAction + local minAttente, priorite, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut = Ovale:CalculerMeilleureAction(self.masterNode) if (Ovale.trace) then Ovale.trace=false @@ -24,16 +24,16 @@ minAttente = nil end - if (minAttente~=nil and meilleureAction) then + if (minAttente~=nil and actionTexture) then - if (meilleureAction~=self.actionCourante or self.ancienneAttente==nil or + if (actionTexture~=self.actionCourante or self.ancienneAttente==nil or (minAttente~=0 and minAttente>self.ancienneAttente+0.01) or (Ovale.maintenant + minAttente < self.finAction-0.01)) then - if (meilleureAction~=self.actionCourante or self.ancienneAttente==nil or + if (actionTexture~=self.actionCourante or self.ancienneAttente==nil or (minAttente~=0 and minAttente>self.ancienneAttente+0.01)) then self.debutAction = Ovale.maintenant end - self.actionCourante = meilleureAction + self.actionCourante = actionTexture self.finAction = minAttente + Ovale.maintenant if (minAttente == 0) then self.cd:Hide() @@ -47,16 +47,15 @@ -- L'icône avec le cooldown self.icone:Show() - self.icone:SetTexture(GetActionTexture(meilleureAction)); + self.icone:SetTexture(actionTexture); - if (IsUsableAction(meilleureAction)) then + if (actionUsable) then self.icone:SetAlpha(1.0) else self.icone:SetAlpha(0.25) end - local start, duration, enable = GetActionCooldown(meilleureAction) - if (Ovale.maintenant + minAttente > start + duration + 0.01 and minAttente > 0 + if (Ovale.maintenant + minAttente > actionCooldownStart + actionCooldownDuration + 0.01 and minAttente > 0 and minAttente>Ovale.attenteFinCast) then self.icone:SetVertexColor(0.75,0,0) else @@ -78,17 +77,17 @@ -- Le raccourcis clavier if (Ovale.db.profile.apparence.raccourcis) then self.shortcut:Show() - self.shortcut:SetText(Ovale.shortCut[meilleureAction]) + self.shortcut:SetText(actionShortcut) else self.shortcut:Hide() end -- L'indicateur de portée self.aPortee:Show() - if (IsActionInRange(meilleureAction,"target")==1) then + if (actionInRange==1) then self.aPortee:SetVertexColor(0.6,0.6,0.6) self.aPortee:Show() - elseif (IsActionInRange(meilleureAction,"target")==0) then + elseif (actionInRange==0) then self.aPortee:SetVertexColor(1.0,0.1,0.1) self.aPortee:Show() else -- 1.7.9.5