annotate RatPageController.lua @ 34:6ce173840e68

Reworked the whole "wow object" system: - Only save what is strictly necessary. - Save appropriate persistent information for all objects (like spellIDs instead of spellBook+spellIndex). - Fixed Battle Pets objects (non-combat pets in pre-MoP). - Fixed item objects. - Cleaned and simplified most objects implementation. - Moved the settings and button profile to the root of the saved data, rather than in a per-character sub-table (that data is already tagged as saved per character). This should fix most issues with objects changing without user interaction on diverse occasions. Old profiles are not converted to the new system. This will come soon. Some issues persist due to the asynchronous loading of some informations: - Pet icons are never properly loaded from saved data. - Items are not properly loaded the first time the UI is started (a "/reload ui" or disconnect/connect cycle fixes this problem).
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Thu, 25 Apr 2013 01:31:31 +0000
parents b7074b47cfc7
children 3b1f85a1cbb1
rev   line source
madcatzinc@13 1 --~ Warcraft Plugin for Cyborg MMO7
madcatzinc@0 2 --~ Filename: RatPageController.lua
madcatzinc@0 3 --~ Description: Controller logic for the RatPage
madcatzinc@0 4 --~ Copyright (C) 2012 Mad Catz Inc.
madcatzinc@0 5 --~ Author: Christopher Hooks
madcatzinc@0 6
madcatzinc@0 7 --~ This program is free software; you can redistribute it and/or
madcatzinc@0 8 --~ modify it under the terms of the GNU General Public License
madcatzinc@0 9 --~ as published by the Free Software Foundation; either version 2
madcatzinc@0 10 --~ of the License, or (at your option) any later version.
madcatzinc@0 11
madcatzinc@0 12 --~ This program is distributed in the hope that it will be useful,
madcatzinc@0 13 --~ but WITHOUT ANY WARRANTY; without even the implied warranty of
madcatzinc@0 14 --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
madcatzinc@0 15 --~ GNU General Public License for more details.
madcatzinc@0 16
madcatzinc@0 17 --~ You should have received a copy of the GNU General Public License
madcatzinc@0 18 --~ along with this program; if not, write to the Free Software
madcatzinc@0 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
madcatzinc@0 20
madcatzinc@18 21 ------------------------------------------------------------------------------
madcatzinc@0 22
madcatzinc@18 23 local RatPageController_methods = {}
madcatzinc@18 24 local RatPageController_mt = {__index=RatPageController_methods}
madcatzinc@0 25
madcatzinc@18 26 local function RatPageController()
madcatzinc@18 27 local self = {}
madcatzinc@18 28 -- CyborgMMO_RatPageModel:SetMode(1)
madcatzinc@18 29 setmetatable(self, RatPageController_mt)
madcatzinc@18 30 return self
madcatzinc@18 31 end
madcatzinc@18 32
madcatzinc@18 33 function RatPageController_methods:SlotClicked(slot)
madcatzinc@18 34 local slotObject = nil
madcatzinc@18 35 slotObject = CyborgMMO_RatPageModel:GetObjectOnButton(slot.Id)
madcatzinc@18 36 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), self:GetCursorObject())
madcatzinc@18 37
madcatzinc@18 38 if slotObject then
madcatzinc@25 39 slotObject:Pickup()
madcatzinc@18 40 end
madcatzinc@18 41 end
madcatzinc@18 42
madcatzinc@18 43 function RatPageController_methods:ModeClicked(mode)
madcatzinc@18 44 CyborgMMO_DPrint("Setting mode "..tostring(mode.Id))
madcatzinc@18 45 CyborgMMO_RatPageModel:SetMode(mode.Id)
madcatzinc@18 46 end
madcatzinc@18 47
madcatzinc@18 48 function RatPageController_methods:GetCursorObject()
madcatzinc@34 49 local type,a,b,c = GetCursorInfo()
madcatzinc@34 50 ClearCursor()
madcatzinc@34 51 if type=='item' then
madcatzinc@34 52 local id,link = a,b
madcatzinc@34 53 return CyborgMMO_CreateWowObject('item', id)
madcatzinc@34 54 elseif type=='spell' then
madcatzinc@34 55 local index,book,id = a,b,c
madcatzinc@34 56 return CyborgMMO_CreateWowObject('spell', id)
madcatzinc@34 57 elseif type=='macro' then
madcatzinc@34 58 local index = a
madcatzinc@34 59 local name = GetMacroInfo(index)
madcatzinc@34 60 return CyborgMMO_CreateWowObject('macro', name)
madcatzinc@34 61 elseif type=='companion' then
madcatzinc@34 62 local index,subtype = a,b
madcatzinc@34 63 local spellID = select(3, GetCompanionInfo(subtype, index))
madcatzinc@34 64 return CyborgMMO_CreateWowObject('companion', spellID)
madcatzinc@34 65 elseif type=='battlepet' then
madcatzinc@34 66 local petID = a
madcatzinc@34 67 return CyborgMMO_CreateWowObject('battlepet', petID)
madcatzinc@34 68 elseif type=='petaction' then
madcatzinc@34 69 return nil
madcatzinc@34 70 elseif type=='money' then
madcatzinc@34 71 return nil
madcatzinc@34 72 elseif type=='merchant' then
madcatzinc@34 73 return nil
madcatzinc@34 74 elseif type==nil then
madcatzinc@34 75 return nil
madcatzinc@34 76 else
madcatzinc@34 77 CyborgMMO_DPrint("unexpected cursor info:", type, a, b, c)
madcatzinc@34 78 return nil
madcatzinc@18 79 end
madcatzinc@18 80 end
madcatzinc@18 81
madcatzinc@18 82 function RatPageController_methods:CallbackDropped(callbackObject)
madcatzinc@18 83 local slot = nil
madcatzinc@18 84 local observers = CyborgMMO_RatPageModel:GetAllObservers()
madcatzinc@18 85 for i=1,#observers do
madcatzinc@18 86 if MouseIsOver(observers[i]) then
madcatzinc@18 87 slot = observers[i]
madcatzinc@18 88 break
madcatzinc@0 89 end
madcatzinc@18 90 end
madcatzinc@18 91 if slot then
madcatzinc@18 92 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), callbackObject.wowObject)
madcatzinc@18 93 end
madcatzinc@18 94 end
madcatzinc@0 95
madcatzinc@18 96 ------------------------------------------------------------------------------
madcatzinc@0 97
madcatzinc@18 98 CyborgMMO_RatPageController = RatPageController()
madcatzinc@13 99