Thread Tools Display Modes
05-13-18, 04:47 PM   #1
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
BfA - How can the bag bar be moved?

I want to move this to the left side of the screen.
I tried moving MicroButtonAndBagsBar to BOTTOMLEFT of UIParent. But it doesn't work right.

Any ideas?

Last edited by galvin : 05-13-18 at 05:26 PM.
  Reply With Quote
05-13-18, 05:56 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
It might be overridden by this block of code in the file at : https://www.townlong-yak.com/framexm...ainMenuBar.lua

Code:
function MainMenuBarMixin:OnShow()
  UpdateMicroButtonsParent(MainMenuBarArtFrame);
  MoveMicroButtons("BOTTOMLEFT", MicroButtonAndBagsBar, "BOTTOMLEFT", 6, 3, false);
end
I haven't found anything calling it directly but it is the only thing jumping out at me so far


Edit: D'oh just realised this is lining up the main buttons to the bag bar ...

edit 2 : This definitely looks like something that may cause problems or become a problem

Code:
function MainMenuBarMixin:ChangeMenuBarSizeAndPosition(rightMultiBarShowing)
  local _, width, height;
  if( rightMultiBarShowing ) then
    _, width, height = GetAtlasInfo("hud-MainMenuBar-large");
    self:SetSize(width,height);
    MainMenuBarArtFrame:SetSize(width,height);
    MainMenuBarArtFrameBackground:SetSize(width, height);
    MainMenuBarArtFrameBackground.BackgroundLarge:Show();
    MainMenuBarArtFrameBackground.BackgroundSmall:Hide();
    MainMenuBarArtFrame.PageNumber:ClearAllPoints();
    MainMenuBarArtFrame.PageNumber:SetPoint("CENTER", MainMenuBarArtFrameBackground, "CENTER", 138, -3);
  else
    _, width, height = GetAtlasInfo("hud-MainMenuBar-small");
    self:SetSize(width,height);
    MainMenuBarArtFrame:SetSize(width,height);
    MainMenuBarArtFrameBackground:SetSize(width, height);
    MainMenuBarArtFrameBackground.BackgroundLarge:Hide();
    MainMenuBarArtFrameBackground.BackgroundSmall:Show();
    MainMenuBarArtFrame.PageNumber:ClearAllPoints();
    MainMenuBarArtFrame.PageNumber:SetPoint("RIGHT", MainMenuBarArtFrameBackground, "RIGHT", -6, -3);
  end
  local scale = 1;
  self:SetScale(scale);
  self:SetPoint("BOTTOM");
  local rightGryphon = MainMenuBarArtFrame.RightEndCap:GetRight();
  local xOffset = 0;
  if (rightGryphon > MicroButtonAndBagsBar:GetLeft()) then
    xOffset = rightGryphon - MicroButtonAndBagsBar:GetLeft();
    local newLeft = MainMenuBarArtFrame:GetLeft() - xOffset;
    if (newLeft < 0) then
      local barRight = MainMenuBarArtFrame:GetRight();
      if (barRight > MicroButtonAndBagsBar:GetLeft()) then
        xOffset = barRight - MicroButtonAndBagsBar:GetLeft();
        newLeft = MainMenuBarArtFrame:GetLeft() - xOffset;
      end
    end
    if (newLeft < 0) then
      local xOffsetAdjustment = 8;
      if (UIParent:GetScale() > 1) then
        xOffsetAdjustment = xOffsetAdjustment + (20*UIParent:GetScale());
      end      
      xOffset = xOffset + newLeft + xOffsetAdjustment;
      local availableSpace = MicroButtonAndBagsBar:GetLeft() - 16;
      scale = availableSpace / width;
    end
    self:SetScale(scale);
    self:SetPoint("BOTTOM", UIParent, "BOTTOM", -xOffset, 0);
    barRight = self:GetRight();
  end
  StatusTrackingBarManager:SetBarSize(rightMultiBarShowing);
end
__________________

Last edited by Xrystal : 05-13-18 at 06:01 PM.
  Reply With Quote
05-13-18, 07:04 PM   #3
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
I don't really know what they're trying to do. When I try to offset it with setpoint, the mainbar starts looking smaller. Why can't blizzard just make things simple. And create as a frame that can be moved around.

