Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

And so it begins...

  • Loading branch information...
commit 724f63445421f2b801aac6f2f26c34f48c752ed8 0 parents
Tekkub authored May 16, 2008
239  CallbackHandler-1.0.lua
... ...
@@ -0,0 +1,239 @@
  1
+--[[ $Id: CallbackHandler-1.0.lua 60548 2008-02-07 11:04:06Z nevcairiel $ ]]
  2
+local MAJOR, MINOR = "CallbackHandler-1.0", 3
  3
+local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
  4
+
  5
+if not CallbackHandler then return end -- No upgrade needed
  6
+
  7
+local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
  8
+
  9
+local type = type
  10
+local pcall = pcall
  11
+local pairs = pairs
  12
+local assert = assert
  13
+local concat = table.concat
  14
+local loadstring = loadstring
  15
+local next = next
  16
+local select = select
  17
+local type = type
  18
+local xpcall = xpcall
  19
+
  20
+local function errorhandler(err)
  21
+	return geterrorhandler()(err)
  22
+end
  23
+
  24
+local function CreateDispatcher(argCount)
  25
+	local code = [[
  26
+	local next, xpcall, eh = ...
  27
+
  28
+	local method, ARGS
  29
+	local function call() method(ARGS) end
  30
+
  31
+	local function dispatch(handlers, ...)
  32
+		local index
  33
+		index, method = next(handlers)
  34
+		if not method then return end
  35
+		local OLD_ARGS = ARGS
  36
+		ARGS = ...
  37
+		repeat
  38
+			xpcall(call, eh)
  39
+			index, method = next(handlers, index)
  40
+		until not method
  41
+		ARGS = OLD_ARGS
  42
+	end
  43
+
  44
+	return dispatch
  45
+	]]
  46
+
  47
+	local ARGS, OLD_ARGS = {}, {}
  48
+	for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
  49
+	code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", "))
  50
+	return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
  51
+end
  52
+
  53
+local Dispatchers = setmetatable({}, {__index=function(self, argCount)
  54
+	local dispatcher = CreateDispatcher(argCount)
  55
+	rawset(self, argCount, dispatcher)
  56
+	return dispatcher
  57
+end})
  58
+
  59
+--------------------------------------------------------------------------
  60
+-- CallbackHandler:New
  61
+--
  62
+--   target            - target object to embed public APIs in
  63
+--   RegisterName      - name of the callback registration API, default "RegisterCallback"
  64
+--   UnregisterName    - name of the callback unregistration API, default "UnregisterCallback"
  65
+--   UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
  66
+
  67
+function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused)
  68
+	-- TODO: Remove this after beta has gone out
  69
+	assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused")
  70
+
  71
+	RegisterName = RegisterName or "RegisterCallback"
  72
+	UnregisterName = UnregisterName or "UnregisterCallback"
  73
+	if UnregisterAllName==nil then	-- false is used to indicate "don't want this method"
  74
+		UnregisterAllName = "UnregisterAllCallbacks"
  75
+	end
  76
+
  77
+	-- we declare all objects and exported APIs inside this closure to quickly gain access
  78
+	-- to e.g. function names, the "target" parameter, etc
  79
+
  80
+
  81
+	-- Create the registry object
  82
+	local events = setmetatable({}, meta)
  83
+	local registry = { recurse=0, events=events }
  84
+
  85
+	-- registry:Fire() - fires the given event/message into the registry
  86
+	function registry:Fire(eventname, ...)
  87
+		if not rawget(events, eventname) or not next(events[eventname]) then return end
  88
+		local oldrecurse = registry.recurse
  89
+		registry.recurse = oldrecurse + 1
  90
+
  91
+		Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
  92
+
  93
+		registry.recurse = oldrecurse
  94
+
  95
+		if registry.insertQueue and oldrecurse==0 then
  96
+			-- Something in one of our callbacks wanted to register more callbacks; they got queued
  97
