annotate CallbackFactory.lua @ 71:60e5f3262337 tip

Added tag v6.1.0-1 for changeset 553715eacab6
author Jerome Vuarand <jerome.vuarand@gmail.com>
date Thu, 26 Feb 2015 14:18:54 +0000
parents 2d6684c270b9
children
rev   line source
madcatzinc@13 1 --~ Warcraft Plugin for Cyborg MMO7
madcatzinc@0 2 --~ Filename: CalbackFactory.lua
madcatzinc@0 3 --~ Description: Creates lua callbacks that can be executed from a user keycombination
madcatzinc@0 4 --~ Copyright (C) 2012 Mad Catz Inc.
madcatzinc@0 5 --~ Author: Christopher Hooks
madcatzinc@0 6
madcatzinc@0 7 --~ This program is free software; you can redistribute it and/or
madcatzinc@0 8 --~ modify it under the terms of the GNU General Public License
madcatzinc@0 9 --~ as published by the Free Software Foundation; either version 2
madcatzinc@0 10 --~ of the License, or (at your option) any later version.
madcatzinc@0 11
madcatzinc@0 12 --~ This program is distributed in the hope that it will be useful,
madcatzinc@0 13 --~ but WITHOUT ANY WARRANTY; without even the implied warranty of
madcatzinc@0 14 --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
madcatzinc@0 15 --~ GNU General Public License for more details.
madcatzinc@0 16
madcatzinc@0 17 --~ You should have received a copy of the GNU General Public License
madcatzinc@0 18 --~ along with this program; if not, write to the Free Software
madcatzinc@0 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
madcatzinc@0 20
madcatzinc@23 21 ------------------------------------------------------------------------------
madcatzinc@0 22
madcatzinc@23 23 local CallbackFactory_methods = {}
madcatzinc@23 24 local CallbackFactory_mt = {__index=CallbackFactory_methods}
madcatzinc@0 25
madcatzinc@23 26 local function CallbackFactory()
madcatzinc@23 27 local self = {}
madcatzinc@23 28 self.Frame = CreateFrame("Frame", "CallbackFactoryFrame", UIParent)
madcatzinc@23 29 self.Callbacks = {}
madcatzinc@23 30 self.Id = 1
madcatzinc@13 31
madcatzinc@23 32 setmetatable(self, CallbackFactory_mt)
madcatzinc@0 33
madcatzinc@23 34 return self
madcatzinc@23 35 end
madcatzinc@4 36
madcatzinc@23 37 function CallbackFactory_methods:AddCallback(fn)
madcatzinc@23 38 local name = "Button"..self.Id
madcatzinc@23 39 self.Callbacks[name] = CreateFrame("Button", name, self.Frame)
madcatzinc@23 40 self.Callbacks[name]:SetScript("OnClick", fn)
madcatzinc@23 41 self.Id = self.Id + 1
madcatzinc@23 42 return self.Callbacks[name],self.Frame,name
madcatzinc@23 43 end
madcatzinc@4 44
madcatzinc@23 45 function CallbackFactory_methods:RemoveCallback(name)
madcatzinc@23 46 self.Callbacks[name] = nil
madcatzinc@23 47 end
madcatzinc@4 48
madcatzinc@23 49 local callbacks = {}
madcatzinc@4 50
madcatzinc@23 51 function CallbackFactory_methods:GetCallback(name)
madcatzinc@23 52 return callbacks[name]
madcatzinc@23 53 end
madcatzinc@4 54
madcatzinc@23 55 ------------------------------------------------------------------------------
madcatzinc@4 56
madcatzinc@23 57 function callbacks.Map()
jerome@67 58 ToggleWorldMap()
madcatzinc@23 59 end
madcatzinc@4 60
madcatzinc@23 61 function callbacks.CharacterPage()
madcatzinc@23 62 ToggleCharacter("PaperDollFrame")
madcatzinc@23 63 end
madcatzinc@0 64
madcatzinc@23 65 function callbacks.Spellbook()
madcatzinc@23 66 ToggleFrame(SpellBookFrame)
madcatzinc@23 67 end
madcatzinc@0 68
madcatzinc@23 69 function callbacks.Macros()
madcatzinc@30 70 if MacroFrame and MacroFrame:IsShown() and MacroFrame:IsVisible() then
madcatzinc@23 71 HideUIPanel(MacroFrame)
madcatzinc@23 72 else
madcatzinc@23 73 ShowMacroFrame()
madcatzinc@23 74 end
madcatzinc@23 75 end
madcatzinc@0 76
madcatzinc@23 77 function callbacks.QuestLog()
jerome@67 78 ToggleQuestLog()
madcatzinc@23 79 end
madcatzinc@0 80
madcatzinc@23 81 function callbacks.Achievement()
madcatzinc@23 82 ToggleAchievementFrame()
madcatzinc@23 83 end
madcatzinc@23 84
madcatzinc@23 85 function callbacks.Inventory()
madcatzinc@23 86 ToggleAllBags()
madcatzinc@23 87 end
madcatzinc@23 88
madcatzinc@23 89 ------------------------------------------------------------------------------
madcatzinc@23 90
madcatzinc@23 91 CyborgMMO_CallbackFactory = CallbackFactory()
madcatzinc@23 92