View Single Post
12-17-13, 09:37 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I think Masque handles this situation pretty well.

Addons can register a skin with Masque by passing it a table describing the skin. For Masque, this table just contains strings and numbers describing the position and size of each texture, but for Aurora you would probably want functions, eg:

Code:
Aurora:RegisterSkin("MySkin", {
     SkinFrame = function(frame, settings)
          -- Aurora calls this to skin the specified frame. The plugin can just
          -- use SetBackdrop if that's all it wants to do, or it could add some
          -- texture objects, a background frame, etc.
     end,
     ApplySettings = function(frame, settings)
          -- Aurora calls this for each skinned frame when settings are
          -- changed. The plugin should do whatever is needed to apply
          -- the new settings.
     end,
     settings = {
          -- A table describing the settings the frame makes available.
          -- I'd model the format on AceOptions so you can easily
          -- construct the appropriate options GUI in Aurora.
          color = {
               type = "color",
               default = { r = 0.2, g = 0.2, b = 0.2 },
          },
          opacity = {
               type = "range", min = 0, max = 1, isPercent = true,
               default = 0.8,
          },
          showBackdrop = {
               type = "boolean",
               default = true,
          },
     },
})
The settings for each skin are saved by Aurora, eg:

Code:
Aurora.db = {
     profile = {
          ["Default"] = {
               selectedSkin = "MySkin",
               skinData = {
                    ["MySkin"] = {
                         color = { r = 0.5, g = 0, b = 0.5 },
                         opacity = 1,
                         showBackground = true,
                    },
                    ["OtherSkin"] = {
                         color1 = { r = 1, g = 1, b = 1 },
                         color2 = { r = 0, g = 0, b = 0 },
                         useGradient = false,
                    }
          }
     }
}
Then, whenever one of the skin's functions are called, it's passed (1) a reference to the frame it should do something with, and (b) a reference to the skin's saved settings table, eg:

Code:
settings = {
     color = { r = 0.5, g = 0, b = 0.5 },
     opacity = 1,
     showBackground = true,
}
__________________
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