+			for eventname,callbacks in pairs(registry.insertQueue) do
  98
+				local first = not rawget(events, eventname) or not next(events[eventname])	-- test for empty before. not test for one member after. that one member may have been overwritten.
  99
+				for self,func in pairs(callbacks) do
  100
+					events[eventname][self] = func
  101
+					-- fire OnUsed callback?
  102
+					if first and registry.OnUsed then
  103
+						registry.OnUsed(registry, target, eventname)
  104
+						first = nil
  105
+					end
  106
+				end
  107
+			end
  108
+			registry.insertQueue = nil
  109
+		end
  110
+	end
  111
+
  112
+	-- Registration of a callback, handles:
  113
+	--   self["method"], leads to self["method"](self, ...)
  114
+	--   self with function ref, leads to functionref(...)
  115
+	--   "addonId" (instead of self) with function ref, leads to functionref(...)
  116
+	-- all with an optional arg, which, if present, gets passed as first argument (after self if present)
  117
+	target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
  118
+		if type(eventname) ~= "string" then
  119
+			error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
  120
+		end
  121
+
  122
+		method = method or eventname
  123
+
  124
+		local first = not rawget(events, eventname) or not next(events[eventname])	-- test for empty before. not test for one member after. that one member may have been overwritten.
  125
+
  126
+		if type(method) ~= "string" and type(method) ~= "function" then
  127
+			error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
  128
+		end
  129
+
  130
+		local regfunc
  131
+
  132
+		if type(method) == "string" then
  133
+			-- self["method"] calling style
  134
+			if type(self) ~= "table" then
  135
+				error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
  136
+			elseif self==target then
  137
+				error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
  138
+			elseif type(self[method]) ~= "function" then
  139
+				error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
  140
+			end
  141
+
  142
+			if select("#",...)>=1 then	-- this is not the same as testing for arg==nil!
  143
+				local arg=select(1,...)
  144
+				regfunc = function(...) self[method](self,arg,...) end
  145
+			else
  146
+				regfunc = function(...) self[method](self,...) end
  147
+			end
  148
+		else
  149
+			-- function ref with self=object or self="addonId"
  150
+			if type(self)~="table" and type(self)~="string" then
  151
+				error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2)
  152
+			end
  153
+
  154
+			if select("#",...)>=1 then	-- this is not the same as testing for arg==nil!
  155
+				local arg=select(1,...)
  156
+				regfunc = function(...) method(arg,...) end
  157
+			else
  158
+				regfunc = method
  159
+			end
  160
+		end
  161
+
  162
+
  163
+		if events[eventname][self] or registry.recurse<1 then
  164
+		-- if registry.recurse<1 then
  165
+			-- we're overwriting an existing entry, or not currently recursing. just set it.
  166
+			events[eventname][self] = regfunc
  167
+			-- fire OnUsed callback?
  168
+			if registry.OnUsed and first then
  169
+				registry.OnUsed(registry, target, eventname)
  170
+			end
  171
+		else
  172
+			-- we're currently processing a callback in this registry, so delay the registration of this new entry!
  173
+			-- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
  174
+			registry.insertQueue = registry.insertQueue or setmetatable({},meta)
  175
+			registry.insertQueue[eventname][self] = regfunc
  176
+		end
  177
+	end
  178
+
  179
+	-- Unregister a callback
  180
+	target[UnregisterName] = function(self, eventname)
  181
+		if not self or self==target then
  182
+			error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
  183
+		end
  184
+		if type(eventname) ~= "string" then
  185
+			error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
  186
+		end
  187
+		if rawget(events, eventname) and events[eventname][self] then
  188
+			events[eventname][self] = nil
  189
+			-- Fire OnUnused callback?
  190
+			if registry.OnUnused and not next(events[eventname]) then
  191
+				registry.OnUnused(registry, target, eventname)
  192
+			end
  193
+		end
  194
+		if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
  195
+			registry.insertQueue[eventname][self] = nil
  196
