comparison RatPageModel.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 e8a004a4177b
children ce4ddefb68c2
comparison
equal deleted inserted replaced
33:1c0af1810e06 34:6ce173840e68
75 self.data = data["Rat"] 75 self.data = data["Rat"]
76 if data then 76 if data then
77 for mode=1,RAT7.MODES do 77 for mode=1,RAT7.MODES do
78 for button=1,RAT7.BUTTONS do 78 for button=1,RAT7.BUTTONS do
79 if self.data[mode][button] then 79 if self.data[mode][button] then
80 local object = CyborgMMO_CreateWowObject(self.data[mode][button].Type, self.data[mode][button].Detail, self.data[mode][button].Subdetail) 80 local object = CyborgMMO_CreateWowObject(self.data[mode][button].type, self.data[mode][button].detail, self.data[mode][button].subdetail)
81 self:SetObjectOnButtonNoUpdate(button, mode, object) 81 self:SetObjectOnButtonNoUpdate(button, mode, object)
82 else 82 else
83 local object = CyborgMMO_CreateWowObject("", "", "") 83 local object = CyborgMMO_CreateWowObject()
84 self:SetObjectOnButtonNoUpdate(button, mode, object) 84 self:SetObjectOnButtonNoUpdate(button, mode, object)
85 self.data[mode][button] = object 85 self.data[mode][button] = object
86 end 86 end
87 end 87 end
88 end 88 end
90 end 90 end
91 end 91 end
92 92
93 function RatPageModel_methods:SaveData() 93 function RatPageModel_methods:SaveData()
94 CyborgMMO_DPrint("Saving...") 94 CyborgMMO_DPrint("Saving...")
95 CyborgMMO_SetSaveData(self.data, "Rat") 95 CyborgMMO_SetRatSaveData(self.data)
96 end 96 end
97 97
98 function RatPageModel_methods:SetMode(mode) 98 function RatPageModel_methods:SetMode(mode)
99 self.mode = mode 99 self.mode = mode
100 self:UpdateObservers() 100 self:UpdateObservers()
120 -- CyborgMMO_DPrint("button = "..tostring(button).." mode = "..tostring(mode)) 120 -- CyborgMMO_DPrint("button = "..tostring(button).." mode = "..tostring(mode))
121 self.data[mode][button] = object 121 self.data[mode][button] = object
122 122
123 if object then 123 if object then
124 object:SetBinding(CyborgMMO_ProfileKeyBindings[((mode-1)*RAT7.BUTTONS)+button]) 124 object:SetBinding(CyborgMMO_ProfileKeyBindings[((mode-1)*RAT7.BUTTONS)+button])
125 if("callback" == object.Type) then 125 if "callback" == object.type then
126 CyborgMMO_DPrint("trying to set texture") 126 CyborgMMO_DPrint("trying to set texture")
127 local slot = getglobal("CyborgMMO_MainPageSlotListSlot"..button) 127 local slot = getglobal("CyborgMMO_MainPageSlotListSlot"..button)
128 slot:SetNormalTexture(object.Texture) 128 slot:SetNormalTexture(object.texture)
129 end 129 end
130 else 130 else
131 CyborgMMO_DPrint("clearing "..button) 131 CyborgMMO_DPrint("clearing "..button)
132 CyborgMMO_ClearBinding(CyborgMMO_ProfileKeyBindings[((mode-1)*RAT7.BUTTONS)+button]) 132 CyborgMMO_ClearBinding(CyborgMMO_ProfileKeyBindings[((mode-1)*RAT7.BUTTONS)+button])
133 end 133 end