Thread Tools Display Modes
05-23-14, 10:50 PM   #1
Saurex
A Murloc Raider
Join Date: Apr 2014
Posts: 4
Recount Skin

So I played on a private server for a while which was running 3.3.5 and I made my self a recount skin based on TukUI. But for the past 3 months I have been playing on retail 5.4.7 (well .8 now) and I wanted to use my recount skin but it's not letting me. The code I used to access recount was

Code:
local function SkinFrame(frame)
	all my skinning code
end

local elements = {
	Recount.MainWindow,
	Recount.ConfigWindow,
	Recount.GraphWindow,
	Recount.DetailWindow,
	Recount.ResetFrame,
}
I am guessing something changed in the API that wont let me do that anymore... Anyone think they can help me out with this?

The code I posted above was just the parts I thought relevant.. here is the rest of it, with the exception of the recount button skinning since its very long and irrelevant.

Code:
local backdrop = {bgFile = "Interface\\AddOns\\BlastSkins\\textures\\blank", edgeFile = "Interface\\AddOns\\BlastSkins\\textures\\blank", tile = false, edgeSize = 1, insets = {left = 0, right = 0, top = 0, bottom = 0}}
local backdrop2 = {bgFile = "Interface\\AddOns\\BlastSkins\\textures\\blank", edgeFile = "Interface\\AddOns\\BlastSkins\\textures\\blank", tile = false, edgeSize = 1, insets = {left = -1, right = -1, top = 6, bottom = -1}}

local function SkinFrame(frame)
	frame.bgMain = CreateFrame("Frame", nil, frame)
	frame.bgMain:SetBackdrop(backdrop)
	frame.bgMain:SetBackdropColor(0.1,0.1,0.1,0.35)	
	frame.bgMain:SetBackdropBorderColor(0.6,0.6,0.6,1)
	frame.bgMain:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT")
	frame.bgMain:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT")
	frame.bgMain:SetPoint("TOP", frame, "TOP", 0, -7)
	frame.bgMain:SetFrameLevel(frame:GetFrameLevel())
	frame.CloseButton:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -1, -9)
	frame:SetBackdrop(backdrop2)
	frame:SetBackdropColor(0.1,0.1,0.1,0.35)	
	frame:SetBackdropBorderColor(0.6,0.6,0.6,0)
	frame.TitleBackground = CreateFrame("Frame", nil, frame.bgMain)
	frame.TitleBackground:SetPoint("TOP", 0)
	frame.TitleBackground:SetPoint("LEFT", 0)
	frame.TitleBackground:SetPoint("RIGHT", 0)
	frame.TitleBackground:SetHeight(24)
	frame.TitleBackground:SetBackdrop(backdrop)
	frame.TitleBackground:SetBackdropColor(0.1,0.1,0.1)	
	frame.TitleBackground:SetBackdropBorderColor(0.6,0.6,0.6)
	frame.Title:SetFont("Interface\\AddOns\\SharedMedia_MyMedia\\font\\TukNormal.ttf", 11)
	frame.Title:SetParent(frame.TitleBackground)
	frame.Title:ClearAllPoints()
	frame.Title:SetPoint("LEFT", 4, 0)
	frame.CloseButton:SetNormalTexture("")
	frame.CloseButton:SetPushedTexture("")
	frame.CloseButton:SetHighlightTexture("")
	frame.CloseButton.t = frame.CloseButton:CreateFontString(nil, "OVERLAY")
	frame.CloseButton.t:SetFont("Interface\\AddOns\\SharedMedia_MyMedia\\font\\TukPixel.ttf", 12)
	frame.CloseButton.t:SetPoint("CENTER", -2, 2)
	frame.CloseButton.t:SetText("X")
end

Recount.UpdateBarTextures = function(self)
	for k, v in pairs(Recount.MainWindow.Rows) do
		v.StatusBar:SetStatusBarTexture("Interface\\AddOns\\SharedMedia_MyMedia\\statusbar\\DsmV3")
		v.StatusBar:GetStatusBarTexture():SetHorizTile(false)
		v.StatusBar:GetStatusBarTexture():SetVertTile(false)
		v.LeftText:SetPoint("LEFT", 4, 1)
		v.LeftText:SetFont("Interface\\AddOns\\SharedMedia_MyMedia\\font\\TukNormal.ttf", 12)
		v.RightText:SetPoint("RIGHT", -4, 1)
		v.RightText:SetFont("Interface\\AddOns\\SharedMedia_MyMedia\\font\\TukNormal.ttf", 12)
	end
end
Recount.SetBarTextures = Recount.UpdateBarTextures

-- Fix bar textures as they\'re created
Recount.SetupBar_ = Recount.SetupBar
Recount.SetupBar = function(self, bar)
	self:SetupBar_(bar)
	bar.StatusBar:SetStatusBarTexture("Interface\\AddOns\\SharedMedia_MyMedia\\statusbar\\DsmV3")
end

-- Skin frames when they\'re created
Recount.CreateFrame_ = Recount.CreateFrame
Recount.CreateFrame = function(self, Name, Title, Height, Width, ShowFunc, HideFunc)
	local frame = self:CreateFrame_(Name, Title, Height, Width, ShowFunc, HideFunc)
	SkinFrame(frame)
	return frame
