-
Posted by deltoide on Mon, 17 Oct 2011 08:08:51
WoWProgramming Hello friends, I would like (if possible) that someone gave me a brief explanation on this one addon.
It is intended to display as the amount of numerical combopoints (with rogue / druid) that the target has, but in certain part of the addon, I believe that has been added commands without much purpose for operating the same.
The addon is the code:
local _,Combo=... local Frame=CreateFrame("Frame","Combo",UIParent) function VisualCombo:Initialize() Frame:SetWidth(50) Frame:SetHeight(50) Frame:SetPoint("CENTER",UIParent,"CENTER",1,-185) Frame:SetFrameStrata("HIGH") local Text=Frame:CreateFontString("$Parent-Text","OVERLAY") Text:SetPoint("CENTER",Frame,"CENTER",0,0) Text:SetFont("Interface\\AddOns\\Combo\\COMBOFONT.TTF",30,"THICKOUTLINE") Text:SetShadowColor(0.00,0.00,0.00,0.75) Text:SetShadowOffset(3.00,-3.00) Text:SetJustifyH("CENTER") ????????? Text:SetVertexColor(1.00,1.00,1.00,1.00) ????????? Frame.AnimFrame=CreateFrame("Frame","$ParentAnimFrame",UIParent) ????????? Frame.AnimFrame:SetWidth(50) ????????? Frame.AnimFrame:SetHeight(45) ????????? Frame.AnimFrame:SetPoint("CENTER",Frame,"CENTER",0,3) ????????? Frame:SetFrameLevel(Frame:GetFrameLevel()-1) ????????? Frame.Pulse=Frame.AnimFrame:CreateAnimationGroup("$Parent-Pulse") ????????? local PulseAnim=Frame.Pulse:CreateAnimation("SCALE") ????????? PulseAnim:SetScale(0.5,1) ????????? PulseAnim:SetDuration(0.5) ????????? PulseAnim:SetSmoothing("OUT") ????????? Frame.Pulse:SetLooping("BOUNCE") ????????? Frame.FadeIn=Frame.AnimFrame:CreateAnimationGroup("$Parent-FadeIn") ????????? local FadeInAnim=Frame.FadeIn:CreateAnimation("ALPHA") ????????? FadeInAnim:SetChange(1) ????????? FadeInAnim:SetDuration(0.5) ????????? FadeInAnim:SetSmoothing("IN") ????????? Frame.FadeIn:SetScript("OnPlay",function(self) ????????? Frame.AnimFrame:SetAlpha(0) ????????? end) ????????? Frame.FadeIn:SetScript("OnFinished",function(self) ????????? Frame.AnimFrame:SetAlpha(1) ????????? Frame.Pulse:Play() ????????? end) ????????? Frame.FadeOut=Frame.AnimFrame:CreateAnimationGroup("$Parent-FadeOut") ????????? local FadeOutAnim=Frame.FadeOut:CreateAnimation("ALPHA") ????????? FadeOutAnim:SetChange(-1) ????????? FadeOutAnim:SetDuration(0.5) ????????? FadeOutAnim:SetSmoothing("OUT") ????????? Frame.FadeOut:SetScript("OnPlay",function(self) ????????? Frame.AnimFrame:SetAlpha(1) ????????? Frame.Pulse:Stop() ????????? end) ????????? Frame.FadeOut:SetScript("OnFinished",function(self) ????????? Frame.AnimFrame:SetAlpha(0) ????????? end) VisualCombo:Update() end function VisualCombo:Colorize(P) if(P==1)then return 0.00,1.00,0.00,1.00 end if(P==2)then return 0.40,0.70,1.00,1.00 end if(P==3)then return 1.00,1.00,0.00,1.00 end if(P==4)then return 1.00,0.50,0.20,1.00 end if(P==5)then return 1.00,0.00,0.00,1.00 end return 1.00,1.00,1.00,1.00 end function VisualCombo:Update() local Value=GetComboPoints("player") local Text=_G["VisualCombo-Text"] Text:SetText(Value>0 and Value or nil) Text:SetVertexColor(VisualCombo:Colorize(Value)) if(not Frame.LastValue)then Frame.LastValue=0 end Frame.LastValue=Value end function VisualCombo:OnEvent(Event,Arg1,...) if(Event=="PLAYER_LOGIN")then VisualCombo:Initialize() return end if(Event=="UNIT_COMBO_POINTS" and Arg1=="player" or (Event=="PLAYER_TARGET_CHANGED"))then VisualCombo:Update() return end end Frame:SetScript("OnEvent",VisualCombo.OnEvent) Frame:RegisterEvent("PLAYER_LOGIN") Frame:RegisterEvent("PLAYER_TARGET_CHANGED") Frame:RegisterEvent("UNIT_COMBO_POINTS")
Command lines that begin with "???" are those that I considered useless for the operation of the addon, that is, I can removel of the code without the general operation of the addon is affected.
Am I correct or control these lines are important?
-
Posted by jnwhiteh on Mon, 17 Oct 2011 08:31:40
All of those lines marked with ??? are solely for animating the frame. If you consider that excessive, yes, but it's obviously a major feature of the addon.
-
Posted by deltoide on Mon, 17 Oct 2011 17:13:14
I understand, but I would like to make this addon as "clean" as possible, so that it consumes a minimum of memory and continue to make your goal (display the number of combopoints that something has).
There is the possibility of removing a few lines of command without that disrupts the overall operation of the addon?
-
Posted by jnwhiteh on Mon, 17 Oct 2011 18:48:37
I don't know, but you're grasping at straws. The addon is incredibly lean already, I don't see why you want to remove anything from it. The addon is not written in a way that its consuming memory OR CPU.
-
Posted by deltoide on Tue, 18 Oct 2011 01:36:11
I understand, really good addon and light, it consumes only 6kb of memory, however I removed the command lines with marks "???" and it has worked perfectly without having problems with a consumption of 3kb. Enjoys a help to know without these command lines it can display an error and a suggestion to let it even lighter without losing its functionality.
thanks mate
-
Posted by jnwhiteh on Tue, 18 Oct 2011 08:13:35
I don't know. Unfortunately my time is limited so that going through 40 lines of code checking for semantic errors is not possible.
-
Posted by deltoide on Tue, 18 Oct 2011 14:04:53
Okay my friend, anyway many thanks for your attention, if you do not feel bad, I'll leave the code here so that you (a day that has a time) can calmly look ok? Best wishes and God is