Pollished to alpha

Talen-Shei [08-10-15 - 07:16]
Pollished to alpha
Filename
KeyBindSwapper.lua
diff --git a/KeyBindSwapper.lua b/KeyBindSwapper.lua
index eca2b78..5ec72b8 100644
--- a/KeyBindSwapper.lua
+++ b/KeyBindSwapper.lua
@@ -22,8 +22,8 @@ KBS.Defaults.Account.BindingTarget = "Main"
 KBS.Defaults.Account.AutoSync = false


-KBS.CODE_VERSION = 0.60
-KBS.SAVED_VAR_VERSION = 0.4
+KBS.CODE_VERSION = "0.7MA"
+KBS.SAVED_VAR_VERSION = 0.7
 KBS.UsableOnly = true
 KBS.SettingsFile = "KeyBindSwapperSettings"
 KBS.Name = "Talen-Shei's Keybind Swapper"
@@ -149,9 +149,9 @@ function saveBinds(profile)
 	if profile then
 		getKeyBinds(KBS.Global.KeyTables[profile])
 	elseif KBS.Account.SingleTarget == true then
-		getKeyBinds(KBS.Account.BindingTarget)
+		getKeyBinds(KBS.Global.KeyTables[KBS.Account.BindingTarget])
 	else
-		getKeyBinds(KBS.Character.BindingTarget)
+		getKeyBinds(KBS.Global.KeyTables[KBS.Character.BindingTarget])
 	end
 	-- local isSafe = false
 	-- local accountbound = false
@@ -252,6 +252,21 @@ function setProfile(value)
 	profile = value
 end

+function setBindingTarget(target)
+	if KBS.Account.SingleTarget == true then
+		KBS.Account.BindingTarget = target
+	else
+		KBS.Character.BindingTarget = target
+	end
+end
+
+-- function getBindingTarget()
+-- 	if KBS.Account.SingleTarget then
+-- 		return KBS.Account.BindingTarget
+-- 	else
+-- 		return KBS.Character.BindingTarget
+-- 	end
+-- end
 ---------------------LAM 2.0 SETTINGS--------------------------


@@ -279,7 +294,7 @@ local function CreateSettingsMenu()
 		},
 		[2] = {
 			type = "description",
-			text = "A Tool to save and import keybind profiles."..colorYellow.."For the time being please do not use Per-Character Save Type.",
+			text = "A Tool to save and import keybind profiles.",
 		},
 		-- [3] = {
 		-- 	type = "dropdown",
@@ -305,26 +320,30 @@ local function CreateSettingsMenu()
 			type = "dropdown",
 			name = "Profile",
 			choices = KBS.Global.AvailKeyTables,
+			tooltip = "Profile to load/save to",
 			sort = "name-up",
 			reference = "KBSProfiles",
 			default = "Main",
-			getFunc = function() getProfile() end,
-			setFunc = function(bValue) setProfile(bValue) end,
+			getFunc = function() profile = getProfile() return profile end,
+			setFunc = function(bValue) setBindingTarget(bValue) end,
 			 -- KBS.Character.BindingTarget = bValue end,
 		},
 		[5] = {
-			type = "dropdown",
-			name = "Sync Mode",
-			choices = {"Manual", "Automatic"},
-			default = "Manual",
-			getFunc = function() return KBS.Character.SyncMode end,
-			setFunc = function(bValue) KBS.Character.SyncMode = bValue end,
+			type = "checkbox",
+			name = "AccountWide auto-sync",
+			tooltip = "This sets an entire account to sync to one profile.",
+			getFunc = function() return KBS.Account.AutoSync end,
+			setFunc = function(value) KBS.Account.AutoSync = value end,
+			width = "full",	--or "half" (optional)
+			-- disabled = function() return db.someBooleanSetting end,	--or boolean (optional)
+			-- warning = "Will need to reload the UI.",	--(optional)
+			default = KBS.Defaults.Account.AutoSync,	--(optional)
 		},
 		[6] = {
 			type = "button",
 			name = "Save Profile",
 			tooltip = "Over-write previous profile.",
-			func = function() saveBinds(KBS.Character.saveType, KBS.Character.BindingTarget) end,
+			func = function() saveBinds(getProfile()) end,
 			width = "half",	--or "half" (optional)
 			-- warning = "This will over-write the previous profile.",	--(optional)
 		},
@@ -340,9 +359,9 @@ local function CreateSettingsMenu()
 			type = "editbox",
 			name = "New Profile",
 			-- tooltip = "Save After Entering!",
-			getFunc = function() return KBS.Character.BindingTarget end,
+			getFunc = function() profile = getProfile() return profile end,
 			setFunc = function(text) createNewProfile(text)
-				KBS.Character.BindingTarget = text
+				setBindingTarget(text)
 				saveBinds()
 				KBSProfiles:UpdateChoices()
 				KBSProfilesDel:UpdateChoices()
@@ -391,6 +410,9 @@ local function CreateSettingsMenu()
 				if KBS.Character.DelTarget == KBS.Character.BindingTarget then
 					KBS.Character.BindingTarget = KBS.Global.AvailKeyTables[1]
 				end
+				if KBS.Character.DelTarget == KBS.Account.BindingTarget then
+					KBS.Account.BindingTarget = KBS.Global.AvailKeyTables[1]
+				end
 				KBS.Character.DelTarget = KBS.Global.AvailKeyTables[1]
 				KBSProfiles:UpdateChoices()
 				KBSProfilesDel:UpdateChoices()