Thread Tools Display Modes
04-02-15, 09:22 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Adding Masque support

At Sorha's behest, I have been fixing Sorha's Quest Log; only one thing remains, and that is converting from the dead LibButtonFacade to Masque. Unfortunately, I am not following Masque's API in any way that does not involve tearing my hair out. I have looked at OpieMasque for inspiration, and it isn't helping.

This is what I have thus far. This is a mix of legacy code from LBF, and my attempts at updating.
Code:
-- main chunk
local Masque = LibStub("Masque", true)

-- AddOn defaults
-- Addon Setup
local defaults = {
	profile = {
		ButtonSkins = {
			SkinID = "DreamLayout",
			Gloss = 0,
			Backdrop = false,
			Colors = {},
			SQLItemButtons = {
				SkinID = "DreamLayout",
				Gloss = 0,
				Backdrop = false,
				Colors = {},
			},
		},
	},
}

-- OnInit()
if Masque then
	Masque:Register("SorhaQuestLog", self.SkinChanged)
end

-- SorhaQuestLog:SkinChanged()
-- more Masque stuff
--[[
function SorhaQuestLog:SkinChanged(SkinID, Gloss, Backdrop, Group, Button, Colors)
	if not(Group) then -- Addon level
		db.ButtonSkins.SkinID = SkinID
		db.ButtonSkins.Gloss = Gloss
		db.ButtonSkins.Backdrop = Backdrop
		db.ButtonSkins.Colors = Colors
	else			  -- Subgroup level
		db.ButtonSkins.SQLItemButtons.SkinID = SkinID
		db.ButtonSkins.SQLItemButtons.Gloss = Gloss
		db.ButtonSkins.SQLItemButtons.Backdrop = Backdrop
		db.ButtonSkins.SQLItemButtons.Colors = Colors	
	end
end
]]--
function SorhaQuestLog:SkinChanged()
	local g = Masque:Group("SorhaQuestLog")
	g:Skin(db.ButtonSkins.SkinID, db.ButtonSkins.Gloss, db.ButtonSkins.Backdrop, db.ButtonSkins.Colors)
end
  Reply With Quote
04-05-15, 11:54 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I don't see anything in the snippets you posted that actually register any buttons for Masque to skin?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-05-15, 07:46 PM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I cross posted when I rediscovered the Masque official forum; it has the latest code snippets, and some images.

http://forums.wowace.com/showthread.php?t=19661&page=20

As for registering buttons for skinning, that is the part I'm stuck on. I figured out that I do need to create a skin, and register the two buttons provided, but the original code that had LibButtonFacade didn't leave me much to work with in terms of looking at other people's code. Way too many missing values or values that don't match up to Masque's API.
  Reply With Quote
04-07-15, 10:23 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by myrroddin View Post
I figured out that I do need to create a skin ....
No, unless your addon actually bundles its own skin. You just need to tell Masque about your addon:

Code:
local Masque = LibStub("Masque", true)
local group = Masque:Group("MyAddon")
Then add each button your addon creates to the group:

Code:
group:AddButton(button)
If your buttons have a normal structure with the expected regions at the expected locations, that's all you need to do. If your buttons don't inherit from ActionButtonTemplate, don't have the same regions under the same keys (eg. button -> button.Cooldown) or with the same names (eg. MyButtonGlobalName -> MyButtonGlobalNameCooldown) then you need to additionally explain to Masque how your button works.

For example, if your button's icon texture is referenced only as button.ShinyRainbowThing, you'd need to tell Masque that:

Code:
local buttonData = {
    Icon = button.ShinyRainbowThing,
}
group:AddButton(button, buttonData)
This is also how you tell Masque to leave part of your button alone, either because you want to do something special with that part, or because that part doesn't even exist:

Code:
local buttonData = {
    Cooldown = false,
}
group:AddButton(button, buttonData)
You shouldn't need to register a callback unless you're doing something non-standard. For example, in my buff addon, I want the borders of temporary enchant icons to be purple all the time, no matter what skin the player is using or which color they chose for the border, so I use a callback to re-color those borders purple after Masque does its thing:

Code:
local function OnSkinChanged(_, _, skin, gloss, backdrop, colors, fonts)
	for i = 1, #PhanxTempEnchantFrame.buttons do
		PhanxTempEnchantFrame.buttons[i].border:SetVertexColor(0.46, 0.18, 0.67, 1)
	end
end

Masque:Register("PhanxBuffs", OnSkinChanged)
However, like I said, you probably don't need to worry about anything like that. I'm not even sure what buttons a quest log addon has, but they're probably not doing anything too exotic.

Edit:
You also don't need to do anything in your addon to store skin settings. Unlike its predecessors, Masque stores all that stuff itself; addons don't need to do anything in that area.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Adding Masque support

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