+		end
  197
+	end
  198
+
  199
+	-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
  200
+	if UnregisterAllName then
  201
+		target[UnregisterAllName] = function(...)
  202
+			if select("#",...)<1 then
  203
+				error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
  204
+			end
  205
+			if select("#",...)==1 and ...==target then
  206
+				error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
  207
+			end
  208
+
  209
+
  210
+			for i=1,select("#",...) do
  211
+				local self = select(i,...)
  212
+				if registry.insertQueue then
  213
+					for eventname, callbacks in pairs(registry.insertQueue) do
  214
+						if callbacks[self] then
  215
+							callbacks[self] = nil
  216
+						end
  217
+					end
  218
+				end
  219
+				for eventname, callbacks in pairs(events) do
  220
+					if callbacks[self] then
  221
+						callbacks[self] = nil
  222
+						-- Fire OnUnused callback?
  223
+						if registry.OnUnused and not next(callbacks) then
  224
+							registry.OnUnused(registry, target, eventname)
  225
+						end
  226
+					end
  227
+				end
  228
+			end
  229
+		end
  230
+	end
  231
+
  232
+	return registry
  233
+end
  234
+
  235
+
  236
+-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
  237
+-- try to upgrade old implicit embeds since the system is selfcontained and
  238
+-- relies on closures to work.
  239
+
111  FPSBlock.lua
... ...
@@ -0,0 +1,111 @@
  1
+
  2
+------------------------------
  3
+--      Are you local?      --
  4
+------------------------------
  5
+
  6
+local UPDATEPERIOD = 0.5
  7
+local prevmem, elapsed, tipshown = collectgarbage("count"), 0.5
  8
+local string_format, math_modf, GetNetStats, GetFramerate, collectgarbage = string.format, math.modf, GetNetStats, GetFramerate, collectgarbage
  9
+
  10
+
  11
+local function ColorGradient(perc, r1, g1, b1, r2, g2, b2, r3, g3, b3)
  12
+	if perc >= 1 then return r3, g3, b3 elseif perc <= 0 then return r1, g1, b1 end
  13
+
  14
+	local segment, relperc = math_modf(perc*2)
  15
+	if segment == 1 then r1, g1, b1, r2, g2, b2 = r2, g2, b2, r3, g3, b3 end
  16
+	return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
  17
+end
  18
+
  19
+
  20
+-------------------------------------------
  21
+--      Namespace and all that shit      --
  22
+-------------------------------------------
  23
+
  24
+local f = CreateFrame("frame")
  25
+f:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
  26
+f:RegisterEvent("ADDON_LOADED")
  27
+
  28
+local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("FPSBlock")
  29
+dataobj.text = "75.0 FPS"
  30
+
  31
+
  32
+---------------------------
  33
+--      Init/Enable      --
  34
+---------------------------
  35
+
  36
+function f:ADDON_LOADED(event, addon)
  37
+	if addon ~= "FPSBlock" then return end
  38
+
  39
+	if FPSBlockDB and FPSBlockDB.profiles then FPSBlockDB = nil end
  40
+	FPSBlockDB = FPSBlockDB or {}
  41
+
  42
+	block = LibStub:GetLibrary("tekBlock"):new("FPSBlock", FPSBlockDB)
  43
+
  44
+	f:UnregisterEvent("ADDON_LOADED")
  45
+	f.ADDON_LOADED = nil
  46
+end
  47
+
  48
+
  49
+--------------------------------
  50
+--      OnUpdate Handler      --
  51
+--------------------------------
  52
+
  53
+f:SetScript("OnUpdate", function(self, elap)
  54
+	elapsed = elapsed + elap
  55
+	if elapsed < UPDATEPERIOD then return end
  56
+
  57
+	elapsed = 0
  58
+	local fps = GetFramerate()
  59
+	local r, g, b = ColorGradient(fps/75, 1,0,0, 1,1,0, 0,1,0)
  60
+	dataobj.text = string_format("|cff%02x%02x%02x%.1f|r FPS", r*255, g*255, b*255, fps)
  61
+
  62
+	if tipshown then dataobj.OnEnter(tipshown) end
  63
+end)
  64
