Mercurial > wow > cyborg-mmo7
view 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 |
line wrap: on
line source
--~ Warcraft Plugin for Cyborg MMO7 --~ Filename: RatPageController.lua --~ Description: Controller logic for the RatPage --~ Copyright (C) 2012 Mad Catz Inc. --~ Author: Christopher Hooks --~ This program is free software; you can redistribute it and/or --~ modify it under the terms of the GNU General Public License --~ as published by the Free Software Foundation; either version 2 --~ of the License, or (at your option) any later version. --~ This program is distributed in the hope that it will be useful, --~ but WITHOUT ANY WARRANTY; without even the implied warranty of --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --~ GNU General Public License for more details. --~ You should have received a copy of the GNU General Public License --~ along with this program; if not, write to the Free Software --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. CyborgMMO_RatPageController = { new = function() local self = {} CyborgMMO_RatPageModel.Instance().SetMode(1) self.SlotClicked = function(slot) local slotObject = nil slotObject = CyborgMMO_RatPageModel.Instance().GetObjectOnButton(slot.Id) CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), self.GetCursorObject()) if slotObject then slotObject.Pickup() end end self.ModeClicked = function(mode) msg("Setting mode "..tostring(mode.Id)) CyborgMMO_RatPageModel.Instance().SetMode(mode.Id) end self.GetCursorObject = function() local cursorObject = nil if GetCursorInfo() then local type,detail,subdetail = GetCursorInfo() cursorObject = CyborgMMO_WowObject.Create(type, detail, subdetail) ClearCursor() end return cursorObject end self.CallbackDropped = function(callbackObject) local slot = nil local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers() for i=1,#observers do if MouseIsOver(observers[i]) then slot = observers[i] break end end if slot then CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), callbackObject.wowObject) end end self.Close = function() end self.Open = function() end return self end, m_Instance = nil, Instance = function() if not CyborgMMO_RatPageController.m_Instance then CyborgMMO_RatPageController.m_Instance = CyborgMMO_RatPageController.new() end return CyborgMMO_RatPageController.m_Instance end, }