Mercurial > wow > cyborg-mmo7
changeset 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 | 9f2d838d4f8e |
children | a6f4c8f86130 |
files | CyborgMMO7.lua OptionPage.xml RatPageController.lua RatPageModel.lua RatPageView.lua WowObjects.lua |
diffstat | 6 files changed, 50 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/CyborgMMO7.lua Thu Apr 25 01:29:50 2013 +0000 +++ b/CyborgMMO7.lua Thu Apr 25 01:29:55 2013 +0000 @@ -19,7 +19,7 @@ --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. function CyborgMMO_LoadStrings(self) ---~ msg("LoadStrings("..self:GetName()..") = "..CyborgMMO_StringTable[self:GetName()]) +-- CyborgMMO_DPrint("LoadStrings("..self:GetName()..") = "..CyborgMMO_StringTable[self:GetName()]) self:SetText(CyborgMMO_StringTable[self:GetName()]) end @@ -111,10 +111,10 @@ elseif event == "PLAYER_ENTERING_WORLD" then CyborgMMO_EnteredWorld = true elseif event == "PLAYER_ENTER_COMBAT" then - msg("PLAYER_ENTER_COMBAT") + CyborgMMO_DPrint("PLAYER_ENTER_COMBAT") CyborgMMO_Close() else - msg("Event is "..tostring(event)) + CyborgMMO_DPrint("Event is "..tostring(event)) end -- Fire Loading if and only if the player is in the world and vars are loaded @@ -185,7 +185,7 @@ local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn) local result = SetOverrideBindingClick(parentFrame, true, CyborgMMO_Mode[modeNum], name, "LeftButton") if result ~= 1 then - msg("Failed to Bind modeChange") + CyborgMMO_DPrint("Failed to bind mode change") end end @@ -226,9 +226,26 @@ end end -function msg(m) - local id,name = GetChannelName("Debug") - SendChatMessage(m, "CHANNEL", nil, id) +function CyborgMMO_GetDebugFrame() + for i=1,NUM_CHAT_WINDOWS do + local windowName = GetChatWindowInfo(i); + if windowName == "Debug" then + return getglobal("ChatFrame" .. i) + end + end +end + +local log_prefix = "|cffff6666".."CyborgMMO".."|r:" + +function CyborgMMO_DPrint(...) + local debugframe = CyborgMMO_GetDebugFrame() + if debugframe then + local t = {log_prefix, ...} + for i=1,select('#', ...)+1 do + t[i] = tostring(t[i]) + end + debugframe:AddMessage(table.concat(t, ' ')) + end end function CyborgMMO_SetMainPageSize(percent)
--- a/OptionPage.xml Thu Apr 25 01:29:50 2013 +0000 +++ b/OptionPage.xml Thu Apr 25 01:29:55 2013 +0000 @@ -574,7 +574,7 @@ <Scripts> <OnLoad> CyborgMMO_LoadStrings(getglobal(self:GetName().."Title")) - msg("Loaded Option Page") + CyborgMMO_DPrint("Loaded Option Page") self = CyborgMMO_OptionView.new(self) </OnLoad> </Scripts>
--- a/RatPageController.lua Thu Apr 25 01:29:50 2013 +0000 +++ b/RatPageController.lua Thu Apr 25 01:29:55 2013 +0000 @@ -34,7 +34,7 @@ end self.ModeClicked = function(mode) - msg("Setting mode "..tostring(mode.Id)) + CyborgMMO_DPrint("Setting mode "..tostring(mode.Id)) CyborgMMO_RatPageModel.Instance().SetMode(mode.Id) end
--- a/RatPageModel.lua Thu Apr 25 01:29:50 2013 +0000 +++ b/RatPageModel.lua Thu Apr 25 01:29:55 2013 +0000 @@ -56,7 +56,7 @@ end self.LoadData = function() - msg("Loading...") + CyborgMMO_DPrint("Loading...") local data = CyborgMMO_GetSaveData() if not data["Rat"] then @@ -83,7 +83,7 @@ end self.SaveData = function() - msg("Saving...") + CyborgMMO_DPrint("Saving...") CyborgMMO_SetSaveData(self.Data, "Rat") end @@ -109,18 +109,18 @@ end self.SetObjectOnButtonNoUpdate = function(button, mode, object) - -- msg("button = "..tostring(button).." mode = "..tostring(mode)) + -- CyborgMMO_DPrint("button = "..tostring(button).." mode = "..tostring(mode)) self.Data[mode][button] = object if object then object.SetBinding(CyborgMMO_WowCommands[((mode-1)*RAT7.BUTTONS)+button]) if("callback" == object.Type) then - msg("trying to set texture") + CyborgMMO_DPrint("trying to set texture") local slot = getglobal("CyborgMMO_MainPageSlotListSlot"..button) slot:SetNormalTexture(object.Texture) end else - msg("clearing "..button) + CyborgMMO_DPrint("clearing "..button) CyborgMMO_WowObject.ClearBinding(CyborgMMO_WowCommands[((mode-1)*RAT7.BUTTONS)+button]) end end
--- a/RatPageView.lua Thu Apr 25 01:29:50 2013 +0000 +++ b/RatPageView.lua Thu Apr 25 01:29:55 2013 +0000 @@ -20,27 +20,27 @@ CyborgMMO_RatPageView = { new = function(self) - msg("new Rat Page View") + CyborgMMO_DPrint("new Rat Page View") for _,child in ipairs(self:GetChildren()) do child.Register() end self.SlotClicked = function(slot) - msg("View Recieved Click") + CyborgMMO_DPrint("View Recieved Click") CyborgMMO_RatPageController.Instance().SlotClicked(slot) end self.ModeClicked = function(mode) - msg("View Recieved Click") + CyborgMMO_DPrint("View Recieved Click") CyborgMMO_RatPageController.Instance().ModeClicked(mode) end self.RegisterMode = function() - msg("ModeRegistered") + CyborgMMO_DPrint("ModeRegistered") end self.RegisterSlot = function() - msg("SlotRegistered") + CyborgMMO_DPrint("SlotRegistered") end return self
--- a/WowObjects.lua Thu Apr 25 01:29:50 2013 +0000 +++ b/WowObjects.lua Thu Apr 25 01:29:55 2013 +0000 @@ -29,11 +29,11 @@ -- Methods -- self.DoAction = function() - msg("Nothing To Do") + CyborgMMO_DPrint("Nothing To Do") end self.Pickup = function() - msg("Pick up Item") + CyborgMMO_DPrint("Pick up Item") end self.SetBinding = function(key) @@ -50,7 +50,7 @@ local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(CyborgMMO_WowObject.DoNothing) local result = SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") if result ~= 1 then - msg("Failed to bind companion to button click") + CyborgMMO_DPrint("Failed to bind companion to button click") end end, @@ -155,7 +155,7 @@ self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" self.SetTextures = function(buttonFrame) - msg("TextureName = "..self.CallbackName) + CyborgMMO_DPrint("TextureName = "..self.CallbackName) buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") @@ -163,7 +163,7 @@ self.DoAction = function() local action = CyborgMMO_CallbackFactory.Instance().GetCallback(self.CallbackName) - msg("calling callback:- "..self.CallbackName) + CyborgMMO_DPrint("calling callback:- "..self.CallbackName) action() end @@ -180,7 +180,7 @@ end self.ClickHandler = function(self, button, down) - msg("click handler") + CyborgMMO_DPrint("click handler") CallbackCursor:StopMoving() CallbackCursor:Hide() end @@ -195,7 +195,7 @@ local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction) local result = SetOverrideBindingClick(CyborgMMO_CallbackFactory.Instance().Frame, true, key, name, "LeftButton") if result ~= 1 then - msg("Failed to Bind modeChange") + CyborgMMO_DPrint("Failed to Bind modeChange") end end @@ -222,7 +222,7 @@ -- override method -- self.DoAction = function() - msg("Use Item") + CyborgMMO_DPrint("Use Item") end -- override method -- @@ -254,7 +254,7 @@ -- override method -- self.DoAction = function() - msg("Cast Spell") + CyborgMMO_DPrint("Cast Spell") end -- override method -- @@ -266,7 +266,7 @@ end self.SetBinding = function(key) - msg("Binding to key "..key) + CyborgMMO_DPrint("Binding to key "..key) self.Key = key SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, self.Key, self.Type.." "..self.Name) end @@ -295,7 +295,7 @@ -- override method -- self.DoAction = function() - msg("Use Item") + CyborgMMO_DPrint("Use Item") end -- override method -- @@ -347,7 +347,7 @@ local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction) local result = SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") if result ~= 1 then - msg("Failed to bind companion to button click") + CyborgMMO_DPrint("Failed to bind companion to button click") end -- SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index) end @@ -377,7 +377,7 @@ -- override method -- self.DoAction = function() - msg("Use Item") + CyborgMMO_DPrint("Use Item") end -- override method -- @@ -425,7 +425,7 @@ local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); local result = SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") if result ~= 1 then - msg("Failed to bind companion to button click") + CyborgMMO_DPrint("Failed to bind companion to button click") end end