+
  65
+
  66
+------------------------
  67
+--      Tooltip!      --
  68
+------------------------
  69
+
  70
+local function GetTipAnchor(frame)
  71
+	local x,y = frame:GetCenter()
  72
+	if not x or not y then return "TOPLEFT", "BOTTOMLEFT" end
  73
+	local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
  74
+	local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
  75
+	return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
  76
+end
  77
+
  78
+
  79
+function dataobj.OnLeave()
  80
+	GameTooltip:Hide()
  81
+	tipshown = nil
  82
+end
  83
+
  84
+
  85
+function dataobj.OnEnter(self)
  86
+	tipshown = self
  87
+ 	GameTooltip:SetOwner(self, "ANCHOR_NONE")
  88
+	GameTooltip:SetPoint(GetTipAnchor(self))
  89
+	GameTooltip:ClearLines()
  90
+
  91
+	GameTooltip:AddLine("FPSBlock")
  92
+
  93
+	local fps = GetFramerate()
  94
+	local r, g, b = ColorGradient(fps/75, 1,0,0, 1,1,0, 0,1,0)
  95
+	GameTooltip:AddDoubleLine("FPS:", string_format("%.1f", fps), nil,nil,nil, r,g,b)
  96
+
  97
+	local _, _, lag = GetNetStats()
  98
+	local r, g, b = ColorGradient(lag/1000, 1,0,0, 1,1,0, 0,1,0)
  99
+	GameTooltip:AddDoubleLine("Lag:", lag.. " ms", nil,nil,nil, r,g,b)
  100
+
  101
+	local mem = collectgarbage("count")
  102
+	local deltamem = mem - prevmem
  103
+	prevmem = mem
  104
+	local r, g, b = ColorGradient(mem/(60*1024), 0,1,0, 1,1,0, 1,0,0)
  105
+	GameTooltip:AddDoubleLine("Memory:", string_format("%.2f MiB", mem/1024), nil,nil,nil, r,g,b)
  106
+
  107
+	local r, g, b = ColorGradient(deltamem/15, 0,1,0, 1,1,0, 1,0,0)
  108
+	GameTooltip:AddDoubleLine("Garbage churn:", string_format("%.2f KiB/sec", deltamem), nil,nil,nil, r,g,b)
  109
+
  110
+	GameTooltip:Show()
  111
+end
21  FPSBlock.toc
... ...
@@ -0,0 +1,21 @@
  1
+## Interface: 20400
  2
+
  3
+## Title: FPSBlock
  4
+## Notes: Minimalistic FPS display
  5
+## Author: Tekkub Stoutwrithe
  6
+## Version: Alpha
  7
+## X-Website: http://www.tekkub.net/
  8
+## X-Email: tekkub-wow@googlegroups.com
  9
+## X-Credits: kergoth's PerfBlock
  10
+
  11
+## SavedVariables: FPSBlockDB
  12
+
  13
+## LoadManagers: AddonLoader
  14
+## X-LoadOn-Always: delayed
  15
+
  16
+LibStub.lua
  17
+CallbackHandler-1.0.lua
  18
+LibDataBroker-1.1\LibDataBroker-1.1.lua
  19
+tekBlock\tekBlock.lua
  20
+
  21
+FPSBlock.lua
50  LibDataBroker-1.1/LibDataBroker-1.1.lua
... ...
@@ -0,0 +1,50 @@
  1
+
  2
+assert(LibStub, "LibDataBroker-1.1 requires LibStub")
  3
+assert(LibStub:GetLibrary("CallbackHandler-1.0", true), "LibDataBroker-1.1 requires CallbackHandler-1.0")
  4
+
  5
+local lib = LibStub:NewLibrary("LibDataBroker-1.1", 1)
  6
