Dominos

Dominos

19M Downloads

Enhanced Micro Menu

Goranaws opened this issue ยท 13 comments

commented

Thought it may be a possibility to have it so that you can choose to hide specific buttons from the micro menu. I always use hot-keys to bring certain things like my spellbook, talents, and achievements. It would be nice to be able to hide those buttons from the MicroMenu. One problem I have found with attempting this, is that you can't just hide the icons as they leave a blank gap on the micro menu where they are usually placed. I have made my own addon to do this, but it lacks any in-game modification... in order to do anything with you have to alter the LUA file for it. The best possible implementation of this would to probably make new check box buttons on the advance menu for the micro menu that can be used to hide specific buttons. (here's a link to my addon... it's written really simple... and is kinda crappy. http://wow.curse.com/downloads/wow-addons/details/configuredx.aspx)

commented

Good Point, That may be possible... Since I've learned quite a bit since messing with this idea, I think that I might be able to do it now. I have an idea, but it's nearly impossible for me to explain since I don't know most of the coding terminology... I'll mess with the code a little bit and then send it to you if I get anywhere.

commented

The next comment is what I've got so far. I think this rewrite may allow us to do as my initial comment on this page suggests...

commented

local menuButtons
local NUM_BUTTONS = 10
local MenuBar = Dominos:CreateClass('Frame', Dominos.Frame)
Dominos.MenuBar = MenuBar
--[[ Menu Bar ]]--
function MenuBar:New()
local f = self.super.New(self, 'menu')
f:GenerateButtons()
f:LoadButtons()
f:Layout()
return f
end
function MenuBar:GetDefaults()
return {
point = 'BOTTOMRIGHT',
x = -244,
y = 0,
}
end
function MenuBar:NumButtons()
return self.sets.numButtons or NUM_BUTTONS
end
function MenuBar:AddButton(i)
local b = menuButtons[i]
b:SetParent(self.header)
self.buttons[i] = b
end
function MenuBar:RemoveButton(i)
local b = self.buttons[i]
b:SetParent(nil)
b:Hide()
self.buttons[i] = nil
end
function MenuBar:GenerateButtons()
local loadButtons = function(...)
menuButtons = {}
for i = 1, select('#', ...) do
local b = select(i, ...)
local name = b:GetName()
if name and name:match('(%w+)MicroButton$') then
table.insert(menuButtons, b)
end
end
end
loadButtons(_G['MainMenuBarArtFrame']:GetChildren())
end
local WIDTH_OFFSET = 2
local HEIGHT_OFFSET = 20