Well hoping someone can figure it out. The left side makes more sense since it would fit under the chat window. And that space is probably least used by most people.
  Reply With Quote
05-13-18, 08:57 PM   #4
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Ok I found a workaround not sure if this creates taint or not.


Code:
  MainMenuBarArtFrame.LeftEndCap:Hide()
  MainMenuBarArtFrame.RightEndCap:Hide()

  local OldMainMenuBarSetScale = MainMenuBar.SetScale

  MainMenuBar.SetScale = function()
    local Width = MainMenuBar:GetWidth() + 40
    MicroButtonAndBagsBar:SetPoint('BOTTOMRIGHT', -Width, 0)
    OldMainMenuBarSetScale(MainMenuBar, 1)
  end
This works even when the right bar is hidden. Let me know if this code is ok to use, and won't cause taint or other issues I may not know about.
Thanks

This is what it looks like
https://screenshots.firefox.com/GIH5ElMPzcLmuGgf/null
  Reply With Quote
05-13-18, 09:47 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
The way you can test taint, I believe, is to get in combat and see what happens when you interact or don't interact with the buttons.

I'm not sure if using the SetScale function like that is the best way to go, we used to use Hook functions/scripts for those sorts of things, but then they have changed quite a bit of their lua functionality since I last dabbled with my addons so I'm currently on a new learning curve while upgrading my addons.
__________________
  Reply With Quote
05-13-18, 11:19 PM   #6
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
I thought about hook. Long as that code is not secure code I should be good. I'll do some more testing.

Update: You're right it did taint. I did it thru hooksecurefunction. No taint.

Modified code
Code:
  
  local OldMainMenuBarSetScale = MainMenuBar.SetScale

  local function MySetScale()
    local Width = MainMenuBar:GetWidth() + 40
    MicroButtonAndBagsBar:SetPoint('BOTTOMRIGHT', -Width, 0)
    OldMainMenuBarSetScale(MainMenuBar, 1)
  end

  hooksecurefunc(MainMenuBar, 'SetScale', MySetScale)

Last edited by galvin : 05-14-18 at 12:11 AM.
  Reply With Quote
05-16-18, 07:09 PM   #7
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
I hit an issue. Once in a while in combat. The bag bar gets updated. Which causes the setscale function which is protected to give an error.
  Reply With Quote
05-17-18, 05:42 AM   #8
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
I'm not sure I understand it right. But hooksecure calls your code after calling the original code.
So you should not call it again in your function I think.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
05-17-18, 11:07 AM   #9
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
The bags bar gets repositioned at any time. Even during combat. I tried making it so it only does it out of combat. But sometimes the whole bar shrinks.

You have to call SetScale() in the function. But all the code is protected the main bar and bags bar.

For some reason if the bags bar is moved to the left side. Blizzard has code that will set the scale really small on the main bar.

Someone must know how to work around this?
  Reply With Quote
05-17-18, 02:26 PM   #10
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by galvin View Post
For some reason if the bags bar is moved to the left side. Blizzard has code that will set the scale really small on the main bar.

Someone must know how to work around this?
Lua Code:
  1. local availableSpace = MicroButtonAndBagsBar:GetLeft() - 16;
  2. scale = availableSpace / width;
  3. self:SetScale(scale);

It's in the quoted code. If the leftmost point of the microbar is on the left side of the rightmost point of the right gryphon, the bar will scale down, probably in a weird way since it's not expecting the negative offset to be that high. It's not "for some reason", it's because they're not expecting you to move the microbar to the left side.

Having that said, this piece of code isn't really top notch imo. They can solve this in a better way, and while beta is still on-going, maybe you should just ask Blizzard for a less hacky way to evaluate whether the two bars overlap.

Isn't it really just as easy as taking the space between the leftmost point of the left gryphon and the rightmost point of the right gryphon, adding it together with the width of the microbar and checking if it's the correct fraction of UIParent's total width? That way you would be able to put the microbar on the left side with ease.
__________________

Last edited by MunkDev : 05-17-18 at 02:34 PM.
  Reply With Quote
05-17-18, 03:26 PM   #11
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
No matter what I do i'll have to set the position of the microbar. After their code does. And that causes a protected function call error. Which I mentioned I did make it so it would only do it out of combat.

