Page 1 of 1

Tukui Classic: T00LKIT Help

Posted: Sat Sep 07, 2019 11:08 pm
by Luaerror

I'm remaking my own tukui edit to support WoW Classic, but I'm having some difficulties to work with this T00LKIT.
I want to change the SetTemplate function to use old the 3px border as default. On the previuos version of tukui I used to have a Api.lua to override this SetTemplate, like this:

Code: Select all

local T, C, L = Tukui:unpack()

-- API: Read DOCS\API.txt for more informations.
-- Override previous Tukui SetOutside function.
local function SetOutside(obj, anchor, xOffset, yOffset)
	xOffset = xOffset or 2
	yOffset = yOffset or 2
	anchor = anchor or obj:GetParent()

	if obj:GetPoint() then obj:ClearAllPoints() end

	obj:Point("TOPLEFT", anchor, "TOPLEFT", -xOffset, yOffset)
	obj:Point("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", xOffset, -yOffset)

-- Override previous Tukui SetInside function.
local function SetInside(obj, anchor, xOffset, yOffset)
	xOffset = xOffset or 2
	yOffset = yOffset or 2
	anchor = anchor or obj:GetParent()

	if obj:GetPoint() then obj:ClearAllPoints() end

	obj:Point("TOPLEFT", anchor, "TOPLEFT", xOffset, -yOffset)
	obj:Point("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", -xOffset, yOffset)

