View Single Post
12-11-14, 10:53 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Other:
De-duplication looking much better overall.
Code:
                self.Health:SetHeight(29)
Having this in the unit specific function with the frame height set in the shared function will present difficulties when making changes later, since you'll have to change one height value in one place, and another in another place, and it's very likely you'll just change it in one place and then have to waste time debugging and remembering where the other value is.

The best way to avoid this would be to use relative positioning. Instead of anchoring the health bar by the TOPLEFT and TOPRIGHT corners and giving it an explicit height, add a third anchor to the BOTTOM point with a vertical offset to leave space for the power bar -- and then anchor the TOP of the power bar to the BOTTOM of the health bar. That way the only value you have to change is the frame height, and the health bar will automatically get bigger or smaller accordingly.

========================

Several problems in here:
Code:
                local leaderassistframe = CreateFrame('Button', 'PlayerLeaderAssistFrame', self)
                        leaderassistframe:SetSize(3,8)
                        leaderassistframe:SetPoint('TOPLEFT', self, 'TOPLEFT', 2, 0)
                        leaderassistframe:RegisterEvent('GROUP_ROSTER_UPDATE')
                        leaderassistframe:RegisterEvent('PARTY_LEADER_CHANGED')
                        leaderassistframe:RegisterEvent('PLAYER_ENTERING_WORLD')
                        
                local leaderassisttexture = leaderassistframe:CreateTexture('PlayerLeaderAssistTexture', 'OVERLAY')
                        --leaderassisttexture:SetTexture('Interface\AddOns\oUF_Terenna\Status_Texture', 'OVERLAY')
                        leaderassisttexture = leaderassistframe:CreateTexture('Interface\AddOns\oUF_P3lim\F1_StatusBox_Bar', 'OVERLAY')
                        leaderassisttexture:SetTexture(1, 1, 0)
                        leaderassisttexture:SetAllPoints(true)
                        
                leaderassistframe:SetScript('OnEvent', function(self, event, unit)
                        if UnitIsGroupLeader('player') or UnitIsRaidOfficer('player') then
                                leaderassisttexture:Show()
                        else
                                leaderassisttexture:Hide()
                        end
                end)
1. These objects do not need global names. Get rid of the global names.

2. These objects don't need to exist at all. Get rid of them and use oUF's native Assistant and Leader elements; you can set them both to use the same texture if you really don't want to know the difference.

3. Those file paths are invalid; you need to either escape your backslashes by doubling them, or use [[ literal string notation ]] instead of "double quotes" around the path.

4. This appears to be a bad copypasta:
Code:
leaderassisttexture = leaderassistframe:CreateTexture('Interface\AddOns\oUF_P3lim\F1_StatusBox_Bar', 'OVERLAY')
a. You already created a texture object and assigned it to the "leaderassisttexture" variable.
b. This usage of CreateTexture will actually produce a new texture object whose global name is that (malformed) file path. You should delete this line and uncomment the SetTexture line directly above it.

========================

oUF also already provides a combat indicator element and a resting indicator element; you don't need to create your own frames and manage them yourself with event handlers. Just use the elements and give them the textures, dimensions, etc. that you want.

========================

However, oUF does not provide any elements named "BuffBars" or "DebuffBars" so if you want those objects to do anything, you either need to use the proper names -- "Buffs" and "Debuffs" -- or install/write a third-party element/plugin to handle them.

========================

Code:
oUF:RegisterStyle('Terenna', Shared)
oUF:RegisterStyle('oUF_Terenna_Player', UnitSpecific.player)
oUF:SetActiveStyle('oUF_Terenna_Player')
While this works (though the first line isn't necessary) I'd suggest you're actually doing things a bit backward. You should call the UnitSpecific function from inside the Shared function, rather than the other way around, so you only need to register one style and spawn all your frames with the same style.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote