Quantcast rRingMod 6.2 - WoWInterface
Thread Tools Display Modes
08-30-15, 11:56 PM   #1
EvilMaddness
A Fallenroot Satyr
 
EvilMaddness's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2015
Posts: 26
rRingMod 6.2

I been working on one of Zork's add-on's rRingMod and I almost have it setup. Right now I'm trying to figure out how to hide the background in the ring and whatever shows the clear donut or frame on ClearTarget();
then to appear on target. It works for health and mana I don't know how I just know it's working at the moment. It might take me some time to figure out how to do it...it's a working progress.
__________________
The Maddness Within lua
  Reply With Quote
08-31-15, 09:54 AM   #2
EvilMaddness
A Fallenroot Satyr
 
EvilMaddness's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2015
Posts: 26
Can you hide / show background ring when for target?

I can't figure out how to make the background ring hide for target. It's showing all the time so I wanted to see if anyone here that knows lua more could show me what I have to change. It's the ring on the right in photo.

Code:
 ---------------------  
  -- FUNCTIONS
  ---------------------

  local function am(text)
    DEFAULT_CHAT_FRAME:AddMessage("text") 
  end
  
  local function cre_ring_holder(ring_config)
    --am(ring_config.global.anchorframe)
    local f = CreateFrame("Frame",ring_config.global.ringname,ring_config.global.anchorframe)
    f:SetWidth(ring_config.global.size)
    f:SetHeight(ring_config.global.size)
    f:SetPoint(ring_config.global.anchorpoint,ring_config.global.anchorposx,ring_config.global.anchorposy)
    f:SetFrameLevel(ring_config.global.framelevel)
    f:SetScale(ring_config.global.scale)
    f:SetAlpha(ring_config.global.alpha)
    return f
  end
  
  local r2 = math.sqrt(0.5^2+0.5^2);
  
  --background rotation
  local function do_background_rotation(self, elapsed)
    self.rotation.totalElapsed = self.rotation.totalElapsed + elapsed
    if (self.rotation.totalElapsed < self.rotation.update_timer) then 
      return 
    else
      self.rotation.totalElapsed = 0
      if self.rotation.direction == 1 then
        self.texture:SetTexCoord(
        0.5+r2*cos(self.rotation.degrees+135), 0.5+r2*sin(self.rotation.degrees+135),
        0.5+r2*cos(self.rotation.degrees-135), 0.5+r2*sin(self.rotation.degrees-135),
        0.5+r2*cos(self.rotation.degrees+45), 0.5+r2*sin(self.rotation.degrees+45),
        0.5+r2*cos(self.rotation.degrees-45), 0.5+r2*sin(self.rotation.degrees-45)
        ) 
        self.rotation.degrees = self.rotation.degrees+self.rotation.step_size
        if self.rotation.degrees > 360 then
          self.rotation.degrees = 0
        end
      else
        self.texture:SetTexCoord(
        0.5+r2*cos(self.rotation.degrees+45), 0.5+r2*sin(self.rotation.degrees+45),
        0.5+r2*cos(self.rotation.degrees+135), 0.5+r2*sin(self.rotation.degrees+135),
        0.5+r2*cos(self.rotation.degrees-45), 0.5+r2*sin(self.rotation.degrees-45),            
        0.5+r2*cos(self.rotation.degrees-135), 0.5+r2*sin(self.rotation.degrees-135)
        )
        self.rotation.degrees = self.rotation.degrees-self.rotation.step_size
        if self.rotation.degrees < 0 then
          self.rotation.degrees = 360
        end
      end
    end
  end
  
  local function cre_ring_background(ring_config, ring_object)
    local f = CreateFrame("Frame",nil,ring_object)
    f:SetAllPoints(ring_object)
    f:SetFrameLevel(ring_config.background.framelevel)
    f:SetAlpha(ring_config.background.alpha)
    if (ring_config.background.use_texture == 1) then
      local t = f:CreateTexture(nil,"BACKGROUND")
      t:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\"..ring_config.global.gfx_folder.."\\ring_background")
      t:SetAllPoints(f)
      t:SetVertexColor(ring_config.background.color.r,ring_config.background.color.g,ring_config.background.color.b,ring_config.background.color.a)
      t:SetBlendMode(ring_config.background.blendmode)
      f.texture = t
      --rotation
      if (ring_config.background.do_rotation == 1) then
        f.rotation = CreateFrame("Frame",nil,f)
        f.rotation.totalElapsed = 0
        f.rotation.direction = ring_config.background.rotation.direction
        if ring_config.background.rotation.direction == 1 then
          f.rotation.degrees = 0
        else 
          f.rotation.degrees = 360
        end
        f.rotation.step_size = ring_config.background.rotation.step_size
        f.rotation.update_timer = ring_config.background.rotation.update_timer
        f.rotation.starttime = GetTime()
        f:SetScript("OnUpdate", function (self,elapsed)
          do_background_rotation(f,elapsed)
        end)
      end
    end
    return f
  end
  
  local function cre_ring_foreground(ring_config, ring_object)
    local f = CreateFrame("Frame",nil,ring_object)
    f:SetAllPoints(ring_object)
    f:SetFrameLevel(ring_config.foreground.framelevel)
    f:SetAlpha(ring_config.foreground.alpha)
    if (ring_config.foreground.use_texture == 1) then
      local t = f:CreateTexture(nil,"foreground")
      t:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\"..ring_config.global.gfx_folder.."\\ring_foreground")
      t:SetAllPoints(f)
      t:SetVertexColor(ring_config.foreground.color.r,ring_config.foreground.color.g,ring_config.foreground.color.b,ring_config.foreground.color.a)
      t:SetBlendMode(ring_config.foreground.blendmode)
      f.texture = t
    end
    return f
  end
  
  -- calculates the one specific ring segment 
  local function calc_ring_segment(self, value)
  
    local t0 = self.square1
    local t1 = self.square2
    local t2 = self.slicer
    local t3 = self.fullsegment

    local direction = self.direction
    local segmentsize = self.segmentsize
    local outer_radius = self.outer_radius
    local difference = self.difference
    local inner_radius = self.inner_radius
    local ring_factor = self.ring_factor
    local ring_width = self.ring_width
    
    
    --remember to invert the value when direction is counter-clockwise
    local statusbarvalue = floor(value)
    if direction == 0 then
      statusbarvalue = 100 - statusbarvalue
    end
    if statusbarvalue == 0 then
      statusbarvalue = 1
      --am("Oh Oh")
    end

    --am(statusbarvalue)

    --angle
    local angle = statusbarvalue * 90 / 100
    local Arad = math.rad(angle)

    local Nx = 0
    local Ny = 0
    local Mx = segmentsize
    local My = segmentsize
    
    local Ix,Iy,Ox,Oy
    local IxCoord, IyCoord, OxCoord, OyCoord, NxCoord, NyCoord, MxCoord, MyCoord
    local sq1_c1_x, sq1_c1_y, sq1_c2_x, sq1_c2_y, sq1_c3_x, sq1_c3_y, sq1_c4_x, sq1_c4_y
    local sq2_c1_x, sq2_c1_y, sq2_c2_x, sq2_c2_y, sq2_c3_x, sq2_c3_y, sq2_c4_x, sq2_c4_y
    
    if direction == 1 then
      
      Ix = inner_radius * math.sin(Arad)
      Iy = (outer_radius - (inner_radius * math.cos(Arad))) + difference
      Ox = outer_radius * math.sin(Arad)
      Oy = (outer_radius - (outer_radius * math.cos(Arad))) + difference
      IxCoord = Ix / segmentsize 
      IyCoord = Iy / segmentsize
      OxCoord = Ox / segmentsize
      OyCoord = Oy / segmentsize   
      NxCoord = Nx / segmentsize
      NyCoord = Ny / segmentsize
      MxCoord = Nx / segmentsize
      MyCoord = Ny / segmentsize
      
      sq1_c1_x = NxCoord
      sq1_c1_y = NyCoord
      sq1_c2_x = NxCoord
      sq1_c2_y = IyCoord
      sq1_c3_x = IxCoord
      sq1_c3_y = NyCoord
      sq1_c4_x = IxCoord
      sq1_c4_y = IyCoord
            
      sq2_c1_x = IxCoord
      sq2_c1_y = NyCoord
      sq2_c2_x = IxCoord
      sq2_c2_y = OyCoord
      sq2_c3_x = OxCoord
      sq2_c3_y = NyCoord
      sq2_c4_x = OxCoord
      sq2_c4_y = OyCoord
      
      if self.field == 1 then
        t0:SetPoint("TOPLEFT",Nx,-Ny)
        t0:SetWidth(Ix)
        t0:SetHeight(Iy)
        t1:SetPoint("TOPLEFT",Ix,-Ny)
        t1:SetWidth(Ox-Ix)
        t1:SetHeight(Oy)
        t2:SetPoint("TOPLEFT",Ix,-Oy)
        t2:SetWidth(Ox-Ix)
        t2:SetHeight(Iy-Oy)
      elseif self.field == 2 then
        t0:SetPoint("TOPRIGHT",Nx,Ny)
        t0:SetWidth(Iy)
        t0:SetHeight(Ix)
        t1:SetPoint("TOPRIGHT",Ny,-Ix)
        t1:SetWidth(Oy)
        t1:SetHeight(Ox-Ix)
        t2:SetPoint("TOPRIGHT",-Oy,-Ix)
        t2:SetWidth(Iy-Oy)
        t2:SetHeight(Ox-Ix)
        t2:SetTexCoord(0,1, 1,1, 0,0, 1,0)
      elseif self.field == 3 then
        t0:SetPoint("BOTTOMRIGHT",Nx,Ny)
        t0:SetWidth(Ix)
        t0:SetHeight(Iy)
        t1:SetPoint("BOTTOMRIGHT",-Ix,Ny)
        t1:SetWidth(Ox-Ix)
        t1:SetHeight(Oy)
        t2:SetPoint("BOTTOMRIGHT",-Ix,Oy)
        t2:SetWidth(Ox-Ix)
        t2:SetHeight(Iy-Oy)
        t2:SetTexCoord(1,1, 1,0, 0,1, 0,0)
      elseif self.field == 4 then
        t0:SetPoint("BOTTOMLEFT",Nx,Ny)
        t0:SetWidth(Iy)
        t0:SetHeight(Ix)
        t1:SetPoint("BOTTOMLEFT",Ny,Ix)
        t1:SetWidth(Oy)
        t1:SetHeight(Ox-Ix)
        t2:SetPoint("BOTTOMLEFT",Oy,Ix)
        t2:SetWidth(Iy-Oy)
        t2:SetHeight(Ox-Ix)
        t2:SetTexCoord(1,0, 0,0, 1,1, 0,1)
      end
      
    else
      
      Ix = inner_radius * math.sin(Arad)
      Iy = (outer_radius - (inner_radius * math.cos(Arad))) + difference
      Ox = outer_radius * math.sin(Arad)
      Oy = (outer_radius - (outer_radius * math.cos(Arad))) + difference
      IxCoord = Ix / segmentsize 
      IyCoord = Iy / segmentsize
      OxCoord = Ox / segmentsize
      OyCoord = Oy / segmentsize   
      NxCoord = Nx / segmentsize
      NyCoord = Ny / segmentsize
      MxCoord = Mx / segmentsize
      MyCoord = My / segmentsize
      
      sq1_c1_x = IxCoord
      sq1_c1_y = IyCoord
      sq1_c2_x = IxCoord
      sq1_c2_y = MyCoord
      sq1_c3_x = MxCoord
      sq1_c3_y = IyCoord
      sq1_c4_x = MxCoord
      sq1_c4_y = MyCoord
            
      sq2_c1_x = OxCoord
      sq2_c1_y = OyCoord
      sq2_c2_x = OxCoord
      sq2_c2_y = IyCoord
      sq2_c3_x = MxCoord
      sq2_c3_y = OyCoord
      sq2_c4_x = MxCoord
      sq2_c4_y = IyCoord
      
      if self.field == 1 then
        t0:SetPoint("TOPLEFT",Ix,-Iy)
        t0:SetWidth(segmentsize-Ix)
        t0:SetHeight(segmentsize-Iy)
        t1:SetPoint("TOPLEFT",Ox,-Oy)
        t1:SetWidth(segmentsize-Ox)
        t1:SetHeight(Iy-Oy)
        t2:SetPoint("TOPLEFT",Ix,-Oy)
        t2:SetWidth(Ox-Ix)
        t2:SetHeight(Iy-Oy)
      elseif self.field == 2 then
        t0:SetPoint("TOPRIGHT",-Iy,-Ix)
        t0:SetWidth(segmentsize-Iy)
        t0:SetHeight(segmentsize-Ix)
        t1:SetPoint("TOPRIGHT",-Oy,-Ox)
        t1:SetWidth(Iy-Oy)
        t1:SetHeight(segmentsize-Ox)
        t2:SetPoint("TOPRIGHT",-Oy,-Ix)
        t2:SetWidth(Iy-Oy)
        t2:SetHeight(Ox-Ix)
        t2:SetTexCoord(0,1, 1,1, 0,0, 1,0)
      elseif self.field == 3 then
        t0:SetPoint("BOTTOMRIGHT",-Ix,Iy)
        t0:SetWidth(segmentsize-Ix)
        t0:SetHeight(segmentsize-Iy)
        t1:SetPoint("BOTTOMRIGHT",-Ox,Oy)
        t1:SetWidth(segmentsize-Ox)
        t1:SetHeight(Iy-Oy)
        t2:SetPoint("BOTTOMRIGHT",-Ix,Oy)
        t2:SetWidth(Ox-Ix)
        t2:SetHeight(Iy-Oy)
        t2:SetTexCoord(1,1, 1,0, 0,1, 0,0)
      elseif self.field == 4 then
        t0:SetPoint("BOTTOMLEFT",Iy,Ix)
        t0:SetWidth(segmentsize-Iy)
        t0:SetHeight(segmentsize-Ix)
        t1:SetPoint("BOTTOMLEFT",Oy,Ox)
        t1:SetWidth(Iy-Oy)
        t1:SetHeight(segmentsize-Ox)
        t2:SetPoint("BOTTOMLEFT",Oy,Ix)
        t2:SetWidth(Iy-Oy)
        t2:SetHeight(Ox-Ix)
        t2:SetTexCoord(1,0, 0,0, 1,1, 0,1)
      end
    end
    
    if self.field == 1 then
      --1,2,3,4
      t0:SetTexCoord(sq1_c1_x,sq1_c1_y, sq1_c2_x,sq1_c2_y, sq1_c3_x,sq1_c3_y, sq1_c4_x, sq1_c4_y)
      t1:SetTexCoord(sq2_c1_x,sq2_c1_y, sq2_c2_x,sq2_c2_y, sq2_c3_x,sq2_c3_y, sq2_c4_x, sq2_c4_y)
    elseif self.field == 2 then
      --2,4,1,3
      t0:SetTexCoord(sq1_c2_x,sq1_c2_y, sq1_c4_x, sq1_c4_y, sq1_c1_x,sq1_c1_y, sq1_c3_x,sq1_c3_y)
      t1:SetTexCoord(sq2_c2_x,sq2_c2_y, sq2_c4_x, sq2_c4_y, sq2_c1_x,sq2_c1_y, sq2_c3_x,sq2_c3_y)
    elseif self.field == 3 then
      --4,3,2,1
      t0:SetTexCoord(sq1_c4_x, sq1_c4_y, sq1_c3_x,sq1_c3_y, sq1_c2_x,sq1_c2_y, sq1_c1_x,sq1_c1_y)
      t1:SetTexCoord(sq2_c4_x, sq2_c4_y, sq2_c3_x,sq2_c3_y, sq2_c2_x,sq2_c2_y, sq2_c1_x,sq2_c1_y)
    elseif self.field == 4 then
      --3,1,4,2
      t0:SetTexCoord(sq1_c3_x,sq1_c3_y, sq1_c1_x,sq1_c1_y, sq1_c4_x, sq1_c4_y, sq1_c2_x,sq1_c2_y)
      t1:SetTexCoord(sq2_c3_x,sq2_c3_y, sq2_c1_x,sq2_c1_y, sq2_c4_x, sq2_c4_y, sq2_c2_x,sq2_c2_y)
    end

  
  end
  
  --function that creates the textures for each segment
  local function cre_segment_textures(ring_config,self)
    --am(self.field)
    
    local direction = ring_config.global.fill_direction
    local segmentsize = ring_config.segment.segmentsize
    local outer_radius = ring_config.segment.outer_radius
    local difference = segmentsize-outer_radius
    local inner_radius = ring_config.segment.inner_radius
    local ring_factor = outer_radius/inner_radius
    local ring_width = outer_radius-inner_radius
    
    self.direction =  ring_config.global.fill_direction
    self.segmentsize = ring_config.segment.segmentsize
    self.outer_radius = ring_config.segment.outer_radius
    self.difference = segmentsize-outer_radius
    self.inner_radius = ring_config.segment.inner_radius
    self.ring_factor = outer_radius/inner_radius
    self.ring_width = outer_radius-inner_radius
    
    local t0 = self:CreateTexture(nil, "BACKGROUND")
    t0:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\"..ring_config.global.gfx_folder.."\\ring_segment")
    t0:SetVertexColor(ring_config.segment.color.r,ring_config.segment.color.g,ring_config.segment.color.b,ring_config.segment.color.a)
    t0:SetBlendMode(ring_config.segment.blendmode)
    t0:Hide()
	
    
    local t1 = self:CreateTexture(nil, "LOW")
    t1:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\"..ring_config.global.gfx_folder.."\\ring_segment")
    t1:SetVertexColor(ring_config.segment.color.r,ring_config.segment.color.g,ring_config.segment.color.b,ring_config.segment.color.a)
    t1:SetBlendMode(ring_config.segment.blendmode)
    t1:Hide()

    local t2 = self:CreateTexture(nil, "BACKGROUND")
    t2:SetVertexColor(ring_config.segment.color.r,ring_config.segment.color.g,ring_config.segment.color.b,ring_config.segment.color.a)
    t2:SetBlendMode(ring_config.segment.blendmode)
    if direction == 1 then
      t2:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\slicer1")
    else
      t2:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\slicer0")
    end
    t2:Hide()
	

    local t3 = self:CreateTexture(nil, "BACKGROUND")
	t3:SetTexture("Interface\\AddOns\\rRingMod\\ring_gfx\\"..ring_config.global.gfx_folder.."\\ring_segment")
    t3:SetVertexColor(ring_config.segment.color.r,ring_config.segment.color.g,ring_config.segment.color.b,ring_config.segment.color.a)
    t3:SetBlendMode(ring_config.segment.blendmode)
    t3:SetPoint("CENTER",0,0)
    t3:SetWidth(segmentsize)
    t3:SetHeight(segmentsize)
    if self.field == 1 then
      --no coord needed
    elseif self.field == 2 then
      t3:SetTexCoord(0,1, 1,1, 0,0, 1,0)
    elseif self.field == 3 then
      t3:SetTexCoord(1,1, 1,0, 0,1, 0,0)
    elseif self.field == 4 then
      t3:SetTexCoord(1,0, 0,0, 1,1, 0,1)
    end
    t3:Hide()
    
    self.square1 = t0
    self.square2 = t1
    self.slicer = t2
    self.fullsegment = t3
    
  end
  
  --calculate the segment number based on starting segment and direction
  local function calc_segment_num(ring_config,current)
    local start = ring_config.global.start_segment
    local dir = ring_config.global.fill_direction
    local id
    if dir == 0 then
      if start-current < 1 then
        id = start-current+4
      else
        id = start-current
      end
    else
      if start+current > 4 then
        id = start+current-4
      else
        id = start+current
      end          
    end
    return id
  end
  
  --create the ring segments
  local function cre_ring_segments(ring_config, ring_object)
    local f = CreateFrame("Frame",nil,ring_object)
    f:SetAllPoints(ring_object)
    f:SetFrameLevel(ring_config.segment.framelevel)
    f:SetAlpha(ring_config.segment.alpha)
    for i=1,(ring_config.global.segments_used) do
      f[i] = CreateFrame("Frame",nil,f)
      f[i]:SetWidth(ring_config.global.size/2)
      f[i]:SetHeight(ring_config.global.size/2)
      f[i].id = i
      f[i].field = calc_segment_num(ring_config,i-1)
      --am(f[i].id.." ~ "..f[i].field)
      if f[i].field == 1 then
        f[i]:SetPoint("TOPRIGHT",0,0)
      elseif f[i].field == 2 then
        f[i]:SetPoint("BOTTOMRIGHT",0,0)
      elseif f[i].field == 3 then
        f[i]:SetPoint("BOTTOMLEFT",0,0)
      elseif f[i].field == 4 then
        f[i]:SetPoint("TOPLEFT",0,0)
      end
      cre_segment_textures(ring_config,f[i])
    end
    return f
  end

  
  local function calc_ring_health(self,ring_config,unit)
    local act, max, perc, perc_per_seg = UnitHealth(unit), UnitHealthMax(unit), (UnitHealth(unit)/UnitHealthMax(unit))*100, 100/ring_config.global.segments_used
    local anz_seg, sum_radius = ring_config.global.segments_used, ring_config.global.segments_used*90
    
    -- need to run through ring segments
    -- anz_segments defines how much of 100 is taken by each segment
    -- 1 segment = 100, 2 = 50, 3 = 33, 4 = 25
    -- segments have 3 states, totally active, totally not active, partially active
    
    -- example, lets assume we use 4 segments, thuse 25% each segment
    -- we use player health as our ring and player has 64% health
    -- segment 1 is active, segment 2 is active, segment 3 is partial active, segment 4 is not active
    
    -- Special 
    -- if unit is dead or ghost too
    if perc == 0 or UnitIsDeadOrGhost(unit) == 1 then
	
      -- hide every element
      -- because every segment is saved in an array we can use a loop from 1-anz_seg here.
      --am("zero,nada,nix")
      for i=1, anz_seg do
        self.segments[i].square1:Hide()
        self.segments[i].square2:Hide()
        self.segments[i].slicer:Hide()
        self.segments[i].fullsegment:Hide()
		
		
		
      end
    elseif perc == 100 then
      -- make every element visible
      -- because every segment is saved in an array we can use a loop from 1-anz_seg here.
      --am("100!")
      for i=1, anz_seg do
        self.segments[i].square1:Hide()
        self.segments[i].square2:Hide()
        self.segments[i].slicer:Hide()
        self.segments[i].fullsegment:Show()
		
      end
    else
      -- neeed to run through segments
      for i=1, anz_seg do
        if(perc > (i*perc_per_seg)) then
          -- player has more hp than this segment can handle
          -- show fullsegement texture, hide the rest
          --am(i.." fully visible baby!")
          self.segments[i].square1:Hide()
          self.segments[i].square2:Hide()
          self.segments[i].slicer:Hide()
          self.segments[i].fullsegment:Show()
        elseif ((perc >= ((i-1)*perc_per_seg)) and (perc <= (i*perc_per_seg))) then
          -- player hp is exactly in this segment
          --am(i.." look at me more closely")
          -- need to calc how much of this segment is filled.
          -- thuse I need to subtract ((i-1)*perc_per_seg) from my perc value
          -- example 64%, thus I am in segment 3. => 2*25 = 50
          -- 64-50=14, so 14 is the value I get, now need the "Dreisatz"
          -- 14/perc_per_seg = 0.56, so the segment we look at is filled to 56%
          -- so now we can paste this value to our function
          -- calc_ring_segment(self,value)
          -- remember to invert the value, depending on fill_direction!
          local value = ((perc-((i-1)*perc_per_seg))/perc_per_seg)*100
          calc_ring_segment(self.segments[i],value)
          self.segments[i].square1:Show()
          self.segments[i].square2:Show()
          self.segments[i].slicer:Show()
          self.segments[i].fullsegment:Hide()
        else
          -- crap my health is not high enough to fill this
          -- hide everything
          --am(i.." i'm out :/")
          self.segments[i].square1:Hide()
          self.segments[i].square2:Hide()
          self.segments[i].slicer:Hide()
          self.segments[i].fullsegment:Hide()
        end
      end
    end

    --am(act.."/"..max.." ~ "..perc)
    --am(ring_config.global.segments_used)
    
  end  
  
  local function calc_ring_mana(self,ring_config,unit)
    local act, max, perc, perc_per_seg = UnitMana(unit), UnitManaMax(unit), (UnitMana(unit)/UnitManaMax(unit))*100, 100/ring_config.global.segments_used
    local anz_seg, sum_radius = ring_config.global.segments_used, ring_config.global.segments_used*90
    
    if perc == 0 or UnitIsDeadOrGhost(unit) == 1 then
      for i=1, anz_seg do
        self.segments[i].square1:Hide()
        self.segments[i].square2:Hide()
        self.segments[i].slicer:Hide()
        self.segments[i].fullsegment:Hide()
		
      end
    elseif perc == 100 then
      for i=1, anz_seg do
        self.segments[i].square1:Hide()
        self.segments[i].square2:Hide()
        self.segments[i].slicer:Hide()
        self.segments[i].fullsegment:Show()
      end
    else
      for i=1, anz_seg do
        if(perc > (i*perc_per_seg)) then
          self.segments[i].square1:Hide()
          self.segments[i].square2:Hide()
          self.segments[i].slicer:Hide()
          self.segments[i].fullsegment:Show()
        elseif ((perc >= ((i-1)*perc_per_seg)) and (perc <= (i*perc_per_seg))) then
          local value = ((perc-((i-1)*perc_per_seg))/perc_per_seg)*100
          calc_ring_segment(self.segments[i],value)
          self.segments[i].square1:Show()
          self.segments[i].square2:Show()
          self.segments[i].slicer:Show()
          self.segments[i].fullsegment:Hide()
        else
          self.segments[i].square1:Hide()
          self.segments[i].square2:Hide()
          self.segments[i].slicer:Hide()
          self.segments[i].fullsegment:Hide()
        end
      end
    end
  end   
   
   
   
  
  local function setup_rings(id)
  
    local ring_config = ring_table[id]
    --am(ring_config.global.ringname)
    --am(ring_config.global.unit)
    
    if ring_config.global.active == 1 then
    
      local ring_object = cre_ring_holder(ring_config)
      ring_object.background = cre_ring_background(ring_config, ring_object)
      ring_object.segments = cre_ring_segments(ring_config, ring_object)
      ring_object.foreground = cre_ring_foreground(ring_config, ring_object)
      --am(ring_object.background.texture:GetTexture())
      --am(ring_object.segments[1].field)
	  
	  
	  
      if ring_config.global.ringtype == "health" then
        ring_object:SetScript("OnEvent", function(self, event, unit)
          if (event == "UNIT_HEALTH" and unit == ring_config.global.unit) or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_TARGET_CHANGED" then
            calc_ring_health(ring_object,ring_config,ring_config.global.unit)
			
          end    
        end)
        ring_object:RegisterEvent("UNIT_HEALTH")
        ring_object:RegisterEvent("PLAYER_ENTERING_WORLD")
		ring_object:RegisterEvent("PLAYER_TARGET_CHANGED")
      end
      
      if ring_config.global.ringtype == "mana" then
        ring_object:SetScript("OnEvent", function(self, event, unit)
          if (event == "UNIT_POWER" and unit == ring_config.global.unit) or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_TARGET_CHANGED" or event == "UNIT_MANA" or event == "UNIT_DISPLAYPOWER" or event == "UNIT_POWER_FREQUENT" or event == "SPELL_POWER_ENERGY" or event == "SPELL_POWER_FOCUS" or event == "SPELL_POWER_MANA" or event == "UNIT_RUNIC_POWER" or event == "SPELL_POWER_RAGE" then calc_ring_mana(ring_object,ring_config,ring_config.global.unit)
          end    
        end)
        ring_object:RegisterEvent("UNIT_MANA")	
		ring_object:RegisterEvent("UNIT_POWER_FREQUENT")
		ring_object:RegisterEvent("UNIT_DISPLAYPOWER")
        ring_object:RegisterEvent("SPELL_POWER_ENERGY")
        ring_object:RegisterEvent("SPELL_POWER_FOCUS")
        ring_object:RegisterEvent("SPELL_POWER_MANA")
        ring_object:RegisterEvent("UNIT_RUNIC_POWER")
        ring_object:RegisterEvent("SPELL_POWER_RAGE")
        ring_object:RegisterEvent("PLAYER_ENTERING_WORLD")
		ring_object:RegisterEvent("PLAYER_TARGET_CHANGED")
      end
	end
  end
  
  ---------------------  
  -- CALL
  ---------------------
  
  local a = CreateFrame("Frame", nil, UIParent)
  
  a:RegisterEvent("PLAYER_LOGIN")
  
  a:SetScript("OnEvent", function (self,event,arg1)
    if(event=="PLAYER_LOGIN") then
      am("RingMod loaded.")
      for i in ipairs(ring_table) do 
        setup_rings(i)
      end
    end
  end)
__________________
The Maddness Within lua
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » UI Screenshots, Feedback and Design Discussion » rRingMod 6.2

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off