+if not lib then return end
  7
+
  8
+
  9
+lib.callbacks = lib.callbacks or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
  10
+lib.attributestorage, lib.namestorage, lib.proxystorage = lib.attributestorage or {}, lib.namestorage or {}, lib.proxystorage or {}
  11
+local attributestorage, namestorage, proxystorage = lib.attributestorage, lib.namestorage, lib.proxystorage
  12
+
  13
+local domt = {
  14
+	__metatable = "access denied",
  15
+	__newindex = function(self, key, value)
  16
+		if not attributestorage[self] then attributestorage[self] = {} end
  17
+		if attributestorage[self][key] == value then return end
  18
+		attributestorage[self][key] = value
  19
+		local name = namestorage[self]
  20
+		if not name then return end
  21
+		lib.callbacks:Fire("LibDataBroker_AttributeChanged", name, key, value)
  22
+		lib.callbacks:Fire("LibDataBroker_AttributeChanged_"..name, name, key, value)
  23
+		lib.callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_"..key, name, key, value)
  24
+		lib.callbacks:Fire("LibDataBroker_AttributeChanged__"..key, name, key, value)
  25
+	end,
  26
+	__index = function(self, key)
  27
+		return attributestorage[self] and attributestorage[self][key]
  28
+	end,
  29
+}
  30
+
  31
+function lib:NewDataObject(name)
  32
+	if proxystorage[name] then return end
  33
+
  34
+	local dataobj = setmetatable({}, domt)
  35
+	proxystorage[name], namestorage[dataobj] = dataobj, name
  36
+	lib.callbacks:Fire("LibDataBroker_DataObjectCreated", name, dataobj)
  37
+	return dataobj
  38
+end
  39
+
  40
+function lib:DataObjectIterator()
  41
+	return pairs(proxystorage)
  42
+end
  43
+
  44
+function lib:GetDataObjectByName(dataobjectname)
  45
+	return proxystorage[dataobjectname]
  46
+end
  47
+
  48
+function lib:GetNameByDataObject(dataobject)
  49
+	return namestorage[dataobject]
  50
+end
30  LibStub.lua
... ...
@@ -0,0 +1,30 @@
  1
+-- LibStub is a simple versioning stub meant for use in Libraries.  http://www.wowace.com/wiki/LibStub for more info
  2
+-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
  3
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2  -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
  4
+local LibStub = _G[LIBSTUB_MAJOR]
  5
+
  6
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
  7
+	LibStub = LibStub or {libs = {}, minors = {} }
  8
+	_G[LIBSTUB_MAJOR] = LibStub
  9
+	LibStub.minor = LIBSTUB_MINOR
  10
+	
  11
+	function LibStub:NewLibrary(major, minor)
  12
+		assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
  13
+		minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
  14
+		
  15
+		local oldminor = self.minors[major]
  16
+		if oldminor and oldminor >= minor then return nil end
  17
+		self.minors[major], self.libs[major] = minor, self.libs[major] or {}
  18
+		return self.libs[major], oldminor
  19
+	end
  20
+	
  21
+	function LibStub:GetLibrary(major, silent)
  22
+		if not self.libs[major] and not silent then
  23
+			error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
  24
+		end
  25
+		return self.libs[major], self.minors[major]
  26
+	end
  27
+	
  28
+	function LibStub:IterateLibraries() return pairs(self.libs) end
  29
+	setmetatable(LibStub, { __call = LibStub.GetLibrary })
  30
+end
90  tekBlock/tekBlock.lua
... ...
@@ -0,0 +1,90 @@
  1
+
  2
+local MINOR = 1
  3
+local lib = LibStub:NewLibrary("tekBlock", MINOR)
  4
+if not lib then return end
  5
+
  6
+
  7
+lib.init = lib.init or 0
  8
+function lib:new(dataobjname, db)
  9
+	-- Delayed init, don't init until first call, and only upgrade that which needs it if previously init'd
  10