But sometimes blizzard calls their bar code during combat. And my whole bar UI shrinks down to unusable. Very bad if that were to happen in the middle of a raid.

I may just bite the bullet and recode the bar my self. Then find a way to hide the original. Just don't want to take a week or 2 figuring out how to do that.

Theres no way to put the bar on the left side without causing the main bar UI to scale down. I did the offset, cause setpoint on a different point wasn't working.
  Reply With Quote
05-18-18, 12:36 PM   #12
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by galvin View Post
Theres no way to put the bar on the left side without causing the main bar UI to scale down. I did the offset, cause setpoint on a different point wasn't working.
I don't think that's true.
Lua Code:
  1. MainMenuBar:UnregisterEvent("DISPLAY_SIZE_CHANGED");
  2. MainMenuBar:UnregisterEvent("UI_SCALE_CHANGED");

Write your own version of the function (or just copy it and run yours after), then make sure you don't call it in combat.
You might have to run the code again after a multibar update though.
__________________

Last edited by MunkDev : 05-18-18 at 12:39 PM.
  Reply With Quote
05-18-18, 04:15 PM   #13
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Don't think this can be done reliably. Going to pass. Also blizzards current implementation of the bags bar doesn't work too well with max ui scale. So they may have to ditch it. Or change it up.

Problem is this code can run in combat. And I don't want to break the bar to make my stuff work.

There is other events the bar gets called on. To make the bar work correctly. Which in turns calls the code to set the main menu bar again. Some of these things can happen in combat. Just not feasible.

Thanks though, I spent too much time on this.
  Reply With Quote
05-28-18, 09:42 PM   #14
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Finally did it without taint. Basically had to recreate the bar. But not as hard as I thought it would be.
Someone else can make it movable or what not.

UPDATE: Now handles enter/leaving a vehicle.

Code:
local function CreateBagsBar()

  -- Create a new frame and set the frame to the left of the mainmenubar frame
  local BagsBarFrame = CreateFrame('Frame', nil, MainMenuBar)

  BagsBarFrame:SetPoint('TOPRIGHT', MainMenuBarArtFrame.LeftEndCap, 'TOPLEFT', 40, 30)
  BagsBarFrame:Show()

  -- Load bags bar texture
  local BagsBarTexture = BagsBarFrame:CreateTexture()
  BagsBarTexture:SetAtlas('hud-MicroBagBar', true)
  BagsBarTexture:SetPoint('CENTER')
  BagsBarTexture:Show()

  local Width, Height = BagsBarTexture:GetSize()
  BagsBarFrame:SetSize(Width, Height)

  -- Attach blizzard bags and micro buttons to the frame
  MainMenuBarBackpackButton:SetParent(BagsBarFrame)
  CharacterBag0Slot:SetParent(BagsBarFrame)
  CharacterBag1Slot:SetParent(BagsBarFrame)
  CharacterBag2Slot:SetParent(BagsBarFrame)
  CharacterBag3Slot:SetParent(BagsBarFrame)

  MainMenuBarBackpackButton:ClearAllPoints()
  MainMenuBarBackpackButton:SetPoint('TOPRIGHT', -4, -4)

  -- Hide the orginal frame
  MicroButtonAndBagsBar:Hide()

  -- Hide the gryphons on the main menu bar
  MainMenuBarArtFrame.LeftEndCap:Hide()
  MainMenuBarArtFrame.RightEndCap:Hide()

  -- Handle placing the buttons back when ever the main menu bar gets hidden/shown.
  -- Such as enter vehicle then leaving
  local function MoveButtons()
    -- Move the micro buttons using blizzards function
    MoveMicroButtons('BOTTOMLEFT', BagsBarFrame, 'BOTTOMLEFT', 6, 3, false)
  end

  MoveButtons()

  -- Delay the move buttons call, so this happens after blizzards placement
  -- of the micro buttons.
  BagsBarFrame:SetScript('OnShow', function()
    C_Timer.After(0.30, MoveButtons)
  end)
end

Last edited by galvin : 05-29-18 at 05:40 PM.
  Reply With Quote

WoWInterface » PTR » PTR General Discussion » BfA - How can the bag bar be moved?

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