Mercurial > wow > cyborg-mmo7
comparison CyborgMMO7.lua @ 5:8428fa7cf0e4
Updated the profile to use macros and rename all the variables and functions with the prefix CyborgMMO. Added a tooltip to inform the user to assign the profile.
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
|---|---|
| date | Tue, 29 May 2012 10:26:40 +0000 |
| parents | d186f8cd5000 |
| children | 43f45e032db8 |
comparison
equal
deleted
inserted
replaced
| 4:d186f8cd5000 | 5:8428fa7cf0e4 |
|---|---|
| 21 | 21 |
| 22 | 22 |
| 23 | 23 |
| 24 | 24 |
| 25 function CyborgMMO_LoadStrings(self) | 25 function CyborgMMO_LoadStrings(self) |
| 26 --~ msg("LoadStrings("..self:GetName()..") = "..StringTable[self:GetName()]) | 26 --~ msg("LoadStrings("..self:GetName()..") = "..CyborgMMO_StringTable[self:GetName()]) |
| 27 self:SetText(StringTable[self:GetName()]); | 27 self:SetText(CyborgMMO_StringTable[self:GetName()]); |
| 28 end | 28 end |
| 29 | 29 |
| 30 local VarsLoaded = false; | 30 local CyborgMMO_VarsLoaded = false; |
| 31 local EnteredWorld = false; | 31 local CyborgMMO_EnteredWorld = false; |
| 32 local LoadBinding = false; | 32 local CyborgMMO_LoadBinding = false; |
| 33 local SaveName = GetRealmName().."_"..UnitName("player"); | 33 local CyborgMMO_SaveName = GetRealmName().."_"..UnitName("player"); |
| 34 local Settings = nil; | 34 local CyborgMMO_Settings = nil; |
| 35 | 35 |
| 36 | 36 |
| 37 function CyborgMMO_MiniMapButtonReposition(pos) | 37 function CyborgMMO_MiniMapButtonReposition(pos) |
| 38 CyborgMMO_MiniMapFrame:SetPoint("TOPLEFT", | 38 CyborgMMO_MiniMapFrame:SetPoint("TOPLEFT", |
| 39 "Minimap", | 39 "Minimap", |
| 83 OpenButtonGlowTexture:SetVertexColor(0.67,0.31,0.85,0.5); | 83 OpenButtonGlowTexture:SetVertexColor(0.67,0.31,0.85,0.5); |
| 84 end | 84 end |
| 85 end | 85 end |
| 86 | 86 |
| 87 function CyborgMMO_LoadWowCommands() | 87 function CyborgMMO_LoadWowCommands() |
| 88 if (ProfileKeyBindings == nil) then | 88 if (CyborgMMO_ProfileKeyBindings == nil) then |
| 89 ProfileKeyBindings = {} | 89 CyborgMMO_ProfileKeyBindings = {} |
| 90 ProfileKeyBindings = InternationalWowCommands[GetLocale()] | 90 CyborgMMO_ProfileKeyBindings = CyborgMMO_InternationalWowCommands[GetLocale()] |
| 91 end | 91 end |
| 92 WowCommands = ProfileKeyBindings | 92 CyborgMMO_WowCommands = CyborgMMO_ProfileKeyBindings |
| 93 end | 93 end |
| 94 | 94 |
| 95 function CyborgMMO_GetSaveData() | 95 function CyborgMMO_GetSaveData() |
| 96 if(VarsLoaded) then | 96 if(CyborgMMO_VarsLoaded) then |
| 97 if (CyborgMMO7SaveData == nil) then | 97 if (CyborgMMO7SaveData == nil) then |
| 98 CyborgMMO7SaveData = {}; | 98 CyborgMMO7SaveData = {}; |
| 99 CyborgMMO7SaveData[SaveName] = {} | 99 CyborgMMO7SaveData[CyborgMMO_SaveName] = {} |
| 100 end | 100 end |
| 101 CyborgMMO_LoadWowCommands() | 101 CyborgMMO_LoadWowCommands() |
| 102 return CyborgMMO7SaveData[SaveName]; | 102 return CyborgMMO7SaveData[CyborgMMO_SaveName]; |
| 103 end | 103 end |
| 104 return nil; | 104 return nil; |
| 105 end | 105 end |
| 106 | 106 |
| 107 function CyborgMMO_SetSaveData(data, index) | 107 function CyborgMMO_SetSaveData(data, index) |
| 108 if(VarsLoaded) then | 108 if(CyborgMMO_VarsLoaded) then |
| 109 CyborgMMO_GetSaveData()[index] = data | 109 CyborgMMO_GetSaveData()[index] = data |
| 110 ProfileKeyBindings = WowCommands | 110 CyborgMMO_ProfileKeyBindings = CyborgMMO_WowCommands |
| 111 end | 111 end |
| 112 end | 112 end |
| 113 | 113 |
| 114 function CyborgMMO_Event(self, event, ...) | 114 function CyborgMMO_Event(self, event, ...) |
| 115 if(event == "VARIABLES_LOADED") then | 115 if(event == "VARIABLES_LOADED") then |
| 116 VarsLoaded = true; | 116 CyborgMMO_VarsLoaded = true; |
| 117 elseif(event == "PLAYER_ENTERING_WORLD") then | 117 elseif(event == "PLAYER_ENTERING_WORLD") then |
| 118 EnteredWorld = true; | 118 CyborgMMO_EnteredWorld = true; |
| 119 elseif(event == "PLAYER_ENTER_COMBAT") then | 119 elseif(event == "PLAYER_ENTER_COMBAT") then |
| 120 msg("PLAYER_ENTER_COMBAT"); | 120 msg("PLAYER_ENTER_COMBAT"); |
| 121 Close(); | 121 Close(); |
| 122 elseif(event == nil) then | 122 elseif(event == nil) then |
| 123 msg("Event is nil"); | 123 msg("Event is nil"); |
| 125 msg("Event is " + event); | 125 msg("Event is " + event); |
| 126 end | 126 end |
| 127 | 127 |
| 128 | 128 |
| 129 -- 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 |
| 130 if(false == LoadBinding) then | 130 if(false == CyborgMMO_LoadBinding) then |
| 131 if(VarsLoaded) then | 131 if(CyborgMMO_VarsLoaded) then |
| 132 if(EnteredWorld) then | 132 if(CyborgMMO_EnteredWorld) then |
| 133 local data = CyborgMMO_GetSaveData() | 133 local data = CyborgMMO_GetSaveData() |
| 134 | 134 |
| 135 CyborgMMO_RatPageModel.Instance().LoadData(); | 135 CyborgMMO_RatPageModel.Instance().LoadData(); |
| 136 LoadBinding = true; | 136 CyborgMMO_LoadBinding = true; |
| 137 | 137 |
| 138 ShowMacroFrame(); | 138 ShowMacroFrame(); |
| 139 HideUIPanel(MacroFrame); | 139 HideUIPanel(MacroFrame); |
| 140 | 140 |
| 141 | 141 |
| 151 data["Settings"]["Plugin"] = 0.75; | 151 data["Settings"]["Plugin"] = 0.75; |
| 152 data["Settings"]["MiniMapButton"] = true; | 152 data["Settings"]["MiniMapButton"] = true; |
| 153 data["Settings"]["CyborgButton"] = true; | 153 data["Settings"]["CyborgButton"] = true; |
| 154 end | 154 end |
| 155 | 155 |
| 156 Settings = data["Settings"]; | 156 CyborgMMO_Settings = data["Settings"]; |
| 157 | 157 |
| 158 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(Settings["Cyborg"]); | 158 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(CyborgMMO_Settings["Cyborg"]); |
| 159 CyborgMMO_SetOpenButtonSize(Settings["Cyborg"]) | 159 CyborgMMO_SetOpenButtonSize(CyborgMMO_Settings["Cyborg"]) |
| 160 CyborgMMO_OptionPagePluginSizeSlider:SetValue(Settings["Plugin"]); | 160 CyborgMMO_OptionPagePluginSizeSlider:SetValue(CyborgMMO_Settings["Plugin"]); |
| 161 CyborgMMO_SetMainPageSize(Settings["Plugin"]); | 161 CyborgMMO_SetMainPageSize(CyborgMMO_Settings["Plugin"]); |
| 162 | 162 |
| 163 CyborgMMO_SetMiniMapButton(Settings["MiniMapButton"]) | 163 CyborgMMO_SetMiniMapButton(CyborgMMO_Settings["MiniMapButton"]) |
| 164 CyborgMMO_SetCyborgHeadButton(Settings["CyborgButton"]) | 164 CyborgMMO_SetCyborgHeadButton(CyborgMMO_Settings["CyborgButton"]) |
| 165 | 165 |
| 166 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom() | 166 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom() |
| 167 CyborgMMO_MiniMapButtonReposition(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 CyborgMMO_Close(); | 169 CyborgMMO_Close(); |
| 190 CyborgMMO_MouseModeChange(modeNum); | 190 CyborgMMO_MouseModeChange(modeNum); |
| 191 CyborgMMO_RatPageModel.Instance().SetMode(modeNum) | 191 CyborgMMO_RatPageModel.Instance().SetMode(modeNum) |
| 192 end | 192 end |
| 193 | 193 |
| 194 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn); | 194 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn); |
| 195 if(1 ~= SetOverrideBindingClick(parentFrame, true, Mode[modeNum], name, "LeftButton")) then | 195 if(1 ~= SetOverrideBindingClick(parentFrame, true, CyborgMMO_Mode[modeNum], name, "LeftButton")) then |
| 196 msg("Failed to Bind modeChange"); | 196 msg("Failed to Bind modeChange"); |
| 197 end | 197 end |
| 198 end | 198 end |
| 199 | 199 |
| 200 function CyborgMMO_Loaded() | 200 function CyborgMMO_Loaded() |
| 203 CyborgMMO_MainPage:RegisterEvent("PLAYER_ENTER_COMBAT"); | 203 CyborgMMO_MainPage:RegisterEvent("PLAYER_ENTER_COMBAT"); |
| 204 end | 204 end |
| 205 | 205 |
| 206 function CyborgMMO_Close() | 206 function CyborgMMO_Close() |
| 207 CyborgMMO_MainPage:Hide(); | 207 CyborgMMO_MainPage:Hide(); |
| 208 if(Settings["CyborgButton"] == true) then | 208 if(CyborgMMO_Settings["CyborgButton"] == true) then |
| 209 CyborgMMO_OpenButtonPage:Show(); | 209 CyborgMMO_OpenButtonPage:Show(); |
| 210 end | 210 end |
| 211 end | 211 end |
| 212 | 212 |
| 213 function CyborgMMO_Open() | 213 function CyborgMMO_Open() |
| 214 CyborgMMO_MainPage:Show(); | 214 CyborgMMO_MainPage:Show(); |
| 215 CyborgMMO_RatQuickPage:Hide(); | 215 CyborgMMO_RatQuickPage:Hide(); |
| 216 if(Settings["CyborgButton"] == true) then | 216 if(CyborgMMO_Settings["CyborgButton"] == true) then |
| 217 CyborgMMO_OpenButtonPage:Show(); | 217 CyborgMMO_OpenButtonPage:Show(); |
| 218 end | 218 end |
| 219 end | 219 end |
| 220 | 220 |
| 221 function CyborgMMO_IsOpen() | 221 function CyborgMMO_IsOpen() |
| 238 local id, name = GetChannelName("Debug"); | 238 local id, name = GetChannelName("Debug"); |
| 239 SendChatMessage(m, "CHANNEL", nil, id); | 239 SendChatMessage(m, "CHANNEL", nil, id); |
| 240 end | 240 end |
| 241 | 241 |
| 242 function CyborgMMO_SetMainPageSize(percent) | 242 function CyborgMMO_SetMainPageSize(percent) |
| 243 if(VarsLoaded) then | 243 if(CyborgMMO_VarsLoaded) then |
| 244 if(EnteredWorld) then | 244 if(CyborgMMO_EnteredWorld) then |
| 245 CyborgMMO_MainPage:SetScale(percent); | 245 CyborgMMO_MainPage:SetScale(percent); |
| 246 Settings["Plugin"] = percent; | 246 CyborgMMO_Settings["Plugin"] = percent; |
| 247 local data = CyborgMMO_GetSaveData() | 247 local data = CyborgMMO_GetSaveData() |
| 248 data["Settings"] = Settings | 248 data["Settings"] = CyborgMMO_Settings |
| 249 CyborgMMO_OptionPagePluginSizeSlider:SetValue(percent); | 249 CyborgMMO_OptionPagePluginSizeSlider:SetValue(percent); |
| 250 end | 250 end |
| 251 end | 251 end |
| 252 end | 252 end |
| 253 | 253 |
| 254 function CyborgMMO_SetOpenButtonSize(percent) | 254 function CyborgMMO_SetOpenButtonSize(percent) |
| 255 if(VarsLoaded) then | 255 if(CyborgMMO_VarsLoaded) then |
| 256 if(EnteredWorld) then | 256 if(CyborgMMO_EnteredWorld) then |
| 257 CyborgMMO_OpenButtonPage:SetScale(percent) | 257 CyborgMMO_OpenButtonPage:SetScale(percent) |
| 258 Settings["Cyborg"] = percent; | 258 CyborgMMO_Settings["Cyborg"] = percent; |
| 259 local data = CyborgMMO_GetSaveData() | 259 local data = CyborgMMO_GetSaveData() |
| 260 data["Settings"] = Settings | 260 data["Settings"] = CyborgMMO_Settings |
| 261 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(percent); | 261 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(percent); |
| 262 end | 262 end |
| 263 end | 263 end |
| 264 end | 264 end |
| 265 | 265 |
| 266 function CyborgMMO_SetCyborgHeadButton(boolVal) | 266 function CyborgMMO_SetCyborgHeadButton(boolVal) |
| 267 Settings["CyborgButton"] = boolVal; | 267 CyborgMMO_Settings["CyborgButton"] = boolVal; |
| 268 CyborgMMO_OptionPageCyborgButton:SetChecked(boolVal); | 268 CyborgMMO_OptionPageCyborgButton:SetChecked(boolVal); |
| 269 if(Settings["CyborgButton"] == true) then | 269 if(CyborgMMO_Settings["CyborgButton"] == true) then |
| 270 CyborgMMO_Close(); | 270 CyborgMMO_Close(); |
| 271 else | 271 else |
| 272 CyborgMMO_OpenButtonPage:Hide(); | 272 CyborgMMO_OpenButtonPage:Hide(); |
| 273 end | 273 end |
| 274 local data = CyborgMMO_GetSaveData() | 274 local data = CyborgMMO_GetSaveData() |
| 275 data["Settings"] = Settings | 275 data["Settings"] = CyborgMMO_Settings |
| 276 end | 276 end |
| 277 | 277 |
| 278 function CyborgMMO_SetMiniMapButton(boolVal) | 278 function CyborgMMO_SetMiniMapButton(boolVal) |
| 279 Settings["MiniMapButton"] = boolVal | 279 CyborgMMO_Settings["MiniMapButton"] = boolVal |
| 280 Settings["MiniMapButton"] = boolVal | 280 CyborgMMO_Settings["MiniMapButton"] = boolVal |
| 281 CyborgMMO_OptionPageMiniMapButton:SetChecked(boolVal) | 281 CyborgMMO_OptionPageMiniMapButton:SetChecked(boolVal) |
| 282 if(Settings["MiniMapButton"] == true) then | 282 if(CyborgMMO_Settings["MiniMapButton"] == true) then |
| 283 CyborgMMO_MiniMapFrameButton:Show() | 283 CyborgMMO_MiniMapFrameButton:Show() |
| 284 else | 284 else |
| 285 CyborgMMO_MiniMapFrameButton:Hide() | 285 CyborgMMO_MiniMapFrameButton:Hide() |
| 286 end | 286 end |
| 287 local data = CyborgMMO_GetSaveData() | 287 local data = CyborgMMO_GetSaveData() |
| 288 data["Settings"] = Settings | 288 data["Settings"] = CyborgMMO_Settings |
| 289 end | 289 end |
| 290 | 290 |
