vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Name: idChat2_Buttons |
||
3 | Developed by: Curney of Uther |
||
4 | Originally by: Industrial |
||
5 | Thanks to: Wubin for helping me understand hooking better |
||
6 | Website: http://wiki.wowace.com/idChat2_Buttons |
||
7 | SVN: http://svn.wowace.com/root/trunk/idChat2_Buttons |
||
8 | Description: Module for idChat2 that toggles the chat menu and chat window buttons on and off (default=off). |
||
9 | Dependencies: idChat2 |
||
10 | ]] |
||
11 | |||
12 | idChat2_Buttons = idChat2:NewModule('buttons') |
||
13 | |||
14 | function idChat2_Buttons:OnInitialize() |
||
15 | |||
16 | self.db = idChat2:AcquireDBNamespace('Buttons') |
||
17 | |||
18 | idChat2:RegisterDefaults('Buttons', 'profile', { |
||
19 | on = true, |
||
20 | default = true, |
||
21 | menu = false, |
||
22 | chatframe = {false, false, false, false, false, false, false} |
||
23 | }) |
||
24 | |||
25 | idChat2.Options.args.buttons = { |
||
26 | name = "Buttons", |
||
27 | desc = "Toggle the chat menu and chat window buttons on and off (default=off)", |
||
28 | type = "group", |
||
29 | args = { |
||
30 | toggle = { |
||
31 | name = "Toggle", |
||
32 | desc = "Toggle the module on and off", |
||
33 | type = "toggle", |
||
34 | get = function() return self.db.profile.on end, |
||
35 | set = function(v) |
||
36 | if v then |
||
37 | self:OnEnable() |
||
38 | else |
||
39 | self:OnDisable() |
||
40 | end |
||
41 | self.db.profile.on = v |
||
42 | end |
||
43 | }, |
||
44 | chatmenu = { |
||
45 | name = "ChatMenu", |
||
46 | type = "toggle", |
||
47 | desc = "Toggles chat menu on and off", |
||
48 | get = function() return self.db.profile.menu end, |
||
49 | set = function(v) |
||
50 | self.db.profile.menu = v |
||
51 | self:Menu(v) |
||
52 | end |
||
53 | }, |
||
54 | chat1 = { |
||
55 | name = "Chat1Buttons", |
||
56 | type = "toggle", |
||
57 | desc = "Toggles buttons on and off for chat window 1", |
||
58 | get = function() return self.db.profile.chatframe[1] end, |
||
59 | set = function(v) |
||
60 | self.db.profile.chatframe[1] = v |
||
61 | self:Buttons(1,v) |
||
62 | end |
||
63 | }, |
||
64 | chat2 = { |
||
65 | name = "Chat2Buttons", |
||
66 | type = "toggle", |
||
67 | desc = "Toggles buttons on and off for chat window 2", |
||
68 | get = function() return self.db.profile.chatframe[2] end, |
||
69 | set = function(v) |
||
70 | self.db.profile.chatframe[2] = v |
||
71 | self:Buttons(2,v) |
||
72 | end |
||
73 | }, |
||
74 | chat3 = { |
||
75 | name = "Chat3Buttons", |
||
76 | type = "toggle", |
||
77 | desc = "Toggles buttons on and off for chat window 3", |
||
78 | get = function() return self.db.profile.chatframe[3] end, |
||
79 | set = function(v) |
||
80 | self.db.profile.chatframe[3] = v |
||
81 | self:Buttons(3,v) |
||
82 | end |
||
83 | }, |
||
84 | chat4 = { |
||
85 | name = "Chat4Buttons", |
||
86 | type = "toggle", |
||
87 | desc = "Toggles buttons on and off for chat window 4", |
||
88 | get = function() return self.db.profile.chatframe[4] end, |
||
89 | set = function(v) |
||
90 | self.db.profile.chatframe[4] = v |
||
91 | self:Buttons(4,v) |
||
92 | end |
||
93 | }, |
||
94 | chat5 = { |
||
95 | name = "Chat5Buttons", |
||
96 | type = "toggle", |
||
97 | desc = "Toggles buttons on and off for chat window 5", |
||
98 | get = function() return self.db.profile.chatframe[5] end, |
||
99 | set = function(v) |
||
100 | self.db.profile.chatframe[5] = v |
||
101 | self:Buttons(5,v) |
||
102 | end |
||
103 | }, |
||
104 | chat6 = { |
||
105 | name = "Chat6Buttons", |
||
106 | type = "toggle", |
||
107 | desc = "Toggles buttons on and off for chat window 6", |
||
108 | get = function() return self.db.profile.chatframe[6] end, |
||
109 | set = function(v) |
||
110 | self.db.profile.chatframe[6] = v |
||
111 | self:Buttons(6,v) |
||
112 | end |
||
113 | }, |
||
114 | chat7 = { |
||
115 | name = "Chat7Buttons", |
||
116 | type = "toggle", |
||
117 | desc = "Toggles buttons on and off for chat window 7", |
||
118 | get = function() return self.db.profile.chatframe[7] end, |
||
119 | set = function(v) |
||
120 | self.db.profile.chatframe[7] = v |
||
121 | self:Buttons(7,v) |
||
122 | end |
||
123 | } |
||
124 | } |
||
125 | } |
||
126 | end |
||
127 | |||
128 | function idChat2_Buttons:OnEnable() |
||
129 | self:Hook("ChatFrame_OnUpdate") |
||
130 | end |
||
131 | |||
132 | function idChat2_Buttons:OnDisable() |
||
133 | self:Unhook("ChatFrame_OnUpdate") |
||
134 | self:Menu(self.db.profile.default) |
||
135 | for i = 1, 7 do |
||
136 | self:Buttons(i,self.db.profile.default) |
||
137 | end |
||
138 | end |
||
139 | |||
140 | function idChat2_Buttons:ChatFrame_OnUpdate(elapsed) |
||
141 | self.hooks["ChatFrame_OnUpdate"](elapsed) |
||
142 | self:Control() |
||
143 | end |
||
144 | |||
145 | function idChat2_Buttons:Control() |
||
146 | self:Menu(self.db.profile.menu) |
||
147 | for i = 1, 7 do |
||
148 | self:Buttons(i,self.db.profile.chatframe[i]) |
||
149 | end |
||
150 | end |
||
151 | |||
152 | function idChat2_Buttons:Menu(visible) |
||
153 | if visible then |
||
154 | ChatFrameMenuButton:Show() |
||
155 | else |
||
156 | ChatFrameMenuButton:Hide() |
||
157 | end |
||
158 | end |
||
159 | |||
160 | function idChat2_Buttons:Buttons(frame,visible) |
||
161 | if visible then |
||
162 | getglobal('ChatFrame'..frame..'UpButton'):Show() |
||
163 | getglobal('ChatFrame'..frame..'DownButton'):Show() |
||
164 | getglobal('ChatFrame'..frame..'BottomButton'):Show() |
||
165 | else |
||
166 | getglobal('ChatFrame'..frame..'UpButton'):Hide() |
||
167 | getglobal('ChatFrame'..frame..'DownButton'):Hide() |
||
168 | getglobal('ChatFrame'..frame..'BottomButton'):Hide() |
||
169 | end |
||
170 | end |