function MenuBar:Layout()
if #self.buttons > 0 then
local cols = min(self:NumColumns(), #self.buttons)
local rows = ceil(#self.buttons / cols)
local pW, pH = self:GetPadding()
local spacing = self:GetSpacing()

    local b = self.buttons[1]
    local w = b:GetWidth() + spacing - WIDTH_OFFSET
    local h = b:GetHeight() + spacing - HEIGHT_OFFSET

    for i,b in pairs(self.buttons) do
        local col = (i-1) % cols
        local row = ceil(i / cols) - 1
        b:ClearAllPoints()
        b:SetPoint('TOPLEFT', w*col + pW, -(h*row + pH) + HEIGHT_OFFSET)
    end

    self:SetWidth(max(w*cols - spacing + pW*2 + WIDTH_OFFSET, 8))
    self:SetHeight(max(h*ceil(#self.buttons/cols) - spacing + pH*2, 8))
else
    self:SetWidth(30); self:SetHeight(30)
end

end
--[[ Menu Code ]]--
local function AddSizeSlider(p)
local L = LibStub('AceLocale-3.0'):GetLocale('Dominos-Config')
local size = p:NewSlider(L.Size, 1, 1, 1)
size.OnShow = function(self)
self:SetMinMaxValues(1, NUM_BUTTONS)
self:SetValue(self:GetParent().owner:NumButtons())
end
size.UpdateValue = function(self, value)
self:GetParent().owner:SetNumButtons(value)
_G[self:GetParent():GetName() .. L.Columns]:OnShow()
end
end
local function AddLayoutPanel(menu)
local p = menu:NewPanel(LibStub('AceLocale-3.0'):GetLocale('Dominos-Config').Layout)
p:NewOpacitySlider()
p:NewFadeSlider()
p:NewScaleSlider()
p:NewPaddingSlider()
p:NewSpacingSlider()
p:NewColumnsSlider()
AddSizeSlider(p)
end
local function AddAdvancedLayout(self)
self:AddAdvancedPanel()
end
function MenuBar:CreateMenu()
local menu = Dominos:NewMenu(self.id)
AddLayoutPanel(menu)
AddAdvancedLayout(menu)
self.menu = menu
end

commented

One thing to note about this: The micro menu bar needs to remain dynamically generated. In 4.2, for example, I like that I require no code changes even though Blizzard has implemented an extra button on the bar for the new dungeon guide feature :)

commented

Yup, the buttons don't reappear properly... I'm not sure why though, that'll take some more testing. And I'm currently working on a way to remove specific buttons, but so far, it would apply only after logging out and back in.

commented

From testing:

  • If you shrink the bar, then the buttons do not reappear when you show the bar again.
  • I've not noticed a way to hide a specific button, without hiding any buttons after it as well.
commented

Issue one is fixed. really simple too... I changed the following:

function MenuBar:AddButton(i)
local b = menuButtons[i]
b:SetParent(self.header)
self.buttons[i] = b
end

so that it is now

function MenuBar:AddButton(i)
local b = menuButtons[i]
b:SetParent(self.header)
b:Show()
self.buttons[i] = b
end

commented

oh, also made a few more changes than that...in the next comment

commented

local menuButtons
local MenuBar = Dominos:CreateClass('Frame', Dominos.Frame)
Dominos.MenuBar = MenuBar
--[[ Menu Bar ]]--
function MenuBar:New()
local f = self.super.New(self, 'menu')
f:GenerateButtons()
f:LoadButtons()
f:Layout()
return f
end
function MenuBar:GetDefaults()
return {
point = 'BOTTOMRIGHT',
x = -244,
y = 0,
}
end
function MenuBar:NumButtons()
return self.sets.numButtons or #menuButtons
end
function MenuBar:AddButton(i)
local b = menuButtons[i]
b:SetParent(self.header)
b:Show()
self.buttons[i] = b
end
function MenuBar:RemoveButton(i)
local b = self.buttons[i]
b:SetParent(nil)
b:Hide()
self.buttons[i] = nil
end
function MenuBar:GenerateButtons()
local loadButtons = function(...)
menuButtons = {}
for i = 1, select('#', ...) do
local b = select(i, ...)
local name = b:GetName()
if name and name:match('(%w+)MicroButton$') then
table.insert(menuButtons, b)
end
end
end
loadButtons(_G['MainMenuBarArtFrame']:GetChildren())
end
local WIDTH_OFFSET = 2
local HEIGHT_OFFSET = 20
function MenuBar:Layout()
if #self.buttons > 0 then
local cols = min(self:NumColumns(), #self.buttons)
local rows = ceil(#self.buttons / cols)
local pW, pH = self:GetPadding()
local spacing = self:GetSpacing()
local b = self.buttons[1]
local w = b:GetWidth() + spacing - WIDTH_OFFSET
local h = b:GetHeight() + spacing - HEIGHT_OFFSET
for i,b in pairs(self.buttons) do
local col = (i-1) % cols
local row = ceil(i / cols) - 1
b:ClearAllPoints()
b:SetPoint('TOPLEFT', w_col + pW, -(h_row + pH) + HEIGHT_OFFSET)
end
self:SetWidth(max(w_cols - spacing + pW_2 + WIDTH_OFFSET, 8))
self:SetHeight(max(h_ceil(#self.buttons/cols) - spacing + pH_2, 8))
else
self:SetWidth(30); self:SetHeight(30)
end
end
--[[ Menu Code ]]--
local function AddSizeSlider(p)
local L = LibStub('AceLocale-3.0'):GetLocale('Dominos-Config')
local size = p:NewSlider(L.Size, 1, 1, 1)
size.OnShow = function(self)
self:SetMinMaxValues(1, #menuButtons)
self:SetValue(self:GetParent().owner:NumButtons())
end
size.UpdateValue = function(self, value)
self:GetParent().owner:SetNumButtons(value)
_G[self:GetParent():GetName() .. L.Columns]:OnShow()
end
end
local function AddLayoutPanel(menu)
local p = menu:NewPanel(LibStub('AceLocale-3.0'):GetLocale('Dominos-Config').Layout)
p:NewOpacitySlider()
p:NewFadeSlider()
p:NewScaleSlider()
p:NewPaddingSlider()
p:NewSpacingSlider()
p:NewColumnsSlider()
AddSizeSlider(p)
end
local function AddAdvancedLayout(self)
self:AddAdvancedPanel()
end
function MenuBar:CreateMenu()
local menu = Dominos:NewMenu(self.id)
AddLayoutPanel(menu)
AddAdvancedLayout(menu)
self.menu = menu
end

commented

The changes allow for other addons that may add buttons to the MicroMenu. I actually use one that moves the friends button from the chat frame to the MicroMenu. And I can't get it to hide a specific button and not he ones after it... I'll havta look at it some other time, as I'm heading out to dinner right now.

commented

Posting to mark that I've read this. Its not too terribly difficult to do, but it's also not something high on my list to do.

commented

With some minor rewriting, I've made progress trying to do this myself. I've got the checkbutton displaying in game on only the micro menu, however, I just can't get it to function porperly.

Here's the original bit of code I've utilized as my template to try do this:

function REP:SetAlwaysShowREP(enable)
self.sets.alwaysShowREP = enable

end
function REP:ToggleText(enable)
self.sets.alwaysShowText = enable or nil
self:UpdateTextShown()
end
local showText = p:NewCheckButton(L.AlwaysShowText)
showText:SetScript('OnClick', function(self) self:GetParent().owner:ToggleText(self:GetChecked()) end)
showText:SetScript('OnShow', function(self) self:SetChecked(self:SetParent().owner.sets.alwaysShowText) end)

end

I didn't provide the modified version as it wasn't working... My question is how do I rewrite it to get it working?

commented

Might help if I provide the rewrites I had to do else where in the menuBar.lua code.

CreateFrame("Frame", "MicroButtonsFrame", MainMenuBar);
CharacterMicroButton:SetParent(MicroButtonsFrame);
SpellbookMicroButton:SetParent(MicroButtonsFrame);
QuestLogMicroButton:SetParent(MicroButtonsFrame);
GuildMicroButton:SetParent(MicroButtonsFrame);
TalentMicroButton:SetParent(MicroButtonsFrame);
AchievementMicroButton:SetParent(MicroButtonsFrame);
PVPMicroButton:SetParent(MicroButtonsFrame);
LFDMicroButton:SetParent(MicroButtonsFrame);
MainMenuMicroButton:SetParent(MicroButtonsFrame);
HelpMicroButton:SetParent(MicroButtonsFrame);
loadButtons(_G['MicroButtonsFrame']:GetChildren())

I found this to be necessary in order to get it to recognized what buttons are being pointed at. Also here is the modified version of the previoulsy posted code:

function MenuBar:SetAlwaysShowCharacter(enable)
self.sets.alwaysShowCharacter = enable
end
function MenuBar:ToggleCharacter(enable)
self.sets.alwaysShowCharacter = enable or nil
end

local showCharacter = p:NewCheckButton(L.AlwaysShowCharacter)
showCharacter:SetScript('OnClick', function(self) self:GetParent(MicroButtonsFrame).owner:ToggleCharacter(self:GetChecked()) end)
showCharacter:SetScript('OnShow', function(self) self:SetChecked(CharacterMicroButton:Hide() end)

Pretty sure I've screwed it up, or forgotten something