Persistent Theme Customization

76 views
Skip to first unread message

Daniel

unread,
Feb 24, 2011, 8:36:43 AM2/24/11
to Tidy Plates
When a user wants to customize their copy of a bundled theme, they
usually just edit the theme file directly. The advantage of this
method is that it's pretty easy. The biggest downside is that when
Tidy Plates and it's packaged themes are updated, you'd have to redo
all of your changes. But, there's another way...

1. Under your addons folder, create a folder called,
"TidyPlates_Custom"

2. Create a file under that folder, called "TidyPlates_Custom.toc"

3. Open up "TidyPlates_Custom.toc" and paste this:

## Interface: 40000
## Title: Tidy Plates: Customizations
## Dependencies: TidyPlates_Quatre

Custom.lua

4. On the line containing, "## Dependencies: TidyPlates_Quatre",
change "TidyPlates_Quatre" to the name of the folder of the theme you
want to customize. This will load your customizations AFTER the theme
has been created.

5. Save the .TOC file, and create another file, called "Custom.lua".
Paste this:

local ThemeName = "Quatre/|cFFFF4400Damage"
local Theme = TidyPlatesThemeList[ThemeName]

Theme.name.typeface = "FONTS\\FRIZQT__.TTF"

6. With the above code, "Custom.lua" changes the font for "Quatre/
Damage". You can change the target theme by editing the ThemeName.
In the above example, you can see that I needed to use the complete
string, with color information embedded, since that's what is stored
in the list. You can find the exact string by looking for
"TidyPlatesThemeList" in the theme's LUA file.

7. Add your own customizations. Clever users can even hook the
delegate functions to extended functionality to the mechanics.
Example:

local OriginalScaleFunction
OriginalScaleFunction = Theme.SetScale

local function NewScaleFunction(...)
local unit = ...
if unit.name == "Rat" then return 2
else return OriginalScaleFunction(...) end
end

Theme.SetScale = NewScaleFunction

8. Enjoy!





Daniel

unread,
Mar 17, 2011, 3:19:26 AM3/17/11
to Tidy Plates
Here's another example of what could go into Custom.lua, based on
changing parts of the 'name' element.

[CODE]
local ThemeName = "Neon/|cFFFF4400Damage"
local Theme = TidyPlatesThemeList[ThemeName]
local Style = Theme["Default"]
Style.name.y = 0
[/CODE]

The first three lines are basically just grabbing a reference to the
existing data table. Because the references are defined as 'local',
we can use simple names like, 'Theme'.

Neon uses the 'multi-style' feature of Tidy Plates, which is like
allowing multiple themes within the same file. A special function
controls which one gets shown. As a consequence, there's that extra
line of code, which grabs that 'Style' table. With single-style
themes (Grey and Quatre), you don't need to do the 'Style' thing, you
can edit the 'Theme' itself.

If you want to change both themes at the same time, you could do
something like this:

[CODE]
local ThemeName = "Neon/|cFFFF4400Damage"
local Theme = TidyPlatesThemeList[ThemeName]
local Style = Theme["Default"]
Style.name.y = 0

ThemeName = "Neon/|cFF3782D1Tank"
Theme = TidyPlatesThemeList[ThemeName]
Style = Theme["Default"]
Style.name.y = 0
[/CODE]

Why this works: We've defined local variables, which we fill with
references to the actual theme tables. After making the changes to
the 'Damage' theme, we can reuse those variables to get the next
reference for the 'Tank' theme.

You could also overwrite all properties of an element by doing this:

[CODE]
local font = "Interface\\Addons\\CustomFonts\\Font.ttf"
local ThemeName = "Neon/|cFFFF4400Damage"
local Theme = TidyPlatesThemeList[ThemeName]
local Style = Theme["Default"]
Style.name = {
typeface = font,
size = 12,
width = 200,
height = 11,
x = 0,
y = 1,
align = "CENTER",
anchor = "CENTER",
vertical = "CENTER",
shadow = true,
}
[/CODE]

The "Style.name = {}" means that we're creating a new array of data
for 'name', and replacing the old table. You can see how I've defined
the 'font' variable, which I've used within the 'typeface' definition.
Reply all
Reply to author
Forward
0 new messages