annotate CallbackFactory.lua @ 34:6ce173840e68

Reworked the whole "wow object" system: - Only save what is strictly necessary. - Save appropriate persistent information for all objects (like spellIDs instead of spellBook+spellIndex). - Fixed Battle Pets objects (non-combat pets in pre-MoP). - Fixed item objects. - Cleaned and simplified most objects implementation. - Moved the settings and button profile to the root of the saved data, rather than in a per-character sub-table (that data is already tagged as saved per character). This should fix most issues with objects changing without user interaction on diverse occasions. Old profiles are not converted to the new system. This will come soon. Some issues persist due to the asynchronous loading of some informations: - Pet icons are never properly loaded from saved data. - Items are not properly loaded the first time the UI is started (a "/reload ui" or disconnect/connect cycle fixes this problem).
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Thu, 25 Apr 2013 01:31:31 +0000
parents ea423ee3a8c1
children 2d6684c270b9
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()
madcatzinc@23 58 ToggleFrame(WorldMapFrame)
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()
madcatzinc@23 78 ToggleFrame(QuestLogFrame)
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