end

-- frame we want to skins
local elements = {
	Recount.MainWindow,
	Recount.ConfigWindow,
	Recount.GraphWindow,
	Recount.DetailWindow,
	Recount.ResetFrame,
}

-- skin them
for i = 1, getn(elements) do
	local frame = elements[i]
	if frame then
		SkinFrame(frame)
	end
end

--Update Textures
Recount:UpdateBarTextures()
  Reply With Quote
05-23-14, 11:19 PM   #2
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
This is a official fan site I highly suggest removing the mention of a private server from your post.
__________________
Tweets YouTube Website
  Reply With Quote
05-24-14, 12:09 AM   #3
Saurex
A Murloc Raider
Join Date: Apr 2014
Posts: 4
Originally Posted by 10leej View Post
This is a official fan site I highly suggest removing the mention of a private server from your post.
I agree but I am not playing on it anymore and I am not asking for help to create an addon compatible with it either. I just want to make a working recount skin for 5.4.8
  Reply With Quote
05-24-14, 01:30 AM   #4
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
- Have you tried installing BugSack and seeing if there are errors?
- Have you tried debugging with some print commands (or tekDebug / Spew)?
  Reply With Quote
05-24-14, 02:07 AM   #5
repooc
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Oct 2008
Posts: 10
Considering you are familiar with how Tukui implementation was back then, you should check out how AddonSkins Tukui does it. Since Tukz and Elvz no longer handle the skinning now with in Tukui/ElvUI you can view the addon that handles it now and get an idea how its handled.
  Reply With Quote
05-24-14, 07:19 PM   #6
Saurex
A Murloc Raider
Join Date: Apr 2014
Posts: 4
Here is the specific error I get:

Code:
3x CustomSkins\recountskin.lua:48: attempt to index global "Recount" (a nil value)
CustomSkins\recountskin.lua:48: in main chunk

Locals:
That line is calling Recount. If I delete that line it and /reload it will just throw an error where ever the next line calling Recount is.
  Reply With Quote
05-24-14, 10:52 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That error means that Recount has not yet loaded when your addon is loading. On most filesystems, addons are loaded in alphabetical order, and "CustomSkins" comes before "Recount" in alphabetical order. There are three basic ways to solve this problem:

1. Add Recount to your addon's list of dependencies in its TOC file so WoW will load Recount out of order before your addon, and won't load your addon unless Recount is loaded first. This is the simplest method, but has the obvious disadvantage of making your addon impossible to use without Recount, and based on the fact that you named it "CustomSkins" I'm guessing it skins other addons as well, so you probably do not want to use this method.

Code:
## Dependencies: Recount
2. Add Recount to your addon's optional dependencies, so WoW will load Recount out of order before your addon if it's available, but load your addon anyway if it's not, and then also add a check at the top of your Recount skin file that checks that Recount is actually present before running the rest of the code. This is also fairly simple, but if your addon skins many addons, your list of optional dependencies can get quite long and unwieldy.

Code:
## OptionalDependencies: Recount
Code:
if not Recount then return end
3. Listen for the ADDON_LOADED event to detect when Recount loads, and don't try to skin it before then. This is the most complicated method, but if you're skinning a lot of addons, it's the way I'd recommend:

Code:
local function SkinRecount()
     -- insert your skinning code here
end

if Recount then
     SkinRecount()
else
     local f = CreateFrame("Frame")
     f:RegisterEvent("ADDON_LOADED")
     f:SetScript("OnEvent", function(self, event, addon)
          if addon == "Recount" then
               self:UnregisterEvent(event)
               SkinRecount()
          end
     end)
end
Alternatively, you could set up a more centralized system wherein the core handled checking for addons and listening for addon loading events, and the individual addon skin files just registered their skins:

Code:
-- Core:
local _, skins = ...
local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, addon)
     local func = skins[addon]
     if func then
          func()
          skins[addon] = nil
     end
     if not next(skins) then
          self:UnregisterEvent(event)
          self:SetScript("OnEvent", nil)
     end
end)
Code:
-- Addon skin:
local _, skins = ...
skins["Recount"] = function()
     -- insert your skinning code here
end
__________________
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
05-24-14, 11:41 PM   #8
Saurex
A Murloc Raider
Join Date: Apr 2014
Posts: 4
Originally Posted by Phanx View Post
That error means that Recount has not yet loaded when your addon is loading. On most filesystems, addons are loaded in alphabetical order, and "CustomSkins" comes before "Recount" in alphabetical order.
Wow. Very weird. I already had the optional dependency set up as I only skin 4 addons. For some reason even setting the mandatory dependency results in the error. However the ADDON_LOADED method worked perfectly. Thank you so much.

Last edited by Saurex : 05-25-14 at 12:18 AM.
  Reply With Quote
05-24-14, 11:56 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Some addons may not create their global objects until their own ADDON_LOADED event, so a simple dependency may not always work, and in some cases you may even need to get more creative if the addon uses a more esoteric method of creating its object(s).

(Also, quoting all 500 lines of a post results in a huge amount of annoyingly unnecessary scrolling. )
__________________
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 » Recount Skin


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