+	if self.init < 1 then
  11
+		self.backdrop = {
  12
+			bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
  13
+			edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  14
+			edgeSize = 16,
  15
+			insets = {left = 5, right = 5, top = 5, bottom = 5},
  16
+			tile = true, tileSize = 16,
  17
+		}
  18
+
  19
+
  20
+		function self:OnDragStart()
  21
+			if self.db.locked then return end
  22
+			local OnLeave = self:GetScript("OnLeave")
  23
+			if OnLeave then OnLeave(self) end
  24
+			self.OnEnter = self:GetScript("OnEnter")
  25
+			self:SetScript("OnEnter", nil)
  26
+			self:StartMoving()
  27
+		end
  28
+
  29
+
  30
+		function self:OnDragStop()
  31
+			if self.db.locked then return end
  32
+			self:SetScript("OnEnter", self.OnEnter)
  33
+			if self.OnEnter then self.OnEnter(self) end
  34
+			self.OnEnter = nil
  35
+			self:StopMovingOrSizing()
  36
+			self.db.x, self.db.y = self:GetCenter()
  37
+		end
  38
+
  39
+
  40
+		function self:TextUpdate(event, name, key, value)
  41
+			self.text:SetText(value)
  42
+			if self.db.resize then self:SetWidth(self.text:GetStringWidth() + 8) end
  43
+		end
  44
+
  45
+
  46
+		function self:SetDObjScript(event, name, key, value) self:SetScript(key, value) end
  47
+	end
  48
+
  49
+	self.init = MINOR
  50
+
  51
+
  52
+	-- And now the good bits
  53
+	local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
  54
+	local dataobj = ldb:GetDataObjectByName(dataobjname)
  55
+
  56
+	local frame = CreateFrame("Button", nil, UIParent)
  57
+	frame:SetHeight(24)
  58
+
  59
+	frame.db = db
  60
+	frame:SetPoint("CENTER", UIParent, db.x and "BOTTOMLEFT" or "TOP", db.x or 0, db.y or -100)
  61
+
  62
+--~ 	frame:EnableMouse(true)
  63
+--~ 	frame:RegisterForClicks("AnyUp")
  64
+	frame:SetMovable(true)
  65
+	frame:RegisterForDrag("LeftButton")
  66
+	frame:SetClampedToScreen(true)
  67
+
  68
+	frame:SetBackdrop(self.backdrop)
  69
+	frame:SetBackdropColor(0.09, 0.09, 0.19, 0.5)
  70
+	frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 0.5)
  71
+
  72
+	frame:SetScript("OnDragStart", self.OnDragStart)
  73
+	frame:SetScript("OnDragStop", self.OnDragStop)
  74
+
  75
+	frame.text = frame:CreateFontString(nil, nil, "GameFontNormalSmall")
  76
+	frame.text:SetPoint("CENTER")
  77
+	frame.text:SetText(dataobj.text or dataobjname)
  78
+	frame:SetWidth(frame.text:GetStringWidth() + 8)
  79
+	frame.TextUpdate = self.TextUpdate
  80
+	ldb.RegisterCallback(frame, "LibDataBroker_AttributeChanged_"..dataobjname.."_text", "TextUpdate")
  81
+
  82
+	frame.SetDObjScript = self.SetDObjScript
  83
+	frame:SetScript("OnEnter", dataobj.OnEnter)
  84
+	ldb.RegisterCallback(frame, "LibDataBroker_AttributeChanged_"..dataobjname.."_OnEnter", "SetDObjScript")
  85
+
  86
+	frame:SetScript("OnLeave", dataobj.OnLeave)
  87
+	ldb.RegisterCallback(frame, "LibDataBroker_AttributeChanged_"..dataobjname.."_OnLeave", "SetDObjScript")
  88
+
  89
+	return frame
  90
+end

0 notes on commit 724f634

Please sign in to comment.
Something went wrong with that request. Please try again.