diff 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
line wrap: on
line diff
--- a/CyborgMMO7.lua	Mon May 28 15:54:52 2012 +0000
+++ b/CyborgMMO7.lua	Tue May 29 10:26:40 2012 +0000
@@ -23,15 +23,15 @@
 
 
 function CyborgMMO_LoadStrings(self)
---~ 	msg("LoadStrings("..self:GetName()..") = "..StringTable[self:GetName()])
-	self:SetText(StringTable[self:GetName()]);
+--~ 	msg("LoadStrings("..self:GetName()..") = "..CyborgMMO_StringTable[self:GetName()])
+	self:SetText(CyborgMMO_StringTable[self:GetName()]);
 end
 
-local VarsLoaded = false;
-local EnteredWorld = false;
-local LoadBinding = false;
-local SaveName = GetRealmName().."_"..UnitName("player");
-local Settings = nil;
+local CyborgMMO_VarsLoaded = false;
+local CyborgMMO_EnteredWorld = false;
+local CyborgMMO_LoadBinding = false;
+local CyborgMMO_SaveName = GetRealmName().."_"..UnitName("player");
+local CyborgMMO_Settings = nil;
 
 
 function CyborgMMO_MiniMapButtonReposition(pos)
@@ -85,37 +85,37 @@
 end
 
 function CyborgMMO_LoadWowCommands()
-	if (ProfileKeyBindings == nil) then
-		ProfileKeyBindings = {}
-		ProfileKeyBindings = InternationalWowCommands[GetLocale()]
+	if (CyborgMMO_ProfileKeyBindings == nil) then
+		CyborgMMO_ProfileKeyBindings = {}
+		CyborgMMO_ProfileKeyBindings = CyborgMMO_InternationalWowCommands[GetLocale()]
 	end
-	WowCommands = ProfileKeyBindings 
+	CyborgMMO_WowCommands = CyborgMMO_ProfileKeyBindings 
 end
 
 function CyborgMMO_GetSaveData()
-	if(VarsLoaded) then
+	if(CyborgMMO_VarsLoaded) then
 		if (CyborgMMO7SaveData == nil) then
 			CyborgMMO7SaveData = {};
-			CyborgMMO7SaveData[SaveName] = {}
+			CyborgMMO7SaveData[CyborgMMO_SaveName] = {}
 		end
 		CyborgMMO_LoadWowCommands()
-		return CyborgMMO7SaveData[SaveName];
+		return CyborgMMO7SaveData[CyborgMMO_SaveName];
 	end
 	return nil;
 end
 
 function CyborgMMO_SetSaveData(data, index)
-	if(VarsLoaded) then
+	if(CyborgMMO_VarsLoaded) then
 		CyborgMMO_GetSaveData()[index] = data
-		ProfileKeyBindings = WowCommands
+		CyborgMMO_ProfileKeyBindings = CyborgMMO_WowCommands
 	end
 end
 
 function CyborgMMO_Event(self, event, ...)
     if(event == "VARIABLES_LOADED") then
-		VarsLoaded = true;
+		CyborgMMO_VarsLoaded = true;
     elseif(event == "PLAYER_ENTERING_WORLD") then
-		EnteredWorld = true;
+		CyborgMMO_EnteredWorld = true;
     elseif(event == "PLAYER_ENTER_COMBAT") then
 		msg("PLAYER_ENTER_COMBAT");
 		Close();
@@ -127,13 +127,13 @@
 
 
 	-- Fire Loading if and only if the player is in the world and vars are loaded
-	if(false == LoadBinding) then
-		if(VarsLoaded) then
-			if(EnteredWorld) then
+	if(false == CyborgMMO_LoadBinding) then
+		if(CyborgMMO_VarsLoaded) then
+			if(CyborgMMO_EnteredWorld) then
 				local data = CyborgMMO_GetSaveData()
 
 				CyborgMMO_RatPageModel.Instance().LoadData();
-				LoadBinding = true;
+				CyborgMMO_LoadBinding = true;
 
 				ShowMacroFrame();
 				HideUIPanel(MacroFrame);
@@ -153,15 +153,15 @@
 					data["Settings"]["CyborgButton"] = true;
 				end
 
-				Settings = data["Settings"];
+				CyborgMMO_Settings = data["Settings"];
 
-				CyborgMMO_OptionPageCyborgSizeSlider:SetValue(Settings["Cyborg"]);
-				CyborgMMO_SetOpenButtonSize(Settings["Cyborg"])
-				CyborgMMO_OptionPagePluginSizeSlider:SetValue(Settings["Plugin"]);
-				CyborgMMO_SetMainPageSize(Settings["Plugin"]);
+				CyborgMMO_OptionPageCyborgSizeSlider:SetValue(CyborgMMO_Settings["Cyborg"]);
+				CyborgMMO_SetOpenButtonSize(CyborgMMO_Settings["Cyborg"])
+				CyborgMMO_OptionPagePluginSizeSlider:SetValue(CyborgMMO_Settings["Plugin"]);
+				CyborgMMO_SetMainPageSize(CyborgMMO_Settings["Plugin"]);
 				
