Quantcast

testing profile sharing

Munglunch [03-09-15 - 21:25]
testing profile sharing
Filename
SVUI_!Core/libs/_SVUI_Lib/Registry.lua
SVUI_!Core/system/core.lua
SVUI_!Core/system/debug.lua
SVUI_!Core/system/slash.lua
SVUI_!Options/SVUI_!Options.lua
diff --git a/SVUI_!Core/libs/_SVUI_Lib/Registry.lua b/SVUI_!Core/libs/_SVUI_Lib/Registry.lua
index 82a7910..db9e0be 100644
--- a/SVUI_!Core/libs/_SVUI_Lib/Registry.lua
+++ b/SVUI_!Core/libs/_SVUI_Lib/Registry.lua
@@ -532,11 +532,7 @@ function lib:CleanUpData(deep)
     local media = CoreObject.mediadefaults
     if(DEEP_CLEAN_REQUESTED) then
         for key,data in pairs(GLOBAL_SV.profiles) do
-            if(not GLOBAL_SV.profileKeys[key]) then
-                GLOBAL_SV.profiles[key] = nil
-            else
-                sanitize(data, defaults)
-            end
+            sanitize(data, defaults)
         end
         for theme,profile in pairs(MEDIA_SV.profiles) do
             if(not SAFE_THEME_KEYS[theme]) then
@@ -1227,7 +1223,7 @@ function lib:ImportDatabase(key, linked)
     end
 end

-function lib:ExportDatabase(key)
+function lib:CloneDatabase(key)
     if(not key) then return end

     local export, saved
@@ -1247,6 +1243,14 @@ function lib:ExportDatabase(key)
     UpdateProfileSources(key)
 end

+function lib:ExportDatabase()
+    local output = {["PROFILE"] = {}, ["MEDIA"] = {[THEME_KEY] = {}}};
+    tablecopy(output["PROFILE"], GLOBAL_SV.profiles[PROFILE_KEY]);
+    tablecopy(output["MEDIA"][THEME_KEY], MEDIA_SV.profiles[THEME_KEY][PROFILE_KEY]);
+
+    return output
+end
+
 function lib:WipeDatabase()
     for k,v in pairs(GLOBAL_SV.profiles[PROFILE_KEY]) do
         GLOBAL_SV.profiles[PROFILE_KEY][k] = nil
diff --git a/SVUI_!Core/system/core.lua b/SVUI_!Core/system/core.lua
index 48f4950..e50c175 100644
--- a/SVUI_!Core/system/core.lua
+++ b/SVUI_!Core/system/core.lua
@@ -629,6 +629,18 @@ function SV:CopyProfile(key)
     self:StaticPopup_Show("COPY_PROFILE_PROMPT")
 end

+function SV:ShareProfile()
+    local t = SVUILib:ExportDatabase()
+    SV.ScriptError:TableDump(t)
+end
+
+function SV.ScriptError:DebugOutput(msg)
+    if not self:IsShown() then
+        self:Show()
+    end
+    ScriptErrorDialog.Input:SetText(msg)
+end
+
 function SV:ToggleConfig()
     if InCombatLockdown() then
         self:AddonMessage(ERR_NOT_IN_COMBAT)
@@ -781,7 +793,8 @@ function SV:PLAYER_ENTERING_WORLD()
         self:RefreshAllMedia()
     end
     local _,instanceType = IsInInstance()
-    if(instanceType == "pvp") then
+    if(instanceType == "pvp") then
+        self:GearSwap()
         self.BGTimer = self.Timers:ExecuteLoop(RequestBattlefieldScoreData, 5)
     elseif(self.BGTimer) then
         self.Timers:RemoveLoop(self.BGTimer)
diff --git a/SVUI_!Core/system/debug.lua b/SVUI_!Core/system/debug.lua
index 7879dae..424c4f5 100644
--- a/SVUI_!Core/system/debug.lua
+++ b/SVUI_!Core/system/debug.lua
@@ -470,6 +470,10 @@ function SV.ScriptError:DebugOutput(msg)
     ScriptErrorDialog.Input:SetText(msg)
 end

+function SV.ScriptError:TableDump(t)
+    self:DebugOutput(DebugDump(t))
+end
+
 function SV.ScriptError:ShowDebug(header, ...)
     wipe(DUMPTABLE);
     wipe(CHECKTABLE);
diff --git a/SVUI_!Core/system/slash.lua b/SVUI_!Core/system/slash.lua
index e50b969..1218f67 100644
--- a/SVUI_!Core/system/slash.lua
+++ b/SVUI_!Core/system/slash.lua
@@ -44,12 +44,14 @@ local SVUI_SLASH_COMMAND_INFO = {
 	["install"] = "Open the SVUI installer window.",
 	["move"] = "Lock/Unlock frames for moving.",
 	["reset"] = "Reset All SVUI Settings.",
+	["sharecopy"] = "Copy your settings to share with others.",
 	["help"] = "I feel like you MIGHT have already discovered this one.",
 };
 local SVUI_SLASH_COMMANDS = {
 	["install"] = SV.Setup.Install,
 	["move"] = SV.MoveAnchors,
 	["reset"] = SV.ResetAllUI,
+	["sharecopy"] = SV.ShareProfile,
 	["help"] = function()
 		for cmd,desc in pairs(SVUI_SLASH_COMMAND_INFO) do
 			local outbound = (msgPattern):format(cmd, desc);
diff --git a/SVUI_!Options/SVUI_!Options.lua b/SVUI_!Options/SVUI_!Options.lua
index 87ad970..c5d7cd5 100644
--- a/SVUI_!Options/SVUI_!Options.lua
+++ b/SVUI_!Options/SVUI_!Options.lua
@@ -167,7 +167,7 @@ local function RefreshProfileOptions()
 		type = "input",
 		order = 6,
 		get = false,
-		set = function(key, value) SVUILib:ExportDatabase(value) SV:SavedPopup() RefreshProfileOptions() end,
+		set = function(key, value) SVUILib:CloneDatabase(value) SV:SavedPopup() RefreshProfileOptions() end,
 		disabled = function()
 			local t = SVUILib:CheckDualProfile()
 			return t