comparison CyborgMMO7.lua @ 15:80192bc4a108

Replaced the global msg function with CyborgMMO_DPrint: - avoids conflicts with other addons ('msg' is too generic) - has 'print' semantics (several values accepted, calls tostring) - use AddMessage with a colored prefix, instead of plain SendChatMessage
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Thu, 25 Apr 2013 01:29:55 +0000
parents 6cb9a2936580
children a6f4c8f86130
comparison
equal deleted inserted replaced
14:9f2d838d4f8e 15:80192bc4a108
17 --~ You should have received a copy of the GNU General Public License 17 --~ You should have received a copy of the GNU General Public License
18 --~ along with this program; if not, write to the Free Software 18 --~ along with this program; if not, write to the Free Software
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 20
21 function CyborgMMO_LoadStrings(self) 21 function CyborgMMO_LoadStrings(self)
22 --~ msg("LoadStrings("..self:GetName()..") = "..CyborgMMO_StringTable[self:GetName()]) 22 -- CyborgMMO_DPrint("LoadStrings("..self:GetName()..") = "..CyborgMMO_StringTable[self:GetName()])
23 self:SetText(CyborgMMO_StringTable[self:GetName()]) 23 self:SetText(CyborgMMO_StringTable[self:GetName()])
24 end 24 end
25 25
26 local CyborgMMO_VarsLoaded = false 26 local CyborgMMO_VarsLoaded = false
27 local CyborgMMO_EnteredWorld = false 27 local CyborgMMO_EnteredWorld = false
109 if event == "VARIABLES_LOADED" then 109 if event == "VARIABLES_LOADED" then
110 CyborgMMO_VarsLoaded = true 110 CyborgMMO_VarsLoaded = true
111 elseif event == "PLAYER_ENTERING_WORLD" then 111 elseif event == "PLAYER_ENTERING_WORLD" then
112 CyborgMMO_EnteredWorld = true 112 CyborgMMO_EnteredWorld = true
113 elseif event == "PLAYER_ENTER_COMBAT" then 113 elseif event == "PLAYER_ENTER_COMBAT" then
114 msg("PLAYER_ENTER_COMBAT") 114 CyborgMMO_DPrint("PLAYER_ENTER_COMBAT")
115 CyborgMMO_Close() 115 CyborgMMO_Close()
116 else 116 else
117 msg("Event is "..tostring(event)) 117 CyborgMMO_DPrint("Event is "..tostring(event))
118 end 118 end
119 119
120 -- Fire Loading if and only if the player is in the world and vars are loaded 120 -- Fire Loading if and only if the player is in the world and vars are loaded
121 if not CyborgMMO_LoadBinding then 121 if not CyborgMMO_LoadBinding then
122 if CyborgMMO_VarsLoaded then 122 if CyborgMMO_VarsLoaded then
183 end 183 end
184 184
185 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn) 185 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn)
186 local result = SetOverrideBindingClick(parentFrame, true, CyborgMMO_Mode[modeNum], name, "LeftButton") 186 local result = SetOverrideBindingClick(parentFrame, true, CyborgMMO_Mode[modeNum], name, "LeftButton")
187 if result ~= 1 then 187 if result ~= 1 then
188 msg("Failed to Bind modeChange") 188 CyborgMMO_DPrint("Failed to bind mode change")
189 end 189 end
190 end 190 end
191 191
192 function CyborgMMO_Loaded() 192 function CyborgMMO_Loaded()
193 CyborgMMO_MainPage:RegisterEvent("VARIABLES_LOADED") 193 CyborgMMO_MainPage:RegisterEvent("VARIABLES_LOADED")
224 else 224 else
225 CyborgMMO_Open() 225 CyborgMMO_Open()
226 end 226 end
227 end 227 end
228 228
229 function msg(m) 229 function CyborgMMO_GetDebugFrame()
230 local id,name = GetChannelName("Debug") 230 for i=1,NUM_CHAT_WINDOWS do
231 SendChatMessage(m, "CHANNEL", nil, id) 231 local windowName = GetChatWindowInfo(i);
232 if windowName == "Debug" then
233 return getglobal("ChatFrame" .. i)
234 end
235 end
236 end
237
238 local log_prefix = "|cffff6666".."CyborgMMO".."|r:"
239
240 function CyborgMMO_DPrint(...)
241 local debugframe = CyborgMMO_GetDebugFrame()
242 if debugframe then
243 local t = {log_prefix, ...}
244 for i=1,select('#', ...)+1 do
245 t[i] = tostring(t[i])
246 end
247 debugframe:AddMessage(table.concat(t, ' '))
248 end
232 end 249 end
233 250
234 function CyborgMMO_SetMainPageSize(percent) 251 function CyborgMMO_SetMainPageSize(percent)
235 if CyborgMMO_VarsLoaded then 252 if CyborgMMO_VarsLoaded then
236 if CyborgMMO_EnteredWorld then 253 if CyborgMMO_EnteredWorld then