-				CyborgMMO_SetMiniMapButton(Settings["MiniMapButton"])
-				CyborgMMO_SetCyborgHeadButton(Settings["CyborgButton"])
+				CyborgMMO_SetMiniMapButton(CyborgMMO_Settings["MiniMapButton"])
+				CyborgMMO_SetCyborgHeadButton(CyborgMMO_Settings["CyborgButton"])
 
 				local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
 				CyborgMMO_MiniMapButtonReposition(math.deg(math.atan2(ymin,xmin)))
@@ -192,7 +192,7 @@
 	end
 
 	local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(fn);
-	if(1 ~= SetOverrideBindingClick(parentFrame, true, Mode[modeNum], name, "LeftButton")) then
+	if(1 ~= SetOverrideBindingClick(parentFrame, true, CyborgMMO_Mode[modeNum], name, "LeftButton")) then
 		msg("Failed to Bind modeChange");
 	end
 end
@@ -205,7 +205,7 @@
 
 function CyborgMMO_Close()
     CyborgMMO_MainPage:Hide();
-	if(Settings["CyborgButton"] == true) then
+	if(CyborgMMO_Settings["CyborgButton"] == true) then
 		CyborgMMO_OpenButtonPage:Show();
 	end
 end
@@ -213,7 +213,7 @@
 function CyborgMMO_Open()
 	CyborgMMO_MainPage:Show();
 	CyborgMMO_RatQuickPage:Hide();
-	if(Settings["CyborgButton"] == true) then
+	if(CyborgMMO_Settings["CyborgButton"] == true) then
 		CyborgMMO_OpenButtonPage:Show();
 	end
 end
@@ -240,51 +240,51 @@
 end
 
 function CyborgMMO_SetMainPageSize(percent)
-	if(VarsLoaded) then
-		if(EnteredWorld) then
+	if(CyborgMMO_VarsLoaded) then
+		if(CyborgMMO_EnteredWorld) then
 			CyborgMMO_MainPage:SetScale(percent);
-			Settings["Plugin"] = percent;
+			CyborgMMO_Settings["Plugin"] = percent;
 			local data = CyborgMMO_GetSaveData()
-			data["Settings"] = Settings
+			data["Settings"] = CyborgMMO_Settings
 			CyborgMMO_OptionPagePluginSizeSlider:SetValue(percent);
 		end
 	end
 end
 
 function CyborgMMO_SetOpenButtonSize(percent)
-	if(VarsLoaded) then
-		if(EnteredWorld) then
+	if(CyborgMMO_VarsLoaded) then
+		if(CyborgMMO_EnteredWorld) then
 			CyborgMMO_OpenButtonPage:SetScale(percent)
-			Settings["Cyborg"] = percent;
+			CyborgMMO_Settings["Cyborg"] = percent;
 			local data = CyborgMMO_GetSaveData()
-			data["Settings"] = Settings
+			data["Settings"] = CyborgMMO_Settings
 			CyborgMMO_OptionPageCyborgSizeSlider:SetValue(percent);
 		end
 	end
 end
 
 function CyborgMMO_SetCyborgHeadButton(boolVal)
-	Settings["CyborgButton"] = boolVal;
+	CyborgMMO_Settings["CyborgButton"] = boolVal;
 	CyborgMMO_OptionPageCyborgButton:SetChecked(boolVal);
-	if(Settings["CyborgButton"] == true) then
+	if(CyborgMMO_Settings["CyborgButton"] == true) then
 		CyborgMMO_Close();
 	else
 		CyborgMMO_OpenButtonPage:Hide();
 	end
 	local data = CyborgMMO_GetSaveData()
-	data["Settings"] = Settings
+	data["Settings"] = CyborgMMO_Settings
 end
 
 function CyborgMMO_SetMiniMapButton(boolVal)
-	Settings["MiniMapButton"] = boolVal
-	Settings["MiniMapButton"] = boolVal
+	CyborgMMO_Settings["MiniMapButton"] = boolVal
+	CyborgMMO_Settings["MiniMapButton"] = boolVal
 	CyborgMMO_OptionPageMiniMapButton:SetChecked(boolVal)
-	if(Settings["MiniMapButton"] == true) then
+	if(CyborgMMO_Settings["MiniMapButton"] == true) then
 		CyborgMMO_MiniMapFrameButton:Show()
 	else
 		CyborgMMO_MiniMapFrameButton:Hide()
 	end
 	local data = CyborgMMO_GetSaveData()
-	data["Settings"] = Settings
+	data["Settings"] = CyborgMMO_Settings
 end