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