Mercurial > wow > cyborg-mmo7
comparison RatPageController.lua @ 13:6cb9a2936580
Miscellanous Lua code consistency improvements:
- no semicolon except between statements on same line
- use of implicit cast to bool in if/while conditions, instead of various eq/neq against true, false or nil
- no parenthesis around if/while conditions (C-ism)
- avoid long function calls in if conditions
- removed space in comma-separated expressions lists in multiple assignments
- added spaces between arguments of functions calls
- use tabs for indentation (in Lua files only)
- don't reverse == in if conditions, like "if 42==foo then" (C-ism)
- removed some extra parenthesis in complex expressions (C-ism)
- added spaces around operators in most expressions for ease of reading
- added comma after last element of table initializers
- removed space after # operator
- moved comment prefix of disabled code into tab (to keep disabled code aligned)
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
|---|---|
| date | Thu, 25 Apr 2013 01:29:45 +0000 |
| parents | d186f8cd5000 |
| children | 80192bc4a108 |
comparison
equal
deleted
inserted
replaced
| 12:72b92b3e476e | 13:6cb9a2936580 |
|---|---|
| 1 --~ Warcraft Plugin for Cyborg MMO7 | 1 --~ Warcraft Plugin for Cyborg MMO7 |
| 2 --~ Filename: RatPageController.lua | 2 --~ Filename: RatPageController.lua |
| 3 --~ Description: Controller logic for the RatPage | 3 --~ Description: Controller logic for the RatPage |
| 4 --~ Copyright (C) 2012 Mad Catz Inc. | 4 --~ Copyright (C) 2012 Mad Catz Inc. |
| 5 --~ Author: Christopher Hooks | 5 --~ Author: Christopher Hooks |
| 6 | 6 |
| 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 CyborgMMO_RatPageController = { | 21 CyborgMMO_RatPageController = { |
| 22 new = function() | 22 new = function() |
| 23 local self = {}; | 23 local self = {} |
| 24 CyborgMMO_RatPageModel.Instance().SetMode(1); | 24 CyborgMMO_RatPageModel.Instance().SetMode(1) |
| 25 | 25 |
| 26 self.SlotClicked = function(slot) | 26 self.SlotClicked = function(slot) |
| 27 local slotObject = nil | 27 local slotObject = nil |
| 28 slotObject = CyborgMMO_RatPageModel.Instance().GetObjectOnButton(slot.Id) | 28 slotObject = CyborgMMO_RatPageModel.Instance().GetObjectOnButton(slot.Id) |
| 29 CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), self.GetCursorObject()); | 29 CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), self.GetCursorObject()) |
| 30 | 30 |
| 31 if(slotObject ~= nil) then | 31 if slotObject then |
| 32 slotObject.Pickup(); | 32 slotObject.Pickup() |
| 33 end | 33 end |
| 34 | |
| 35 end | 34 end |
| 36 | 35 |
| 37 self.ModeClicked = function(mode) | 36 self.ModeClicked = function(mode) |
| 38 msg("Setting mode "..tostring(mode.Id)); | 37 msg("Setting mode "..tostring(mode.Id)) |
| 39 CyborgMMO_RatPageModel.Instance().SetMode(mode.Id); | 38 CyborgMMO_RatPageModel.Instance().SetMode(mode.Id) |
| 40 end | 39 end |
| 41 | 40 |
| 42 self.GetCursorObject = function() | 41 self.GetCursorObject = function() |
| 43 local cursorObject = nil; | 42 local cursorObject = nil |
| 44 if(nil ~= GetCursorInfo()) then | 43 if GetCursorInfo() then |
| 45 local type, detail, subdetail = GetCursorInfo(); | 44 local type,detail,subdetail = GetCursorInfo() |
| 46 cursorObject = CyborgMMO_WowObject.Create(type, detail, subdetail); | 45 cursorObject = CyborgMMO_WowObject.Create(type, detail, subdetail) |
| 47 ClearCursor(); | 46 ClearCursor() |
| 48 end | 47 end |
| 49 return cursorObject; | 48 return cursorObject |
| 50 end | 49 end |
| 51 | 50 |
| 52 self.CallbackDropped = function(callbackObject) | 51 self.CallbackDropped = function(callbackObject) |
| 53 local slot = nil; | 52 local slot = nil |
| 54 local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers(); | 53 local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers() |
| 55 for i = 1, (# observers) do | 54 for i=1,#observers do |
| 56 if(MouseIsOver(observers[i])) then | 55 if MouseIsOver(observers[i]) then |
| 57 slot = observers[i]; | 56 slot = observers[i] |
| 58 break; | 57 break |
| 59 end | 58 end |
| 60 end | 59 end |
| 61 if(nil ~= slot) then | 60 if slot then |
| 62 CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), callbackObject.wowObject); | 61 CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), callbackObject.wowObject) |
| 63 end | 62 end |
| 64 end | 63 end |
| 65 | |
| 66 | |
| 67 | 64 |
| 68 self.Close = function() | 65 self.Close = function() |
| 69 | |
| 70 end | 66 end |
| 71 | 67 |
| 72 self.Open = function() | 68 self.Open = function() |
| 73 end | 69 end |
| 74 | 70 |
| 75 return self; | 71 return self |
| 76 end, | 72 end, |
| 77 | 73 |
| 78 m_Instance = nil, | 74 m_Instance = nil, |
| 79 | 75 |
| 80 Instance = function() | 76 Instance = function() |
| 81 if(nil == CyborgMMO_RatPageController.m_Instance) then | 77 if not CyborgMMO_RatPageController.m_Instance then |
| 82 CyborgMMO_RatPageController.m_Instance = CyborgMMO_RatPageController.new(); | 78 CyborgMMO_RatPageController.m_Instance = CyborgMMO_RatPageController.new() |
| 83 end | 79 end |
| 84 return CyborgMMO_RatPageController.m_Instance; | 80 return CyborgMMO_RatPageController.m_Instance |
| 85 end | 81 end, |
| 86 } | 82 } |
| 83 |
