From 5adf84da6b072b16c1d378cd00bcffd97c866d1e Mon Sep 17 00:00:00 2001 From: tercio Date: Thu, 18 Sep 2014 13:57:28 -0300 Subject: [PATCH] - Changed thw way to set the broker text. - Fixed a problem while reporting a custom display. - New API: _detalhes:GetOpenedWindowsAmount() --- Libs/LibGraph-2.0/LibGraph-2.0.lua | 2167 ++++++++++++++-------------- boot.lua | 8 +- classes/classe_custom.lua | 16 +- classes/classe_instancia.lua | 10 + core/windows.lua | 226 ++- framework/dropdown.xml | 8 +- functions/profiles.lua | 1 + functions/timedata.lua | 236 ++- gumps/janela_options.lua | 86 +- startup.lua | 2 + 10 files changed, 1564 insertions(+), 1196 deletions(-) diff --git a/Libs/LibGraph-2.0/LibGraph-2.0.lua b/Libs/LibGraph-2.0/LibGraph-2.0.lua index e855e0fa..22f1a8cb 100644 --- a/Libs/LibGraph-2.0/LibGraph-2.0.lua +++ b/Libs/LibGraph-2.0/LibGraph-2.0.lua @@ -1,6 +1,6 @@ --[[ Name: LibGraph-2.0 -Revision: $Rev: 49 $ +Revision: $Rev: 51 $ Author(s): Cryect (cryect@gmail.com), Xinhuan Website: http://www.wowace.com/ Documentation: http://www.wowace.com/wiki/GraphLib @@ -11,24 +11,19 @@ Description: Allows for easy creation of graphs --Thanks to Nelson Minar for catching several errors where width was being used instead of height (damn copy and paste >_>) local major = "LibGraph-2.0" -local minor = 90000 + tonumber(("$Revision: 50 $"):match("(%d+)")) +local minor = 90000 + tonumber(("$Revision: 52 $"):match("(%d+)")) + --Search for just Addon\\ at the front since the interface part often gets trimmed --Do this before anything else, so if it errors, any existing loaded copy of LibGraph-2.0 --doesn't get modified with a newer revision (this one) - ---change log: - -- 10/07/2013 added new methods (tercioo): - --SetLineTexture (texture path or 'line', 'smalline', 'thinline') for line graphics. - --SetBorderSize (border side, length) border side can be left right top bottom, done to line graph atm. - local TextureDirectory do - local path = string.match(debugstack(1,1,0), "AddOns\\(.+)LibGraph%-2%.0%.lua") + local path = string.match(debugstack(1, 1, 0), "AddOns\\(.+)LibGraph%-2%.0%.lua") if path then TextureDirectory = "Interface\\AddOns\\"..path else - error(major.." cannot determine the folder it is located in because the path is too long and got truncated in the debugstack(1,1,0) function call") + error(major.." cannot determine the folder it is located in because the path is too long and got truncated in the debugstack(1, 1, 0) function call") end end @@ -38,10 +33,16 @@ if not LibStub then error(major .. " requires LibStub") end local lib, oldLibMinor = LibStub:NewLibrary(major, minor) if not lib then return end -local GraphFunctions={} +local GraphFunctions = {} -local tinsert, tremove = tinsert, tremove -local pairs, ipairs = pairs, ipairs +local gsub = gsub +local ipairs = ipairs +local pairs = pairs +local sqrt = sqrt +local table = table +local tinsert = tinsert +local tremove = tremove +local type = type local math_max = math.max local math_min = math.min local math_ceil = math.ceil @@ -56,14 +57,22 @@ local math_atan = math.atan local math_abs = math.abs local math_fmod = math.fmod local math_huge = math.huge + +local CreateFrame = CreateFrame +local GetCursorPosition = GetCursorPosition local GetTime = GetTime +local MouseIsOver = MouseIsOver +local UnitHealth = UnitHealth + +local UIParent = UIParent + +local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME -- lib upgrade stuff -lib.RegisteredGraphRealtime = lib.RegisteredGraphRealtime or {} -lib.RegisteredGraphLine = lib.RegisteredGraphLine or {} -lib.RegisteredGraphScatterPlot = lib.RegisteredGraphScatterPlot or {} -lib.RegisteredGraphPieChart = lib.RegisteredGraphPieChart or {} - +lib.RegisteredGraphRealtime = lib.RegisteredGraphRealtime or {} +lib.RegisteredGraphLine = lib.RegisteredGraphLine or {} +lib.RegisteredGraphScatterPlot = lib.RegisteredGraphScatterPlot or {} +lib.RegisteredGraphPieChart = lib.RegisteredGraphPieChart or {} -------------------------------------------------------------------------------- @@ -75,138 +84,137 @@ local function SetupGraphRealtimeFunctions(graph, upgrade) local self = lib --Set the various functions - graph.SetXAxis=GraphFunctions.SetXAxis - graph.SetYMax=GraphFunctions.SetYMax - graph.AddTimeData=GraphFunctions.AddTimeData - graph.OnUpdate=GraphFunctions.OnUpdateGraphRealtime - graph.CreateGridlines=GraphFunctions.CreateGridlines - graph.RefreshGraph=GraphFunctions.RefreshRealtimeGraph - graph.SetAxisDrawing=GraphFunctions.SetAxisDrawing - graph.SetGridSpacing=GraphFunctions.SetGridSpacing - graph.SetAxisColor=GraphFunctions.SetAxisColor - graph.SetGridColor=GraphFunctions.SetGridColor - graph.SetGridColorSecondary=GraphFunctions.SetGridColorSecondary - graph.SetGridSecondaryMultiple=GraphFunctions.SetGridSecondaryMultiple - graph.SetFilterRadius=GraphFunctions.SetFilterRadius - --graph.SetAutoscaleYAxis=GraphFunctions.SetAutoscaleYAxis - graph.SetBarColors=GraphFunctions.SetBarColors - graph.SetMode=GraphFunctions.SetMode - graph.SetAutoScale=GraphFunctions.SetAutoScale + graph.SetXAxis = GraphFunctions.SetXAxis + graph.SetYMax = GraphFunctions.SetYMax + graph.AddTimeData = GraphFunctions.AddTimeData + graph.OnUpdate = GraphFunctions.OnUpdateGraphRealtime + graph.CreateGridlines = GraphFunctions.CreateGridlines + graph.RefreshGraph = GraphFunctions.RefreshRealtimeGraph + graph.SetAxisDrawing = GraphFunctions.SetAxisDrawing + graph.SetGridSpacing = GraphFunctions.SetGridSpacing + graph.SetAxisColor = GraphFunctions.SetAxisColor + graph.SetGridColor = GraphFunctions.SetGridColor + graph.SetGridColorSecondary = GraphFunctions.SetGridColorSecondary + graph.SetGridSecondaryMultiple = GraphFunctions.SetGridSecondaryMultiple + graph.SetFilterRadius = GraphFunctions.SetFilterRadius + --graph.SetAutoscaleYAxis = GraphFunctions.SetAutoscaleYAxis + graph.SetBarColors = GraphFunctions.SetBarColors + graph.SetMode = GraphFunctions.SetMode + graph.SetAutoScale = GraphFunctions.SetAutoScale if not upgrade then -- This is the original frame:SetWidth() and frame:SetHeight() -- standard frame functions - graph.OldSetWidth=graph.SetWidth - graph.OldSetHeight=graph.SetHeight + graph.OldSetWidth = graph.SetWidth + graph.OldSetHeight = graph.SetHeight end - graph.SetWidth=GraphFunctions.RealtimeSetWidth - graph.SetHeight=GraphFunctions.RealtimeSetHeight - graph.SetBarColors=GraphFunctions.RealtimeSetColors - graph.GetMaxValue=GraphFunctions.GetMaxValue - graph.GetValue=GraphFunctions.RealtimeGetValue - graph.SetUpdateLimit=GraphFunctions.SetUpdateLimit - graph.SetDecay=GraphFunctions.SetDecay - graph.SetMinMaxY=GraphFunctions.SetMinMaxY - graph.AddBar=GraphFunctions.AddBar - graph.SetYLabels=GraphFunctions.SetYLabels - - + graph.SetWidth = GraphFunctions.RealtimeSetWidth + graph.SetHeight = GraphFunctions.RealtimeSetHeight + graph.SetBarColors = GraphFunctions.RealtimeSetColors + graph.GetMaxValue = GraphFunctions.GetMaxValue + graph.GetValue = GraphFunctions.RealtimeGetValue + graph.SetUpdateLimit = GraphFunctions.SetUpdateLimit + graph.SetDecay = GraphFunctions.SetDecay + graph.SetMinMaxY = GraphFunctions.SetMinMaxY + graph.AddBar = GraphFunctions.AddBar + graph.SetYLabels = GraphFunctions.SetYLabels - graph.DrawLine=self.DrawLine - graph.DrawHLine=self.DrawHLine - graph.DrawVLine=self.DrawVLine - graph.HideLines=self.HideLines - graph.HideFontStrings=GraphFunctions.HideFontStrings - graph.FindFontString=GraphFunctions.FindFontString - graph.SetBars=GraphFunctions.SetBars + + graph.DrawLine = self.DrawLine + graph.DrawHLine = self.DrawHLine + graph.DrawVLine = self.DrawVLine + graph.HideLines = self.HideLines + graph.HideFontStrings = GraphFunctions.HideFontStrings + graph.FindFontString = GraphFunctions.FindFontString + graph.SetBars = GraphFunctions.SetBars --Set the update function graph:SetScript("OnUpdate", graph.OnUpdate) end -function lib:CreateGraphRealtime(name,parent,relative,relativeTo,offsetX,offsetY,Width,Height) +function lib:CreateGraphRealtime(name, parent, relative, relativeTo, offsetX, offsetY, Width, Height) local graph local i - graph = CreateFrame("Frame",name,parent) + graph = CreateFrame("Frame", name, parent) - Width=math_floor(Width) + Width = math_floor(Width) - - graph:SetPoint(relative,parent,relativeTo,offsetX,offsetY) + + graph:SetPoint(relative, parent, relativeTo, offsetX, offsetY) graph:SetWidth(Width) graph:SetHeight(Height) graph:Show() --Create the bars - graph.Bars={} - graph.BarsUsing={} - graph.BarNum=Width - graph.Height=Height - for i=1,Width do + graph.Bars = {} + graph.BarsUsing = {} + graph.BarNum = Width + graph.Height = Height + for i = 1, Width do local bar - bar = CreateFrame("StatusBar",name.."Bar"..i,graph)--graph:CreateTexture(nil,"ARTWORK") - bar:SetPoint("BOTTOMLEFT",graph,"BOTTOMLEFT",i-1,0) + bar = CreateFrame("StatusBar", name.."Bar"..i, graph)--graph:CreateTexture(nil, "ARTWORK") + bar:SetPoint("BOTTOMLEFT", graph, "BOTTOMLEFT", i - 1, 0) bar:SetHeight(Height) bar:SetWidth(1) bar:SetOrientation("VERTICAL") - bar:SetMinMaxValues(0,1) - bar:SetStatusBarTexture("Interface\\Buttons\\WHITE8X8.blp") + bar:SetMinMaxValues(0, 1) + bar:SetStatusBarTexture("Interface\\Buttons\\WHITE8X8") bar:GetStatusBarTexture():SetHorizTile(false) bar:GetStatusBarTexture():SetVertTile(false) - local t=bar:GetStatusBarTexture() - t:SetGradientAlpha("VERTICAL",0.2,0.0,0.0,0.5,1.0,0.0,0.0,1.0) - + local t = bar:GetStatusBarTexture() + t:SetGradientAlpha("VERTICAL", 0.2, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 1.0) + bar:Show() - tinsert(graph.Bars,bar) - tinsert(graph.BarsUsing,bar) + tinsert(graph.Bars, bar) + tinsert(graph.BarsUsing, bar) end - + SetupGraphRealtimeFunctions(graph) --Initialize Data - graph.GraphType="REALTIME" - graph.YMax=60 - graph.YMin=0 - graph.XMax=-0.75 - graph.XMin=-10 - graph.TimeRadius=0.5 - graph.Mode="FAST" - graph.Filter="RECT" - graph.AxisColor={1.0,1.0,1.0,1.0} - graph.GridColor={0.5,0.5,0.5,0.5} - graph.BarColorTop={1.0,0.0,0.0,1.0} - graph.BarColorBot={0.2,0.0,0.0,0.5} - graph.AutoScale=false - graph.Data={} - graph.MinMaxY=0 - graph.CurVal=0 - graph.LastDataTime=GetTime() + graph.GraphType = "REALTIME" + graph.YMax = 60 + graph.YMin = 0 + graph.XMax = -0.75 + graph.XMin = -10 + graph.TimeRadius = 0.5 + graph.Mode = "FAST" + graph.Filter = "RECT" + graph.AxisColor = {1.0, 1.0, 1.0, 1.0} + graph.GridColor = {0.5, 0.5, 0.5, 0.5} + graph.BarColorTop = {1.0, 0.0, 0.0, 1.0} + graph.BarColorBot = {0.2, 0.0, 0.0, 0.5} + graph.AutoScale = false + graph.Data = {} + graph.MinMaxY = 0 + graph.CurVal = 0 + graph.LastDataTime = GetTime() - graph.Textures={} - graph.TexturesUsed={} + graph.Textures = {} + graph.TexturesUsed = {} - graph.LimitUpdates=0 - graph.NextUpdate=0 + graph.LimitUpdates = 0 + graph.NextUpdate = 0 - graph.BarHeight={} - graph.LastShift=GetTime() - graph.BarWidth=(graph.XMax-graph.XMin)/graph.BarNum - graph.DecaySet=0.8 - graph.Decay=math_pow(graph.DecaySet,graph.BarWidth) - graph.ExpNorm=1/(1-graph.Decay) + graph.BarHeight = {} + graph.LastShift = GetTime() + graph.BarWidth = (graph.XMax - graph.XMin) / graph.BarNum + graph.DecaySet = 0.8 + graph.Decay = math_pow(graph.DecaySet, graph.BarWidth) + graph.ExpNorm = 1 / (1 - graph.Decay) - graph.FilterOverlap=math_max(math_ceil((graph.TimeRadius+graph.XMax)/graph.BarWidth),0) - for i=1,graph.BarNum do - graph.BarHeight[i]=0 + graph.FilterOverlap = math_max(math_ceil((graph.TimeRadius + graph.XMax) / graph.BarWidth), 0) + for i = 1, graph.BarNum do + graph.BarHeight[i] = 0 end - graph.TextFrame = CreateFrame("Frame",nil,graph) + graph.TextFrame = CreateFrame("Frame", nil, graph) graph.TextFrame:SetAllPoints(graph) - graph.TextFrame:SetFrameLevel(graph:GetFrameLevel()+2) - + graph.TextFrame:SetFrameLevel(graph:GetFrameLevel() + 2) + tinsert(self.RegisteredGraphRealtime, graph) return graph end @@ -216,51 +224,53 @@ local function SetupGraphLineFunctions(graph) local self = lib --Set the various functions - graph.SetXAxis=GraphFunctions.SetXAxis - graph.SetYAxis=GraphFunctions.SetYAxis - graph.AddDataSeries=GraphFunctions.AddDataSeries - graph.AddFilledDataSeries=GraphFunctions.AddFilledDataSeries - graph.ResetData=GraphFunctions.ResetData - graph.RefreshGraph=GraphFunctions.RefreshLineGraph - graph.CreateGridlines=GraphFunctions.CreateGridlines - graph.SetAxisDrawing=GraphFunctions.SetAxisDrawing - graph.SetGridSpacing=GraphFunctions.SetGridSpacing - graph.SetAxisColor=GraphFunctions.SetAxisColor - graph.SetGridColor=GraphFunctions.SetGridColor - graph.SetGridColorSecondary=GraphFunctions.SetGridColorSecondary - graph.SetGridSecondaryMultiple=GraphFunctions.SetGridSecondaryMultiple - graph.SetAutoScale=GraphFunctions.SetAutoScale - graph.SetYLabels=GraphFunctions.SetYLabels - graph.SetLineTexture=GraphFunctions.SetLineTexture - graph.SetBorderSize=GraphFunctions.SetBorderSize - graph.OnUpdate=GraphFunctions.OnUpdateGraph + graph.SetXAxis = GraphFunctions.SetXAxis + graph.SetYAxis = GraphFunctions.SetYAxis + graph.AddDataSeries = GraphFunctions.AddDataSeries + graph.AddFilledDataSeries = GraphFunctions.AddFilledDataSeries + graph.ResetData = GraphFunctions.ResetData + graph.RefreshGraph = GraphFunctions.RefreshLineGraph + graph.CreateGridlines = GraphFunctions.CreateGridlines + graph.SetAxisDrawing = GraphFunctions.SetAxisDrawing + graph.SetGridSpacing = GraphFunctions.SetGridSpacing + graph.SetAxisColor = GraphFunctions.SetAxisColor + graph.SetGridColor = GraphFunctions.SetGridColor + graph.SetGridColorSecondary = GraphFunctions.SetGridColorSecondary + graph.SetGridSecondaryMultiple = GraphFunctions.SetGridSecondaryMultiple + graph.SetAutoScale = GraphFunctions.SetAutoScale + graph.SetYLabels = GraphFunctions.SetYLabels + graph.OnUpdate = GraphFunctions.OnUpdateGraph - graph.LockXMin=GraphFunctions.LockXMin - graph.LockXMax=GraphFunctions.LockXMax - graph.LockYMin=GraphFunctions.LockYMin - graph.LockYMax=GraphFunctions.LockYMax + graph.SetLineTexture = GraphFunctions.SetLineTexture + graph.SetBorderSize = GraphFunctions.SetBorderSize + + graph.LockXMin = GraphFunctions.LockXMin + graph.LockXMax = GraphFunctions.LockXMax + graph.LockYMin = GraphFunctions.LockYMin + graph.LockYMax = GraphFunctions.LockYMax - graph.DrawLine=self.DrawLine - graph.DrawHLine=self.DrawHLine - graph.DrawVLine=self.DrawVLine - graph.HideLines=self.HideLines - graph.DrawBar=self.DrawBar - graph.HideBars=self.HideBars - graph.HideFontStrings=GraphFunctions.HideFontStrings - graph.FindFontString=GraphFunctions.FindFontString + + graph.DrawLine = self.DrawLine + graph.DrawHLine = self.DrawHLine + graph.DrawVLine = self.DrawVLine + graph.HideLines = self.HideLines + graph.DrawBar = self.DrawBar + graph.HideBars = self.HideBars + graph.HideFontStrings = GraphFunctions.HideFontStrings + graph.FindFontString = GraphFunctions.FindFontString --Set the update function graph:SetScript("OnUpdate", graph.OnUpdate) end --TODO: Clip lines with the bounds -function lib:CreateGraphLine(name,parent,relative,relativeTo,offsetX,offsetY,Width,Height) +function lib:CreateGraphLine(name, parent, relative, relativeTo, offsetX, offsetY, Width, Height) local graph local i - graph = CreateFrame("Frame",name,parent) + graph = CreateFrame("Frame",name, parent) - - graph:SetPoint(relative,parent,relativeTo,offsetX,offsetY) + + graph:SetPoint(relative, parent, relativeTo, offsetX, offsetY) graph:SetWidth(Width) graph:SetHeight(Height) graph:Show() @@ -269,31 +279,31 @@ function lib:CreateGraphLine(name,parent,relative,relativeTo,offsetX,offsetY,Wid SetupGraphLineFunctions(graph) - graph.NeedsUpdate=false + graph.NeedsUpdate = false --Initialize Data - graph.GraphType="LINE" - graph.YMax=1 - graph.YMin=-1 - graph.XMax=1 - graph.XMin=-1 - graph.AxisColor={1.0,1.0,1.0,1.0} - graph.GridColor={0.5,0.5,0.5,0.5} - graph.XGridInterval=0.25 - graph.YGridInterval=0.25 - graph.XAxisDrawn=true - graph.YAxisDrawn=true - - graph.LockOnXMin=false - graph.LockOnXMax=false - graph.LockOnYMin=false - graph.LockOnYMax=false - graph.Data={} - graph.FilledData={} - graph.Textures={} - graph.TexturesUsed={} - graph.TextFrame = CreateFrame("Frame",nil,graph) + graph.GraphType = "LINE" + graph.YMax = 1 + graph.YMin = -1 + graph.XMax = 1 + graph.XMin = -1 + graph.AxisColor = {1.0, 1.0, 1.0, 1.0} + graph.GridColor = {0.5, 0.5, 0.5, 0.5} + graph.XGridInterval = 0.25 + graph.YGridInterval = 0.25 + graph.XAxisDrawn = true + graph.YAxisDrawn = true + + graph.LockOnXMin = false + graph.LockOnXMax = false + graph.LockOnYMin = false + graph.LockOnYMax = false + graph.Data = {} + graph.FilledData = {} + graph.Textures = {} + graph.TexturesUsed = {} + graph.TextFrame = CreateFrame("Frame", nil, graph) graph.TextFrame:SetAllPoints(graph) @@ -307,85 +317,85 @@ local function SetupGraphScatterPlotFunctions(graph) local self = lib --Set the various functions - graph.SetXAxis=GraphFunctions.SetXAxis - graph.SetYAxis=GraphFunctions.SetYAxis - graph.AddDataSeries=GraphFunctions.AddDataSeries - graph.ResetData=GraphFunctions.ResetData - graph.RefreshGraph=GraphFunctions.RefreshScatterPlot - graph.CreateGridlines=GraphFunctions.CreateGridlines - graph.OnUpdate=GraphFunctions.OnUpdateGraph - - graph.LinearRegression=GraphFunctions.LinearRegression - graph.SetAxisDrawing=GraphFunctions.SetAxisDrawing - graph.SetGridSpacing=GraphFunctions.SetGridSpacing - graph.SetAxisColor=GraphFunctions.SetAxisColor - graph.SetGridColor=GraphFunctions.SetGridColor - graph.SetGridColorSecondary=GraphFunctions.SetGridColorSecondary - graph.SetGridSecondaryMultiple=GraphFunctions.SetGridSecondaryMultiple - graph.SetLinearFit=GraphFunctions.SetLinearFit - graph.SetAutoScale=GraphFunctions.SetAutoScale - graph.SetYLabels=GraphFunctions.SetYLabels + graph.SetXAxis = GraphFunctions.SetXAxis + graph.SetYAxis = GraphFunctions.SetYAxis + graph.AddDataSeries = GraphFunctions.AddDataSeries + graph.ResetData = GraphFunctions.ResetData + graph.RefreshGraph = GraphFunctions.RefreshScatterPlot + graph.CreateGridlines = GraphFunctions.CreateGridlines + graph.OnUpdate = GraphFunctions.OnUpdateGraph - graph.LockXMin=GraphFunctions.LockXMin - graph.LockXMax=GraphFunctions.LockXMax - graph.LockYMin=GraphFunctions.LockYMin - graph.LockYMax=GraphFunctions.LockYMax + graph.LinearRegression = GraphFunctions.LinearRegression + graph.SetAxisDrawing = GraphFunctions.SetAxisDrawing + graph.SetGridSpacing = GraphFunctions.SetGridSpacing + graph.SetAxisColor = GraphFunctions.SetAxisColor + graph.SetGridColor = GraphFunctions.SetGridColor + graph.SetGridColorSecondary = GraphFunctions.SetGridColorSecondary + graph.SetGridSecondaryMultiple = GraphFunctions.SetGridSecondaryMultiple + graph.SetLinearFit = GraphFunctions.SetLinearFit + graph.SetAutoScale = GraphFunctions.SetAutoScale + graph.SetYLabels = GraphFunctions.SetYLabels - graph.DrawLine=self.DrawLine - graph.DrawHLine=self.DrawHLine - graph.DrawVLine=self.DrawVLine - graph.HideLines=self.HideLines - graph.HideTextures=GraphFunctions.HideTextures - graph.FindTexture=GraphFunctions.FindTexture - graph.HideFontStrings=GraphFunctions.HideFontStrings - graph.FindFontString=GraphFunctions.FindFontString + graph.LockXMin = GraphFunctions.LockXMin + graph.LockXMax = GraphFunctions.LockXMax + graph.LockYMin = GraphFunctions.LockYMin + graph.LockYMax = GraphFunctions.LockYMax + + graph.DrawLine = self.DrawLine + graph.DrawHLine = self.DrawHLine + graph.DrawVLine = self.DrawVLine + graph.HideLines = self.HideLines + graph.HideTextures = GraphFunctions.HideTextures + graph.FindTexture = GraphFunctions.FindTexture + graph.HideFontStrings = GraphFunctions.HideFontStrings + graph.FindFontString = GraphFunctions.FindFontString --Set the update function graph:SetScript("OnUpdate", graph.OnUpdate) end -function lib:CreateGraphScatterPlot(name,parent,relative,relativeTo,offsetX,offsetY,Width,Height) +function lib:CreateGraphScatterPlot(name, parent, relative, relativeTo, offsetX, offsetY, Width, Height) local graph local i - graph = CreateFrame("Frame",name,parent) + graph = CreateFrame("Frame",name, parent) - - graph:SetPoint(relative,parent,relativeTo,offsetX,offsetY) + + graph:SetPoint(relative, parent, relativeTo, offsetX, offsetY) graph:SetWidth(Width) graph:SetHeight(Height) graph:Show() SetupGraphScatterPlotFunctions(graph) - - graph.NeedsUpdate=false + + graph.NeedsUpdate = false --Initialize Data - graph.GraphType="SCATTER" - graph.YMax=1 - graph.YMin=-1 - graph.XMax=1 - graph.XMin=-1 - graph.AxisColor={1.0,1.0,1.0,1.0} - graph.GridColor={0.5,0.5,0.5,0.5} - graph.XGridInterval=0.25 - graph.YGridInterval=0.25 - graph.XAxisDrawn=true - graph.YAxisDrawn=true - graph.AutoScale=false - graph.LinearFit=false - graph.LockOnXMin=false - graph.LockOnXMax=false - graph.LockOnYMin=false - graph.LockOnYMax=false - graph.Data={} - graph.Textures={} - graph.TexturesUsed={} + graph.GraphType = "SCATTER" + graph.YMax = 1 + graph.YMin = -1 + graph.XMax = 1 + graph.XMin = -1 + graph.AxisColor = {1.0, 1.0, 1.0, 1.0} + graph.GridColor = {0.5, 0.5, 0.5, 0.5} + graph.XGridInterval = 0.25 + graph.YGridInterval = 0.25 + graph.XAxisDrawn = true + graph.YAxisDrawn = true + graph.AutoScale = false + graph.LinearFit = false + graph.LockOnXMin = false + graph.LockOnXMax = false + graph.LockOnYMin = false + graph.LockOnYMax = false + graph.Data = {} + graph.Textures = {} + graph.TexturesUsed = {} - graph.TextFrame = CreateFrame("Frame",nil,graph) + graph.TextFrame = CreateFrame("Frame", nil, graph) graph.TextFrame:SetAllPoints(graph) - + tinsert(self.RegisteredGraphScatterPlot, graph) return graph end @@ -395,83 +405,74 @@ local function SetupGraphPieChartFunctions(graph) local self = lib --Set the various functions - graph.AddPie=GraphFunctions.AddPie - graph.CompletePie=GraphFunctions.CompletePie - graph.ResetPie=GraphFunctions.ResetPie + graph.AddPie = GraphFunctions.AddPie + graph.CompletePie = GraphFunctions.CompletePie + graph.ResetPie = GraphFunctions.ResetPie - graph.DrawLine=self.DrawLine - graph.DrawHLine=self.DrawHLine - graph.DrawVLine=self.DrawVLine - graph.DrawLinePie=GraphFunctions.DrawLinePie - graph.HideLines=self.HideLines - graph.HideTextures=GraphFunctions.HideTextures - graph.FindTexture=GraphFunctions.FindTexture - graph.OnUpdate=GraphFunctions.PieChart_OnUpdate - graph.SetSelectionFunc=GraphFunctions.SetSelectionFunc + graph.DrawLine = self.DrawLine + graph.DrawHLine = self.DrawHLine + graph.DrawVLine = self.DrawVLine + graph.DrawLinePie = GraphFunctions.DrawLinePie + graph.HideLines = self.HideLines + graph.HideTextures = GraphFunctions.HideTextures + graph.FindTexture = GraphFunctions.FindTexture + graph.OnUpdate = GraphFunctions.PieChart_OnUpdate + graph.SetSelectionFunc = GraphFunctions.SetSelectionFunc graph:SetScript("OnUpdate", graph.OnUpdate) end -function lib:CreateGraphPieChart(name,parent,relative,relativeTo,offsetX,offsetY,Width,Height) +function lib:CreateGraphPieChart(name, parent, relative, relativeTo, offsetX, offsetY, Width, Height) local graph local i - graph = CreateFrame("Frame",name,parent) + graph = CreateFrame("Frame",name, parent) - - graph:SetPoint(relative,parent,relativeTo,offsetX,offsetY) + + graph:SetPoint(relative, parent, relativeTo, offsetX, offsetY) graph:SetWidth(Width) graph:SetHeight(Height) graph:Show() SetupGraphPieChartFunctions(graph) - - + --Initialize Data - graph.GraphType="PIE" - graph.PieUsed=0 - graph.PercentOn=0 - graph.Remaining=0 - graph.Textures={} - graph.Ratio=Width/Height - graph.Radius=0.88*(Width/2) - graph.Radius=graph.Radius*graph.Radius - graph.Sections={} - graph.Textures={} - graph.TexturesUsed={} - graph.LastSection=nil - graph.onColor=1 - graph.TotalSections=0 + graph.GraphType = "PIE" + graph.PieUsed = 0 + graph.PercentOn = 0 + graph.Remaining = 0 + graph.Textures = {} + graph.Ratio = Width / Height + graph.Radius = 0.88 * (Width / 2) + graph.Radius = graph.Radius * graph.Radius + graph.Sections = {} + graph.Textures = {} + graph.TexturesUsed = {} + graph.LastSection = nil + graph.onColor = 1 + graph.TotalSections = 0 tinsert(self.RegisteredGraphPieChart, graph) return graph end - - - - - - - - ------------------------------------------------------------------------------- --Functions for Realtime Graphs ------------------------------------------------------------------------------- --AddTimeData - Adds a data value to the realtime graph at this moment in time function GraphFunctions:AddTimeData(value) - if type(value)~="number" then + if type(value) ~= "number" then return end - local t={} - t.Time=GetTime() - self.LastDataTime=t.Time - t.Value=value - tinsert(self.Data,t) + local t = {} + t.Time = GetTime() + self.LastDataTime = t.Time + t.Value = value + tinsert(self.Data, t) end --RefreshRealtimeGraph - Refreshes the gridlines for the realtime graph @@ -482,105 +483,104 @@ end --SetFilterRadius - controls the radius of the filter function GraphFunctions:SetFilterRadius(radius) - self.TimeRadius=radius + self.TimeRadius = radius end --SetAutoscaleYAxis - If enabled the maximum y axis is adjusted to be 25% more than the max value function GraphFunctions:SetAutoscaleYAxis(scale) - self.AutoScale=scale + self.AutoScale = scale end --SetBarColors - -function GraphFunctions:SetBarColors(BotColor,TopColor) +function GraphFunctions:SetBarColors(BotColor, TopColor) local Temp if BotColor.r then - Temp=BotColor - BotColor={Temp.r,Temp.g,Temp.b,Temp.a} + Temp = BotColor + BotColor = {Temp.r, Temp.g, Temp.b, Temp.a} end if TopColor.r then - Temp=TopColor - TopColor={Temp.r,Temp.g,Temp.b,Temp.a} + Temp = TopColor + TopColor = {Temp.r, Temp.g, Temp.b, Temp.a} end - for i=1,self.BarNum do - local t=self.Bars[i]:GetStatusBarTexture() - t:SetGradientAlpha("VERTICAL",BotColor[1],BotColor[2],BotColor[3],BotColor[4],TopColor[1],TopColor[2],TopColor[3],TopColor[4]) + for i = 1, self.BarNum do + local t = self.Bars[i]:GetStatusBarTexture() + t:SetGradientAlpha("VERTICAL", BotColor[1], BotColor[2], BotColor[3], BotColor[4], TopColor[1], TopColor[2], TopColor[3], TopColor[4]) end end function GraphFunctions:SetMode(mode) - self.Mode=mode + self.Mode = mode - if mode~="SLOW" then - self.LastShift=GetTime()+self.XMin + if mode ~= "SLOW" then + self.LastShift = GetTime() + self.XMin end end -function GraphFunctions:RealtimeSetColors(BotColor,TopColor) +function GraphFunctions:RealtimeSetColors(BotColor, TopColor) local Temp if BotColor.r then - Temp=BotColor - BotColor={Temp.r,Temp.g,Temp.b,Temp.a} + Temp = BotColor + BotColor = {Temp.r, Temp.g, Temp.b, Temp.a} end if TopColor.r then - Temp=TopColor - TopColor={Temp.r,Temp.g,Temp.b,Temp.a} + Temp = TopColor + TopColor = {Temp.r, Temp.g, Temp.b, Temp.a} end - self.BarColorBot=BotColor - self.BarColorTop=TopColor - for _,v in pairs(self.Bars) do - v:GetStatusBarTexture():SetGradientAlpha("VERTICAL",self.BarColorBot[1],self.BarColorBot[2],self.BarColorBot[3],self.BarColorBot[4],self.BarColorTop[1],self.BarColorTop[2],self.BarColorTop[3],self.BarColorTop[4]) + self.BarColorBot = BotColor + self.BarColorTop = TopColor + for _, v in pairs(self.Bars) do + v:GetStatusBarTexture():SetGradientAlpha("VERTICAL", self.BarColorBot[1], self.BarColorBot[2], self.BarColorBot[3], self.BarColorBot[4], self.BarColorTop[1], self.BarColorTop[2], self.BarColorTop[3], self.BarColorTop[4]) end end function GraphFunctions:RealtimeSetWidth(Width) - Width=math_floor(Width) + Width = math_floor(Width) - if Width==self.BarNum then + if Width == self.BarNum then return end - self.BarNum=Width - for i=1,Width do - if type(self.Bars[i])=="nil" then + self.BarNum = Width + for i = 1, Width do + if type(self.Bars[i]) == "nil" then local bar - bar = CreateFrame("StatusBar",self:GetName().."Bar"..i,self) - bar:SetPoint("BOTTOMLEFT",self,"BOTTOMLEFT",i-1,0) + bar = CreateFrame("StatusBar", self:GetName().."Bar"..i, self) + bar:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", i - 1, 0) bar:SetHeight(self.Height) bar:SetWidth(1) bar:SetOrientation("VERTICAL") - bar:SetMinMaxValues(0,1) - bar:SetStatusBarTexture("Interface\\Buttons\\WHITE8X8.blp") + bar:SetMinMaxValues(0, 1) + bar:SetStatusBarTexture("Interface\\Buttons\\WHITE8X8") bar:GetStatusBarTexture():SetHorizTile(false) bar:GetStatusBarTexture():SetVertTile(false) - local t=bar:GetStatusBarTexture() - t:SetGradientAlpha("VERTICAL",self.BarColorBot[1],self.BarColorBot[2],self.BarColorBot[3],self.BarColorBot[4],self.BarColorTop[1],self.BarColorTop[2],self.BarColorTop[3],self.BarColorTop[4]) - - tinsert(self.Bars,bar) + local t = bar:GetStatusBarTexture() + t:SetGradientAlpha("VERTICAL", self.BarColorBot[1], self.BarColorBot[2], self.BarColorBot[3], self.BarColorBot[4], self.BarColorTop[1], self.BarColorTop[2], self.BarColorTop[3], self.BarColorTop[4]) + + tinsert(self.Bars, bar) else - self.Bars[i]:SetPoint("BOTTOMLEFT",self,"BOTTOMLEFT",i-1,0) + self.Bars[i]:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", i - 1, 0) end - self.BarHeight[i]=0 + self.BarHeight[i] = 0 end - local SizeOfBarsUsed=table.maxn(self.BarsUsing) + local SizeOfBarsUsed = table.maxn(self.BarsUsing) - if Width>SizeOfBarsUsed then - for i=SizeOfBarsUsed+1,Width do - tinsert(self.BarsUsing,self.Bars[i]) + if Width > SizeOfBarsUsed then + for i = SizeOfBarsUsed + 1, Width do + tinsert(self.BarsUsing, self.Bars[i]) self.Bars[i]:Show() end - elseif Widthself.XMax then + if Time < self.XMin or Time > self.XMax then return 0 end - - Bar=math_min(math_max(math_floor(self.BarNum*(Time-self.XMin)/(self.XMax-self.XMin)+0.5),1),self.BarNum) + + Bar = math_min(math_max(math_floor(self.BarNum * (Time - self.XMin) / (self.XMax - self.XMin) + 0.5), 1), self.BarNum) return self.BarHeight[Bar] end function GraphFunctions:SetUpdateLimit(Time) - self.LimitUpdates=Time + self.LimitUpdates = Time end function GraphFunctions:SetDecay(decay) - self.DecaySet=decay - self.Decay=math_pow(self.DecaySet,self.BarWidth) - self.ExpNorm=1/(1-self.Decay)/0.95 --Actually a finite geometric series (divide 0.96 instead of 1 since seems doesn't quite work right) + self.DecaySet = decay + self.Decay = math_pow(self.DecaySet, self.BarWidth) + self.ExpNorm = 1 / (1 - self.Decay) / 0.95 --Actually a finite geometric series (divide 0.96 instead of 1 since seems doesn't quite work right) end -function GraphFunctions:AddBar(value) - for i=1,self.BarNum-1 do - self.BarHeight[i]=self.BarHeight[i+1] +function GraphFunctions:AddBar(value) + for i = 1, self.BarNum - 1 do + self.BarHeight[i] = self.BarHeight[i + 1] end - self.BarHeight[self.BarNum]=value - self.AddedBar=true + self.BarHeight[self.BarNum] = value + self.AddedBar = true end function GraphFunctions:SetBars() - local YHeight=self.YMax-self.YMin + local YHeight = self.YMax - self.YMin - for i,bar in pairs(self.BarsUsing) do + for i, bar in pairs(self.BarsUsing) do local h - h=(self.BarHeight[i]-self.YMin)/YHeight + h = (self.BarHeight[i] - self.YMin) / YHeight bar:SetValue(h) end end + ------------------------------------------------------------------------------- --Functions for Line Graph Data ------------------------------------------------------------------------------- -function GraphFunctions:AddDataSeries(points,color,n2) +function GraphFunctions:AddDataSeries(points, color, n2) local data --Make sure there is data points if not points then return end - data=points - if n2==nil then - n2=false + data = points + if n2 == nil then + n2 = false end - if n2 or (table.getn(points)==2 and table.getn(points[1])~=2) then - data={} - for k,v in ipairs(points[1]) do - tinsert(data,{v,points[2][k]}) + if n2 or (table.getn(points) == 2 and table.getn(points[1]) ~= 2) then + data = {} + for k, v in ipairs(points[1]) do + tinsert(data, {v, points[2][k]}) end end - - tinsert(self.Data,{Points=data;Color=color}) - - self.NeedsUpdate=true + + tinsert(self.Data,{Points = data; Color = color}) + + self.NeedsUpdate = true end -function GraphFunctions:AddFilledDataSeries(points,color,n2) +function GraphFunctions:AddFilledDataSeries(points, color, n2) local data --Make sure there is data points - if not points or #points==0 then + if not points or #points == 0 then return end - data=points - if n2==nil then - n2=false + data = points + if n2 == nil then + n2 = false end - if n2 or (table.getn(points)==2 and table.getn(points[1])~=2) then - data={} - for k,v in ipairs(points[1]) do - tinsert(data,{v,points[2][k]}) + if n2 or (table.getn(points) == 2 and table.getn(points[1]) ~= 2) then + data = {} + for k, v in ipairs(points[1]) do + tinsert(data, {v, points[2][k]}) end end - - tinsert(self.FilledData,{Points=data;Color=color}) - - self.NeedsUpdate=true + + tinsert(self.FilledData, {Points = data; Color = color}) + + self.NeedsUpdate = true end function GraphFunctions:ResetData() - self.Data={} + self.Data = {} if self.FilledData then - self.FilledData={} + self.FilledData = {} end - - self.NeedsUpdate=true + + self.NeedsUpdate = true end function GraphFunctions:SetLinearFit(fit) - self.LinearFit=fit - - self.NeedsUpdate=true + self.LinearFit = fit + + self.NeedsUpdate = true end function GraphFunctions:HideTextures() - local k=#self.TexturesUsed - while k>0 do - self.Textures[#self.Textures+1]=self.TexturesUsed[k] + local k = #self.TexturesUsed + while k > 0 do + self.Textures[#self.Textures + 1] = self.TexturesUsed[k] self.TexturesUsed[k]:Hide() - self.TexturesUsed[k]=nil - k=k-1 + self.TexturesUsed[k] = nil + k = k - 1 end end --Make sure to show a texture after you grab it or its free for anyone else to grab function GraphFunctions:FindTexture() local t - if #self.Textures>0 then - t=self.Textures[#self.Textures] - self.TexturesUsed[#self.TexturesUsed+1]=t - self.Textures[#self.Textures]=nil + if #self.Textures > 0 then + t = self.Textures[#self.Textures] + self.TexturesUsed[#self.TexturesUsed + 1] = t + self.Textures[#self.Textures] = nil return t end - local g=self:CreateTexture(nil,"BACKGROUND") - self.TexturesUsed[#self.TexturesUsed+1]=g + local g = self:CreateTexture(nil, "BACKGROUND") + self.TexturesUsed[#self.TexturesUsed + 1] = g return g end function GraphFunctions:HideFontStrings() if not self.FontStrings then - self.FontStrings={} + self.FontStrings = {} end for k, t in pairs(self.FontStrings) do t:Hide() @@ -768,218 +769,216 @@ function GraphFunctions:FindFontString() end end local g - + if self.TextFrame then - g=self.TextFrame:CreateFontString(nil,"OVERLAY") + g = self.TextFrame:CreateFontString(nil, "OVERLAY") else - g=self:CreateFontString(nil,"OVERLAY") + g = self:CreateFontString(nil, "OVERLAY") end - tinsert(self.FontStrings,g) + tinsert(self.FontStrings, g) return g end --Linear Regression via Least Squares function GraphFunctions:LinearRegression(data) local alpha, beta - local n, SX,SY,SXX, SXY = 0,0,0,0,0 + local n, SX, SY, SXX, SXY = 0, 0, 0, 0, 0 - for k,v in pairs(data) do - n=n+1 + for k, v in pairs(data) do + n = n + 1 - SX=SX+v[1] - SXX=SXX+v[1]*v[1] - SY=SY+v[2] - SXY=SXY+v[1]*v[2] + SX = SX + v[1] + SXX = SXX + v[1] * v[1] + SY = SY + v[2] + SXY = SXY + v[1] * v[2] end - - beta=(n*SXY-SX*SY)/(n*SXX-SX*SX) - alpha=(SY-beta*SX)/n + + beta = (n * SXY - SX * SY) / (n * SXX - SX * SX) + alpha = (SY - beta * SX) / n return alpha, beta end - - ------------------------------------------------------------------------------- --Functions for Pie Chart ------------------------------------------------------------------------------- -local PiePieces={"1-2", - "1-4", - "1-8", - "1-16", - "1-32", - "1-64", - "1-128"} + +local PiePieces = { + "1-2", + "1-4", + "1-8", + "1-16", + "1-32", + "1-64", + "1-128" +} --26 Colors -local ColorTable={ - {0.9,0.1,0.1}, - {0.1,0.9,0.1}, - {0.1,0.1,0.9}, - {0.9,0.9,0.1}, - {0.9,0.1,0.9}, - {0.1,0.9,0.9}, - {0.9,0.9,0.9}, - {0.5,0.1,0.1}, - {0.1,0.5,0.1}, - {0.1,0.1,0.5}, - {0.5,0.5,0.1}, - {0.5,0.1,0.5}, - {0.1,0.5,0.5}, - {0.5,0.5,0.5}, - {0.75,0.15,0.15}, - {0.15,0.75,0.15}, - {0.15,0.15,0.75}, - {0.75,0.75,0.15}, - {0.75,0.15,0.75}, - {0.15,0.75,0.75}, - {0.9,0.5,0.1}, - {0.1,0.5,0.9}, - {0.9,0.1,0.5}, - {0.5,0.9,0.1}, - {0.5,0.1,0.9}, - {0.1,0.9,0.5}, +local ColorTable = { + {0.9, 0.1, 0.1}, + {0.1, 0.9, 0.1}, + {0.1, 0.1, 0.9}, + {0.9, 0.9, 0.1}, + {0.9, 0.1, 0.9}, + {0.1, 0.9, 0.9}, + {0.9, 0.9, 0.9}, + {0.5, 0.1, 0.1}, + {0.1, 0.5, 0.1}, + {0.1, 0.1, 0.5}, + {0.5, 0.5, 0.1}, + {0.5, 0.1, 0.5}, + {0.1, 0.5, 0.5}, + {0.5, 0.5, 0.5}, + {0.75, 0.15, 0.15}, + {0.15, 0.75, 0.15}, + {0.15, 0.15, 0.75}, + {0.75, 0.75, 0.15}, + {0.75, 0.15, 0.75}, + {0.15, 0.75, 0.75}, + {0.9, 0.5, 0.1}, + {0.1, 0.5, 0.9}, + {0.9, 0.1, 0.5}, + {0.5, 0.9, 0.1}, + {0.5, 0.1, 0.9}, + {0.1, 0.9, 0.5}, } + function GraphFunctions:AddPie(Percent, Color) - local k,v - local PiePercent=self.PercentOn + local PiePercent = self.PercentOn - local CurPiece=50 - local Angle=180 - local CurAngle=PiePercent*360/100 + local CurPiece = 50 + local Angle = 180 + local CurAngle = PiePercent * 360 / 100 - self.TotalSections=self.TotalSections+1 - if type(self.Sections[self.TotalSections])~="table" then - self.Sections[self.TotalSections]={} + self.TotalSections = self.TotalSections + 1 + if type(self.Sections[self.TotalSections]) ~= "table" then + self.Sections[self.TotalSections] = {} end - local Section=self.Sections[self.TotalSections] - Section.Textures={} + local Section = self.Sections[self.TotalSections] + Section.Textures = {} - if type(Color)~="table" then - if self.onColor<=table.maxn(ColorTable) then - Color=ColorTable[self.onColor] + if type(Color) ~= "table" then + if self.onColor <= table.maxn(ColorTable) then + Color = ColorTable[self.onColor] else - Color={math_random(),math_random(),math_random()} + Color = {math_random(), math_random(), math_random()} end - self.onColor=self.onColor+1 + self.onColor = self.onColor + 1 end - if PiePercent==0 then + if PiePercent == 0 then self:DrawLinePie(0) end - - Percent=Percent+self.Remaining - local LastPiece=0 - for k,v in pairs(PiePieces) do - if (Percent+0.1)>CurPiece then - local t=self:FindTexture() + + Percent = Percent + self.Remaining + local LastPiece = 0 + for k, v in pairs(PiePieces) do + if (Percent + 0.1) > CurPiece then + local t = self:FindTexture() t:SetTexture(TextureDirectory..v) t:ClearAllPoints() - t:SetPoint("CENTER",self,"CENTER",0,0) + t:SetPoint("CENTER", self, "CENTER", 0, 0) t:SetHeight(self:GetHeight()) t:SetWidth(self:GetWidth()) - GraphFunctions:RotateTexture(t,CurAngle) + GraphFunctions:RotateTexture(t, CurAngle) t:Show() - t:SetVertexColor(Color[1],Color[2],Color[3],1.0) - Percent=Percent-CurPiece - PiePercent=PiePercent+CurPiece - CurAngle=CurAngle+Angle + t:SetVertexColor(Color[1], Color[2], Color[3], 1.0) + Percent = Percent - CurPiece + PiePercent = PiePercent + CurPiece + CurAngle = CurAngle + Angle - tinsert(Section.Textures,t) + tinsert(Section.Textures, t) if k == 7 then - LastPiece=0.09 + LastPiece = 0.09 end end - CurPiece=CurPiece/2 - Angle=Angle/2 + CurPiece = CurPiece / 2 + Angle = Angle / 2 end --Finish adding section data - Section.Color=Color - Section.Angle=CurAngle - - self:DrawLinePie((PiePercent+LastPiece)*360/100) - self.PercentOn=PiePercent - self.Remaining=Percent + Section.Color = Color + Section.Angle = CurAngle + + self:DrawLinePie((PiePercent + LastPiece) * 360 / 100) + self.PercentOn = PiePercent + self.Remaining = Percent return Color end function GraphFunctions:CompletePie(Color) - local Percent=100-self.PercentOn - local k,v - local PiePercent=self.PercentOn + local Percent = 100 - self.PercentOn + local PiePercent = self.PercentOn - local CurPiece=50 - local Angle=180 - local CurAngle=PiePercent*360/100 + local CurPiece = 50 + local Angle = 180 + local CurAngle = PiePercent * 360 / 100 - self.TotalSections=self.TotalSections+1 + self.TotalSections = self.TotalSections + 1 if not self.Sections[self.TotalSections] then - self.Sections[self.TotalSections]={} + self.Sections[self.TotalSections] = {} end - local Section=self.Sections[self.TotalSections] - Section.Textures={} - - if type(Color)~="table" then - if self.onColor<=table.maxn(ColorTable) then - Color=ColorTable[self.onColor] + local Section = self.Sections[self.TotalSections] + Section.Textures = {} + + if type(Color) ~= "table" then + if self.onColor <= table.maxn(ColorTable) then + Color = ColorTable[self.onColor] else - Color={math_random(),math_random(),math_random()} + Color = {math_random(), math_random(), math_random()} end - self.onColor=self.onColor+1 + self.onColor = self.onColor + 1 end - - - - Percent=Percent+self.Remaining - if PiePercent~=0 then - for k,v in pairs(PiePieces) do - if (Percent+0.1)>CurPiece then - local t=self:FindTexture() + + Percent = Percent + self.Remaining + if PiePercent ~= 0 then + for k, v in pairs(PiePieces) do + if (Percent + 0.1) > CurPiece then + local t = self:FindTexture() t:SetTexture(TextureDirectory..v) t:ClearAllPoints() - t:SetPoint("CENTER",self,"CENTER",0,0) + t:SetPoint("CENTER", self, "CENTER", 0, 0) t:SetHeight(self:GetHeight()) t:SetWidth(self:GetWidth()) - GraphFunctions:RotateTexture(t,CurAngle) + GraphFunctions:RotateTexture(t, CurAngle) t:Show() - t:SetVertexColor(Color[1],Color[2],Color[3],1.0) - Percent=Percent-CurPiece - PiePercent=PiePercent+CurPiece - CurAngle=CurAngle+Angle + t:SetVertexColor(Color[1], Color[2], Color[3], 1.0) + Percent = Percent - CurPiece + PiePercent = PiePercent + CurPiece + CurAngle = CurAngle + Angle - tinsert(Section.Textures,t) + tinsert(Section.Textures, t) end - CurPiece=CurPiece/2 - Angle=Angle/2 + CurPiece = CurPiece / 2 + Angle = Angle / 2 end else--Special case if its by itself - local t=self:FindTexture() + local t = self:FindTexture() t:SetTexture(TextureDirectory.."1-1") t:ClearAllPoints() - t:SetPoint("CENTER",self,"CENTER",0,0) + t:SetPoint("CENTER", self, "CENTER", 0, 0) t:SetHeight(self:GetHeight()) t:SetWidth(self:GetWidth()) - GraphFunctions:RotateTexture(t,CurAngle) + GraphFunctions:RotateTexture(t, CurAngle) t:Show() - t:SetVertexColor(Color[1],Color[2],Color[3],1.0) - tinsert(Section.Textures,t) + t:SetVertexColor(Color[1], Color[2], Color[3], 1.0) + tinsert(Section.Textures, t) end --Finish adding section data - Section.Color=Color - Section.Angle=360 + Section.Color = Color + Section.Angle = 360 - self.PercentOn=PiePercent - self.Remaining=Percent + self.PercentOn = PiePercent + self.Remaining = Percent return Color end @@ -988,84 +987,83 @@ function GraphFunctions:ResetPie() self:HideTextures() self:HideLines(self) - self.PieUsed=0 - self.PercentOn=0 - self.Remaining=0 - self.onColor=1 - self.LastSection=nil - self.TotalSections=0 - --self.Sections={} + self.PieUsed = 0 + self.PercentOn = 0 + self.Remaining = 0 + self.onColor = 1 + self.LastSection = nil + self.TotalSections = 0 + --self.Sections = {} end function GraphFunctions:DrawLinePie(angle) - local sx,sy,ex,ey - local Radian=math_pi*(90-angle)/180 - local w,h - w=self:GetWidth()/2 - h=self:GetHeight()/2 + local sx, sy, ex, ey + local Radian = math_pi * (90 - angle) / 180 + local w, h + w = self:GetWidth() / 2 + h = self:GetHeight() / 2 - sx=w - sy=h - - ex=sx+0.88*w*math_cos(Radian) - ey=sx+0.88*h*math_sin(Radian) - - self:DrawLine(self,sx,sy,ex,ey,34,{0.0,0.0,0.0,1.0},"OVERLAY") + sx = w + sy = h + + ex = sx + 0.88 * w * math_cos(Radian) + ey = sx + 0.88 * h * math_sin(Radian) + + self:DrawLine(self, sx, sy, ex, ey, 34, {0.0, 0.0, 0.0, 1.0}, "OVERLAY") end --Used to rotate the pie slices -function GraphFunctions:RotateTexture(texture,angle) - local Radian=math_pi*(45-angle)/180 - local Radian2=math_pi*(45+90-angle)/180 - local Radius=0.70710678118654752440084436210485 +function GraphFunctions:RotateTexture(texture, angle) + local Radian = math_pi * (45 - angle) / 180 + local Radian2 = math_pi * (45 + 90 - angle) / 180 + local Radius = 0.70710678118654752440084436210485 - local tx,ty,tx2,ty2 - tx=Radius*math_cos(Radian) - ty=Radius*math_sin(Radian) - tx2=-ty - ty2=tx + local tx, ty, tx2, ty2 + tx = Radius * math_cos(Radian) + ty = Radius * math_sin(Radian) + tx2 = -ty + ty2 = tx - texture:SetTexCoord(0.5-tx,0.5-ty,0.5+tx2,0.5+ty2,0.5-tx2,0.5-ty2,0.5+tx,0.5+ty) + texture:SetTexCoord(0.5 - tx, 0.5 - ty, 0.5 + tx2, 0.5 + ty2, 0.5 - tx2, 0.5 - ty2, 0.5 + tx, 0.5 + ty) end function GraphFunctions:SetSelectionFunc(f) - self.SelectionFunc=f + self.SelectionFunc = f end --TODO: Pie chart pieces need to be clickable function GraphFunctions:PieChart_OnUpdate() if (MouseIsOver(self)) then - local sX,sY=self:GetCenter() - local Scale=self:GetEffectiveScale() - local mX,mY=GetCursorPosition() - local dX,dY + local sX, sY = self:GetCenter() + local Scale = self:GetEffectiveScale() + local mX, mY = GetCursorPosition() + local dX, dY - dX=mX/Scale-sX - dY=mY/Scale-sY + dX = mX / Scale - sX + dY = mY / Scale - sY - local Angle=90-math_deg(math_atan(dY/dX)) - dY=dY*self.Ratio - local Dist=dX*dX+dY*dY + local Angle = 90-math_deg(math_atan(dY / dX)) + dY = dY * self.Ratio + local Dist = dX * dX + dY * dY - if dX<0 then - Angle=Angle+180 + if dX < 0 then + Angle = Angle + 180 end - local k,v --Are we on the Pie Chart? - if Dist added 10/07/2013 (tercioo) function GraphFunctions:SetLineTexture (texture) - if (type (texture) ~= "string") then return assert (false, "Parameter 1 for SetLineTexture must be a string") end @@ -1299,7 +1295,6 @@ function GraphFunctions:SetLineTexture (texture) end end ---> added 10/07/2013 (tercioo) function GraphFunctions:SetBorderSize (border, size) border = string.lower (border) @@ -1325,47 +1320,48 @@ function GraphFunctions:SetBorderSize (border, size) end function GraphFunctions:CreateGridlines() - local Width=self:GetWidth() - local Height=self:GetHeight() - local NoSecondary=(self.GridSecondaryY==nil) or (self.GridSecondaryX==nil) or (type(self.GridColorSecondary)~="table") + local Width = self:GetWidth() + local Height = self:GetHeight() + local NoSecondary = (self.GridSecondaryY == nil) or (self.GridSecondaryX == nil) or (type(self.GridColorSecondary) ~= "table") + local F self:HideLines(self) self:HideFontStrings() if self.YGridInterval then - local LowerYGridLine,UpperYGridLine,TopSpace - LowerYGridLine=self.YMin/self.YGridInterval - LowerYGridLine=math_max(math_floor(LowerYGridLine),math_ceil(LowerYGridLine)) - UpperYGridLine=self.YMax/self.YGridInterval - UpperYGridLine=math_min(math_floor(UpperYGridLine),math_ceil(UpperYGridLine)) - TopSpace=Height*(1-(UpperYGridLine*self.YGridInterval-self.YMin)/(self.YMax-self.YMin)) - for i=LowerYGridLine,UpperYGridLine do - if i~=0 or not self.YAxisDrawn then - local YPos,T,F - YPos=Height*(i*self.YGridInterval-self.YMin)/(self.YMax-self.YMin) - if NoSecondary or math_fmod(i,self.GridSecondaryY)==0 then - T=self:DrawLine(self,0,YPos,Width,YPos,24,self.GridColor,"BACKGROUND") + local LowerYGridLine, UpperYGridLine, TopSpace + LowerYGridLine = self.YMin / self.YGridInterval + LowerYGridLine = math_max(math_floor(LowerYGridLine),math_ceil(LowerYGridLine)) + UpperYGridLine = self.YMax / self.YGridInterval + UpperYGridLine = math_min(math_floor(UpperYGridLine),math_ceil(UpperYGridLine)) + TopSpace = Height * (1 - (UpperYGridLine * self.YGridInterval - self.YMin) / (self.YMax - self.YMin)) + for i = LowerYGridLine, UpperYGridLine do + if i ~= 0 or not self.YAxisDrawn then + local YPos, T + YPos = Height * (i * self.YGridInterval - self.YMin) / (self.YMax - self.YMin) + if NoSecondary or math_fmod(i, self.GridSecondaryY) == 0 then + T = self:DrawLine(self, 0, YPos, Width, YPos, 24, self.GridColor, "BACKGROUND") else - T=self:DrawLine(self,0,YPos,Width,YPos,24,self.GridColorSecondary,"BACKGROUND") + T = self:DrawLine(self, 0, YPos, Width, YPos, 24, self.GridColorSecondary, "BACKGROUND") end - if ((i~=UpperYGridLine) or (TopSpace>12)) and (NoSecondary or math_fmod(i,self.GridSecondaryY)==0) then + if ((i ~= UpperYGridLine) or (TopSpace > 12)) and (NoSecondary or math_fmod(i, self.GridSecondaryY) == 0) then if self.YLabelsLeft then - F=self:FindFontString() + F = self:FindFontString() F:SetFontObject("GameFontHighlightSmall") - F:SetTextColor(1,1,1) + F:SetTextColor(1, 1, 1) F:ClearAllPoints() - F:SetPoint("BOTTOMLEFT",T,"LEFT",2,2) - F:SetText(i*self.YGridInterval) + F:SetPoint("BOTTOMLEFT", T, "LEFT", 2, 2) + F:SetText(i * self.YGridInterval) F:Show() end if self.YLabelsRight then - F=self:FindFontString() + F = self:FindFontString() F:SetFontObject("GameFontHighlightSmall") - F:SetTextColor(1,1,1) + F:SetTextColor(1, 1, 1) F:ClearAllPoints() - F:SetPoint("BOTTOMRIGHT",T,"RIGHT",-2,2) - F:SetText(i*self.YGridInterval) + F:SetPoint("BOTTOMRIGHT", T, "RIGHT", -2, 2) + F:SetText(i * self.YGridInterval) F:Show() end end @@ -1374,65 +1370,60 @@ function GraphFunctions:CreateGridlines() end if self.XGridInterval then - local LowerXGridLine,UpperXGridLine - LowerXGridLine=self.XMin/self.XGridInterval - LowerXGridLine=math_max(math_floor(LowerXGridLine),math_ceil(LowerXGridLine)) - UpperXGridLine=self.XMax/self.XGridInterval - UpperXGridLine=math_min(math_floor(UpperXGridLine),math_ceil(UpperXGridLine)) + local LowerXGridLine, UpperXGridLine + LowerXGridLine = self.XMin / self.XGridInterval + LowerXGridLine = math_max(math_floor(LowerXGridLine), math_ceil(LowerXGridLine)) + UpperXGridLine = self.XMax / self.XGridInterval + UpperXGridLine = math_min(math_floor(UpperXGridLine), math_ceil(UpperXGridLine)) - for i=LowerXGridLine,UpperXGridLine do - if i~=0 or not self.XAxisDrawn then + for i = LowerXGridLine, UpperXGridLine do + if i ~= 0 or not self.XAxisDrawn then local XPos - XPos=Width*(i*self.XGridInterval-self.XMin)/(self.XMax-self.XMin) - if NoSecondary or math_fmod(i,self.GridSecondaryX)==0 then - self:DrawLine(self,XPos,0,XPos,Height,24,self.GridColor,"BACKGROUND") + XPos = Width * (i * self.XGridInterval - self.XMin) / (self.XMax - self.XMin) + if NoSecondary or math_fmod(i, self.GridSecondaryX) == 0 then + self:DrawLine(self, XPos, 0, XPos, Height, 24, self.GridColor, "BACKGROUND") else - self:DrawLine(self,XPos,0,XPos,Height,24,self.GridColorSecondary,"BACKGROUND") + self:DrawLine(self, XPos, 0, XPos, Height, 24, self.GridColorSecondary, "BACKGROUND") end end end end - if self.YAxisDrawn and self.YMax>=0 and self.YMin<=0 then - local YPos,T + if self.YAxisDrawn and self.YMax >= 0 and self.YMin <= 0 then + local YPos, T - YPos=Height*(-self.YMin)/(self.YMax-self.YMin) - T=self:DrawLine(self,0,YPos,Width,YPos,24,self.AxisColor,"BACKGROUND") + YPos = Height * (-self.YMin) / (self.YMax - self.YMin) + T = self:DrawLine(self, 0, YPos, Width, YPos, 24, self.AxisColor, "BACKGROUND") - if self.YLabelsLeft then - F=self:FindFontString() + if self.YLabelsLeft then + F = self:FindFontString() F:SetFontObject("GameFontHighlightSmall") - F:SetTextColor(1,1,1) + F:SetTextColor(1, 1, 1) F:ClearAllPoints() - F:SetPoint("BOTTOMLEFT",T,"LEFT",2,2) + F:SetPoint("BOTTOMLEFT", T, "LEFT", 2, 2) F:SetText(0) F:Show() end - if self.YLabelsRight then - F=self:FindFontString() + if self.YLabelsRight then + F = self:FindFontString() F:SetFontObject("GameFontHighlightSmall") - F:SetTextColor(1,1,1) + F:SetTextColor(1, 1, 1) F:ClearAllPoints() - F:SetPoint("BOTTOMRIGHT",T,"RIGHT",-2,2) + F:SetPoint("BOTTOMRIGHT", T, "RIGHT", -2, 2) F:SetText(0) F:Show() end end - if self.XAxisDrawn and self.XMax>=0 and self.XMin<=0 then - local XPos; + if self.XAxisDrawn and self.XMax >= 0 and self.XMin <= 0 then + local XPos - XPos=Width*(-self.XMin)/(self.XMax-self.XMin) - self:DrawLine(self,XPos,0,XPos,Height,24,self.AxisColor,"BACKGROUND") + XPos = Width * (-self.XMin) / (self.XMax - self.XMin) + self:DrawLine(self, XPos, 0, XPos, Height, 24, self.AxisColor, "BACKGROUND") end end - - - - - -------------------------------------------------------------------------------- --Refresh functions -------------------------------------------------------------------------------- @@ -1440,237 +1431,232 @@ end function GraphFunctions:OnUpdateGraph() if self.NeedsUpdate and self.RefreshGraph then self:RefreshGraph() - self.NeedsUpdate=false + self.NeedsUpdate = false end end --Performs a convolution in realtime allowing to graph Framerate, DPS, or any other data you want graphed in realtime function GraphFunctions:OnUpdateGraphRealtime() - local i,j - local CurTime=GetTime() + local CurTime = GetTime() local BarsChanged - if self.NextUpdate>CurTime or (self.Mode=="RAW" and not (self.NeedsUpdate or self.AddedBar)) then + if self.NextUpdate > CurTime or (self.Mode == "RAW" and not (self.NeedsUpdate or self.AddedBar)) then return end - self.NextUpdate=CurTime+self.LimitUpdates - - --Slow Mode performs an entire convolution every frame - if self.Mode=="SLOW" then - --Initialize Bar Data - self.BarHeight={} - for i=1,self.BarNum do - self.BarHeight[i]=0 - end - local k,v - local BarTimeRadius=(self.XMax-self.XMin)/self.BarNum - local DataValue=1/(2*self.TimeRadius) + self.NextUpdate = CurTime + self.LimitUpdates - if self.Filter=="RECT" then + --Slow Mode performs an entire convolution every frame + if self.Mode == "SLOW" then + --Initialize Bar Data + self.BarHeight = {} + for i = 1, self.BarNum do + self.BarHeight[i] = 0 + end + local k, v + local BarTimeRadius = (self.XMax - self.XMin) / self.BarNum + local DataValue = 1 / (2 * self.TimeRadius) + + if self.Filter == "RECT" then --Take the convolution of the dataset on to the bars wtih a rectangular filter - local DataValue=1/(2*self.TimeRadius) - for k,v in pairs(self.Data) do - if v.Time<(CurTime+self.XMin-self.TimeRadius) then - tremove(self.Data,k) - else - local DataTime=v.Time-CurTime - local LowestBar=math_max(math_floor((DataTime-self.XMin-self.TimeRadius)/BarTimeRadius),1) - local HighestBar=math_min(math_ceil((DataTime-self.XMin+self.TimeRadius)/BarTimeRadius),self.BarNum) - for i=LowestBar,HighestBar do - self.BarHeight[i]=self.BarHeight[i]+v.Value*DataValue + local DataValue = 1 / (2 * self.TimeRadius) + for k, v in pairs(self.Data) do + if v.Time < (CurTime + self.XMin - self.TimeRadius) then + tremove(self.Data, k) + else + local DataTime = v.Time - CurTime + local LowestBar = math_max(math_floor((DataTime - self.XMin - self.TimeRadius) / BarTimeRadius), 1) + local HighestBar = math_min(math_ceil((DataTime - self.XMin + self.TimeRadius) / BarTimeRadius), self.BarNum) + for i = LowestBar, HighestBar do + self.BarHeight[i] = self.BarHeight[i] + v.Value * DataValue end end end - elseif self.Filter=="TRI" then + elseif self.Filter == "TRI" then --Needs optimization badly --Take the convolution of the dataset on to the bars wtih a triangular filter - local DataValue=1/(self.TimeRadius) - for k,v in pairs(self.Data) do + local DataValue = 1 / (self.TimeRadius) + for k, v in pairs(self.Data) do local Temp - if v.Time<(CurTime+self.XMin-self.TimeRadius) then - tremove(self.Data,k) - else - local DataTime=v.Time-CurTime - local LowestBar=math_max(math_floor((DataTime-self.XMin-self.TimeRadius)/BarTimeRadius),1) - local HighestBar=math_min(math_ceil((DataTime-self.XMin+self.TimeRadius)/BarTimeRadius),self.BarNum) + if v.Time < (CurTime + self.XMin - self.TimeRadius) then + tremove(self.Data, k) + else + local DataTime = v.Time - CurTime + local LowestBar = math_max(math_floor((DataTime - self.XMin - self.TimeRadius) / BarTimeRadius), 1) + local HighestBar = math_min(math_ceil((DataTime - self.XMin + self.TimeRadius) / BarTimeRadius), self.BarNum) - - for i=LowestBar,HighestBar do - self.BarHeight[i]=self.BarHeight[i]+v.Value*DataValue*math_abs(BarTimeRadius*i+self.XMin-DataTime) + for i = LowestBar, HighestBar do + self.BarHeight[i] = self.BarHeight[i] + v.Value * DataValue * math_abs(BarTimeRadius * i + self.XMin - DataTime) end end end end - BarsChanged=true - elseif self.Mode=="FAST" then - local ShiftBars=math_floor((CurTime-self.LastShift)/self.BarWidth) + BarsChanged = true + elseif self.Mode == "FAST" then + local ShiftBars = math_floor((CurTime - self.LastShift) / self.BarWidth) - if ShiftBars>0 and not (self.LastDataTime<(self.LastShift+self.XMin-self.TimeRadius*2)) then - local RecalcBars=self.BarNum-(ShiftBars+self.FilterOverlap)+1 + if ShiftBars > 0 and not (self.LastDataTime < (self.LastShift + self.XMin - self.TimeRadius * 2)) then + local RecalcBars = self.BarNum - (ShiftBars + self.FilterOverlap) + 1 - for i=1,self.BarNum do - if i0 then - local RecalcBars=self.BarNum-ShiftBars+1 + if ShiftBars > 0 then + local RecalcBars = self.BarNum - ShiftBars + 1 - for i=1,self.BarNum do - if i0 and not (self.LastDataTime<(self.LastShift+self.XMin-self.TimeRadius)) then - for i=1,self.BarNum do - if i 0 and not (self.LastDataTime < (self.LastShift + self.XMin-self.TimeRadius)) then + for i = 1, self.BarNum do + if i < RecalcBars then + self.BarHeight[i] = self.BarHeight[i + ShiftBars] end end - + --Now to calculate the new bars local Total - local Weight=1/self.TimeRadius/self.ExpNorm + local Weight = 1 / self.TimeRadius / self.ExpNorm + + Total = 0 - Total=0 - --Implement an EXPFAST which does this only once instead of for each bar - for k,v in pairs(self.Data) do - Total=Total+v.Value*Weight - if v.Time<(self.LastShift-self.TimeRadius) then - tremove(self.Data,k) + for k, v in pairs(self.Data) do + Total = Total + v.Value * Weight + if v.Time < (self.LastShift - self.TimeRadius) then + tremove(self.Data, k) end end - --self.LastShift=self.LastShift+self.BarWidth*ShiftBars + --self.LastShift = self.LastShift+self.BarWidth*ShiftBars - if self.CurVal~=0 or Total~=0 then - for i=RecalcBars,self.BarNum do - self.CurVal=self.Decay*self.CurVal+Total - self.BarHeight[i]=self.CurVal + if self.CurVal ~= 0 or Total ~= 0 then + for i = RecalcBars, self.BarNum do + self.CurVal = self.Decay * self.CurVal + Total + self.BarHeight[i] = self.CurVal end - self.LastDataTime=self.LastShift+self.BarWidth*ShiftBars + self.LastDataTime = self.LastShift + self.BarWidth * ShiftBars else - for i=RecalcBars,self.BarNum do - self.BarHeight[i]=0 + for i = RecalcBars, self.BarNum do + self.BarHeight[i] = 0 end end - if self.CurVal<0.1 then - self.CurVal=0 + if self.CurVal < 0.1 then + self.CurVal = 0 end - BarsChanged=true + BarsChanged = true end - self.LastShift=self.LastShift+self.BarWidth*ShiftBars - elseif self.Mode=="RAW" then + self.LastShift = self.LastShift + self.BarWidth * ShiftBars + elseif self.Mode == "RAW" then --Do nothing really --Using .AddedBar so we cut down on updating the grid - self.AddedBar=false - BarsChanged=true + self.AddedBar = false + BarsChanged = true end - if BarsChanged then if self.AutoScale then - local MaxY=0 + local MaxY = 0 - for i=1,self.BarNum do - MaxY=math_max(MaxY,self.BarHeight[i]) + for i = 1, self.BarNum do + MaxY = math_max(MaxY, self.BarHeight[i]) end - MaxY=1.25*MaxY + MaxY = 1.25 * MaxY - MaxY=math_max(MaxY,self.MinMaxY) - - if MaxY~=0 and math_abs(self.YMax-MaxY)>0.01 then - self.YMax=MaxY - self.NeedsUpdate=true - end + MaxY = math_max(MaxY, self.MinMaxY) + + if MaxY ~= 0 and math_abs(self.YMax - MaxY) > 0.01 then + self.YMax = MaxY + self.NeedsUpdate = true + end end self:SetBars() end if self.NeedsUpdate then - self.NeedsUpdate=false + self.NeedsUpdate = false self:RefreshGraph() end end --Line Graph function GraphFunctions:RefreshLineGraph() - local k1, k2, series self:HideLines(self) self:HideBars(self) @@ -1679,31 +1665,28 @@ function GraphFunctions:RefreshLineGraph() --Go through line data first for k1, series in pairs(self.Data) do for k2, point in pairs(series.Points) do - MinX=math_min(point[1],MinX) - MaxX=math_max(point[1],MaxX) - MinY=math_min(point[2],MinY) - MaxY=math_max(point[2],MaxY) + MinX = math_min(point[1], MinX) + MaxX = math_max(point[1], MaxX) + MinY = math_min(point[2], MinY) + MaxY = math_max(point[2], MaxY) end end --Now through the Filled Lines for k1, series in pairs(self.FilledData) do for k2, point in pairs(series.Points) do - MinX=math_min(point[1],MinX) - MaxX=math_max(point[1],MaxX) - MinY=math_min(point[2],MinY) - MaxY=math_max(point[2],MaxY) + MinX = math_min(point[1], MinX) + MaxX = math_max(point[1], MaxX) + MinY = math_min(point[2], MinY) + MaxY = math_max(point[2], MaxY) end end local XBorder, YBorder - XBorder=0.1*(MaxX-MinX) - YBorder=0.1*(MaxY-MinY) - - --> changed 10/07/2013 (tercioo) - --> add four new members to the line graphic object: CustomLeftBorder CustomRightBorder CustomBottomBorder CustomTopBorder - + XBorder = 0.1 * (MaxX - MinX) + YBorder = 0.1 * (MaxY - MinY) + if not self.LockOnXMin then if (self.CustomLeftBorder) then self.XMin=MinX+self.CustomLeftBorder --> custom size of left border @@ -1735,32 +1718,32 @@ function GraphFunctions:RefreshLineGraph() self.YMax=MaxY+YBorder end end - + end self:CreateGridlines() - local Width=self:GetWidth() - local Height=self:GetHeight() + local Width = self:GetWidth() + local Height = self:GetHeight() for k1, series in pairs(self.Data) do local LastPoint - LastPoint=nil + LastPoint = nil for k2, point in pairs(series.Points) do if LastPoint then - local TPoint={x=point[1];y=point[2]} + local TPoint = {x = point[1]; y = point[2]} - TPoint.x=Width*(TPoint.x-self.XMin)/(self.XMax-self.XMin) - TPoint.y=Height*(TPoint.y-self.YMin)/(self.YMax-self.YMin) + TPoint.x = Width * (TPoint.x - self.XMin) / (self.XMax - self.XMin) + TPoint.y = Height * (TPoint.y - self.YMin) / (self.YMax - self.YMin) - self:DrawLine(self,LastPoint.x,LastPoint.y,TPoint.x,TPoint.y,32,series.Color) + self:DrawLine(self, LastPoint.x, LastPoint.y, TPoint.x, TPoint.y, 32, series.Color, nil, series.LineTexture) - LastPoint=TPoint + LastPoint = TPoint else - LastPoint={x=point[1];y=point[2]} - LastPoint.x=Width*(LastPoint.x-self.XMin)/(self.XMax-self.XMin) - LastPoint.y=Height*(LastPoint.y-self.YMin)/(self.YMax-self.YMin) + LastPoint = {x = point[1]; y = point[2]} + LastPoint.x = Width * (LastPoint.x - self.XMin) / (self.XMax - self.XMin) + LastPoint.y = Height * (LastPoint.y - self.YMin) / (self.YMax - self.YMin) end end end @@ -1768,22 +1751,22 @@ function GraphFunctions:RefreshLineGraph() --Filled Line Graphs for k1, series in pairs(self.FilledData) do local LastPoint - LastPoint=nil + LastPoint = nil for k2, point in pairs(series.Points) do if LastPoint then - local TPoint={x=point[1];y=point[2]} + local TPoint = {x = point[1]; y = point[2]} - TPoint.x=Width*(TPoint.x-self.XMin)/(self.XMax-self.XMin) - TPoint.y=Height*(TPoint.y-self.YMin)/(self.YMax-self.YMin) + TPoint.x = Width * (TPoint.x - self.XMin) / (self.XMax - self.XMin) + TPoint.y = Height * (TPoint.y - self.YMin ) /(self.YMax - self.YMin) - self:DrawBar(self,LastPoint.x,LastPoint.y,TPoint.x,TPoint.y,series.Color,k1) + self:DrawBar(self, LastPoint.x, LastPoint.y, TPoint.x, TPoint.y, series.Color, k1) - LastPoint=TPoint + LastPoint = TPoint else - LastPoint={x=point[1];y=point[2]} - LastPoint.x=Width*(LastPoint.x-self.XMin)/(self.XMax-self.XMin) - LastPoint.y=Height*(LastPoint.y-self.YMin)/(self.YMax-self.YMin) + LastPoint = {x = point[1]; y = point[2]} + LastPoint.x = Width * (LastPoint.x - self.XMin) / (self.XMax - self.XMin) + LastPoint.y = Height * (LastPoint.y - self.YMin) / (self.YMax - self.YMin) end end end @@ -1791,171 +1774,162 @@ end --Scatter Plot Refresh function GraphFunctions:RefreshScatterPlot() - local k1, k2, series, point self:HideLines(self) if self.AutoScale and self.Data then local MinX, MaxX, MinY, MaxY = math_huge, -math_huge, math_huge, -math_huge for k1, series in pairs(self.Data) do for k2, point in pairs(series.Points) do - MinX=math_min(point[1],MinX) - MaxX=math_max(point[1],MaxX) - MinY=math_min(point[2],MinY) - MaxY=math_max(point[2],MaxY) + MinX = math_min(point[1], MinX) + MaxX = math_max(point[1], MaxX) + MinY = math_min(point[2], MinY) + MaxY = math_max(point[2], MaxY) end end local XBorder, YBorder - XBorder=0.1*(MaxX-MinX) - YBorder=0.1*(MaxY-MinY) + XBorder = 0.1 * (MaxX - MinX) + YBorder = 0.1 * (MaxY - MinY) if not self.LockOnXMin then - self.XMin=MinX-XBorder + self.XMin = MinX - XBorder end if not self.LockOnXMax then - self.XMax=MaxX+XBorder + self.XMax = MaxX + XBorder end if not self.LockOnYMin then - self.YMin=MinY-YBorder + self.YMin = MinY - YBorder end if not self.LockOnYMax then - self.YMax=MaxY+YBorder + self.YMax = MaxY + YBorder end end self:CreateGridlines() - local Width=self:GetWidth() - local Height=self:GetHeight() - + local Width = self:GetWidth() + local Height = self:GetHeight() + self:HideTextures() for k1, series in pairs(self.Data) do - local MinX,MaxX = self.XMax, self.XMin + local MinX, MaxX = self.XMax, self.XMin for k2, point in pairs(series.Points) do - local x,y - MinX=math_min(point[1],MinX) - MaxX=math_max(point[1],MaxX) - x=Width*(point[1]-self.XMin)/(self.XMax-self.XMin) - y=Height*(point[2]-self.YMin)/(self.YMax-self.YMin) + local x, y + MinX = math_min(point[1],MinX) + MaxX = math_max(point[1],MaxX) + x = Width * (point[1] - self.XMin) / (self.XMax - self.XMin) + y = Height * (point[2] - self.YMin) / (self.YMax - self.YMin) - local g=self:FindTexture() - g:SetTexture("Spells\\GENERICGLOW2_64.blp") + local g = self:FindTexture() + g:SetTexture("Spells\\GENERICGLOW2_64") g:SetWidth(6) g:SetHeight(6) g:ClearAllPoints() - g:SetPoint("CENTER",self,"BOTTOMLEFT",x,y) - g:SetVertexColor(series.Color[1],series.Color[2],series.Color[3],series.Color[4]); + g:SetPoint("CENTER", self, "BOTTOMLEFT", x, y) + g:SetVertexColor(series.Color[1], series.Color[2], series.Color[3], series.Color[4]) g:Show() end if self.LinearFit then local alpha, beta = self:LinearRegression(series.Points) - local sx,sy,ex,ey - - sx=MinX - sy=beta*sx+alpha - ex=MaxX - ey=beta*ex+alpha + local sx, sy, ex, ey - sx=Width*(sx-self.XMin)/(self.XMax-self.XMin) - sy=Height*(sy-self.YMin)/(self.YMax-self.YMin) - ex=Width*(ex-self.XMin)/(self.XMax-self.XMin) - ey=Height*(ey-self.YMin)/(self.YMax-self.YMin) + sx = MinX + sy = beta * sx + alpha + ex = MaxX + ey = beta*ex+alpha - self:DrawLine(self,sx,sy,ex,ey,32,series.Color) + sx = Width * (sx - self.XMin) / (self.XMax - self.XMin) + sy = Height * (sy - self.YMin) / (self.YMax - self.YMin) + ex = Width * (ex - self.XMin) / (self.XMax - self.XMin) + ey = Height * (ey - self.YMin) / (self.YMax - self.YMin) + + self:DrawLine(self, sx, sy, ex, ey, 32, series.Color) end end end - - - - - - - - --Copied from Blizzard's TaxiFrame code and modifed for IMBA then remodified for GraphLib -- The following function is used with permission from Daniel Stephens -local TAXIROUTE_LINEFACTOR = 128/126; -- Multiplying factor for texture coordinates -local TAXIROUTE_LINEFACTOR_2 = TAXIROUTE_LINEFACTOR / 2; -- Half of that +local TAXIROUTE_LINEFACTOR = 128 / 126 -- Multiplying factor for texture coordinates +local TAXIROUTE_LINEFACTOR_2 = TAXIROUTE_LINEFACTOR / 2 -- Half of that --- T - Texture --- C - Canvas Frame (for anchoring) --- sx,sy - Coordinate of start of line --- ex,ey - Coordinate of end of line --- w - Width of line --- relPoint - Relative point on canvas to interpret coords (Default BOTTOMLEFT) -function lib:DrawLine(C, sx, sy, ex, ey, w, color, layer) +-- T - Texture +-- C - Canvas Frame (for anchoring) +-- sx, sy - Coordinate of start of line +-- ex, ey - Coordinate of end of line +-- w - Width of line +-- relPoint - Relative point on canvas to interpret coords (Default BOTTOMLEFT) +function lib:DrawLine(C, sx, sy, ex, ey, w, color, layer, linetexture) local relPoint = "BOTTOMLEFT" - - if sx==ex then - if sy==ey then + + if sx == ex then + if sy == ey then return else - return self:DrawVLine(C,sx,sy,ey,w, color, layer) + return self:DrawVLine(C, sx, sy, ey, w, color, layer) end - elseif sy==ey then - return self:DrawHLine(C,sx,ex,sy,w, color, layer) + elseif sy == ey then + return self:DrawHLine(C, sx, ex, sy, w, color, layer) end if not C.GraphLib_Lines then - C.GraphLib_Lines={} - C.GraphLib_Lines_Used={} + C.GraphLib_Lines = {} + C.GraphLib_Lines_Used = {} end local T = tremove(C.GraphLib_Lines) or C:CreateTexture(nil, "ARTWORK") - --> changed 10/07/2013 (tercioo) - --> graph:SetLineTexture (texture) - if (not C.CustomLine) then - T:SetTexture(TextureDirectory.."line") - else + if linetexture then --> this data series texture + T:SetTexture(linetexture) + elseif C.CustomLine then --> overall chart texture T:SetTexture(C.CustomLine) + else --> no texture assigned, use default + T:SetTexture(TextureDirectory.."line") end - tinsert(C.GraphLib_Lines_Used,T) + tinsert(C.GraphLib_Lines_Used, T) T:SetDrawLayer(layer or "ARTWORK") - T:SetVertexColor(color[1],color[2],color[3],color[4]); + T:SetVertexColor(color[1], color[2], color[3], color[4]) -- Determine dimensions and center point of line - local dx,dy = ex - sx, ey - sy; - local cx,cy = (sx + ex) / 2, (sy + ey) / 2; + local dx, dy = ex - sx, ey - sy + local cx, cy = (sx + ex) / 2, (sy + ey) / 2 -- Normalize direction if necessary if (dx < 0) then - dx,dy = -dx,-dy; + dx, dy = -dx, -dy end -- Calculate actual length of line - local l = sqrt((dx * dx) + (dy * dy)); + local l = sqrt((dx * dx) + (dy * dy)) -- Sin and Cosine of rotation, and combination (for later) - local s,c = -dy / l, dx / l; - local sc = s * c; + local s, c = -dy / l, dx / l + local sc = s * c -- Calculate bounding box size and texture coordinates - local Bwid, Bhgt, BLx, BLy, TLx, TLy, TRx, TRy, BRx, BRy; + local Bwid, Bhgt, BLx, BLy, TLx, TLy, TRx, TRy, BRx, BRy if (dy >= 0) then - Bwid = ((l * c) - (w * s)) * TAXIROUTE_LINEFACTOR_2; - Bhgt = ((w * c) - (l * s)) * TAXIROUTE_LINEFACTOR_2; - BLx, BLy, BRy = (w / l) * sc, s * s, (l / w) * sc; - BRx, TLx, TLy, TRx = 1 - BLy, BLy, 1 - BRy, 1 - BLx; - TRy = BRx; + Bwid = ((l * c) - (w * s)) * TAXIROUTE_LINEFACTOR_2 + Bhgt = ((w * c) - (l * s)) * TAXIROUTE_LINEFACTOR_2 + BLx, BLy, BRy = (w / l) * sc, s * s, (l / w) * sc + BRx, TLx, TLy, TRx = 1 - BLy, BLy, 1 - BRy, 1 - BLx + TRy = BRx else - Bwid = ((l * c) + (w * s)) * TAXIROUTE_LINEFACTOR_2; - Bhgt = ((w * c) + (l * s)) * TAXIROUTE_LINEFACTOR_2; - BLx, BLy, BRx = s * s, -(l / w) * sc, 1 + (w / l) * sc; - BRy, TLx, TLy, TRy = BLx, 1 - BRx, 1 - BLx, 1 - BLy; - TRx = TLy; + Bwid = ((l * c) + (w * s)) * TAXIROUTE_LINEFACTOR_2 + Bhgt = ((w * c) + (l * s)) * TAXIROUTE_LINEFACTOR_2 + BLx, BLy, BRx = s * s, -(l / w) * sc, 1 + (w / l) * sc + BRy, TLx, TLy, TRy = BLx, 1 - BRx, 1 - BLx, 1 - BLy + TRx = TLy end -- Thanks Blizzard for adding (-)10000 as a hard-cap and throwing errors! -- The cap was added in 3.1.0 and I think it was upped in 3.1.1 - -- (way less chance to get the error) + -- (way less chance to get the error) if TLx > 10000 then TLx = 10000 elseif TLx < -10000 then TLx = -10000 end if TLy > 10000 then TLy = 10000 elseif TLy < -10000 then TLy = -10000 end if BLx > 10000 then BLx = 10000 elseif BLx < -10000 then BLx = -10000 end @@ -1966,10 +1940,10 @@ function lib:DrawLine(C, sx, sy, ex, ey, w, color, layer) if BRy > 10000 then BRy = 10000 elseif BRy < -10000 then BRy = -10000 end -- Set texture coordinates and anchors - T:ClearAllPoints(); - T:SetTexCoord(TLx, TLy, BLx, BLy, TRx, TRy, BRx, BRy); - T:SetPoint("BOTTOMLEFT", C, relPoint, cx - Bwid, cy - Bhgt); - T:SetPoint("TOPRIGHT", C, relPoint, cx + Bwid, cy + Bhgt); + T:ClearAllPoints() + T:SetTexCoord(TLx, TLy, BLx, BLy, TRx, TRy, BRx, BRy) + T:SetPoint("BOTTOMLEFT", C, relPoint, cx - Bwid, cy - Bhgt) + T:SetPoint("TOPRIGHT", C, relPoint, cx + Bwid, cy + Bhgt) T:Show() return T end @@ -1979,27 +1953,27 @@ function lib:DrawVLine(C, x, sy, ey, w, color, layer) local relPoint = "BOTTOMLEFT" if not C.GraphLib_Lines then - C.GraphLib_Lines={} - C.GraphLib_Lines_Used={} + C.GraphLib_Lines = {} + C.GraphLib_Lines_Used = {} end local T = tremove(C.GraphLib_Lines) or C:CreateTexture(nil, "ARTWORK") - T:SetTexture(TextureDirectory.."sline"); - tinsert(C.GraphLib_Lines_Used,T); + T:SetTexture(TextureDirectory.."sline") + tinsert(C.GraphLib_Lines_Used, T) T:SetDrawLayer(layer or "ARTWORK") - T:SetVertexColor(color[1],color[2],color[3],color[4]); + T:SetVertexColor(color[1], color[2], color[3], color[4]) - if sy>ey then + if sy > ey then sy, ey = ey, sy end -- Set texture coordinates and anchors - T:ClearAllPoints(); - T:SetTexCoord(1, 0, 0, 0, 1, 1, 0, 1); - T:SetPoint("BOTTOMLEFT", C, relPoint, x-w/2, sy); - T:SetPoint("TOPRIGHT", C, relPoint, x+w/2, ey); + T:ClearAllPoints() + T:SetTexCoord(1, 0, 0, 0, 1, 1, 0, 1) + T:SetPoint("BOTTOMLEFT", C, relPoint, x - w / 2, sy) + T:SetPoint("TOPRIGHT", C, relPoint, x + w / 2, ey) T:Show() return T end @@ -2008,27 +1982,27 @@ function lib:DrawHLine(C, sx, ex, y, w, color, layer) local relPoint = "BOTTOMLEFT" if not C.GraphLib_Lines then - C.GraphLib_Lines={} - C.GraphLib_Lines_Used={} + C.GraphLib_Lines = {} + C.GraphLib_Lines_Used = {} end local T = tremove(C.GraphLib_Lines) or C:CreateTexture(nil, "ARTWORK") - T:SetTexture(TextureDirectory.."sline"); - tinsert(C.GraphLib_Lines_Used,T); + T:SetTexture(TextureDirectory.."sline") + tinsert(C.GraphLib_Lines_Used, T) T:SetDrawLayer(layer or "ARTWORK") - T:SetVertexColor(color[1],color[2],color[3],color[4]); + T:SetVertexColor(color[1], color[2], color[3], color[4]) - if sx>ex then + if sx > ex then sx, ex = ex, sx end -- Set texture coordinates and anchors - T:ClearAllPoints(); - T:SetTexCoord(0, 0, 0, 1, 1, 0, 1, 1); - T:SetPoint("BOTTOMLEFT", C, relPoint, sx, y-w/2); - T:SetPoint("TOPRIGHT", C, relPoint, ex, y+w/2); + T:ClearAllPoints() + T:SetTexCoord(0, 0, 0, 1, 1, 0, 1, 1) + T:SetPoint("BOTTOMLEFT", C, relPoint, sx, y - w / 2) + T:SetPoint("TOPRIGHT", C, relPoint, ex, y + w / 2) T:Show() return T end @@ -2037,7 +2011,7 @@ function lib:HideLines(C) if C.GraphLib_Lines then for i = #C.GraphLib_Lines_Used, 1, -1 do C.GraphLib_Lines_Used[i]:Hide() - tinsert(C.GraphLib_Lines,tremove(C.GraphLib_Lines_Used)) + tinsert(C.GraphLib_Lines, tremove(C.GraphLib_Lines_Used)) end end end @@ -2045,97 +2019,95 @@ end --Two parts to each bar function lib:DrawBar(C, sx, sy, ex, ey, color, level) local Bar, Tri, barNum, MinY, MaxY - - --Want sx<=ex if not then flip them - if sx>ex then + + --Want sx <= ex if not then flip them + if sx > ex then sx, ex = ex, sx sy, ey = ey, sy end if not C.GraphLib_Bars then - C.GraphLib_Bars={} - C.GraphLib_Tris={} - C.GraphLib_Bars_Used={} - C.GraphLib_Tris_Used={} - C.GraphLib_Frames={} + C.GraphLib_Bars = {} + C.GraphLib_Tris = {} + C.GraphLib_Bars_Used = {} + C.GraphLib_Tris_Used = {} + C.GraphLib_Frames = {} end - - if (#C.GraphLib_Bars)>0 then - Bar=C.GraphLib_Bars[#C.GraphLib_Bars] - tremove(C.GraphLib_Bars,#C.GraphLib_Bars) - Bar:Show() - Tri=C.GraphLib_Tris[#C.GraphLib_Tris] - tremove(C.GraphLib_Tris,#C.GraphLib_Tris) - Tri:Show() + if (#C.GraphLib_Bars) > 0 then + Bar = C.GraphLib_Bars[#C.GraphLib_Bars] + tremove(C.GraphLib_Bars, #C.GraphLib_Bars) + Bar:Show() + + Tri = C.GraphLib_Tris[#C.GraphLib_Tris] + tremove(C.GraphLib_Tris, #C.GraphLib_Tris) + Tri:Show() end if not Bar then - Bar=C:CreateTexture(nil, "ARTWORK") - Bar:SetTexture(1,1,1,1) - - Tri=C:CreateTexture(nil, "ARTWORK") - Tri:SetTexture(TextureDirectory.."triangle") + Bar = C:CreateTexture(nil, "ARTWORK") + Bar:SetTexture(1, 1, 1, 1) + + Tri = C:CreateTexture(nil, "ARTWORK") + Tri:SetTexture(TextureDirectory.."triangle") end - tinsert(C.GraphLib_Bars_Used,Bar) - tinsert(C.GraphLib_Tris_Used,Tri) - + tinsert(C.GraphLib_Bars_Used, Bar) + tinsert(C.GraphLib_Tris_Used, Tri) + if level then - if type(C.GraphLib_Frames[level])=="nil" then - local newLevel=C:GetFrameLevel()+level - C.GraphLib_Frames[level]=CreateFrame("Frame",nil,C) + if type(C.GraphLib_Frames[level]) == "nil" then + local newLevel = C:GetFrameLevel() + level + C.GraphLib_Frames[level] = CreateFrame("Frame", nil, C) C.GraphLib_Frames[level]:SetFrameLevel(newLevel) C.GraphLib_Frames[level]:SetAllPoints(C) - if C.TextFrame and C.TextFrame:GetFrameLevel()<=newLevel then - C.TextFrame:SetFrameLevel(newLevel+1) - self.NeedsUpdate=true + if C.TextFrame and C.TextFrame:GetFrameLevel() <= newLevel then + C.TextFrame:SetFrameLevel(newLevel + 1) + self.NeedsUpdate = true end end - + Bar:SetParent(C.GraphLib_Frames[level]) Tri:SetParent(C.GraphLib_Frames[level]) end - Bar:SetVertexColor(color[1],color[2],color[3],color[4]) - Tri:SetVertexColor(color[1],color[2],color[3],color[4]) + Bar:SetVertexColor(color[1], color[2], color[3], color[4]) + Tri:SetVertexColor(color[1], color[2], color[3], color[4]) - - - if sy=1 then + if (MaxY-MinY) >= 1 then Tri:ClearAllPoints() Tri:SetPoint("BOTTOMLEFT", C, "BOTTOMLEFT", sx, MinY) Tri:SetWidth(Width) - Tri:SetHeight(MaxY-MinY) + Tri:SetHeight(MaxY - MinY) else Tri:Hide() end @@ -2146,23 +2118,18 @@ function lib:HideBars(C) if not C.GraphLib_Bars then return end - - while (#C.GraphLib_Bars_Used)>0 do - C.GraphLib_Bars[#C.GraphLib_Bars+1]=C.GraphLib_Bars_Used[#C.GraphLib_Bars_Used] - C.GraphLib_Bars[#C.GraphLib_Bars]:Hide() - C.GraphLib_Bars_Used[#C.GraphLib_Bars_Used]=nil - C.GraphLib_Tris[#C.GraphLib_Tris+1]=C.GraphLib_Tris_Used[#C.GraphLib_Tris_Used] + while (#C.GraphLib_Bars_Used) > 0 do + C.GraphLib_Bars[#C.GraphLib_Bars + 1] = C.GraphLib_Bars_Used[#C.GraphLib_Bars_Used] + C.GraphLib_Bars[#C.GraphLib_Bars]:Hide() + C.GraphLib_Bars_Used[#C.GraphLib_Bars_Used] = nil + + C.GraphLib_Tris[#C.GraphLib_Tris + 1] = C.GraphLib_Tris_Used[#C.GraphLib_Tris_Used] C.GraphLib_Tris[#C.GraphLib_Tris]:Hide() - C.GraphLib_Tris_Used[#C.GraphLib_Tris_Used]=nil + C.GraphLib_Tris_Used[#C.GraphLib_Tris_Used] = nil end end - - - - - -- lib upgrade stuff, overwrite the old function references in -- existing graphs with the ones in this newer library for _, graph in ipairs(lib.RegisteredGraphRealtime) do @@ -2178,104 +2145,98 @@ for _, graph in ipairs(lib.RegisteredGraphPieChart) do SetupGraphPieChartFunctions(graph) end - - - - - - --------------------------------------------------- --Test Functions, for reference for addon authors to test, use and copy --To test the library do /script LibStub("LibGraph-2.0"):TestGraph2Lib() local function TestRealtimeGraph() - local Graph=LibStub(major) - local g=Graph:CreateGraphRealtime("TestRealtimeGraph",UIParent,"CENTER","CENTER",-90,90,150,150) + local Graph = LibStub(major) + local g = Graph:CreateGraphRealtime("TestRealtimeGraph", UIParent, "CENTER", "CENTER", -90, 90, 150, 150) g:SetAutoScale(true) - g:SetGridSpacing(1.0,10.0) + g:SetGridSpacing(1.0, 10.0) g:SetYMax(120) - g:SetXAxis(-11,-1) + g:SetXAxis(-11, -1) g:SetFilterRadius(1) - g:SetBarColors({0.2,0.0,0.0,0.4},{1.0,0.0,0.0,1.0}) + g:SetBarColors({0.2, 0.0, 0.0, 0.4}, {1.0, 0.0, 0.0, 1.0}) local f = CreateFrame("Frame") - f:SetScript("OnUpdate",function() g:AddTimeData(1) end) + f:SetScript("OnUpdate", function() + g:AddTimeData(1) + end) f:Show() - DEFAULT_CHAT_FRAME:AddMessage("Testing Reattime Graph") + DEFAULT_CHAT_FRAME:AddMessage("Testing Realtime Graph") end local function TestRealtimeGraphRaw() - local Graph=LibStub(major) - local g=Graph:CreateGraphRealtime("TestRealtimeGraph",UIParent,"TOP","TOP",0,0,150,150) + local Graph = LibStub(major) + local g = Graph:CreateGraphRealtime("TestRealtimeGraph", UIParent, "TOP", "TOP", 0, 0, 150, 150) g:SetAutoScale(true) - g:SetGridSpacing(1.0,10.0) + g:SetGridSpacing(1.0, 10.0) g:SetYMax(120) - g:SetXAxis(-10,0) + g:SetXAxis(-10, 0) g:SetMode("RAW") - g:SetBarColors({0.2,0.0,0.0,0.4},{1.0,0.0,0.0,1.0}) + g:SetBarColors({0.2, 0.0, 0.0, 0.4}, {1.0, 0.0, 0.0, 1.0}) local f = CreateFrame("Frame") - f.frames=0 - f.NextUpdate=GetTime() - f:SetScript("OnUpdate",function() - if f.NextUpdate>GetTime() then - return - end - - g:AddBar(UnitHealth("player")) - f.NextUpdate=f.NextUpdate+g.BarWidth - end) + f.frames = 0 + f.NextUpdate = GetTime() + f:SetScript("OnUpdate",function() + if f.NextUpdate > GetTime() then + return + end + + g:AddBar(UnitHealth("player")) + f.NextUpdate = f.NextUpdate + g.BarWidth + end) f:Show() DEFAULT_CHAT_FRAME:AddMessage("Testing 0") end - - local function TestLineGraph() - local Graph=LibStub(major) - local g=Graph:CreateGraphLine("TestLineGraph",UIParent,"CENTER","CENTER",90,90,150,150) - g:SetXAxis(-1,1) - g:SetYAxis(-1,1) - g:SetGridSpacing(0.25,0.25) - g:SetGridColor({0.5,0.5,0.5,0.5}) - g:SetAxisDrawing(true,true) - g:SetAxisColor({1.0,1.0,1.0,1.0}) + local Graph = LibStub(major) + local g = Graph:CreateGraphLine("TestLineGraph", UIParent, "CENTER", "CENTER", 90, 90, 150, 150) + g:SetXAxis(-1, 1) + g:SetYAxis(-1, 1) + g:SetGridSpacing(0.25, 0.25) + g:SetGridColor({0.5, 0.5, 0.5, 0.5}) + g:SetAxisDrawing(true, true) + g:SetAxisColor({1.0, 1.0, 1.0, 1.0}) g:SetAutoScale(true) - local Data1={{0.05,0.05},{0.2,0.3},{0.4,0.2},{0.9,0.6}} - local Data2={{0.05,0.8},{0.3,0.1},{0.5,0.4},{0.95,0.05}} + local Data1 = {{0.05, 0.05}, {0.2, 0.3}, {0.4, 0.2}, {0.9, 0.6}} + local Data2 = {{0.05, 0.8}, {0.3, 0.1}, {0.5, 0.4}, {0.95, 0.05}} - g:AddDataSeries(Data1,{1.0,0.0,0.0,0.8}) - g:AddDataSeries(Data2,{0.0,1.0,0.0,0.8}) + g:AddDataSeries(Data1,{1.0, 0.0, 0.0, 0.8}) + g:AddDataSeries(Data2,{0.0, 1.0, 0.0, 0.8}) DEFAULT_CHAT_FRAME:AddMessage("Testing Line Graph") end local function TestScatterPlot() - local Graph=LibStub(major) - local g=Graph:CreateGraphScatterPlot("TestScatterPlot",UIParent,"CENTER","CENTER",90,-90,150,150) - g:SetXAxis(-1,1) - g:SetYAxis(-1,1) - g:SetGridSpacing(0.25,0.25) - g:SetGridColor({0.5,0.5,0.5,0.5}) - g:SetAxisDrawing(true,true) - g:SetAxisColor({1.0,1.0,1.0,1.0}) + local Graph = LibStub(major) + local g = Graph:CreateGraphScatterPlot("TestScatterPlot", UIParent, "CENTER", "CENTER", 90, -90, 150, 150) + g:SetXAxis(-1, 1) + g:SetYAxis(-1, 1) + g:SetGridSpacing(0.25, 0.25) + g:SetGridColor({0.5, 0.5, 0.5, 0.5}) + g:SetAxisDrawing(true, true) + g:SetAxisColor({1.0, 1.0, 1.0, 1.0}) g:SetLinearFit(true) g:SetAutoScale(true) - local Data1={{0.05,0.05},{0.2,0.3},{0.4,0.2},{0.9,0.6}} - local Data2={{0.05,0.8},{0.3,0.1},{0.5,0.4},{0.95,0.05}} + local Data1 = {{0.05, 0.05}, {0.2, 0.3}, {0.4, 0.2}, {0.9, 0.6}} + local Data2 = {{0.05, 0.8}, {0.3, 0.1}, {0.5, 0.4}, {0.95, 0.05}} - g:AddDataSeries(Data1,{1.0,0.0,0.0,0.8}) - g:AddDataSeries(Data2,{0.0,1.0,0.0,0.8}) + g:AddDataSeries(Data1,{1.0, 0.0, 0.0, 0.8}) + g:AddDataSeries(Data2,{0.0, 1.0, 0.0, 0.8}) DEFAULT_CHAT_FRAME:AddMessage("Testing Scatter Plot") end local function TestPieChart() - local Graph=LibStub(major) - local g=Graph:CreateGraphPieChart("TestPieChart",UIParent,"CENTER","CENTER",-90,-90,150,150) - g:AddPie(35,{1.0,0.0,0.0}) - g:AddPie(21,{0.0,1.0,0.0}) - g:AddPie(10,{1.0,1.0,1.0}) - g:CompletePie({0.2,0.2,1.0}) + local Graph = LibStub(major) + local g = Graph:CreateGraphPieChart("TestPieChart", UIParent, "CENTER", "CENTER", -90, -90, 150, 150) + g:AddPie(35, {1.0, 0.0, 0.0}) + g:AddPie(21, {0.0, 1.0, 0.0}) + g:AddPie(10, {1.0, 1.0, 1.0}) + g:CompletePie({0.2, 0.2, 1.0}) DEFAULT_CHAT_FRAME:AddMessage("Testing Pie Chart") end diff --git a/boot.lua b/boot.lua index 6fbcf8ad..72e08b8d 100644 --- a/boot.lua +++ b/boot.lua @@ -3,8 +3,8 @@ _ = nil _detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0") - _detalhes.build_counter = 70 --it's 76 for release - _detalhes.userversion = "v1.26.1" + _detalhes.build_counter = 79 --it's 79 for release + _detalhes.userversion = "v1.26.3" _detalhes.realversion = 28 _detalhes.version = _detalhes.userversion .. " (core " .. _detalhes.realversion .. ")" @@ -25,9 +25,11 @@ do |cFFFFFF00-|r Fixed the class color on texts for healing attribute.\n\n |cFFFFFF00-|r Added options for change the tooltip border's size, color and texture.\n\n |cFFFFFF00-|r Added buttons for test interrupt and cooldown announcers under raid tools section.\n\n + + --]] - Loc ["STRING_VERSION_LOG"] = "|cFFFFFF00v1.26.1 (|cFFFFCC00Set 12, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added tutorial and a config panel for bookmarks.\n\n|cFFFFFF00-|r Added option for choose the format type of data broker's text.\n\n|cFFFFFF00-|r Changed few icons on damage done tooltip.\n\n|cFFFFFF00-|r Fixed the class color on texts for healing attribute.\n\n|cFFFFFF00-|r Added options for change the tooltip border's size, color and texture.\n\n|cFFFFFF00-|r Added buttons for test interrupt and cooldown announcers under raid tools section.\n\n|cFFFFFF00v1.25.1 (|cFFFFCC00Set 09, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added buttons to edit the total and percentage code for custom displays.\n\n|cFFFFFF00-|r Fixed a problem while report custom displays.\n\n|cFFFFFF00-|r Added Acitivity Time for Damage + Healing, tooltip show the activity separately.\n\n|cFFFFFF00-|r Major changes on Encounter Details Plugin making more easy to use.\n\n|cFFFFFF00-|r Removed Spell Details Plugin.\n\n|cFFFFFF00-|r Added new plugin for Solo Mode: Dps Tuning.\n\n|cFFFFFF00v1.24.5 (|cFFFFCC00Ago 31, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added Raid Tools bracket on Options Panel.\n\n|cFFFFFF00-|r Added interrupt, cooldown and death announcers (raid tools).\n\n|cFFFFFF00-|r Added pre potion recognition, showing after the encounter on the chat only for you (raid tools).\n\n|cFFFFFF00-|r Added a Boss Emotes tab for Encounter Details plugin |cFF999999(thanks Bloodforce-Azralon)|r.\n\n|cFFFFFF00-|r Rework on Activity Time, now it is tuned to closely match warcraftlogs |cFF999999(thanks www.warcraftlogs.com)|r.\n\n|cFFFFFF00-|r Added two new customs: Damage Activity Time and Healing Activity Time.\n\n|cFFFFFF00-|r Time Attack Plugin now have six fixed time amount options for test your dps on training dummies.\n\n|cFFFFFF00-|r Time Attack Plugin can now also share results on your realm, between players with the same class.\n\n|cFFFFFF00v1.23.6 (|cFFFFCC00Ago 24, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added 2 new bar textures and 6 new fonts.\n\n|cFFFFFF00-|r Swapped left and middle button for enemy bars, now left button open damage taken and middle button player detail window.\n\n|cFFFFFF00-|r Added new skin: Minimalistic v2.\n\n|cFFFFFF00-|r Minimalistic v2 is now the default skin.\n\n|cFFFFFF00-|r Few changes on both icon packs with transparency.\n\n|cFFFFFF00-|r Replaced the slash command '/d' with '/de' |cFF999999(thanks @kamuul-mmochampion forum)|r.\n\n|cFFFFFF00-|r Added custom spells for Atonement, Power Word: Solance and Life Bloom |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00v1.22.4 (|cFFFFCC00Ago 15, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added new skin: ElvUI Frame Style (Black White).\n\n|cFFFFFF00-|r Align With Right Chat Window option now check if the window have statusbar enabled.\n\n|cFFFFFF00-|r Few improvements on report for Deaths and Spells over Player Detail Window.\n\n|cFFFFFF00-|r Added option to disable reset button (reset only using its tooltip menu).\n\n|cFFFFFF00-|r Added option for disable window groups.\n\n|cFFFFFF00-|r Added option for select the icon pack to use, also added black white icon pack.\n\n|cFFFFFF00-|r Fixed many bugs involving skins and profiles, thing should run more smooth now.\n\n|cFFFFFF00-|r Plugin Time Attack now correctly saves the attempt when pressing the big save button.\n\n|cFFFFFF00-|r Added support for hotcorners.\n\n|cFFFFFF00v1.21.4 (|cFFFFCC00Ago 9, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added Shaman's Ancestral Guidance on cooldowns list |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Added a profile selection screen when Details! are running for the first time on a character.\n\n|cFFFFFF00-|r Added Menu Text Size option over miscellaneous section on options panel |cFF999999(thanks @ Revi-mmochampion forum)|r.\n\n|cFFFFFF00-|r Fixed a bug over Healing Player Details Window where pets wasn't being shown |cFF999999(thanks @Mystery2012-mmochampion forum)|r.\n\n|cFFFFFF00-|r Fixed issue with summoning pets with unknown owners where it was breaking the summon of all the others pets. |cFF999999(thanks @ThunderLost-curse website)|r.\n\n|cFFFFFF00-|r Hot Corners isn't no more a part of Details!, instead of that, Hot Corner is now a standalone addon which needs to be installed separately for who wants to use it.\n\n|cFFFFFF00-|r Skin data is now stored inside the profiles, many code parts got rewrite, still may have few bugs but it's more reliable then before.\n\n|cFFFFFF00-|r Rework on Auras and Voidzones: now shows damage, dps and percentage. Also its tooltip got fixes and now shows the correct damage done to players.\n\n|cFFFFFF00-|r Tooltip for Enemies now shows damage taken from players |cFF999999(thanks @Arieth-mmochampion forum)|r.\n\n|cFFFFFF00-|r Right clicking a real-time enemy bar, makes it back to Enemies display instead of show Bookmark panel |cFF999999(thanks @Arieth-mmochampion forum)|r.\n\n|cFFFFFF00-|r Tank comparison from previous segment now uses the same percentage method from player comparison panel.\n\n|cFFFFFF00-|r Fix bug with the slash command 'show' where was ignoring the window limit set on options panel |cFF999999(thanks @Castiel-US-Azralon realm)|r.\n\n|cFFFFFF00-|r Fixed few bugs with scroll bars, including scrolls on dropdown menu and player detail window |cFF999999(thanks @Revi-mmochampion forum)|r.\n\n|cFFFFFF00v1.20.2 (|cFFFFCC00Aug 1, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added a option under Miscellaneous section to provide spell link instead of spell name for helpful spells when reporting a death |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Improvements done on how deaths are handled, now latest events before death will be more precise.\n\n|cFFFFFF00-|r Implemented Damage Taken from environment like lava, gravity, etc.\n\n|cFFFFFF00-|r Added Warlock's Fire and Brimstone spell on customized spells.\n\n|cFFFFFF00-|r Added dwarf racial Stone Form on cooldown list |cFF999999(thanks @Mystery2012-mmochampion forum)|r.\n\n|cFFFFFF00-|r Bookmark now are shared between all characters.\n\n|cFFFFFF00-|r Fixed few inconsistencies with trash recognition.\n\n|cFFFFFF00-|r Fixed Cloud Capture where sometimes it wasn't sharing.\n\n|cFFFFFF00-|r Fixed report where it wasn't sharing for guild and raid when the player name box were empty.\n\n|cFFFFFF00-|r Report box now also saves the position and the last channel used to report |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r You Are Not Prepared plugin now have tooltips for spells and its window auto opens after a boss encounter.\n\n|cFFFFFF00-|r Advanced Death Logs plugin got full rewrite (and still are in development).\n\n|cFFFFFF00v1.19.0 - v1.19.1 - v1.19.2 (|cFFFFCC00Jul 21, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Details! is now able to be translated by its community for all supported languages through Curse Forge Web Site:\n\n|cFFFFFF00http://wow.curseforge.com/addons/details/localization/|r\n\n|cFFFFFF00-|r Slash commands now are multi language, accepting both english and the localized language.\n\n|cFFFFFF00-|r Added Data Broker for: Combat Time, Player Dps and Player Hps.\n\n|cFFFFFF00-|r Rework on plugins: Timeline, You Are Not Prepared, Tiny Threat, Encounter Details. All those plugins got a options panel and few improvaments.\n\n|cFFFFFF00-|r Trash segments won't be saved anymore.\n\n|cFFFFFF00-|r Added support for plugins options.\n\n|cFFFFFF00-|r Revamp on Deaths report lines, adding links for harmful spells and changing the text order |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Modified the percentage used on Comparison panel |cFF999999(thanks @Mystery2012-mmochampion forum)|r.\n\n|cFFFFFF00-|r Fixed the Raid Dps and Hps data exported by Data Broker |cFF999999(thanks @Arieth-mmochampion forum)|r.\n\n|cFFFFFF00v1.18.4 - v1.18.5 - v1.18.6 (|cFFFFCC00Jul 13, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added option to customize the bar left text.\n\n|cFFFFFF00-|r Added option for show or hide bar placement number.\n\n|cFFFFFF00-|r Spell icon is shown in the bar when the enemy character is a environment spell type.\n\n|cFFFFFF00-|r Changed the non-player enemy icon (monsters).\n\n|cFFFFFF00-|r Fixed bug on flex performance profile |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Added new version tracker which should alert you when a newer Details! version is found.\n\n|cFFFFFF00-|r Added Enemy Damage Taken by clicking with middle mouse button over a enemy bar (enemies display).\n\n|cFFFFFF00-|r Added import/export for saved skins and custom displays created.\n\n|cFFFFFF00-|r Small changes on ElvUI Frame Style skin (need reaply).\n\n|cFFFFFF00-|r Fixed the death recognition for bosses, now it should show the correct color over segments menu.\n\n|cFFFFFF00-|r Fixed Dps inacuracy when plyaing solo (no party or raid group).\n\n|cFFFFFF00-|r Fixed the duration time of buffs applied before the pull, like pre-potions.\n\n|cFFFFFF00v1.17.5 (|cFFFFCC00Jun 30, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Shortcut panel is now known as Bookmarks and a revamp has done on its panel.\n\n|cFFFFFF00-|r NickTag now doesnt check anymore if a received nickname from other guild member is invalid.\n\n|cFFFFFF00-|r Healthstone now is considered a cooldown.\n\n|cFFFFFF00-|r Few improvements on Default Skin, Minimalistic Skin and ElvUI Frame Style Skin.\n\n|cFFFFFF00-|r Revamp on Image Editor, many bugs solves and now it is usable." + Loc ["STRING_VERSION_LOG"] = "|cFFFFFF00v1.26.3 (|cFFFFCC00Set 18, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Changed the way to set the broker text to be more customizable.\n\n|cFFFFFF00-|r Fixed the problem with custom display report.\n\n|cFFFFFF00-|r Added tutorial and a config panel for bookmarks.\n\n|cFFFFFF00-|r Added option for choose the format type of data broker's text.\n\n|cFFFFFF00-|r Changed few icons on damage done tooltip.\n\n|cFFFFFF00-|r Fixed the class color on texts for healing attribute.\n\n|cFFFFFF00-|r Added options for change the tooltip border's size, color and texture.\n\n|cFFFFFF00-|r Added buttons for test interrupt and cooldown announcers under raid tools section.\n\n|cFFFFFF00v1.25.1 (|cFFFFCC00Set 09, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added buttons to edit the total and percentage code for custom displays.\n\n|cFFFFFF00-|r Fixed a problem while report custom displays.\n\n|cFFFFFF00-|r Added Acitivity Time for Damage + Healing, tooltip show the activity separately.\n\n|cFFFFFF00-|r Major changes on Encounter Details Plugin making more easy to use.\n\n|cFFFFFF00-|r Removed Spell Details Plugin.\n\n|cFFFFFF00-|r Added new plugin for Solo Mode: Dps Tuning.\n\n|cFFFFFF00v1.24.5 (|cFFFFCC00Ago 31, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added Raid Tools bracket on Options Panel.\n\n|cFFFFFF00-|r Added interrupt, cooldown and death announcers (raid tools).\n\n|cFFFFFF00-|r Added pre potion recognition, showing after the encounter on the chat only for you (raid tools).\n\n|cFFFFFF00-|r Added a Boss Emotes tab for Encounter Details plugin |cFF999999(thanks Bloodforce-Azralon)|r.\n\n|cFFFFFF00-|r Rework on Activity Time, now it is tuned to closely match warcraftlogs |cFF999999(thanks www.warcraftlogs.com)|r.\n\n|cFFFFFF00-|r Added two new customs: Damage Activity Time and Healing Activity Time.\n\n|cFFFFFF00-|r Time Attack Plugin now have six fixed time amount options for test your dps on training dummies.\n\n|cFFFFFF00-|r Time Attack Plugin can now also share results on your realm, between players with the same class.\n\n|cFFFFFF00v1.23.6 (|cFFFFCC00Ago 24, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added 2 new bar textures and 6 new fonts.\n\n|cFFFFFF00-|r Swapped left and middle button for enemy bars, now left button open damage taken and middle button player detail window.\n\n|cFFFFFF00-|r Added new skin: Minimalistic v2.\n\n|cFFFFFF00-|r Minimalistic v2 is now the default skin.\n\n|cFFFFFF00-|r Few changes on both icon packs with transparency.\n\n|cFFFFFF00-|r Replaced the slash command '/d' with '/de' |cFF999999(thanks @kamuul-mmochampion forum)|r.\n\n|cFFFFFF00-|r Added custom spells for Atonement, Power Word: Solance and Life Bloom |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00v1.22.4 (|cFFFFCC00Ago 15, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added new skin: ElvUI Frame Style (Black White).\n\n|cFFFFFF00-|r Align With Right Chat Window option now check if the window have statusbar enabled.\n\n|cFFFFFF00-|r Few improvements on report for Deaths and Spells over Player Detail Window.\n\n|cFFFFFF00-|r Added option to disable reset button (reset only using its tooltip menu).\n\n|cFFFFFF00-|r Added option for disable window groups.\n\n|cFFFFFF00-|r Added option for select the icon pack to use, also added black white icon pack.\n\n|cFFFFFF00-|r Fixed many bugs involving skins and profiles, thing should run more smooth now.\n\n|cFFFFFF00-|r Plugin Time Attack now correctly saves the attempt when pressing the big save button.\n\n|cFFFFFF00-|r Added support for hotcorners.\n\n|cFFFFFF00v1.21.4 (|cFFFFCC00Ago 9, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added Shaman's Ancestral Guidance on cooldowns list |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Added a profile selection screen when Details! are running for the first time on a character.\n\n|cFFFFFF00-|r Added Menu Text Size option over miscellaneous section on options panel |cFF999999(thanks @ Revi-mmochampion forum)|r.\n\n|cFFFFFF00-|r Fixed a bug over Healing Player Details Window where pets wasn't being shown |cFF999999(thanks @Mystery2012-mmochampion forum)|r.\n\n|cFFFFFF00-|r Fixed issue with summoning pets with unknown owners where it was breaking the summon of all the others pets. |cFF999999(thanks @ThunderLost-curse website)|r.\n\n|cFFFFFF00-|r Hot Corners isn't no more a part of Details!, instead of that, Hot Corner is now a standalone addon which needs to be installed separately for who wants to use it.\n\n|cFFFFFF00-|r Skin data is now stored inside the profiles, many code parts got rewrite, still may have few bugs but it's more reliable then before.\n\n|cFFFFFF00-|r Rework on Auras and Voidzones: now shows damage, dps and percentage. Also its tooltip got fixes and now shows the correct damage done to players.\n\n|cFFFFFF00-|r Tooltip for Enemies now shows damage taken from players |cFF999999(thanks @Arieth-mmochampion forum)|r.\n\n|cFFFFFF00-|r Right clicking a real-time enemy bar, makes it back to Enemies display instead of show Bookmark panel |cFF999999(thanks @Arieth-mmochampion forum)|r.\n\n|cFFFFFF00-|r Tank comparison from previous segment now uses the same percentage method from player comparison panel.\n\n|cFFFFFF00-|r Fix bug with the slash command 'show' where was ignoring the window limit set on options panel |cFF999999(thanks @Castiel-US-Azralon realm)|r.\n\n|cFFFFFF00-|r Fixed few bugs with scroll bars, including scrolls on dropdown menu and player detail window |cFF999999(thanks @Revi-mmochampion forum)|r.\n\n|cFFFFFF00v1.20.2 (|cFFFFCC00Aug 1, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Added a option under Miscellaneous section to provide spell link instead of spell name for helpful spells when reporting a death |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Improvements done on how deaths are handled, now latest events before death will be more precise.\n\n|cFFFFFF00-|r Implemented Damage Taken from environment like lava, gravity, etc.\n\n|cFFFFFF00-|r Added Warlock's Fire and Brimstone spell on customized spells.\n\n|cFFFFFF00-|r Added dwarf racial Stone Form on cooldown list |cFF999999(thanks @Mystery2012-mmochampion forum)|r.\n\n|cFFFFFF00-|r Bookmark now are shared between all characters.\n\n|cFFFFFF00-|r Fixed few inconsistencies with trash recognition.\n\n|cFFFFFF00-|r Fixed Cloud Capture where sometimes it wasn't sharing.\n\n|cFFFFFF00-|r Fixed report where it wasn't sharing for guild and raid when the player name box were empty.\n\n|cFFFFFF00-|r Report box now also saves the position and the last channel used to report |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r You Are Not Prepared plugin now have tooltips for spells and its window auto opens after a boss encounter.\n\n|cFFFFFF00-|r Advanced Death Logs plugin got full rewrite (and still are in development).\n\n|cFFFFFF00v1.19.0 - v1.19.1 - v1.19.2 (|cFFFFCC00Jul 21, 2014|r|cFFFFFF00)|r:\n\n|cFFFFFF00-|r Details! is now able to be translated by its community for all supported languages through Curse Forge Web Site:\n\n|cFFFFFF00http://wow.curseforge.com/addons/details/localization/|r\n\n|cFFFFFF00-|r Slash commands now are multi language, accepting both english and the localized language.\n\n|cFFFFFF00-|r Added Data Broker for: Combat Time, Player Dps and Player Hps.\n\n|cFFFFFF00-|r Rework on plugins: Timeline, You Are Not Prepared, Tiny Threat, Encounter Details. All those plugins got a options panel and few improvaments.\n\n|cFFFFFF00-|r Trash segments won't be saved anymore.\n\n|cFFFFFF00-|r Added support for plugins options.\n\n|cFFFFFF00-|r Revamp on Deaths report lines, adding links for harmful spells and changing the text order |cFF999999(thanks @skmzarn-mmochampion forum)|r.\n\n|cFFFFFF00-|r Modified the percentage used on Comparison panel |cFF999999(thanks @Mystery2012-mmochampion forum)|r.\n\n|cFFFFFF00-|r Fixed the Raid Dps and Hps data exported by Data Broker |cFF999999(thanks @Arieth-mmochampion forum)|r." Loc ["STRING_DETAILS1"] = "|cffffaeaeDetails!:|r " --> startup diff --git a/classes/classe_custom.lua b/classes/classe_custom.lua index 18202e5b..3865f78b 100644 --- a/classes/classe_custom.lua +++ b/classes/classe_custom.lua @@ -179,25 +179,25 @@ local total_script = _detalhes.custom_function_cache [instance.customName .. "Total"] for index, actor in _ipairs (instance_container._ActorTable) do - local percent, total + local percent, ptotal if (percent_script) then - percent = percent_script (actor.value, top, total, combat, instance) + percent = percent_script (_math_floor (actor.value), top, total, combat, instance) else - percent = _cstr ("%.1f", self.value / total * 100) + percent = _cstr ("%.1f", _math_floor (actor.value) / total * 100) end if (total_script) then - local value = total_script (actor.value, top, total, combat, instance) + local value = total_script (_math_floor (actor.value), top, total, combat, instance) if (type (value) == "number") then - total = SelectedToKFunction (_, value) + ptotal = SelectedToKFunction (_, value) else - total = value + ptotal = value end else - total = SelectedToKFunction (_, self.value) + ptotal = SelectedToKFunction (_, _math_floor (actor.value)) end - actor.report_value = total .. " (" .. percent .. "%)" + actor.report_value = ptotal .. " (" .. percent .. "%)" end end diff --git a/classes/classe_instancia.lua b/classes/classe_instancia.lua index 5cadd4a7..f7b93e98 100644 --- a/classes/classe_instancia.lua +++ b/classes/classe_instancia.lua @@ -231,6 +231,16 @@ function _detalhes:GetFreeInstancesAmount() return _detalhes.instances_amount - #_detalhes.tabela_instancias end +function _detalhes:GetOpenedWindowsAmount() + local amount = 0 + for _, instance in _detalhes:ListInstances() do + if (instance:IsEnabled()) then + amount = amount + 1 + end + end + return amount +end + function _detalhes:GetNumRows() return self.rows_fit_in_window end diff --git a/core/windows.lua b/core/windows.lua index 982fce80..1f2ba9f7 100644 --- a/core/windows.lua +++ b/core/windows.lua @@ -1246,6 +1246,220 @@ _detalhes:CriarInstancia (_, true) end) + function _detalhes:OpenBrokerTextEditor() + + if (not DetailsWindowOptionsBrokerTextEditor) then + + local panel = _detalhes.gump:NewPanel (UIParent, nil, "DetailsWindowOptionsBrokerTextEditor", nil, 650, 200) + panel:SetPoint ("center", UIParent, "center") + panel:Hide() + panel:SetFrameStrata ("FULLSCREEN") + panel:SetBackdrop ({ bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 64, insets = {left=3, right=3, top=3, bottom=3}}) + panel:DisableGradient() + panel:SetBackdropColor (0, 0, 0, 0) + panel.locked = false + + local bg_texture = _detalhes.gump:NewImage (panel, [[Interface\AddOns\Details\images\welcome]], 1, 1, "background") + bg_texture:SetPoint ("topleft", panel, "topleft") + bg_texture:SetPoint ("bottomright", panel, "bottomright") + + local textentry = _detalhes.gump:NewSpecialLuaEditorEntry (panel.widget, 450, 180, "editbox", "$parentEntry", true) + textentry:SetPoint ("topleft", panel.widget, "topleft", 10, -10) + + textentry.editbox:SetScript ("OnTextChanged", function() + local text = panel.widget.editbox:GetText() + _detalhes.data_broker_text = text + _detalhes:BrokerTick() + if (_G.DetailsOptionsWindow) then + _G.DetailsOptionsWindow19BrokerEntry.MyObject:SetText (_detalhes.data_broker_text) + end + end) + + local option_selected = 1 + local onclick= function (_, _, value) + option_selected = value + end + local AddOptions = { + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD1"], value = 1, onclick = onclick}, + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD2"], value = 2, onclick = onclick}, + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD3"], value = 3, onclick = onclick}, + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD4"], value = 4, onclick = onclick}, + + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD5"], value = 5, onclick = onclick}, + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD6"], value = 6, onclick = onclick}, + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD7"], value = 7, onclick = onclick}, + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD8"], value = 8, onclick = onclick}, + + {label = Loc ["STRING_OPTIONS_DATABROKER_TEXT_ADD9"], value = 9, onclick = onclick}, + } + local buildAddMenu = function() + return AddOptions + end + + local d = _detalhes.gump:NewDropDown (panel, _, "$parentTextOptionsDropdown", "TextOptionsDropdown", 150, 20, buildAddMenu, 1) + d:SetPoint ("topright", panel, "topright", -10, -14) + --d:SetFrameStrata ("TOOLTIP") + + local optiontable = {"{dmg}", "{dps}", "{dpos}", "{ddiff}", "{heal}", "{hps}", "{hpos}", "{hdiff}", "{time}"} + + local add_button = _detalhes.gump:NewButton (panel, nil, "$parentAddButton", nil, 20, 20, function() + textentry.editbox:Insert (optiontable [option_selected]) + end, + nil, nil, nil, "<-") + add_button:SetPoint ("right", d, "left", -2, 0) + add_button:InstallCustomTexture() + + + -- code author Saiket from http://www.wowinterface.com/forums/showpost.php?p=245759&postcount=6 + --- @return StartPos, EndPos of highlight in this editbox. + local function GetTextHighlight ( self ) + local Text, Cursor = self:GetText(), self:GetCursorPosition(); + self:Insert( "" ); -- Delete selected text + local TextNew, CursorNew = self:GetText(), self:GetCursorPosition(); + -- Restore previous text + self:SetText( Text ); + self:SetCursorPosition( Cursor ); + local Start, End = CursorNew, #Text - ( #TextNew - CursorNew ); + self:HighlightText( Start, End ); + return Start, End; + end + + local StripColors; + do + local CursorPosition, CursorDelta; + --- Callback for gsub to remove unescaped codes. + local function StripCodeGsub ( Escapes, Code, End ) + if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code + if ( CursorPosition and CursorPosition >= End - 1 ) then + CursorDelta = CursorDelta - #Code; + end + return Escapes; + end + end + --- Removes a single escape sequence. + local function StripCode ( Pattern, Text, OldCursor ) + CursorPosition, CursorDelta = OldCursor, 0; + return Text:gsub( Pattern, StripCodeGsub ), OldCursor and CursorPosition + CursorDelta; + end + --- Strips Text of all color escape sequences. + -- @param Cursor Optional cursor position to keep track of. + -- @return Stripped text, and the updated cursor position if Cursor was given. + function StripColors ( Text, Cursor ) + Text, Cursor = StripCode( "(|*)(|c%x%x%x%x%x%x%x%x)()", Text, Cursor ); + return StripCode( "(|*)(|r)()", Text, Cursor ); + end + end + + local COLOR_END = "|r"; + --- Wraps this editbox's selected text with the given color. + local function ColorSelection ( self, ColorCode ) + local Start, End = GetTextHighlight( self ); + local Text, Cursor = self:GetText(), self:GetCursorPosition(); + if ( Start == End ) then -- Nothing selected + --Start, End = Cursor, Cursor; -- Wrap around cursor + return; -- Wrapping the cursor in a color code and hitting backspace crashes the client! + end + -- Find active color code at the end of the selection + local ActiveColor; + if ( End < #Text ) then -- There is text to color after the selection + local ActiveEnd; + local CodeEnd, _, Escapes, Color = 0; + while ( true ) do + _, CodeEnd, Escapes, Color = Text:find( "(|*)(|c%x%x%x%x%x%x%x%x)", CodeEnd + 1 ); + if ( not CodeEnd or CodeEnd > End ) then + break; + end + if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code + ActiveColor, ActiveEnd = Color, CodeEnd; + end + end + + if ( ActiveColor ) then + -- Check if color gets terminated before selection ends + CodeEnd = 0; + while ( true ) do + _, CodeEnd, Escapes = Text:find( "(|*)|r", CodeEnd + 1 ); + if ( not CodeEnd or CodeEnd > End ) then + break; + end + if ( CodeEnd > ActiveEnd and #Escapes % 2 == 0 ) then -- Terminates ActiveColor + ActiveColor = nil; + break; + end + end + end + end + + local Selection = Text:sub( Start + 1, End ); + -- Remove color codes from the selection + local Replacement, CursorReplacement = StripColors( Selection, Cursor - Start ); + + self:SetText( ( "" ):join( + Text:sub( 1, Start ), + ColorCode, Replacement, COLOR_END, + ActiveColor or "", Text:sub( End + 1 ) + ) ); + + -- Restore cursor and highlight, adjusting for wrapper text + Cursor = Start + CursorReplacement; + if ( CursorReplacement > 0 ) then -- Cursor beyond start of color code + Cursor = Cursor + #ColorCode; + end + if ( CursorReplacement >= #Replacement ) then -- Cursor beyond end of color + Cursor = Cursor + #COLOR_END; + end + + self:SetCursorPosition( Cursor ); + -- Highlight selection and wrapper + self:HighlightText( Start, #ColorCode + ( #Replacement - #Selection ) + #COLOR_END + End ); + end + + local color_func = function (_, r, g, b, a) + local hex = _detalhes:hex (a*255).._detalhes:hex (r*255).._detalhes:hex (g*255).._detalhes:hex (b*255) + ColorSelection ( textentry.editbox, "|c" .. hex) + end + + local color_button = _detalhes.gump:NewColorPickButton (panel, "$parentButton5", nil, color_func) + color_button:SetSize (80, 20) + color_button:SetPoint ("topright", panel, "topright", -10, -102) + color_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_COLOR_TOOLTIP"] + + local done = function() + local text = panel.widget.editbox:GetText() + _detalhes.data_broker_text = text + if (_G.DetailsOptionsWindow) then + _G.DetailsOptionsWindow19BrokerEntry.MyObject:SetText (_detalhes.data_broker_text) + end + _detalhes:BrokerTick() + panel:Hide() + end + + local ok_button = _detalhes.gump:NewButton (panel, nil, "$parentButtonOk", nil, 80, 20, done, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_DONE"], 1) + ok_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DONE_TOOLTIP"] + ok_button:InstallCustomTexture() + ok_button:SetPoint ("topright", panel, "topright", -10, -174) + + local reset_button = _detalhes.gump:NewButton (panel, nil, "$parentDefaultOk", nil, 80, 20, function() textentry.editbox:SetText ("") end, nil, nil, nil, "Reset", 1) + reset_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_RESET_TOOLTIP"] + reset_button:InstallCustomTexture() + reset_button:SetPoint ("topright", panel, "topright", -100, -152) + + local cancel_button = _detalhes.gump:NewButton (panel, nil, "$parentDefaultCancel", nil, 80, 20, function() textentry.editbox:SetText (panel.default_text); done(); end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL"], 1) + cancel_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL_TOOLTIP"] + cancel_button:InstallCustomTexture() + cancel_button:SetPoint ("topright", panel, "topright", -100, -174) + + end + + local panel = DetailsWindowOptionsBrokerTextEditor.MyObject + + local text = _detalhes.data_broker_text:gsub ("||", "|") + panel.default_text = text + panel.widget.editbox:SetText (text) + + panel:Show() + end + --> row text editor local panel = _detalhes.gump:NewPanel (UIParent, nil, "DetailsWindowOptionsBarTextEditor", nil, 650, 200) panel:SetPoint ("center", UIParent, "center") @@ -1658,9 +1872,15 @@ elseif (_detalhes.minimap.onclick_what_todo == 2) then _detalhes.tabela_historico:resetar() - --> 3 = unknown + --> 3 = show hide windows elseif (_detalhes.minimap.onclick_what_todo == 3) then - + local opened = _detalhes:GetOpenedWindowsAmount() + + if (opened == 0) then + _detalhes:ReabrirTodasInstancias() + else + _detalhes:ShutDownAllInstances() + end end elseif (button == "RightButton") then @@ -1727,6 +1947,8 @@ tooltip:AddLine (Loc ["STRING_MINIMAP_TOOLTIP1"]) elseif (_detalhes.minimap.onclick_what_todo == 2) then tooltip:AddLine (Loc ["STRING_MINIMAP_TOOLTIP11"]) + elseif (_detalhes.minimap.onclick_what_todo == 3) then + tooltip:AddLine (Loc ["STRING_MINIMAP_TOOLTIP12"]) end tooltip:AddLine (Loc ["STRING_MINIMAP_TOOLTIP2"]) end, diff --git a/framework/dropdown.xml b/framework/dropdown.xml index c1f28ade..540dfd7f 100644 --- a/framework/dropdown.xml +++ b/framework/dropdown.xml @@ -72,7 +72,7 @@ - + @@ -102,14 +102,14 @@ -