From d302e3addb5c10690b4c1f18c830ad8064dee112 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 23 Nov 2012 17:16:33 +0000 Subject: [PATCH] Remove split compilation and use a single pass for compiling again. Back out part of r604 that split compilation into a "quick" part and an expensive part. The more efficient method in r606 for searching and replacing defines with key values seems to have fixed the slow compilation enough that it fits within the Lua execution window. Re-merging the compilation phases fixes some issues with Ovale not properly updating the script when a toon levels, as well as some other edge cases. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@636 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- Ovale.lua | 24 ++-- OvaleCompile.lua | 11 +- OvaleData.lua | 4 +- OvaleFrame.lua | 363 ++++++++++++++++++++++++++---------------------------- 4 files changed, 190 insertions(+), 212 deletions(-) diff --git a/Ovale.lua b/Ovale.lua index d7bc601..7dca23a 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -34,7 +34,6 @@ Ovale.checkBoxes = {} Ovale.dropDowns = {} --master nodes of the current script (one node for each icon) Ovale.masterNodes = nil -Ovale.masterNodesEnabled = {} --set it if there was a bug, traces will be enabled on next frame Ovale.bug = false Ovale.traced = false @@ -50,7 +49,6 @@ Ovale.refreshNeeded = {} Ovale.compileOnItems = false Ovale.compileOnStances = false Ovale.combatStartTime = nil ---needCompile is true, false, or "quick" Ovale.needCompile = false Ovale.listes = {} --debug flags @@ -91,20 +89,14 @@ end function Ovale:CompileAll() local code = OvaleOptions:GetProfile().code if code then - if self.needCompile == "quick" then - self:debugPrint("compile", "quick compile") - code = OvaleCompile:CompileComments(code) - code = OvaleCompile:CompileDeclarations(code) - code = OvaleCompile:CompileInputs(code) - elseif self.needCompile then + if self.needCompile then self:debugPrint("compile", "FULL compile") self.masterNodes = OvaleCompile:Compile(code) end OvaleData:FillMissingSpells() - OvaleCompile:UpdateNodesEnabled(self.masterNodes, self.masterNodesEnabled) self.refreshNeeded.player = true - self.needCompile = false self:UpdateFrame() + self.needCompile = false end end @@ -159,7 +151,7 @@ end function Ovale:UNIT_INVENTORY_CHANGED(event) if self.compileOnItems then self:debugPrint("compile", event) - self.needCompile = self.needCompile or "quick" + self.needCompile = true else self.refreshNeeded.player = true end @@ -168,7 +160,7 @@ end function Ovale:Ovale_UpdateShapeshiftForm(event) if Ovale.compileOnStances then self:debugPrint("compile", event) - self.needCompile = self.needCompile or "quick" + self.needCompile = true else self.refreshNeeded.player = true end @@ -186,14 +178,14 @@ end --The script needs to be compiled function Ovale:GLYPH_ADDED(event) self:debugPrint("compile", event) - self.needCompile = self.needCompile or "quick" + self.needCompile = true end --Called when a glyph has been updated --The script needs to be compiled function Ovale:GLYPH_UPDATED(event) self:debugPrint("compile", event) - self.needCompile = self.needCompile or "quick" + self.needCompile = true end function Ovale:CHAT_MSG_ADDON(event, prefix, msg, type, author) @@ -255,7 +247,7 @@ local function OnCheckBoxValueChanged(widget) OvaleOptions:GetProfile().check[widget.userdata.k] = widget:GetValue() if Ovale.casesACocher[widget.userdata.k].compile then Ovale:debugPrint("compile", "checkbox value changed: " .. widget.userdata.k) - Ovale.needCompile = Ovale.needCompile or "quick" + Ovale.needCompile = true end end @@ -263,7 +255,7 @@ local function OnDropDownValueChanged(widget) OvaleOptions:GetProfile().list[widget.userdata.k] = widget.value if Ovale.listes[widget.userdata.k].compile then Ovale:debugPrint("compile", "list value changed: " .. widget.userdata.k) - Ovale.needCompile = Ovale.needCompile or "quick" + Ovale.needCompile = true end end diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 87d6028..11ef51c 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -514,6 +514,9 @@ local function ParseAddIcon(params, text, secure) masterNode = node[tonumber(masterNode)] masterNode.params = ParseParameters(params) masterNode.secure = secure + if not TestConditions(masterNode.params) then + return nil + end return masterNode end @@ -588,14 +591,6 @@ function OvaleCompile:CompileDeclarations(text) return text end -function OvaleCompile:UpdateNodesEnabled(masterNodes, enabledTbl) - if masterNodes then - for k, node in pairs(masterNodes) do - enabledTbl[k] = TestConditions(node.params) - end - end -end - function OvaleCompile:Compile(text) Ovale.compileOnItems = false Ovale.compileOnStances = false diff --git a/OvaleData.lua b/OvaleData.lua index becc77e..2e7c08f 100644 --- a/OvaleData.lua +++ b/OvaleData.lua @@ -301,7 +301,7 @@ end function OvaleData:SPELLS_CHANGED(event) Ovale:debugPrint("compile", event) self:FillSpellList() - Ovale.needCompile = Ovale.needCompile or "quick" + Ovale.needCompile = true end function OvaleData:GetRootSpellList() @@ -418,7 +418,7 @@ function OvaleData:RemplirListeTalents() self.pointsTalent[talentId] = 0 end self.listeTalentsRemplie = true - needCompile = Ovale.needCompile or "quick" + needCompile = true talentId = talentId + 1 end if needCompile then diff --git a/OvaleFrame.lua b/OvaleFrame.lua index 196e808..87f8962 100644 --- a/OvaleFrame.lua +++ b/OvaleFrame.lua @@ -116,26 +116,24 @@ do local function GetScore(self, spellId) for k,action in pairs(self.actions) do - if Ovale.masterNodesEnabled[k] then - if action.spellId == spellId then - if not action.waitStart then - -- print("sort "..spellId.." parfait") - return 1 + if action.spellId == spellId then + if not action.waitStart then + -- print("sort "..spellId.." parfait") + return 1 + else + local lag = OvaleState.maintenant - action.waitStart + if lag>5 then + -- print("sort "..spellId.." ignoré (>5s)") + return nil + elseif lag>1.5 then + -- print("sort "..spellId.." trop lent !") + return 0 + elseif lag>0 then + -- print("sort "..spellId.." un peu lent "..lag) + return 1-lag/1.5 else - local lag = OvaleState.maintenant - action.waitStart - if lag>5 then - -- print("sort "..spellId.." ignoré (>5s)") - return nil - elseif lag>1.5 then - -- print("sort "..spellId.." trop lent !") - return 0 - elseif lag>0 then - -- print("sort "..spellId.." un peu lent "..lag) - return 1-lag/1.5 - else - -- print("sort "..spellId.." juste bon") - return 1 - end + -- print("sort "..spellId.." juste bon") + return 1 end end end @@ -165,116 +163,111 @@ do OvaleState:StartNewFrame() for k,node in pairs(Ovale.masterNodes) do - if Ovale.masterNodesEnabled[k] then - local target = node.params.target or "target" - OvaleCondition.defaultTarget = target + local target = node.params.target or "target" + OvaleCondition.defaultTarget = target - if forceRefresh or Ovale.refreshNeeded[target] or Ovale.refreshNeeded["player"] or Ovale.refreshNeeded["pet"] then - if Ovale.trace then - Ovale:Print("****Master Node "..k) + if forceRefresh or Ovale.refreshNeeded[target] or Ovale.refreshNeeded["player"] or Ovale.refreshNeeded["pet"] then + if Ovale.trace then + Ovale:Print("****Master Node "..k) + end + OvaleBestAction:StartNewAction() + local start, ending, priorite, element = OvaleBestAction:Compute(node) + if start then + Ovale:Log("Compute start = "..start) + end + local action = self.actions[k] + local icons + if action.secure then + icons = action.secureIcons + else + icons = action.icons + end + if element and element.type == "value" then + local actionTexture + if node.params.texture then + actionTexture = GetSpellTexture(node.params.texture) end - OvaleBestAction:StartNewAction() - local start, ending, priorite, element = OvaleBestAction:Compute(node) - if start then - Ovale:Log("Compute start = "..start) + local value + if element.value and element.origin and element.rate then + value = element.value + (OvaleState.maintenant - element.origin) * element.rate end - local action = self.actions[k] - local icons - if action.secure then - icons = action.secureIcons - else - icons = action.icons + icons[1]:SetValue(value, actionTexture) + if #icons > 1 then + icons[2]:Update(element, nil) end - if element and element.type == "value" then - local actionTexture - if node.params.texture then - actionTexture = GetSpellTexture(node.params.texture) - end - local value - if element.value and element.origin and element.rate then - value = element.value + (OvaleState.maintenant - element.origin) * element.rate - end - icons[1]:SetValue(value, actionTexture) - if #icons > 1 then - icons[2]:Update(element, nil) - end - else - local actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, - actionUsable, actionShortcut, actionIsCurrent, actionEnable, spellId, actionTarget, noRed = OvaleBestAction:GetActionInfo(element) - if noRed then - start = actionCooldownStart + actionCooldownDuration - if start < OvaleState.currentTime then - start = OvaleState.currentTime - end + else + local actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, + actionUsable, actionShortcut, actionIsCurrent, actionEnable, spellId, actionTarget, noRed = OvaleBestAction:GetActionInfo(element) + if noRed then + start = actionCooldownStart + actionCooldownDuration + if start < OvaleState.currentTime then + start = OvaleState.currentTime end - + end -- Dans le cas de canStopChannelling, on risque de demander d'interrompre le channelling courant, ce qui est stupide - if start and OvaleState.currentSpellId and OvaleState.attenteFinCast and spellId == OvaleState.currentSpellId and start1 then - top = 1 - end - icons[1]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",(action.left + top*action.dx)/action.scale,(action.top - top*action.dy)/action.scale) - if icons[2] then - icons[2]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",(action.left + (top+1)*action.dx)/action.scale,(action.top - (top+1)*action.dy)/action.scale) - end + if OvaleOptions:GetApparence().moving and icons[1].debutAction and icons[1].finAction then + local top=1-(OvaleState.maintenant - icons[1].debutAction)/(icons[1].finAction-icons[1].debutAction) + if top<0 then + top = 0 + elseif top>1 then + top = 1 + end + icons[1]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",(action.left + top*action.dx)/action.scale,(action.top - top*action.dy)/action.scale) + if icons[2] then + icons[2]:SetPoint("TOPLEFT",self.frame,"TOPLEFT",(action.left + (top+1)*action.dx)/action.scale,(action.top - (top+1)*action.dy)/action.scale) end + end - if (node.params.size ~= "small" and not node.params.nocd and OvaleOptions:GetApparence().predictif) then - if start then - local castTime=0 - if spellId then - local _, _, _, _, _, _, _castTime = GetSpellInfo(spellId) - if _castTime and _castTime>0 then - castTime = _castTime/1000 - end - end - local gcd = OvaleData:GetGCD(spellId) - local nextCast - if (castTime>gcd) then - nextCast = start + castTime - else - nextCast = start + gcd - end - if Ovale.trace then - Ovale:Print("****Second icon " .. start) - end - local spellTarget - if element then - spellTarget = element.params.target - end - if spellTarget == "target" or not spellTarget then - spellTarget = target + if (node.params.size ~= "small" and not node.params.nocd and OvaleOptions:GetApparence().predictif) then + if start then + local castTime=0 + if spellId then + local _, _, _, _, _, _, _castTime = GetSpellInfo(spellId) + if _castTime and _castTime>0 then + castTime = _castTime/1000 end - OvaleState:AddSpellToStack(spellId, start, start + castTime, nextCast, false, UnitGUID(spellTarget)) - start, ending, priorite, element = OvaleBestAction:Compute(node) - icons[2]:Update(element, start, OvaleBestAction:GetActionInfo(element)) + end + local gcd = OvaleData:GetGCD(spellId) + local nextCast + if (castTime>gcd) then + nextCast = start + castTime else - icons[2]:Update(element, nil) + nextCast = start + gcd + end + if Ovale.trace then + Ovale:Print("****Second icon " .. start) + end + local spellTarget + if element then + spellTarget = element.params.target + end + if spellTarget == "target" or not spellTarget then + spellTarget = target end + OvaleState:AddSpellToStack(spellId, start, start + castTime, nextCast, false, UnitGUID(spellTarget)) + start, ending, priorite, element = OvaleBestAction:Compute(node) + icons[2]:Update(element, start, OvaleBestAction:GetActionInfo(element)) + else + icons[2]:Update(element, nil) end end end @@ -323,88 +316,86 @@ do local margin = OvaleOptions:GetApparence().margin for k,node in pairs(Ovale.masterNodes) do - if Ovale.masterNodesEnabled[k] then - if not self.actions[k] then - self.actions[k] = {icons={}, secureIcons={}} - end - local action = self.actions[k] + if not self.actions[k] then + self.actions[k] = {icons={}, secureIcons={}} + end + local action = self.actions[k] - local width, height, newScale - local nbIcons - if (node.params.size == "small") then - newScale = OvaleOptions:GetApparence().smallIconScale - width = newScale * 36 + margin - height = newScale * 36 + margin - nbIcons = 1 + local width, height, newScale + local nbIcons + if (node.params.size == "small") then + newScale = OvaleOptions:GetApparence().smallIconScale + width = newScale * 36 + margin + height = newScale * 36 + margin + nbIcons = 1 + else + newScale = OvaleOptions:GetApparence().iconScale + width =newScale * 36 + margin + height = newScale * 36 + margin + if OvaleOptions:GetApparence().predictif and node.params.type ~= "value" then + nbIcons = 2 else - newScale = OvaleOptions:GetApparence().iconScale - width =newScale * 36 + margin - height = newScale * 36 + margin - if OvaleOptions:GetApparence().predictif and node.params.type ~= "value" then - nbIcons = 2 - else - nbIcons = 1 - end - end - if (top + height > OvaleOptions:GetApparence().iconScale * 36 + margin) then - top = 0 - left = maxWidth + nbIcons = 1 end + end + if (top + height > OvaleOptions:GetApparence().iconScale * 36 + margin) then + top = 0 + left = maxWidth + end - action.scale = newScale - if (OvaleOptions:GetApparence().vertical) then - action.left = top - action.top = -left-BARRE-margin - action.dx = width - action.dy = 0 - else - action.left = left - action.top = -top-BARRE-margin - action.dx = 0 - action.dy = height - end - action.secure = node.secure + action.scale = newScale + if (OvaleOptions:GetApparence().vertical) then + action.left = top + action.top = -left-BARRE-margin + action.dx = width + action.dy = 0 + else + action.left = left + action.top = -top-BARRE-margin + action.dx = 0 + action.dy = height + end + action.secure = node.secure - for l=1,nbIcons do - local icon - if not node.secure then - if not action.icons[l] then - action.icons[l] = CreateFrame("CheckButton", "Icon"..k.."n"..l,self.frame,"OvaleIconTemplate"); - end - icon = action.icons[l] - else - if not action.secureIcons[l] then - action.secureIcons[l] = CreateFrame("CheckButton", "SecureIcon"..k.."n"..l,self.frame,"SecureOvaleIconTemplate"); - end - icon = action.secureIcons[l] + for l=1,nbIcons do + local icon + if not node.secure then + if not action.icons[l] then + action.icons[l] = CreateFrame("CheckButton", "Icon"..k.."n"..l,self.frame,"OvaleIconTemplate"); end - local scale = action.scale - if l> 1 then - scale = scale * OvaleOptions:GetApparence().secondIconScale - end - icon:SetPoint("TOPLEFT",self.frame,"TOPLEFT",(action.left + (l-1)*action.dx)/scale,(action.top - (l-1)*action.dy)/scale) - icon:SetScale(scale) - icon:SetFontScale(OvaleOptions:GetApparence().fontScale) - icon:SetParams(node.params) - icon:SetHelp(node.params.help) - icon:SetRangeIndicator(OvaleOptions:GetApparence().targetText) - icon:EnableMouse(not OvaleOptions:GetApparence().clickThru) - icon.cdShown = (l == 1) - if Masque then - self.skinGroup:AddButton(icon) - end - if l==1 then - icon:Show(); + icon = action.icons[l] + else + if not action.secureIcons[l] then + action.secureIcons[l] = CreateFrame("CheckButton", "SecureIcon"..k.."n"..l,self.frame,"SecureOvaleIconTemplate"); end + icon = action.secureIcons[l] end - - top = top + height - if (top> maxHeight) then - maxHeight = top + local scale = action.scale + if l> 1 then + scale = scale * OvaleOptions:GetApparence().secondIconScale end - if (left + width > maxWidth) then - maxWidth = left + width + icon:SetPoint("TOPLEFT",self.frame,"TOPLEFT",(action.left + (l-1)*action.dx)/scale,(action.top - (l-1)*action.dy)/scale) + icon:SetScale(scale) + icon:SetFontScale(OvaleOptions:GetApparence().fontScale) + icon:SetParams(node.params) + icon:SetHelp(node.params.help) + icon:SetRangeIndicator(OvaleOptions:GetApparence().targetText) + icon:EnableMouse(not OvaleOptions:GetApparence().clickThru) + icon.cdShown = (l == 1) + if Masque then + self.skinGroup:AddButton(icon) end + if l==1 then + icon:Show(); + end + end + + top = top + height + if (top> maxHeight) then + maxHeight = top + end + if (left + width > maxWidth) then + maxWidth = left + width end end -- 1.7.9.5