1. #1
    Deleted

    [lua] oUF Layout

    hi all,

    working on some new unitframes for my interface and i've got a question.
    so this i what i've got
    http://imageshack.us/photo/my-images/593/gmmz.jpg/

    it's all percent based, like healthbar ist 45% from uiparent, manabar ist 33% from healthbar and so on.
    and that is my question before i go more into depth with it.
    is it ok to do it this way, is the memory usage to big? don't really know much about programming.

    here a piece of code from the healthbar
    Code:
    MyCenterPiece = CreateFrame('Frame', nil, UIParent)
        MyCenterPiece:SetPoint("TOP", UIParent,0,18)
        MyCenterPiece:SetSize(((UIParent:GetWidth()/100)*10),((UIParent:GetWidth()/100)*10))
        MyCenterPiece:SetFrameStrata("LOW")
        MyCenterPiece:SetFrameLevel(5)
        
        local MyCenterPieceBGTex = MyCenterPiece:CreateTexture()
              MyCenterPieceBGTex:SetParent(MyCenterPiece)
              MyCenterPieceBGTex:SetAllPoints(MyCenterPiece)
              MyCenterPieceBGTex:SetTexture("Interface\\Addons\\!beatemupmedia\\centerpiece.tga")
    
    -- HEALTHBAR IN PERCENT FROM UIPARENT          
    local HealthPercentWidth = 46.85
    -- POWERBAR IN PERCENT FROM HEALTHBAR
    local PowerPercentWidth = 33  
    -----------------------------------------------------------------------------------------------
    --- <| PLAYER |> ------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------
    local cPlayer = function(self)
        self:SetSize(((UIParent:GetWidth()/100)*HealthPercentWidth), (UIParent:GetHeight()/100)*3)
    self:SetScale(1)
    --- <| HEALTHBAR |> --------------------------
    ----------------------------------------------
    self.Health = CreateFrame('StatusBar', nil, self)
        self.Health:SetFrameStrata("LOW")
        self.Health:SetFrameLevel(1)
        self.Health:SetPoint("TOPLEFT", self, 0, 1)
        self.Health:SetStatusBarTexture("Interface\\AddOns\\!beatemupmedia\\statusbar\\statusbar.tga")
        self.Health.frequentUpdates = FreqUpdate
        self.Health:SetReverseFill(true)
        self.Health.Smooth = true
        self.Health:SetHeight((UIParent:GetHeight()/100)*3)
        self.Health:SetWidth((UIParent:GetWidth()/100)*HealthPercentWidth)
        self.Health.colorClass = false
        self.Health.colorPower = false 
    
    local MyPlayerHealthBG = CreateFrame('Frame', nil, UIParent)
          MyPlayerHealthBG:SetPoint("TOPRIGHT", self.Health, 0, 0)
          MyPlayerHealthBG:SetWidth(self.Health:GetWidth())
          MyPlayerHealthBG:SetHeight(self.Health:GetHeight())
          MyPlayerHealthBG:SetFrameStrata("LOW")
          MyPlayerHealthBG:SetFrameLevel(0)
    
          local MyPlayerHealthBGTex = MyPlayerHealthBG:CreateTexture()
                MyPlayerHealthBGTex:SetParent(MyPlayerHealthBG)
                MyPlayerHealthBGTex:SetAllPoints(MyPlayerHealthBG)
                MyPlayerHealthBGTex:SetTexture(0,0,0,1)
    
                local MyPlayerHealthBorder = CreateFrame('Frame', nil, UIParent)
                      MyPlayerHealthBorder:SetPoint("CENTER", self.Health, 0, 0)
                      MyPlayerHealthBorder:SetBackdrop(beatemupbackdrop)
                      MyPlayerHealthBorder:SetWidth(self.Health:GetWidth()+4)
                      MyPlayerHealthBorder:SetHeight(self.Health:GetHeight()+4)
                      MyPlayerHealthBorder:SetFrameStrata("LOW")
                      MyPlayerHealthBorder:SetFrameLevel(2)
    thank you for helping me out
    Vyntrox

  2. #2
    Deleted
    Very nice idea. Kind of a StreetFighter style.

    I'm pretty firm with oUF if you got questions just PM me.

    -----------------------------------

    I got suggestion on how to do the positioning stuff more easily:

    -----------------------------------

    1) First you create your center piece.
    Code:
    local centerPiece = CreateFrame(nil, "MyCenterPiece", UIParent)
    centerPiece:SetSize(256,128)
    centerPiece:SetScale(1)
    centerPiece:SetPoint("TOP")
    centerPiece.texture = CenterPiece:CreateTexture(nil, "BACKGROUND", nil, -8)
    centerPiece.texture:SetAllPoints()
    centerPiece.texture:SetTexture("Interface\\Addons\\!beatemupmedia\\centerpiece")
    2) Now we create the player and target styles. The trick with positioning is to use already existing edges. You do not have to set width. You just need points. Thus your point for your player frame should go from the topleft corner of UIParent to the topleft edge of centerPiece.
    I suggest that you keep positions of self.Health and self.Power relative to the parent frame, thus self is the container that you will position absolutely.
    Code:
    --create health func
    local function CreateHealth(self)
      --self.Health
      self.Health = CreateFrame("StatusBar",nil,self)
      self.Health:SetPoint("TOPLEFT") --TOPLEFT of parent = self
      self.Health:SetPoint("TOPRIGHT") --TOPRIGHT of parent = self
      self.Health:SetHeight(self.height*0.8) 80% of the height of self
    end
    
    --create power func
    local function CreatePower(self)
      --self.Power
      self.Power = CreateFrame("StatusBar",nil,self)
      self.Power:SetPoint("BOTTOM") --BOTTOM center of parent = self
      self.Power:SetHeight(self.height*0.3) 30% of the height of self
      self.Power:SetWidth(self.width*0.5) 50% of the width of self
    end
    
    
    --the player style
    local function CreatePlayerStyle(self)
      self:SetScale(1)
      --position self
      self:SetPoint("TOPLEFT") --topleft of UIParent
      self:SetPoint("TOPRIGHT",centerPiece,"TOPLEFT",0,0) --topright corner of self will point to topleft corner of centerpiece, you still can adjust using the x-coordinate
      --we need height, so we add it
      self:SetHeight(100)
      self.width, self.height = self:GetSize()
      CreateHealth(self)
      CreatePower(self)
    end
    
    --the target style
    local function CreateTargetStyle(self)
      self:SetScale(1)
      --position self
      self:SetPoint("TOPLEFT",centerPiece,"TOPRIGHT",0,0) --topleft corner of self will point to topright corner of centerpiece
      self:SetPoint("TOPRIGHT") --topright of UIParent
      --we need height, so we add it
      self:SetHeight(100)
      self.width, self.height = self:GetSize()
      CreateHealth(self)
      CreatePower(self)
    end
    
    oUF:RegisterStyle("MyPlayerStyleName", CreatePlayerStyle)
    oUF:SetActiveStyle("MyPlayerStyleName")
    oUF:Spawn("player","MyPlayerFrameName")
    
    oUF:RegisterStyle("MyTargetStyleName", CreateTargetStyle)
    oUF:SetActiveStyle("MyTargetStyleName")
    oUF:Spawn("target","MyTargetFrameName")
    If your centerpiece texture file does not fill the texture completly you can still use the x-coordinates of the setpoints to adjust the positions of the player and the health frame.

    If you work with scale which is not bad at all you may need to multiply your positions with the frame scale. But that needs to be tested live.

    For more about setpoints read:
    http://wowprogramming.com/docs/widgets/Region/SetPoint
    Last edited by mmoc48efa32b91; 2013-10-02 at 07:36 AM.

  3. #3
    Very nice idea! if you want any help for something else feel free to PM me. My entire UI is based on an oUF layout.

    Anyway, Zork is waaaaaay more expert than me you got one of the best right on the spot .
    Non ti fidar di me se il cuor ti manca.

  4. #4
    Deleted
    Thank you for helping me out :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •