Thread Tools Display Modes
05-04-12, 06:57 AM   #1
JamesR4494
A Defias Bandit
Join Date: Apr 2012
Posts: 2
Need help shortening actionbar

Code:
  
  --get the addon namespace
  local addon, ns = ...
  
  --get the config values
  local cfg = ns.cfg
  local barcfg = cfg.bars.bar5
  
  local bar = CreateFrame("Frame","rABS_MultiBarLeft",UIParent, "SecureHandlerStateTemplate")
  bar:SetHeight(barcfg.buttonsize*12+barcfg.buttonspacing*11)
  bar:SetWidth(barcfg.buttonsize)
  bar:SetPoint(barcfg.pos.a1,barcfg.pos.af,barcfg.pos.a2,barcfg.pos.x,barcfg.pos.y)
  bar:SetHitRectInsets(-cfg.barinset, -cfg.barinset, -cfg.barinset, -cfg.barinset)
  
  if barcfg.testmode then
    bar:SetBackdrop(cfg.backdrop)
    bar:SetBackdropColor(1,0.8,1,0.6)
  end
  bar:SetScale(barcfg.barscale)

  cfg.applyDragFunctionality(bar,barcfg.userplaced,barcfg.locked)

  MultiBarLeft:SetParent(bar)
  
  for i=1, 12 do
    local button = _G["MultiBarLeftButton"..i]
    button:ClearAllPoints()
    button:SetSize(barcfg.buttonsize, barcfg.buttonsize)
    if i == 1 then
      button:SetPoint("TOPLEFT", bar, 0,0)
    else
      local previous = _G["MultiBarLeftButton"..i-1]
      button:SetPoint("TOP", previous, "BOTTOM", 0, -barcfg.buttonspacing)
    end
  end
  
  if barcfg.showonmouseover then    
    local function lighton(alpha)
      if MultiBarLeft:IsShown() then
        for i=1, 12 do
          local pb = _G["MultiBarLeftButton"..i]
          pb:SetAlpha(alpha)
        end
      end
    end    
    bar:EnableMouse(true)
    bar:SetScript("OnEnter", function(self) lighton(1) end)
    bar:SetScript("OnLeave", function(self) lighton(0) end)  
    for i=1, 12 do
      local pb = _G["MultiBarLeftButton"..i]
      pb:SetAlpha(0)
      pb:HookScript("OnEnter", function(self) lighton(1) end)
      pb:HookScript("OnLeave", function(self) lighton(0) end)
    end    
  end
Trying to edit Roth UI's rActionBarStyler's bar 5 to make it so only 4 buttons show up instead of the default 12, is there anyway i could do this?
  Reply With Quote
05-04-12, 08:44 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Find this:
Lua Code:
  1. button:SetPoint("TOP", previous, "BOTTOM", 0, -barcfg.buttonspacing)
Make it:
Lua Code:
  1. if i>4 then
  2.   button:SetPoint("RIGHT",UIParent,9000,9000);
  3. else
  4.   button:SetPoint("TOP", previous, "BOTTOM", 0, -barcfg.buttonspacing)
  5. end
That will move every button > 4 out of the window.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 05-04-12 at 08:47 AM.
  Reply With Quote
05-04-12, 08:50 AM   #3
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
What would happen if you changed every instance of "for i=1, 12 do" to "for i=1, 4 do" in the code? Major errors?

Just curious here.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
05-04-12, 10:18 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
The buttons are anchored on each other. If you do not reposition them they would keep their default anchors. (Even the Blizzard buttons are buttons are anchored that way)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
05-04-12, 10:44 AM   #5
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Ahhhhh. So, you have to tell the buttons you don't want where to hide, in effect, instead of just telling them to not actually appear. Which is what I assumed (dangerous word, that) would happen if you changed that little bit of code.

Thank you for your explanation, Zork. As I've said before (somewhere), I'm not too good with Lua, but pretty handy with "copy-n-paste".
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 05-04-12 at 10:48 AM.
  Reply With Quote
05-05-12, 02:36 PM   #6
JamesR4494
A Defias Bandit
Join Date: Apr 2012
Posts: 2
Ah I see, thanks it worked.

How do I make this action bar horizontal like the bars on the bottom?
  Reply With Quote
05-05-12, 09:06 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Anchor them RIGHT to LEFT instead of TOP to BOTTOM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help shortening actionbar

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