View Single Post
04-13-15, 11:50 AM   #4
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
At the first I have tried to start my custom layout reading classic or lily (also because the wiki is not so much) but I find a them a bit more difficult to read and begin with than others layouts.

So I test a lot of others and at the end I have used the "Elen" layout to begin to study OUF because I have find it easier for me to begin and to understand even if the "self" construct is a thing I have to approch better ...

I simplified it a lot (also removing the things that Phanx and p3lim pointed me in the string management because I really didn't understand them :-) and then begin to rewrite my own simple layout :-)

For example... the border in this case is quite simple:

Lua Code:
  1. -- [other code here]
  2.  
  3. local backdrop = {
  4.     bgFile      = mediapath .. "back.tga",
  5.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  6. }
  7.  
  8. local backdrop2 = {
  9.     bgFile      = mediapath .. "back.tga",
  10.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  11. }
  12. local statusback = {
  13.     bgFile      = mediapath .. "statusbar.tga",
  14.     insets = {top = 0, left = 0, bottom = 0, right = 0},
  15. }
  16.  
  17. -- [other code here]
  18.  
  19. local cPlayer = function(self)
  20.         self:SetSize(250, 40)
  21.  
  22.         self.Back = CreateFrame('Frame', nil, self)
  23.         self.Back:SetPoint('TOPLEFT', self)
  24.         self.Back:SetWidth(250)
  25.         self.Back:SetHeight(51)    
  26.         self.Back:SetFrameStrata('BACKGROUND')
  27.         self.Back:SetBackdrop(backdrop)
  28.         self.Back:SetBackdropColor(0.05, 0.05, 0.05)   
  29.                
  30.         --: HEALTH BAR :--
  31.         self.Health = CreateFrame('StatusBar', nil, self)
  32.         self.Health:SetPoint('TOPLEFT', self)      
  33.         self.Health:SetWidth(250)
  34.         self.Health:SetHeight(25)          
  35.         self.Health:SetBackdrop(statusback)
  36.         self.Health:SetBackdropColor(0.165,0.165,0.165)
  37.         self.Health:SetFrameStrata('LOW')  
  38.         self.Health:SetStatusBarTexture(statusbar)     
  39.         self.Health.frequentUpdates = FreqUpdate
  40.         self.Health.Smooth = cSmooth
  41.         self.Health.colorClass = false
  42.         self.Health:SetStatusBarColor(START_green[1],START_green[2],START_green[3])
  43.                
  44.         --: POWER BAR :--
  45.         self.Power = CreateFrame('StatusBar', nil, self)
  46.         self.Power:SetPoint('TOPLEFT', self.Health, 'BOTTOMLEFT', 0, -1)
  47.         self.Power:SetHeight(25)
  48.         self.Power:SetWidth(250)
  49.         self.Power:SetBackdropColor(0.15,0.15,0.15)
  50.         self.Power:SetFrameStrata('LOW')
  51.         self.Power:SetStatusBarTexture(statusbar)
  52.         self.Power:SetStatusBarColor(0.28,0.28,0.28)
  53.         self.Power.frequentUpdates = FreqUpdate
  54.         self.Power.Smooth = cSmooth
  55.         self.Power.colorClass = false
  56.         self.Power.colorPower=true
  57.  
  58.     --:: PG NAME ::--  
  59.         self.Info = self.Health:CreateFontString(nil, 'OVERLAY')
  60.         self.Info:SetPoint('LEFT',self.Health,'LEFT', 5, 0)
  61.         self.Info:SetAlpha(1)
  62.         self.Info:SetFont( START_font , START_fs , '')
  63.         self:Tag(self.Info,'[name]')       
  64.        
  65.         --: HEALTH TEXT NUM :--
  66.         self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY')
  67.         self.Health.Text:SetFont( START_font , START_smfs , '')
  68.         self:Tag(self.Health.Text,'[gmarco:curhp]')
  69.         self.Health.Text.frequentUpdates = FreqUpdate
  70.         self.Health.Text:SetPoint('RIGHT',self.Health,'RIGHT', -5, 0 )
  71.        
  72.         --: POWER TEXT :--
  73.         self.Power.Text = self.Health:CreateFontString(nil, 'OVERLAY')
  74.         self.Power.Text:SetFont(START_font, START_smfs, '')
  75.         self.Power.Text.frequentUpdates = FreqUpdate
  76.         self:Tag(self.Power.Text,'[curpp]')
  77.         self.Power.Text:SetPoint('RIGHT',self.Power,'RIGHT', -5, 0)
  78.        
  79.         self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", check_threat)
  80.  
  81. -- and then castbar etc etc ....

As you see :

self.Back:SetHeight(51) = self.Health:SetHeight(25) + 1 pixel from healthbar and powerbar + self.Power:SetHeight(25) .

The countour I think is made by:
insets = {top = -1, left = -1, bottom = -1, right = -1}

The result of this frame can be seen in my answer in the other link above.

Please let me know :-)
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.

Last edited by gmarco : 04-13-15 at 11:55 AM.
  Reply With Quote