annotate libs/ReBound-1.0/ReBound-1.0.lua @ 12:2735edcf9ab7

Version 0.34
author Flick <flickerstreak@gmail.com>
date Wed, 21 Mar 2007 00:13:27 +0000
parents f3a7bfebc283
children 639282f3a0e0
rev   line source
flickerstreak@10 1 --[[
flickerstreak@10 2 Name: ReBound-1.0
flickerstreak@12 3 Revision: $Rev: 2 $
flickerstreak@10 4 Author: Flick
flickerstreak@10 5 Website:
flickerstreak@10 6 Documentation:
flickerstreak@10 7 SVN:
flickerstreak@12 8 Description: A library to assist with click-binding
flickerstreak@10 9 License: MIT
flickerstreak@12 10 Dependencies: AceLibrary, AceEvent-2.0, AceLocale-2.2, AceOO-2.0
flickerstreak@10 11 ]]
flickerstreak@10 12
flickerstreak@10 13
flickerstreak@12 14 local version_major, version_minor = "ReBound-1.0", "$Rev: 2 $"
flickerstreak@10 15
flickerstreak@10 16 if not AceLibrary then error(version_major .. " requires AceLibrary.") end
flickerstreak@10 17 if not AceLibrary:IsNewVersion(version_major, version_minor) then return end
flickerstreak@10 18 if not AceLibrary:HasInstance("AceEvent-2.0") then error(version_major .. " requires AceEvent-2.0.") end
flickerstreak@10 19 if not AceLibrary:HasInstance("AceLocale-2.2") then error(version_major .. " requires AceLocale-2.2.") end
flickerstreak@12 20 if not AceLibrary:HasInstance("AceOO-2.0") then error(version_major .. " requires AceOO-2.0.") end
flickerstreak@10 21
flickerstreak@10 22 local L = AceLibrary("AceLocale-2.2"):new("ReBound")
flickerstreak@10 23
flickerstreak@10 24 local colorGreen = "|cff00ff00"
flickerstreak@10 25 local colorOff = "|r"
flickerstreak@10 26
flickerstreak@10 27 local mouseButtonConvert = {
flickerstreak@12 28 LeftButton = "BUTTON1",
flickerstreak@12 29 RightButton = "BUTTON2",
flickerstreak@10 30 MiddleButton = "BUTTON3",
flickerstreak@10 31 Button4 = "BUTTON4",
flickerstreak@10 32 Button5 = "BUTTON5"
flickerstreak@10 33 }
flickerstreak@10 34
flickerstreak@12 35 --local BINDING_PENDING = { } -- a constant
flickerstreak@12 36
flickerstreak@10 37 -- localization
flickerstreak@10 38 L:RegisterTranslations( "enUS", function()
flickerstreak@10 39 return {
flickerstreak@10 40 ["none"] = true,
flickerstreak@10 41 ["Right-click"] = true,
flickerstreak@12 42 ["Right Click"] = true,
flickerstreak@10 43 ["Click to select for binding"] = true,
flickerstreak@10 44 ["Shift-click to clear binding"] = true,
flickerstreak@10 45 ["Press a key to assign binding"] = true,
flickerstreak@10 46 ["is now unbound"] = true,
flickerstreak@10 47 }
flickerstreak@10 48 end )
flickerstreak@10 49
flickerstreak@10 50
flickerstreak@12 51 local ReBound = AceLibrary("AceOO-2.0").Class("AceEvent-2.0")
flickerstreak@10 52
flickerstreak@12 53 --[[
flickerstreak@12 54 ReBound publishes the following events:
flickerstreak@10 55
flickerstreak@12 56 -- temporary bindings (prior to SaveBindings() being called)
flickerstreak@12 57 REBOUND_BIND_TEMP (id, key, targetFrameName, mouseButton)
flickerstreak@12 58 REBOUND_UNBIND_TEMP (id, key)
flickerstreak@12 59
flickerstreak@12 60 -- permanent bindings (fired all at once when SaveBindings() is called)
flickerstreak@12 61 REBOUND_BIND (id, key, targetFrameName, mouseButton)
flickerstreak@12 62 REBOUND_UNBIND (id, key)
flickerstreak@12 63
flickerstreak@12 64 These events are published in response to click actions ONLY. This means
flickerstreak@12 65 that if a key is unbound from a click-binding frame, and bound to some
flickerstreak@12 66 other action, then REBOUND_UNBIND(id,key) will be fired.
flickerstreak@12 67 ]]
flickerstreak@12 68
flickerstreak@12 69
flickerstreak@12 70 --[[
flickerstreak@12 71 Calls to new() which share ids will return an existing object with that id, similar
flickerstreak@12 72 to AceLocale-2.2.
flickerstreak@12 73 ]]
flickerstreak@12 74 local super_new = ReBound.new
flickerstreak@12 75 function ReBound:new( id )
flickerstreak@12 76 self.instances = self.instances or { }
flickerstreak@12 77 if self.instances[id] then
flickerstreak@12 78 return self.instances[id]
flickerstreak@12 79 else
flickerstreak@12 80 local i = super_new(self,id)
flickerstreak@12 81 self.instances[id] = i
flickerstreak@12 82 return i
flickerstreak@12 83 end
flickerstreak@12 84 end
flickerstreak@12 85
flickerstreak@12 86
flickerstreak@12 87 --[[
flickerstreak@12 88 Class object constructor
flickerstreak@12 89
flickerstreak@12 90 arguments:
flickerstreak@12 91 id : the ID that will be provided in events. This can be absolutely
flickerstreak@12 92 anything, but a string is recommended.
flickerstreak@12 93 ]]
flickerstreak@12 94 local super_init = ReBound.prototype.init
flickerstreak@12 95 function ReBound.prototype:init( id )
flickerstreak@12 96 super_init(self)
flickerstreak@12 97
flickerstreak@12 98 self.id = id
flickerstreak@12 99 self.frames = { }
flickerstreak@12 100 self.pending = { }
flickerstreak@12 101 self.bindings = { }
flickerstreak@12 102 end
flickerstreak@12 103
flickerstreak@12 104
flickerstreak@10 105
flickerstreak@10 106
flickerstreak@10 107 --[[
flickerstreak@10 108 Arguments:
flickerstreak@10 109 key: A string representation of a key, suitable for passing to SetBinding.
flickerstreak@12 110 target: The frame with an OnClick handler to which the click-binding should be attached
flickerstreak@10 111 [button]: The mouse button to emulate. Default is "LeftButton".
flickerstreak@10 112
flickerstreak@10 113 Returns:
flickerstreak@10 114 nothing.
flickerstreak@10 115
flickerstreak@10 116 Notes:
flickerstreak@10 117 This does not save the bindings.
flickerstreak@10 118 ]]
flickerstreak@12 119 function ReBound.prototype:SetBinding( key, target, button )
flickerstreak@12 120 if not key then error("ReBound:SetBinding() requires a key argument.") end
flickerstreak@12 121 if not target then error("ReBound:SetBinding() requires a binding target argument") end
flickerstreak@10 122 button = button or "LeftButton"
flickerstreak@10 123
flickerstreak@10 124 -- prevent setting a binding that's already set
flickerstreak@10 125 local current = { self:GetBinding(target,button) }
flickerstreak@10 126 for _, b in pairs(current) do
flickerstreak@10 127 if b == key then
flickerstreak@10 128 return
flickerstreak@10 129 end
flickerstreak@10 130 end
flickerstreak@10 131
flickerstreak@10 132 -- clear the old binding for the key. This isn't strictly necessary, but it allows us to collect
flickerstreak@10 133 -- notification of the unbinding in one place (ClearBinding).
flickerstreak@10 134 self:ClearBinding( key )
flickerstreak@10 135
flickerstreak@10 136 -- clear the old binding for the target and button (silently)
flickerstreak@10 137 self:ClearBinding( nil, target, button, true )
flickerstreak@10 138
flickerstreak@10 139 -- set the new binding
flickerstreak@10 140 SetBindingClick(key, target:GetName(), button)
flickerstreak@10 141
flickerstreak@12 142 -- store the temporary binding as "pending" for later notification
flickerstreak@12 143 table.insert(self.pending, key)
flickerstreak@12 144
flickerstreak@12 145 -- notify listeners, e.g. for displaying the setting
flickerstreak@12 146 self:TriggerEvent("REBOUND_BIND_TEMP", self.id, key, target:GetName(), button)
flickerstreak@10 147 end
flickerstreak@10 148
flickerstreak@10 149
flickerstreak@10 150 --[[
flickerstreak@10 151 Arguments:
flickerstreak@10 152 [key]: A string representation of a key, suitable for passing to SetBinding. This can be nil if target is specified.
flickerstreak@10 153 [target]: The frame with a click keybinding to search for a key.
flickerstreak@10 154 [button]: The mouse button to emulate. Default is "LeftButton". Only used with [target].
flickerstreak@10 155 [silent]: if true, omits printout.
flickerstreak@10 156
flickerstreak@10 157 Returns:
flickerstreak@10 158 nothing.
flickerstreak@10 159
flickerstreak@10 160 Notes:
flickerstreak@10 161 If key is provided, then the binding for that key is cleared. If key is not provided and target is provided, then
flickerstreak@10 162 all the bindings attached to the click-binding for that target are cleared.
flickerstreak@10 163
flickerstreak@10 164 This does NOT save the bindings. Call SaveBindings() to commit the bindings to disk.
flickerstreak@10 165 ]]
flickerstreak@12 166 function ReBound.prototype:ClearBinding( key, target, button, silent )
flickerstreak@12 167 if not target and not key then error("ReBound:ClearBinding() requires a key or click-binding target argument") end
flickerstreak@10 168 button = button or "LeftButton"
flickerstreak@10 169
flickerstreak@10 170 local keys = key and { key } or { self:GetBinding(target,button) }
flickerstreak@10 171 for _, k in ipairs(keys) do
flickerstreak@10 172 -- Print a notification message
flickerstreak@10 173 if k and not silent then
flickerstreak@10 174 local action = GetBindingAction(k)
flickerstreak@10 175 if action then
flickerstreak@10 176 local name = GetBindingText(action,"BINDING_NAME_")
flickerstreak@10 177 local keyTxt = GetBindingText(k,"KEY_")
flickerstreak@10 178 -- make click-bindings look prettier
flickerstreak@10 179 local f, b = name:match("CLICK (.+)\:(.+)")
flickerstreak@10 180 if f then
flickerstreak@10 181 name = f
flickerstreak@10 182 if b ~= "LeftButton" then
flickerstreak@12 183 if b == "RightButton" then b = L["Right Click"] end
flickerstreak@10 184 name = f .."-"..b
flickerstreak@10 185 end
flickerstreak@10 186 end
flickerstreak@10 187 if name and #name > 0 then
flickerstreak@10 188 UIErrorsFrame:AddMessage(name.." ("..colorGreen..keyTxt..colorOff..") "..L["is now unbound"].."!")
flickerstreak@10 189 end
flickerstreak@10 190 end
flickerstreak@10 191 end
flickerstreak@10 192 SetBinding(k,nil)
flickerstreak@12 193 table.insert(self.pending,k)
flickerstreak@12 194 self:TriggerEvent("REBOUND_UNBIND_TEMP", self.id, k)
flickerstreak@10 195 end
flickerstreak@10 196 end
flickerstreak@10 197
flickerstreak@10 198
flickerstreak@10 199 --[[
flickerstreak@12 200 Gets the keys currently click-bound to a frame.
flickerstreak@10 201
flickerstreak@10 202 Arguments:
flickerstreak@10 203 target: target frame to query
flickerstreak@10 204 [button]: mouse button to emulate ("LeftButton", "RightButton")
flickerstreak@10 205
flickerstreak@10 206 Returns:
flickerstreak@10 207 key1, key2, key3, etc, as strings.
flickerstreak@10 208 ]]
flickerstreak@12 209 function ReBound.prototype:GetBinding( target, button )
flickerstreak@12 210 if not target then error("ReBound:GetBinding() requires a target frame argument") end
flickerstreak@10 211 button = button or "LeftButton"
flickerstreak@10 212 return GetBindingKey("CLICK "..target:GetName()..":"..button)
flickerstreak@10 213 end
flickerstreak@10 214
flickerstreak@10 215
flickerstreak@10 216 --[[
flickerstreak@12 217 Publishes permanent binding notification events.
flickerstreak@12 218 ]]
flickerstreak@12 219 local function PublishBindings(self)
flickerstreak@12 220 for _, key in ipairs(self.pending) do
flickerstreak@12 221 local action = GetBindingAction(key)
flickerstreak@12 222 local frame, button
flickerstreak@12 223 if action then
flickerstreak@12 224 frame, button = action:match("CLICK (.+)\:(.+)")
flickerstreak@12 225 end
flickerstreak@12 226 if frame == nil then
flickerstreak@12 227 self:TriggerEvent("REBOUND_UNBIND", self.id, key)
flickerstreak@12 228 else
flickerstreak@12 229 self:TriggerEvent("REBOUND_BIND", self.id, key, frame, button)
flickerstreak@12 230 end
flickerstreak@12 231 end
flickerstreak@12 232 self.pending = { }
flickerstreak@12 233 end
flickerstreak@12 234
flickerstreak@12 235
flickerstreak@12 236 --[[
flickerstreak@12 237 Saves the bindings using the current scheme. Also publishes events indicating that the
flickerstreak@12 238 bindings have been saved/cleared permanently.
flickerstreak@12 239 ]]
flickerstreak@12 240 function ReBound.prototype:SaveBindings()
flickerstreak@12 241 SaveBindings(GetCurrentBindingSet()) -- will trigger an UPDATE_BINDINGS event.
flickerstreak@12 242 PublishBindings(self)
flickerstreak@12 243 end
flickerstreak@12 244
flickerstreak@12 245
flickerstreak@12 246 --[[
flickerstreak@12 247 Reverts the bindings to the ones previously saved. Also publishes events indicating that the
flickerstreak@12 248 bindings have been reverted.
flickerstreak@12 249 ]]
flickerstreak@12 250 function ReBound.prototype:RevertBindings()
flickerstreak@12 251 LoadBindings(GetCurrentBindingSet()) -- should trigger an UPDATE_BINDINGS event.
flickerstreak@12 252 PublishBindings(self)
flickerstreak@12 253 end
flickerstreak@12 254
flickerstreak@12 255
flickerstreak@12 256 --[[
flickerstreak@12 257 Clears all bindings associated with registered frames. This is useful, for example, when switching profiles
flickerstreak@12 258 and the keybinding data is stored in the profile.
flickerstreak@12 259 ]]
flickerstreak@12 260 function ReBound.prototype:ClearRegisteredBindings()
flickerstreak@12 261 for f, _ in pairs(self.frames) do
flickerstreak@12 262 self:ClearBinding(nil,f,"LeftButton",true)
flickerstreak@12 263 self:ClearBinding(nil,f,"RightButton",true)
flickerstreak@12 264 end
flickerstreak@12 265 end
flickerstreak@12 266
flickerstreak@12 267
flickerstreak@12 268 --[[
flickerstreak@10 269 Registers a target frame by creating a click-binding frame and putting that frame in the list of
flickerstreak@10 270 registered frames, which can then be all shown/hidden as one unit.
flickerstreak@10 271
flickerstreak@10 272 Arguments:
flickerstreak@10 273 target = the frame whose OnClick handler should be the target of keybinding
flickerstreak@10 274
flickerstreak@10 275 Returns:
flickerstreak@10 276 A clickbinder frame.
flickerstreak@10 277 ]]
flickerstreak@12 278 function ReBound.prototype:Register( target )
flickerstreak@10 279 local f = self:CreateClickBindingFrame(target)
flickerstreak@10 280 self.frames[target] = f
flickerstreak@10 281 return f
flickerstreak@10 282 end
flickerstreak@10 283
flickerstreak@10 284
flickerstreak@10 285 --[[
flickerstreak@10 286 Unregisters a target frame by removing it from the internal list. Does nothing to the clickbinding frame.
flickerstreak@10 287
flickerstreak@10 288 Arguments:
flickerstreak@12 289 target = the frame whose OnClick handler should no longer be managed. do NOT pass the clickbinding frame.
flickerstreak@10 290
flickerstreak@10 291 Returns:
flickerstreak@10 292 nothing.
flickerstreak@10 293 ]]
flickerstreak@12 294 function ReBound.prototype:Unregister( target )
flickerstreak@10 295 self.frames[target] = nil
flickerstreak@10 296 end
flickerstreak@10 297
flickerstreak@10 298
flickerstreak@10 299 --[[
flickerstreak@12 300 Unregisters all registered frames.
flickerstreak@12 301 ]]
flickerstreak@12 302 function ReBound.prototype:UnregisterAll()
flickerstreak@12 303 self.frames = { }
flickerstreak@12 304 end
flickerstreak@12 305
flickerstreak@12 306
flickerstreak@12 307
flickerstreak@12 308 --[[
flickerstreak@10 309 Shows all the registered click binding frames.
flickerstreak@10 310 ]]
flickerstreak@12 311 function ReBound.prototype:ShowFrames()
flickerstreak@10 312 if InCombatLockdown() then
flickerstreak@10 313 -- can't set bindings while in combat, so don't bother showing them
flickerstreak@10 314 UIErrorsFrame:AddMessage(ERR_NOT_IN_COMBAT)
flickerstreak@10 315 else
flickerstreak@10 316 for _, f in pairs(self.frames) do
flickerstreak@10 317 f:Show()
flickerstreak@10 318 end
flickerstreak@10 319 end
flickerstreak@10 320 end
flickerstreak@10 321
flickerstreak@10 322
flickerstreak@10 323 --[[
flickerstreak@10 324 Hides all the registered click binding frames.
flickerstreak@10 325 ]]
flickerstreak@12 326 function ReBound.prototype:HideFrames()
flickerstreak@12 327 -- because these frames aren't protected, there's no restriction
flickerstreak@12 328 -- on hiding them while in combat.
flickerstreak@10 329 for _, f in pairs(self.frames) do
flickerstreak@10 330 f:Hide()
flickerstreak@10 331 end
flickerstreak@10 332 end
flickerstreak@10 333
flickerstreak@10 334 -- click binding frame implementation functions
flickerstreak@10 335 local function ShowTooltip1( self )
flickerstreak@10 336 local target = self:GetParent()
flickerstreak@10 337
flickerstreak@10 338 GameTooltip:ClearLines()
flickerstreak@10 339 GameTooltip:SetOwner(self,"ANCHOR_TOPRIGHT")
flickerstreak@10 340 -- line 1: button name and current binding
flickerstreak@10 341 GameTooltip:AddDoubleLine(target:GetName(), colorGreen.."("..(self.ReBound:GetBinding(target,"LeftButton") or L["none"])..")"..colorOff)
flickerstreak@10 342 -- line 2: current right-click binding (if any)
flickerstreak@10 343 local binding2 = self.ReBound:GetBinding(target,"RightButton")
flickerstreak@10 344 if binding2 then
flickerstreak@10 345 GameTooltip:AddDoubleLine(L["Right-click"]..":", colorGreen.."("..binding2..")"..colorOff)
flickerstreak@10 346 end
flickerstreak@10 347 -- line 3: instructions
flickerstreak@10 348 GameTooltip:AddLine(L["Click to select for binding"])
flickerstreak@10 349 GameTooltip:AddLine(L["Shift-click to clear binding"])
flickerstreak@10 350 GameTooltip:Show()
flickerstreak@10 351 end
flickerstreak@10 352
flickerstreak@10 353 local function ShowTooltip2( self )
flickerstreak@10 354 if GameTooltip:IsOwned(self) then
flickerstreak@10 355 local target = self:GetParent()
flickerstreak@10 356 GameTooltip:ClearLines()
flickerstreak@10 357 GameTooltip:SetOwner(self)
flickerstreak@10 358 local clickSuffix = self.selectedButton == "RightButton" and (" ("..L["Right-click"]..")") or ""
flickerstreak@10 359 -- line 1: button name and binding to be set
flickerstreak@10 360 GameTooltip:AddDoubleLine(target:GetName()..clickSuffix, colorGreen.."("..(self.ReBound:GetBinding(target,self.selectedButton) or L["none"])..")"..colorOff)
flickerstreak@10 361 -- line 2: instructions
flickerstreak@10 362 GameTooltip:AddLine(colorGreen..L["Press a key to assign binding"]..colorOff)
flickerstreak@10 363 GameTooltip:Show()
flickerstreak@10 364 end
flickerstreak@10 365 end
flickerstreak@10 366
flickerstreak@10 367 local function OnClick( self, button )
flickerstreak@10 368 if button == "LeftButton" or button == "RightButton" then
flickerstreak@10 369 if IsShiftKeyDown() then
flickerstreak@10 370 self.ReBound:ClearBinding( nil, self:GetParent(), button )
flickerstreak@10 371 self.selectedButton = nil
flickerstreak@10 372 self:EnableKeyboard(false)
flickerstreak@10 373 ShowTooltip1(self)
flickerstreak@10 374 else
flickerstreak@10 375 self.selectedButton = button
flickerstreak@10 376 self:EnableKeyboard(true)
flickerstreak@10 377 ShowTooltip2(self)
flickerstreak@10 378 end
flickerstreak@10 379 elseif self.selectedButton then
flickerstreak@10 380 self.ReBound:SetBinding( mouseButtonConvert[button], self:GetParent(), self.selectedButton )
flickerstreak@10 381 self.selectedButton = nil
flickerstreak@10 382 self:EnableKeyboard(false)
flickerstreak@10 383 ShowTooltip1(self)
flickerstreak@10 384 end
flickerstreak@10 385 end
flickerstreak@10 386
flickerstreak@10 387 local function OnEnter( self )
flickerstreak@10 388 -- clear current binding button
flickerstreak@10 389 self.selectedButton = nil
flickerstreak@10 390 -- show tooltip 1
flickerstreak@10 391 ShowTooltip1(self)
flickerstreak@10 392 end
flickerstreak@10 393
flickerstreak@10 394 local function OnLeave( self )
flickerstreak@10 395 -- disable keyboard input, if it was enabled
flickerstreak@10 396 self:EnableKeyboard(false)
flickerstreak@10 397 -- hide tooltip
flickerstreak@10 398 if GameTooltip:IsOwned(self) then
flickerstreak@10 399 GameTooltip:Hide()
flickerstreak@10 400 end
flickerstreak@10 401 end
flickerstreak@10 402
flickerstreak@10 403 local function OnKeyDown( self, key )
flickerstreak@10 404 if key == nil or key == "UNKNOWN" or key == "SHIFT" or key == "CTRL" or key == "ALT" then
flickerstreak@10 405 return
flickerstreak@10 406 end
flickerstreak@10 407 if IsShiftKeyDown() then key = "SHIFT-"..key end
flickerstreak@10 408 if IsControlKeyDown() then key = "CTRL-"..key end
flickerstreak@10 409 if IsAltKeyDown() then key = "ALT-"..key end
flickerstreak@10 410
flickerstreak@10 411 if key ~= "ESCAPE" then
flickerstreak@10 412 self.ReBound:SetBinding( key, self:GetParent(), self.selectedButton )
flickerstreak@10 413 end
flickerstreak@10 414
flickerstreak@10 415 self:EnableKeyboard(false)
flickerstreak@10 416 self.selectedButton = nil
flickerstreak@10 417 ShowTooltip1(self)
flickerstreak@10 418 end
flickerstreak@10 419
flickerstreak@10 420 --[[
flickerstreak@10 421 Creates a click-binding frame attached to the target frame, which can be used for point-and-click keybind assignments. The
flickerstreak@10 422 frame is initially hidden by default. It is not registered with ReBound for automatic show/hide: use Register() for that.
flickerstreak@10 423
flickerstreak@10 424 Arguments:
flickerstreak@10 425 target - the frame whose OnClick handler should be the target of keybinding
flickerstreak@10 426
flickerstreak@10 427 Returns:
flickerstreak@10 428 A clickbinder frame.
flickerstreak@10 429 ]]
flickerstreak@12 430 function ReBound.prototype:CreateClickBindingFrame( target )
flickerstreak@10 431 local f = CreateFrame("Button", nil, target)
flickerstreak@10 432 f.ReBound = self
flickerstreak@10 433 f:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
flickerstreak@10 434 f:SetToplevel(1)
flickerstreak@10 435 f:SetFrameStrata("DIALOG")
flickerstreak@10 436 f:RegisterForClicks("AnyUp")
flickerstreak@10 437 f:SetScript("OnClick", OnClick)
flickerstreak@10 438 f:SetScript("OnEnter", OnEnter)
flickerstreak@10 439 f:SetScript("OnLeave", OnLeave)
flickerstreak@10 440 f:SetScript("OnKeyDown", OnKeyDown)
flickerstreak@10 441 f:SetAllPoints(target)
flickerstreak@10 442 f:Hide()
flickerstreak@10 443 return f
flickerstreak@10 444 end
flickerstreak@10 445
flickerstreak@10 446
flickerstreak@10 447
flickerstreak@10 448 -- library setup
flickerstreak@10 449
flickerstreak@10 450 local function activate( self, oldLib, oldDeactivate )
flickerstreak@12 451 -- copy the list of active instances
flickerstreak@12 452 self.instances = { }
flickerstreak@12 453 if oldLib and oldLib.instances then
flickerstreak@12 454 for k,v in pairs(oldLib.instances) do
flickerstreak@12 455 self.instances[k] = v
flickerstreak@12 456 end
flickerstreak@12 457 end
flickerstreak@12 458
flickerstreak@10 459 if oldDeactivate then
flickerstreak@10 460 oldDeactivate(oldLib)
flickerstreak@10 461 end
flickerstreak@10 462 end
flickerstreak@10 463
flickerstreak@12 464 AceLibrary:Register(ReBound, version_major, version_minor, activate)
flickerstreak@10 465 ReBound = nil