You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.1 KiB

4 years ago
local DF = _G ["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
end
local _
local rawset = rawset --lua local
local rawget = rawget --lua local
4 years ago
local APIHelpFunctions = false
local HelpMetaFunctions = {}
local get_members_function_index = {}
3 years ago
HelpMetaFunctions.__index = function(_table, _member_requested)
4 years ago
local func = get_members_function_index [_member_requested]
if (func) then
return func (_table, _member_requested)
end
local fromMe = rawget (_table, _member_requested)
4 years ago
if (fromMe) then
return fromMe
end
return HelpMetaFunctions [_member_requested]
end
local set_members_function_index = {}
3 years ago
HelpMetaFunctions.__newindex = function(_table, _key, _value)
4 years ago
local func = set_members_function_index [_key]
if (func) then
return func (_table, _value)
else
return rawset (_table, _key, _value)
4 years ago
end
end
function HelpMetaFunctions:AddHelp (width, height, x, y, buttonX, buttonY, text, anchor)
self.helpTable [#self.helpTable + 1] = {
HighLightBox = {x = x, y = y, width = width, height = height},
ButtonPos = { x = buttonX, y = buttonY},
ToolTipDir = anchor or "RIGHT",
ToolTipText = text
}
end
3 years ago
function HelpMetaFunctions:SetPoint(v1, v2, v3, v4, v5)
4 years ago
v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
if (not v1) then
3 years ago
print("Invalid parameter for SetPoint")
4 years ago
return
end
3 years ago
return self.widget:SetPoint(v1, v2, v3, v4, v5)
4 years ago
end
function HelpMetaFunctions:ShowHelp()
if (not HelpPlate_IsShowing (self.helpTable)) then
HelpPlate_Show (self.helpTable, self.frame, self.button, true)
else
HelpPlate_Hide (true)
end
end
local nameCounter = 1
function DF:NewHelp (parent, width, height, x, y, buttonWidth, buttonHeight, name)
local help = {}
if (parent.dframework) then
parent = parent.widget
end
3 years ago
local helpButton = CreateFrame("button", name or "DetailsFrameworkHelpButton"..nameCounter, parent, "MainHelpPlateButton")
4 years ago
nameCounter = nameCounter + 1
if (not APIHelpFunctions) then
APIHelpFunctions = true
3 years ago
local idx = getmetatable(helpButton).__index
for funcName, funcAddress in pairs(idx) do
4 years ago
if (not HelpMetaFunctions [funcName]) then
3 years ago
HelpMetaFunctions [funcName] = function(object, ...)
4 years ago
local x = loadstring ( "return _G."..object.button:GetName()..":"..funcName.."(...)")
return x (...)
end
end
end
end
if (buttonWidth and buttonHeight) then
3 years ago
helpButton:SetWidth(buttonWidth)
helpButton:SetHeight(buttonHeight)
helpButton.I:SetWidth(buttonWidth*0.8)
helpButton.I:SetHeight(buttonHeight*0.8)
helpButton.Ring:SetWidth(buttonWidth)
helpButton.Ring:SetHeight(buttonHeight)
helpButton.Ring:SetPoint("center", buttonWidth*.2, -buttonWidth*.2)
4 years ago
end
help.helpTable = {
FramePos = {x = x, y = y},
FrameSize = {width = width, height = height}
}
help.frame = parent
help.button = helpButton
help.widget = helpButton
help.I = helpButton.I
help.Ring = helpButton.Ring
3 years ago
helpButton:SetScript("OnClick", function()
4 years ago
help:ShowHelp()
end)
3 years ago
setmetatable(help, HelpMetaFunctions)
4 years ago
return help
end