-- Override previous Tukui SetTemplte function. (old tukui border)
local function SetTemplate(f, t, tex)
	local balpha = 1
	if t == "Transparent" then balpha = 0.8 end
	local borderr, borderg, borderb = unpack(C.General.BorderColor)
	local backdropr, backdropg, backdropb = unpack(C.General.BackdropColor)
	local backdropa = balpha
	local texture = C.Medias.Blank

	if tex then
		texture = C.Medias.Normal

		bgFile = texture,
		edgeFile = C.Medias.Blank,
		tile = false, tileSize = 0, edgeSize = T.Scale(1),

	if (not f.isInsetDone) then
		f.insettop = f:CreateTexture(nil, "BORDER")
		f.insettop:Point("TOPLEFT", f, "TOPLEFT", -1, 1)
		f.insettop:Point("TOPRIGHT", f, "TOPRIGHT", 1, -1)
		f.insettop:SetDrawLayer("BORDER", -7)

		f.insetbottom = f:CreateTexture(nil, "BORDER")
		f.insetbottom:Point("BOTTOMLEFT", f, "BOTTOMLEFT", -1, -1)
		f.insetbottom:Point("BOTTOMRIGHT", f, "BOTTOMRIGHT", 1, -1)
		f.insetbottom:SetDrawLayer("BORDER", -7)

		f.insetleft = f:CreateTexture(nil, "BORDER")
		f.insetleft:Point("TOPLEFT", f, "TOPLEFT", -1, 1)
		f.insetleft:Point("BOTTOMLEFT", f, "BOTTOMLEFT", 1, -1)
		f.insetleft:SetDrawLayer("BORDER", -7)

		f.insetright = f:CreateTexture(nil, "BORDER")
		f.insetright:Point("TOPRIGHT", f, "TOPRIGHT", 1, 1)
		f.insetright:Point("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, -1)
		f.insetright:SetDrawLayer("BORDER", -7)

		f.insetinsidetop = f:CreateTexture(nil, "BORDER")
		f.insetinsidetop:Point("TOPLEFT", f, "TOPLEFT", 1, -1)
		f.insetinsidetop:Point("TOPRIGHT", f, "TOPRIGHT", -1, 1)
		f.insetinsidetop:SetDrawLayer("BORDER", -7)

		f.insetinsidebottom = f:CreateTexture(nil, "BORDER")
		f.insetinsidebottom:Point("BOTTOMLEFT", f, "BOTTOMLEFT", 1, 1)
		f.insetinsidebottom:Point("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1)
		f.insetinsidebottom:SetDrawLayer("BORDER", -7)

		f.insetinsideleft = f:CreateTexture(nil, "BORDER")
		f.insetinsideleft:Point("TOPLEFT", f, "TOPLEFT", 1, -1)
		f.insetinsideleft:Point("BOTTOMLEFT", f, "BOTTOMLEFT", -1, 1)
		f.insetinsideleft:SetDrawLayer("BORDER", -7)

		f.insetinsideright = f:CreateTexture(nil, "BORDER")
		f.insetinsideright:Point("TOPRIGHT", f, "TOPRIGHT", -1, -1)
		f.insetinsideright:Point("BOTTOMRIGHT", f, "BOTTOMRIGHT", 1, 1)
		f.insetinsideright:SetDrawLayer("BORDER", -7)

		f.isInsetDone = true

	f:SetBackdropColor(backdropr, backdropg, backdropb, backdropa)
	f:SetBackdropBorderColor(borderr, borderg, borderb)

local borders = {

-- hide insets (border)
local function HideInsets(f)
	for i, border in pairs(borders) do
		if f[border] then

-- Merge Tukui API with WoW API

local function AddAPI(object)
	local mt = getmetatable(object).__index

    -- override existing API
	mt.SetOutside = SetOutside
	mt.SetInside = SetInside
	mt.SetTemplate = SetTemplate
	mt.HideInsets = HideInsets

    -- create new API
	-- if not object.Kill then mt.Kill = Kill end

local Handled = {["Frame"] = true}

local Object = CreateFrame("Frame")

Object = EnumerateFrames()

while Object do
	if not Object:IsForbidden() and not Handled[Object:GetObjectType()] then
		Handled[Object:GetObjectType()] = true

	Object = EnumerateFrames(Object)
So, how can achieve the same result using this T00LKIT?

obs.: I know I can use like this:

Code: Select all

frame:SetTemplate("Default", C.Medias.Blank, "Triple")
but I don't like it, since that are some frames that it don't seem to work (like TabsBGLeft, DatatextLeft, ...)
besides that, when i use on frames like ExpirenceBar, the status bar cover the border.

Tukui Classic: T00LKIT Help

Posted: Sun Sep 08, 2019 1:51 am
by Tukz
To overwrite a function, just overwrite the function in the T00LKIT.API table. The global variable for the toolkit is T00LKIT. (Zero instead of O, I recommend copy/paste my variable global name) Example:

Code: Select all

T00LKIT.API.SetTemplate = function(self, BackgroundTemplate, BackgroundTexture, BorderTemplate)
	-- your new overwrite function here
Also, any new function created in T00LKIT.API table will also be automatically added to toolkit API.

Code: Select all

T00LKIT.API.MyNewFunction= function(self, ...)
	-- blah blah

Frame:MyNewFunction() -- you can now use your new function
However I do not recommend to overwrite functions, because it could break some authors plugins. Keep that in mind.

Also, as a note, make sure your edit have the "## OptionalDeps: Tukui" line in Tukui, in order to make sure Tukui load before your plugin. Example with one of my plugin:

Code: Select all

## Interface: 11302
## Author: Tukz
## X-Maintainer: Tukz
## Version: 1
## Title: |cffff8000Tukui World Font|r
## Notes: Changes your damage font to something else
## OptionalDeps: Tukui
## X-Tukui-ProjectID: 16
## X-Tukui-ProjectFolders: TukuiWorldFont


Tukui Classic: T00LKIT Help

Posted: Sun Sep 08, 2019 3:07 pm
by Luaerror
Tukz, thank you very much for replaying.

Well... I not sure what I'm doing wrong, but I've tried these methods a few times with no success.

I tested hooksecurefunc, without success too.

Code: Select all

local SetTemplate = function(self, BackgroundTemplate, BackgroundTexture, BorderTemplate)
	-- code
hooksecurefunc(T00LKIT.API, "SetTemplate", SetTemplate)
I noticed that i can't print toolkit settings, like:

Code: Select all

for key, value in pairs(T00LKIT.Settings) do 
	print(key, ": ", value)
So, how can I change this T00LKIT functions to make this change affect all frames that already use it?

Tukui Classic: T00LKIT Help

Posted: Sun Sep 08, 2019 3:56 pm
by Tukz
/dump T00LKIT <- it should return a table value

if not, then refer to what i've sais about the toc, you need to make sure your plugin load after Tukui.

hooksecurefunc is not needed anymore with this toolkit.

Will make a quick addon example that you will be able to download in 2-3 hours when i will be back home.

Tukui Classic: T00LKIT Help

Posted: Sun Sep 08, 2019 5:26 pm
by Luaerror
For dependencies, I have set ##RequiredDeps: Tukui. Should I change?

Tukui Classic: T00LKIT Help

Posted: Thu Sep 19, 2019 7:05 pm
by Pat
Luaerror wrote:
Sun Sep 08, 2019 5:26 pm
For dependencies, I have set ##RequiredDeps: Tukui. Should I change?
no, that's fine it means your Addon will only load after Tukui has loaded.