comparison CyborgMMO7.lua @ 4:d186f8cd5000

Renamed functions to avoid conflicts
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Mon, 28 May 2012 15:54:52 +0000
parents a4e2eaf9cad9
children 8428fa7cf0e4
comparison
equal deleted inserted replaced
3:461854a2849c 4:d186f8cd5000
20 20
21 21
22 22
23 23
24 24
25 function LoadStrings(self) 25 function CyborgMMO_LoadStrings(self)
26 --~ msg("LoadStrings("..self:GetName()..") = "..StringTable[self:GetName()])
26 self:SetText(StringTable[self:GetName()]); 27 self:SetText(StringTable[self:GetName()]);
27 end 28 end
28 29
29 local VarsLoaded = false; 30 local VarsLoaded = false;
30 local EnteredWorld = false; 31 local EnteredWorld = false;
31 local LoadBinding = false; 32 local LoadBinding = false;
32 local SaveName = GetRealmName().."_"..UnitName("player"); 33 local SaveName = GetRealmName().."_"..UnitName("player");
33 local Settings = nil; 34 local Settings = nil;
34 35
35 36
36 function CyborgMiniMapButton_Reposition(pos) 37 function CyborgMMO_MiniMapButtonReposition(pos)
37 CyborgMiniMapFrame:SetPoint("TOPLEFT", 38 CyborgMMO_MiniMapFrame:SetPoint("TOPLEFT",
38 "Minimap", 39 "Minimap",
39 "TOPLEFT", 40 "TOPLEFT",
40 52-(80*cos(pos)), 41 52-(80*cos(pos)),
41 (80*sin(pos))-52) 42 (80*sin(pos))-52)
42 end 43 end
43 44
44 45
45 function CyborgMiniMapButton_OnUpdate() 46 function CyborgMMO_MiniMapButtonOnUpdate()
46 47
47 local xpos,ypos = GetCursorPosition() 48 local xpos,ypos = GetCursorPosition()
48 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom() 49 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
49 50
50 xpos = (xmin)-(xpos / UIParent:GetScale()) 51 xpos = (xmin)-(xpos / UIParent:GetScale())
55 while(degrees < 0) do 56 while(degrees < 0) do
56 degrees = degrees + 360; 57 degrees = degrees + 360;
57 end 58 end
58 59
59 60
60 CyborgMiniMapButton_Reposition(degrees) 61 CyborgMMO_MiniMapButtonReposition(degrees)
61 end 62 end
62 63
63 function MouseModeChange(mode) 64 function CyborgMMO_MouseModeChange(mode)
64 local MiniMapTexture = getglobal("CyborgMiniMapButton_Icon") 65 local MiniMapTexture = getglobal("CyborgMMO_MiniMapFrameButton_Icon")
65 local MiniMapGlowTexture = getglobal("CyborgMiniMapButton_IconGlow") 66 local MiniMapGlowTexture = getglobal("CyborgMMO_MiniMapFrameButton_IconGlow")
66 local OpenButtonTexture = getglobal("OpenButtonPage".."OpenMainForm"):GetNormalTexture(); 67 local OpenButtonTexture = getglobal("CyborgMMO_OpenButtonPage".."OpenMainForm"):GetNormalTexture();
67 local OpenButtonGlowTexture = getglobal("OpenButtonPage".."OpenMainForm"):GetHighlightTexture(); 68 local OpenButtonGlowTexture = getglobal("CyborgMMO_OpenButtonPage".."OpenMainForm"):GetHighlightTexture();
68 if(1==mode) then 69 if(1==mode) then
69 MiniMapTexture:SetVertexColor(1,0,0,1) 70 MiniMapTexture:SetVertexColor(1,0,0,1)
70 --MiniMapGlowTexture:SetVertexColor(1,0.26,0.26,.75); 71 --MiniMapGlowTexture:SetVertexColor(1,0.26,0.26,.75);
71 OpenButtonTexture:SetVertexColor(1,0,0,0.75); 72 OpenButtonTexture:SetVertexColor(1,0,0,0.75);
72 --OpenButtonGlowTexture:SetVertexColor(1,0.26,0.26,0.50); 73 --OpenButtonGlowTexture:SetVertexColor(1,0.26,0.26,0.50);
81 OpenButtonTexture:SetVertexColor(0.52,0.08,0.89,0.75); 82 OpenButtonTexture:SetVertexColor(0.52,0.08,0.89,0.75);
82 OpenButtonGlowTexture:SetVertexColor(0.67,0.31,0.85,0.5); 83 OpenButtonGlowTexture:SetVertexColor(0.67,0.31,0.85,0.5);
83 end 84 end
84 end 85 end
85 86
86 function LoadWowCommands() 87 function CyborgMMO_LoadWowCommands()
87 if (ProfileKeyBindings == nil) then 88 if (ProfileKeyBindings == nil) then
88 ProfileKeyBindings = {} 89 ProfileKeyBindings = {}
89 ProfileKeyBindings = InternationalWowCommands[GetLocale()] 90 ProfileKeyBindings = InternationalWowCommands[GetLocale()]
90 end 91 end
91 WowCommands = ProfileKeyBindings 92 WowCommands = ProfileKeyBindings
92 end 93 end
93 94
94 function GetSaveData() 95 function CyborgMMO_GetSaveData()
95 if(VarsLoaded) then 96 if(VarsLoaded) then
96 if (CyborgMMO7SaveData == nil) then 97 if (CyborgMMO7SaveData == nil) then
97 CyborgMMO7SaveData = {}; 98 CyborgMMO7SaveData = {};
98 CyborgMMO7SaveData[SaveName] = {} 99 CyborgMMO7SaveData[SaveName] = {}
99 end 100 end
100 LoadWowCommands() 101 CyborgMMO_LoadWowCommands()
101 return CyborgMMO7SaveData[SaveName]; 102 return CyborgMMO7SaveData[SaveName];
102 end 103 end
103 return nil; 104 return nil;
104 end 105 end
105 106
106 function SetSaveData(data, index) 107 function CyborgMMO_SetSaveData(data, index)
107 if(VarsLoaded) then 108 if(VarsLoaded) then
108 GetSaveData()[index] = data 109 CyborgMMO_GetSaveData()[index] = data
109 ProfileKeyBindings = WowCommands 110 ProfileKeyBindings = WowCommands
110 end 111 end
111 end 112 end
112 113
113 function Event(self, event, ...) 114 function CyborgMMO_Event(self, event, ...)
114 if(event == "VARIABLES_LOADED") then 115 if(event == "VARIABLES_LOADED") then
115 VarsLoaded = true; 116 VarsLoaded = true;
116 elseif(event == "PLAYER_ENTERING_WORLD") then 117 elseif(event == "PLAYER_ENTERING_WORLD") then
117 EnteredWorld = true; 118 EnteredWorld = true;
118 elseif(event == "PLAYER_ENTER_COMBAT") then 119 elseif(event == "PLAYER_ENTER_COMBAT") then
127 128
128 -- Fire Loading if and only if the player is in the world and vars are loaded 129 -- Fire Loading if and only if the player is in the world and vars are loaded
129 if(false == LoadBinding) then 130 if(false == LoadBinding) then
130 if(VarsLoaded) then 131 if(VarsLoaded) then
131 if(EnteredWorld) then 132 if(EnteredWorld) then
132 local data = GetSaveData() 133 local data = CyborgMMO_GetSaveData()
133 134
134 RatPageModel.Instance().LoadData(); 135 CyborgMMO_RatPageModel.Instance().LoadData();
135 LoadBinding = true; 136 LoadBinding = true;
136 137
137 ShowMacroFrame(); 138 ShowMacroFrame();
138 HideUIPanel(MacroFrame); 139 HideUIPanel(MacroFrame);
139 140
140 141
141 SetupModeCallbacks(1); 142 CyborgMMO_SetupModeCallbacks(1);
142 SetupModeCallbacks(2); 143 CyborgMMO_SetupModeCallbacks(2);
143 SetupModeCallbacks(3); 144 CyborgMMO_SetupModeCallbacks(3);
144 145
145 146
146 --Reload Slider values: 147 --Reload Slider values:
147 if(nil == data["Settings"]) then 148 if(nil == data["Settings"]) then
148 data["Settings"] = {} 149 data["Settings"] = {}
152 data["Settings"]["CyborgButton"] = true; 153 data["Settings"]["CyborgButton"] = true;
153 end 154 end
154 155
155 Settings = data["Settings"]; 156 Settings = data["Settings"];
156 157
157 CyborgSizeSlider:SetValue(Settings["Cyborg"]); 158 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(Settings["Cyborg"]);
158 SetOpenButtonSize(Settings["Cyborg"]) 159 CyborgMMO_SetOpenButtonSize(Settings["Cyborg"])
159 PluginSizeSlider:SetValue(Settings["Plugin"]); 160 CyborgMMO_OptionPagePluginSizeSlider:SetValue(Settings["Plugin"]);
160 SetMainPageSize(Settings["Plugin"]); 161 CyborgMMO_SetMainPageSize(Settings["Plugin"]);
161 162
162 if(Settings["MiniMapButton"] == false) then 163 CyborgMMO_SetMiniMapButton(Settings["MiniMapButton"])
163 CyborgMiniMapButton:Hide(); 164 CyborgMMO_SetCyborgHeadButton(Settings["CyborgButton"])
164 end
165 165
166 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom() 166 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
167 CyborgMiniMapButton_Reposition(math.deg(math.atan2(ymin,xmin))) 167 CyborgMMO_MiniMapButtonReposition(math.deg(math.atan2(ymin,xmin)))
168 -- Close the main window for now 168 -- Close the main window for now
169 Close(); 169 CyborgMMO_Close();
170 end 170 end
171 end 171 end
172 end 172 end
173 end 173 end
174 174
175 function SetDefaultSettings() 175 function CyborgMMO_SetDefaultSettings()
176 OpenButtonPageOpenMainForm:ClearAllPoints(); 176 CyborgMMO_OpenButtonPageOpenMainForm:ClearAllPoints();
177 MainPage:ClearAllPoints(); 177 CyborgMMO_MainPage:ClearAllPoints();
178 OpenButtonPageOpenMainForm:SetPoint("LEFT", UIParent, "LEFT", 0, 0); 178 CyborgMMO_OpenButtonPageOpenMainForm:SetPoint("LEFT", UIParent, "LEFT", 0, 0);
179 MainPage:SetPoint("LEFT", UIParent, "LEFT", 0, 0); 179 CyborgMMO_MainPage:SetPoint("LEFT", UIParent, "LEFT", 0, 0);
180 180
181 SetOpenButtonSize(0.75); 181 CyborgMMO_SetOpenButtonSize(0.75);
182 SetMainPageSize(0.75); 182 CyborgMMO_SetMainPageSize(0.75);
183 MiniMapButton:SetChecked(); 183 CyborgMMO_SetMiniMapButton(true);
184 SetMiniMapButton(true); 184 CyborgMMO_SetCyborgHeadButton(true);
185 CyborgButton:SetChecked(); 185 end
186 SetCyborgHeadButton(true); 186
187 end 187
188 188 function CyborgMMO_SetupModeCallbacks(modeNum)
189 function SetupModeCallbacks(modeNum)
190
191 fn = function() 189 fn = function()
192 MouseModeChange(modeNum); 190 CyborgMMO_MouseModeChange(modeNum);
193 RatPageModel.Instance().SetMode(modeNum) 191 CyborgMMO_RatPageModel.Instance().SetMode(modeNum)
194 end 192 end
195 193
196 local buttonFrame, parentFrame, name = CallbackFactory.Instance().AddCallback(fn); 194 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn);
197 if(1 ~= SetOverrideBindingClick(parentFrame, true, Mode[modeNum], name, "LeftButton")) then 195 if(1 ~= SetOverrideBindingClick(parentFrame, true, Mode[modeNum], name, "LeftButton")) then
198 msg("Failed to Bind modeChange"); 196 msg("Failed to Bind modeChange");
199 end 197 end
200 end 198 end
201 199
202 function Loaded() 200 function CyborgMMO_Loaded()
203 MainPage:RegisterEvent("VARIABLES_LOADED"); 201 CyborgMMO_MainPage:RegisterEvent("VARIABLES_LOADED");
204 MainPage:RegisterEvent("PLAYER_ENTERING_WORLD"); 202 CyborgMMO_MainPage:RegisterEvent("PLAYER_ENTERING_WORLD");
205 MainPage:RegisterEvent("PLAYER_ENTER_COMBAT"); 203 CyborgMMO_MainPage:RegisterEvent("PLAYER_ENTER_COMBAT");
206 end 204 end
207 205
208 function Close() 206 function CyborgMMO_Close()
209 MainPage:Hide(); 207 CyborgMMO_MainPage:Hide();
210 if(Settings["CyborgButton"] == true) then 208 if(Settings["CyborgButton"] == true) then
211 OpenButtonPage:Show(); 209 CyborgMMO_OpenButtonPage:Show();
212 end 210 end
213 end 211 end
214 212
215 function Open() 213 function CyborgMMO_Open()
216 MainPage:Show(); 214 CyborgMMO_MainPage:Show();
217 RatQuickPage:Hide(); 215 CyborgMMO_RatQuickPage:Hide();
218 if(Settings["CyborgButton"] == true) then 216 if(Settings["CyborgButton"] == true) then
219 OpenButtonPage:Show(); 217 CyborgMMO_OpenButtonPage:Show();
220 end 218 end
221 end 219 end
222 220
223 function IsOpen() 221 function CyborgMMO_IsOpen()
224 if(MainPage:IsVisible() == 1) then 222 if(CyborgMMO_MainPage:IsVisible() == 1) then
225 return true; 223 return true;
226 else 224 else
227 return false; 225 return false;
228 end 226 end
229 end 227 end
230 228
231 function Toggle() 229 function CyborgMMO_Toggle()
232 if(IsOpen()) then 230 if(CyborgMMO_IsOpen()) then
233 Close(); 231 CyborgMMO_Close();
234 else 232 else
235 Open(); 233 CyborgMMO_Open();
236 end 234 end
237 end 235 end
238 236
239 function msg(m) 237 function msg(m)
240 local id, name = GetChannelName("Debug"); 238 local id, name = GetChannelName("Debug");
241 SendChatMessage(m, "CHANNEL", nil, id); 239 SendChatMessage(m, "CHANNEL", nil, id);
242 end 240 end
243 241
244 function SetMainPageSize(percent) 242 function CyborgMMO_SetMainPageSize(percent)
245 if(VarsLoaded) then 243 if(VarsLoaded) then
246 if(EnteredWorld) then 244 if(EnteredWorld) then
247 MainPage:SetScale(percent); 245 CyborgMMO_MainPage:SetScale(percent);
248 Settings["Plugin"] = percent; 246 Settings["Plugin"] = percent;
249 local data = GetSaveData() 247 local data = CyborgMMO_GetSaveData()
250 data["Settings"] = Settings 248 data["Settings"] = Settings
251 PluginSizeSlider:SetValue(percent); 249 CyborgMMO_OptionPagePluginSizeSlider:SetValue(percent);
252 end 250 end
253 end 251 end
254 end 252 end
255 253
256 function SetOpenButtonSize(percent) 254 function CyborgMMO_SetOpenButtonSize(percent)
257 if(VarsLoaded) then 255 if(VarsLoaded) then
258 if(EnteredWorld) then 256 if(EnteredWorld) then
259 OpenButtonPage:SetScale(percent) 257 CyborgMMO_OpenButtonPage:SetScale(percent)
260 Settings["Cyborg"] = percent; 258 Settings["Cyborg"] = percent;
261 local data = GetSaveData() 259 local data = CyborgMMO_GetSaveData()
262 data["Settings"] = Settings 260 data["Settings"] = Settings
263 CyborgSizeSlider:SetValue(percent); 261 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(percent);
264 end 262 end
265 end 263 end
266 end 264 end
267 265
268 function SetCyborgHeadButton(boolVal) 266 function CyborgMMO_SetCyborgHeadButton(boolVal)
269 Settings["CyborgButton"] = boolVal; 267 Settings["CyborgButton"] = boolVal;
268 CyborgMMO_OptionPageCyborgButton:SetChecked(boolVal);
270 if(Settings["CyborgButton"] == true) then 269 if(Settings["CyborgButton"] == true) then
271 Close(); 270 CyborgMMO_Close();
272 else 271 else
273 OpenButtonPage:Hide(); 272 CyborgMMO_OpenButtonPage:Hide();
274 end 273 end
275 local data = GetSaveData() 274 local data = CyborgMMO_GetSaveData()
276 data["Settings"] = Settings 275 data["Settings"] = Settings
277 end 276 end
278 277
279 function SetMiniMapButton(boolVal) 278 function CyborgMMO_SetMiniMapButton(boolVal)
280 Settings["MiniMapButton"] = boolVal; 279 Settings["MiniMapButton"] = boolVal
280 Settings["MiniMapButton"] = boolVal
281 CyborgMMO_OptionPageMiniMapButton:SetChecked(boolVal)
281 if(Settings["MiniMapButton"] == true) then 282 if(Settings["MiniMapButton"] == true) then
282 CyborgMiniMapButton:Show(); 283 CyborgMMO_MiniMapFrameButton:Show()
283 else 284 else
284 CyborgMiniMapButton:Hide(); 285 CyborgMMO_MiniMapFrameButton:Hide()
285 end 286 end
286 local data = GetSaveData() 287 local data = CyborgMMO_GetSaveData()
287 data["Settings"] = Settings 288 data["Settings"] = Settings
288 end 289 end
289 290