|
|
@@ -1,15 +1,17 @@
|
|
|
|
local E, L, V, P, G = unpack(ElvUI)
|
|
|
|
local E, L, V, P, G = unpack(ElvUI) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
|
|
|
local D = E:NewModule("Distributor", "AceEvent-3.0","AceTimer-3.0","AceComm-3.0","AceSerializer-3.0")
|
|
|
|
local D = E:NewModule("Distributor", "AceEvent-3.0","AceTimer-3.0","AceComm-3.0","AceSerializer-3.0");
|
|
|
|
local LibCompress = LibStub:GetLibrary("LibCompress");
|
|
|
|
local LibCompress = LibStub:GetLibrary("LibCompress");
|
|
|
|
local LibBase64 = LibStub("LibBase64-1.0");
|
|
|
|
local LibBase64 = LibStub("LibBase64-1.0");
|
|
|
|
|
|
|
|
|
|
|
|
local tonumber, type, pcall, loadstring = tonumber, type, pcall, loadstring;
|
|
|
|
--Cache global variables
|
|
|
|
local len, format, split, find = string.len, string.format, string.split, string.find;
|
|
|
|
--Lua functions
|
|
|
|
|
|
|
|
local tonumber, type, pcall, loadstring = tonumber, type, pcall, loadstring
|
|
|
|
local CreateFrame = CreateFrame;
|
|
|
|
local len, format, split, find = string.len, string.format, string.split, string.find
|
|
|
|
local GetNumRaidMembers, UnitInRaid = GetNumRaidMembers, UnitInRaid;
|
|
|
|
--WoW API / Variables
|
|
|
|
local GetNumPartyMembers, UnitInParty = GetNumPartyMembers, UnitInParty;
|
|
|
|
local CreateFrame = CreateFrame
|
|
|
|
local ACCEPT, CANCEL, YES, NO = ACCEPT, CANCEL, YES, NO;
|
|
|
|
local GetNumRaidMembers, UnitInRaid = GetNumRaidMembers, UnitInRaid
|
|
|
|
|
|
|
|
local GetNumPartyMembers, UnitInParty = GetNumPartyMembers, UnitInParty
|
|
|
|
|
|
|
|
local ACCEPT, CANCEL, YES, NO = ACCEPT, CANCEL, YES, NO
|
|
|
|
|
|
|
|
|
|
|
|
----------------------------------
|
|
|
|
----------------------------------
|
|
|
|
-- CONSTANTS
|
|
|
|
-- CONSTANTS
|
|
|
@@ -29,7 +31,7 @@ function D:Initialize()
|
|
|
|
self:RegisterEvent("CHAT_MSG_ADDON")
|
|
|
|
self:RegisterEvent("CHAT_MSG_ADDON")
|
|
|
|
|
|
|
|
|
|
|
|
self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", UIParent)
|
|
|
|
self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", UIParent)
|
|
|
|
E:RegisterStatusBar(self.statusBar);
|
|
|
|
E:RegisterStatusBar(self.statusBar)
|
|
|
|
E:CreateBackdrop(self.statusBar, "Default")
|
|
|
|
E:CreateBackdrop(self.statusBar, "Default")
|
|
|
|
self.statusBar:SetStatusBarTexture(E.media.normTex)
|
|
|
|
self.statusBar:SetStatusBarTexture(E.media.normTex)
|
|
|
|
self.statusBar:SetStatusBarColor(0.95, 0.15, 0.15)
|
|
|
|
self.statusBar:SetStatusBarColor(0.95, 0.15, 0.15)
|
|
|
@@ -43,7 +45,7 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
-- Used to start uploads
|
|
|
|
-- Used to start uploads
|
|
|
|
function D:Distribute(target, otherServer, isGlobal)
|
|
|
|
function D:Distribute(target, otherServer, isGlobal)
|
|
|
|
local profileKey, data;
|
|
|
|
local profileKey, data
|
|
|
|
if not isGlobal then
|
|
|
|
if not isGlobal then
|
|
|
|
if ElvDB.profileKeys then
|
|
|
|
if ElvDB.profileKeys then
|
|
|
|
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm]
|
|
|
|
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm]
|
|
|
@@ -67,11 +69,11 @@ function D:Distribute(target, otherServer, isGlobal)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if otherServer then
|
|
|
|
if otherServer then
|
|
|
|
local numParty, numRaid = GetNumPartyMembers(), GetNumRaidMembers();
|
|
|
|
local numParty, numRaid = GetNumPartyMembers(), GetNumRaidMembers()
|
|
|
|
if(numRaid > 0 and UnitInRaid("target")) then
|
|
|
|
if numRaid > 0 and UnitInRaid("target") then
|
|
|
|
self:SendCommMessage(REQUEST_PREFIX, message, "RAID");
|
|
|
|
self:SendCommMessage(REQUEST_PREFIX, message, "RAID")
|
|
|
|
elseif(numParty > 0 and UnitInParty("target")) then
|
|
|
|
elseif numParty > 0 and UnitInParty("target") then
|
|
|
|
self:SendCommMessage(REQUEST_PREFIX, message, "PARTY");
|
|
|
|
self:SendCommMessage(REQUEST_PREFIX, message, "PARTY")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
E:Print(L["Must be in group with the player if he isn't on the same server as you."])
|
|
|
|
E:Print(L["Must be in group with the player if he isn't on the same server as you."])
|
|
|
|
return
|
|
|
|
return
|
|
|
@@ -234,240 +236,241 @@ function D:OnCommReceived(prefix, msg, dist, sender)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function GetProfileData(profileType)
|
|
|
|
local function GetProfileData(profileType)
|
|
|
|
if(not profileType or type(profileType) ~= "string") then
|
|
|
|
if not profileType or type(profileType) ~= "string" then
|
|
|
|
E:Print("Bad argument #1 to 'GetProfileData' (string expected)");
|
|
|
|
E:Print("Bad argument #1 to 'GetProfileData' (string expected)")
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local profileKey;
|
|
|
|
local profileKey
|
|
|
|
local profileData = {};
|
|
|
|
local profileData = {}
|
|
|
|
|
|
|
|
|
|
|
|
if(profileType == "profile") then
|
|
|
|
if profileType == "profile" then
|
|
|
|
if(ElvDB.profileKeys) then
|
|
|
|
if ElvDB.profileKeys then
|
|
|
|
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm];
|
|
|
|
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
profileData = E:CopyTable(profileData , ElvDB.profiles[profileKey])
|
|
|
|
profileData = E:CopyTable(profileData , ElvDB.profiles[profileKey])
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, P);
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, P)
|
|
|
|
elseif(profileType == "private") then
|
|
|
|
elseif profileType == "private" then
|
|
|
|
local privateProfileKey = E.myname.." - "..E.myrealm;
|
|
|
|
local privateProfileKey = E.myname.." - "..E.myrealm
|
|
|
|
profileKey = "private";
|
|
|
|
profileKey = "private"
|
|
|
|
|
|
|
|
|
|
|
|
profileData = E:CopyTable(profileData, ElvPrivateDB.profiles[privateProfileKey]);
|
|
|
|
profileData = E:CopyTable(profileData, ElvPrivateDB.profiles[privateProfileKey])
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, V);
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, V)
|
|
|
|
elseif(profileType == "global") then
|
|
|
|
elseif profileType == "global" then
|
|
|
|
profileKey = "global";
|
|
|
|
profileKey = "global"
|
|
|
|
|
|
|
|
|
|
|
|
profileData = E:CopyTable(profileData, ElvDB.global);
|
|
|
|
profileData = E:CopyTable(profileData, ElvDB.global)
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G);
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G)
|
|
|
|
elseif(profileType == "filtersNP") then
|
|
|
|
elseif profileType == "filtersNP" then
|
|
|
|
profileKey = "filtersNP";
|
|
|
|
profileKey = "filtersNP"
|
|
|
|
|
|
|
|
|
|
|
|
profileData["nameplates"] = {};
|
|
|
|
profileData["nameplates"] = {}
|
|
|
|
profileData["nameplates"]["filter"] = {};
|
|
|
|
profileData["nameplates"]["filter"] = {}
|
|
|
|
profileData["nameplates"]["filter"] = E:CopyTable(profileData["nameplates"]["filter"], ElvDB.global.nameplates.filter);
|
|
|
|
profileData["nameplates"]["filter"] = E:CopyTable(profileData["nameplates"]["filter"], ElvDB.global.nameplates.filter)
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G);
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G)
|
|
|
|
elseif(profileType == "filtersUF") then
|
|
|
|
elseif profileType == "filtersUF" then
|
|
|
|
profileKey = "filtersUF";
|
|
|
|
profileKey = "filtersUF"
|
|
|
|
|
|
|
|
|
|
|
|
profileData["unitframe"] = {};
|
|
|
|
profileData["unitframe"] = {}
|
|
|
|
profileData["unitframe"]["aurafilters"] = {};
|
|
|
|
profileData["unitframe"]["aurafilters"] = {}
|
|
|
|
profileData["unitframe"]["aurafilters"] = E:CopyTable(profileData["unitframe"]["aurafilters"], ElvDB.global.unitframe.aurafilters);
|
|
|
|
profileData["unitframe"]["aurafilters"] = E:CopyTable(profileData["unitframe"]["aurafilters"], ElvDB.global.unitframe.aurafilters)
|
|
|
|
profileData["unitframe"]["buffwatch"] = {};
|
|
|
|
profileData["unitframe"]["buffwatch"] = {}
|
|
|
|
profileData["unitframe"]["buffwatch"] = E:CopyTable(profileData["unitframe"]["buffwatch"], ElvDB.global.unitframe.buffwatch);
|
|
|
|
profileData["unitframe"]["buffwatch"] = E:CopyTable(profileData["unitframe"]["buffwatch"], ElvDB.global.unitframe.buffwatch)
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G);
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G)
|
|
|
|
elseif(profileType == "filtersAll") then
|
|
|
|
elseif profileType == "filtersAll" then
|
|
|
|
profileKey = "filtersAll";
|
|
|
|
profileKey = "filtersAll"
|
|
|
|
|
|
|
|
|
|
|
|
profileData["nameplates"] = {};
|
|
|
|
profileData["nameplates"] = {}
|
|
|
|
profileData["nameplates"]["filter"] = {};
|
|
|
|
profileData["nameplates"]["filter"] = {}
|
|
|
|
profileData["nameplates"]["filter"] = E:CopyTable(profileData["nameplates"]["filter"], ElvDB.global.nameplates.filter);
|
|
|
|
profileData["nameplates"]["filter"] = E:CopyTable(profileData["nameplates"]["filter"], ElvDB.global.nameplates.filter)
|
|
|
|
profileData["unitframe"] = {};
|
|
|
|
profileData["unitframe"] = {}
|
|
|
|
profileData["unitframe"]["aurafilters"] = {};
|
|
|
|
profileData["unitframe"]["aurafilters"] = {}
|
|
|
|
profileData["unitframe"]["aurafilters"] = E:CopyTable(profileData["unitframe"]["aurafilters"], ElvDB.global.unitframe.aurafilters);
|
|
|
|
profileData["unitframe"]["aurafilters"] = E:CopyTable(profileData["unitframe"]["aurafilters"], ElvDB.global.unitframe.aurafilters)
|
|
|
|
profileData["unitframe"]["buffwatch"] = {};
|
|
|
|
profileData["unitframe"]["buffwatch"] = {}
|
|
|
|
profileData["unitframe"]["buffwatch"] = E:CopyTable(profileData["unitframe"]["buffwatch"], ElvDB.global.unitframe.buffwatch);
|
|
|
|
profileData["unitframe"]["buffwatch"] = E:CopyTable(profileData["unitframe"]["buffwatch"], ElvDB.global.unitframe.buffwatch)
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G);
|
|
|
|
profileData = E:RemoveTableDuplicates(profileData, G)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return profileKey, profileData;
|
|
|
|
return profileKey, profileData
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function GetProfileExport(profileType, exportFormat)
|
|
|
|
local function GetProfileExport(profileType, exportFormat)
|
|
|
|
local profileExport, exportString;
|
|
|
|
local profileExport, exportString
|
|
|
|
local profileKey, profileData = GetProfileData(profileType);
|
|
|
|
local profileKey, profileData = GetProfileData(profileType)
|
|
|
|
|
|
|
|
|
|
|
|
if(not profileKey or not profileData or (profileData and type(profileData) ~= "table")) then
|
|
|
|
if not profileKey or not profileData or (profileData and type(profileData) ~= "table") then
|
|
|
|
E:Print("Error getting data from 'GetProfileData'");
|
|
|
|
E:Print("Error getting data from 'GetProfileData'")
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if(exportFormat == "text") then
|
|
|
|
if exportFormat == "text" then
|
|
|
|
local serialData = D:Serialize(profileData);
|
|
|
|
local serialData = D:Serialize(profileData)
|
|
|
|
|
|
|
|
|
|
|
|
exportString = D:CreateProfileExport(serialData, profileType, profileKey);
|
|
|
|
exportString = D:CreateProfileExport(serialData, profileType, profileKey)
|
|
|
|
|
|
|
|
|
|
|
|
local compressedData = LibCompress:Compress(exportString);
|
|
|
|
local compressedData = LibCompress:Compress(exportString)
|
|
|
|
local encodedData = LibBase64:Encode(compressedData);
|
|
|
|
local encodedData = LibBase64:Encode(compressedData)
|
|
|
|
profileExport = encodedData;
|
|
|
|
profileExport = encodedData
|
|
|
|
elseif(exportFormat == "luaTable") then
|
|
|
|
elseif exportFormat == "luaTable" then
|
|
|
|
exportString = E:TableToLuaString(profileData);
|
|
|
|
exportString = E:TableToLuaString(profileData)
|
|
|
|
profileExport = D:CreateProfileExport(exportString, profileType, profileKey);
|
|
|
|
profileExport = D:CreateProfileExport(exportString, profileType, profileKey)
|
|
|
|
elseif(exportFormat == "luaPlugin") then
|
|
|
|
elseif exportFormat == "luaPlugin" then
|
|
|
|
profileExport = E:ProfileTableToPluginFormat(profileData, profileType);
|
|
|
|
profileExport = E:ProfileTableToPluginFormat(profileData, profileType)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return profileKey, profileExport;
|
|
|
|
return profileKey, profileExport
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function D:CreateProfileExport(dataString, profileType, profileKey)
|
|
|
|
function D:CreateProfileExport(dataString, profileType, profileKey)
|
|
|
|
local returnString;
|
|
|
|
local returnString
|
|
|
|
|
|
|
|
|
|
|
|
if(profileType == "profile") then
|
|
|
|
if profileType == "profile" then
|
|
|
|
returnString = format("%s::%s::%s", dataString, profileType, profileKey);
|
|
|
|
returnString = format("%s::%s::%s", dataString, profileType, profileKey)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
returnString = format("%s::%s", dataString, profileType);
|
|
|
|
returnString = format("%s::%s", dataString, profileType)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return returnString;
|
|
|
|
return returnString
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function D:GetImportStringType(dataString)
|
|
|
|
function D:GetImportStringType(dataString)
|
|
|
|
local stringType = "";
|
|
|
|
local stringType = ""
|
|
|
|
|
|
|
|
|
|
|
|
if(LibBase64:IsBase64(dataString)) then
|
|
|
|
if LibBase64:IsBase64(dataString) then
|
|
|
|
stringType = "Base64";
|
|
|
|
stringType = "Base64"
|
|
|
|
elseif(find(dataString, "{")) then
|
|
|
|
elseif find(dataString, "{") then
|
|
|
|
stringType = "Table";
|
|
|
|
stringType = "Table"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return stringType;
|
|
|
|
return stringType
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function D:Decode(dataString)
|
|
|
|
function D:Decode(dataString)
|
|
|
|
local profileInfo, profileType, profileKey, profileData, message;
|
|
|
|
local profileInfo, profileType, profileKey, profileData, message
|
|
|
|
local stringType = self:GetImportStringType(dataString);
|
|
|
|
local stringType = self:GetImportStringType(dataString)
|
|
|
|
|
|
|
|
|
|
|
|
if(stringType == "Base64") then
|
|
|
|
if stringType == "Base64" then
|
|
|
|
local decodedData = LibBase64:Decode(dataString);
|
|
|
|
local decodedData = LibBase64:Decode(dataString)
|
|
|
|
local decompressedData, message = LibCompress:Decompress(decodedData);
|
|
|
|
local decompressedData, message = LibCompress:Decompress(decodedData)
|
|
|
|
|
|
|
|
|
|
|
|
if(not decompressedData) then
|
|
|
|
if not decompressedData then
|
|
|
|
E:Print("Error decompressing data:", message);
|
|
|
|
E:Print("Error decompressing data:", message)
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local serializedData, success;
|
|
|
|
local serializedData, success
|
|
|
|
serializedData, profileInfo = E:StringSplitMultiDelim(decompressedData, "^^::");
|
|
|
|
serializedData, profileInfo = E:StringSplitMultiDelim(decompressedData, "^^::")
|
|
|
|
|
|
|
|
|
|
|
|
if not profileInfo then
|
|
|
|
if not profileInfo then
|
|
|
|
E:Print("Error importing profile. String is invalid or corrupted!")
|
|
|
|
E:Print("Error importing profile. String is invalid or corrupted!")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
serializedData = format("%s%s", serializedData, "^^");
|
|
|
|
serializedData = format("%s%s", serializedData, "^^")
|
|
|
|
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::");
|
|
|
|
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::")
|
|
|
|
success, profileData = D:Deserialize(serializedData);
|
|
|
|
success, profileData = D:Deserialize(serializedData)
|
|
|
|
|
|
|
|
|
|
|
|
if(not success) then
|
|
|
|
if not success then
|
|
|
|
E:Print("Error deserializing:", profileData);
|
|
|
|
E:Print("Error deserializing:", profileData)
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif(stringType == "Table") then
|
|
|
|
elseif stringType == "Table" then
|
|
|
|
local profileDataAsString;
|
|
|
|
local profileDataAsString
|
|
|
|
profileDataAsString, profileInfo = E:StringSplitMultiDelim(dataString, "}::");
|
|
|
|
profileDataAsString, profileInfo = E:StringSplitMultiDelim(dataString, "}::")
|
|
|
|
|
|
|
|
|
|
|
|
if not profileInfo then
|
|
|
|
if not profileInfo then
|
|
|
|
E:Print("Error extracting profile info. Invalid import string!")
|
|
|
|
E:Print("Error extracting profile info. Invalid import string!")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if(not profileDataAsString) then
|
|
|
|
if not profileDataAsString then
|
|
|
|
E:Print("Error extracting profile data. Invalid import string!");
|
|
|
|
E:Print("Error extracting profile data. Invalid import string!")
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
profileDataAsString = format("%s%s", profileDataAsString, "}");
|
|
|
|
profileDataAsString = format("%s%s", profileDataAsString, "}")
|
|
|
|
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::");
|
|
|
|
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::")
|
|
|
|
|
|
|
|
|
|
|
|
local profileToTable = loadstring(format("%s %s", "return", profileDataAsString));
|
|
|
|
local profileToTable = loadstring(format("%s %s", "return", profileDataAsString))
|
|
|
|
if(profileToTable) then
|
|
|
|
if profileToTable then
|
|
|
|
message, profileData = pcall(profileToTable);
|
|
|
|
message, profileData = pcall(profileToTable)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if(not profileData or type(profileData) ~= "table") then
|
|
|
|
if not profileData or type(profileData) ~= "table" then
|
|
|
|
E:Print("Error converting lua string to table:", message);
|
|
|
|
E:Print("Error converting lua string to table:", message)
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return profileType, profileKey, profileData;
|
|
|
|
return profileType, profileKey, profileData
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function SetImportedProfile(profileType, profileKey, profileData, force)
|
|
|
|
local function SetImportedProfile(profileType, profileKey, profileData, force)
|
|
|
|
D.profileType = nil;
|
|
|
|
D.profileType = nil
|
|
|
|
D.profileKey = nil;
|
|
|
|
D.profileKey = nil
|
|
|
|
D.profileData = nil;
|
|
|
|
D.profileData = nil
|
|
|
|
|
|
|
|
|
|
|
|
if(profileType == "profile") then
|
|
|
|
if profileType == "profile" then
|
|
|
|
if(not ElvDB.profiles[profileKey] or force) then
|
|
|
|
if not ElvDB.profiles[profileKey] or force then
|
|
|
|
if(force and E.data.keys.profile == profileKey) then
|
|
|
|
if force and E.data.keys.profile == profileKey then
|
|
|
|
local tempKey = profileKey.."_Temp";
|
|
|
|
local tempKey = profileKey.."_Temp"
|
|
|
|
E.data.keys.profile = tempKey;
|
|
|
|
E.data.keys.profile = tempKey
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ElvDB.profiles[profileKey] = profileData;
|
|
|
|
ElvDB.profiles[profileKey] = profileData
|
|
|
|
E.data:SetProfile(profileKey);
|
|
|
|
E.data:SetProfile(profileKey)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
D.profileType = profileType;
|
|
|
|
D.profileType = profileType
|
|
|
|
D.profileKey = profileKey;
|
|
|
|
D.profileKey = profileKey
|
|
|
|
D.profileData = profileData;
|
|
|
|
D.profileData = profileData
|
|
|
|
E:StaticPopup_Show("IMPORT_PROFILE_EXISTS");
|
|
|
|
E:StaticPopup_Show("IMPORT_PROFILE_EXISTS")
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif(profileType == "private") then
|
|
|
|
elseif profileType == "private" then
|
|
|
|
local profileKey = ElvPrivateDB.profileKeys[E.myname.." - "..E.myrealm];
|
|
|
|
local profileKey = ElvPrivateDB.profileKeys[E.myname.." - "..E.myrealm]
|
|
|
|
ElvPrivateDB.profiles[profileKey] = profileData;
|
|
|
|
ElvPrivateDB.profiles[profileKey] = profileData
|
|
|
|
E:StaticPopup_Show("IMPORT_RL");
|
|
|
|
E:StaticPopup_Show("IMPORT_RL")
|
|
|
|
|
|
|
|
|
|
|
|
elseif(profileType == "global") then
|
|
|
|
elseif profileType == "global" then
|
|
|
|
E:CopyTable(ElvDB.global, profileData);
|
|
|
|
E:CopyTable(ElvDB.global, profileData)
|
|
|
|
E:StaticPopup_Show("IMPORT_RL");
|
|
|
|
E:StaticPopup_Show("IMPORT_RL")
|
|
|
|
elseif(profileType == "filtersNP") then
|
|
|
|
elseif profileType == "filtersNP" then
|
|
|
|
E:CopyTable(ElvDB.global.nameplates, profileData.nameplates);
|
|
|
|
E:CopyTable(ElvDB.global.nameplates, profileData.nameplates)
|
|
|
|
elseif(profileType == "filtersUF") then
|
|
|
|
elseif profileType == "filtersUF" then
|
|
|
|
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe);
|
|
|
|
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe)
|
|
|
|
elseif(profileType == "filtersAll") then
|
|
|
|
elseif profileType == "filtersAll" then
|
|
|
|
E:CopyTable(ElvDB.global.nameplates, profileData.nameplates);
|
|
|
|
E:CopyTable(ElvDB.global.nameplates, profileData.nameplates)
|
|
|
|
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe);
|
|
|
|
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
E:UpdateAll(true);
|
|
|
|
E:UpdateAll(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function D:ExportProfile(profileType, exportFormat)
|
|
|
|
function D:ExportProfile(profileType, exportFormat)
|
|
|
|
if(not profileType or not exportFormat) then
|
|
|
|
if not profileType or not exportFormat then
|
|
|
|
E:Print("Bad argument to 'ExportProfile' (string expected)");
|
|
|
|
E:Print("Bad argument to 'ExportProfile' (string expected)")
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local profileKey, profileExport = GetProfileExport(profileType, exportFormat);
|
|
|
|
local profileKey, profileExport = GetProfileExport(profileType, exportFormat)
|
|
|
|
return profileKey, profileExport;
|
|
|
|
return profileKey, profileExport
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function D:ImportProfile(dataString)
|
|
|
|
function D:ImportProfile(dataString)
|
|
|
|
local profileType, profileKey, profileData = self:Decode(dataString);
|
|
|
|
print(self)
|
|
|
|
|
|
|
|
local profileType, profileKey, profileData = self:Decode(dataString)
|
|
|
|
|
|
|
|
|
|
|
|
if(not profileData or type(profileData) ~= "table") then
|
|
|
|
if not profileData or type(profileData) ~= "table" then
|
|
|
|
E:Print("Error: something went wrong when converting string to table!");
|
|
|
|
E:Print("Error: something went wrong when converting string to table!")
|
|
|
|
return;
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if(profileType and ((profileType == "profile" and profileKey) or profileType ~= "profile")) then
|
|
|
|
if profileType and ((profileType == "profile" and profileKey) or profileType ~= "profile") then
|
|
|
|
SetImportedProfile(profileType, profileKey, profileData);
|
|
|
|
SetImportedProfile(profileType, profileKey, profileData)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
E.PopupDialogs["DISTRIBUTOR_SUCCESS"] = {
|
|
|
|
E.PopupDialogs["DISTRIBUTOR_SUCCESS"] = {
|
|
|
@@ -509,24 +512,24 @@ E.PopupDialogs["IMPORT_PROFILE_EXISTS"] = {
|
|
|
|
editBoxWidth = 350,
|
|
|
|
editBoxWidth = 350,
|
|
|
|
maxLetters = 127,
|
|
|
|
maxLetters = 127,
|
|
|
|
OnAccept = function(self)
|
|
|
|
OnAccept = function(self)
|
|
|
|
local profileType = D.profileType;
|
|
|
|
local profileType = D.profileType
|
|
|
|
local profileKey = self.editBox:GetText();
|
|
|
|
local profileKey = self.editBox:GetText()
|
|
|
|
local profileData = D.profileData;
|
|
|
|
local profileData = D.profileData
|
|
|
|
SetImportedProfile(profileType, profileKey, profileData, true);
|
|
|
|
SetImportedProfile(profileType, profileKey, profileData, true)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
EditBoxOnTextChanged = function(self)
|
|
|
|
EditBoxOnTextChanged = function(self)
|
|
|
|
if(self:GetText() == "") then
|
|
|
|
if self:GetText() == "" then
|
|
|
|
self:GetParent().button1:Disable();
|
|
|
|
self:GetParent().button1:Disable()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
self:GetParent().button1:Enable();
|
|
|
|
self:GetParent().button1:Enable()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
OnShow = function() this.editBox:SetText(D.profileKey); this.editBox:SetFocus(); end,
|
|
|
|
OnShow = function() this.editBox:SetText(D.profileKey) this.editBox:SetFocus() end,
|
|
|
|
timeout = 0,
|
|
|
|
timeout = 0,
|
|
|
|
whileDead = 1,
|
|
|
|
whileDead = 1,
|
|
|
|
hideOnEscape = true,
|
|
|
|
hideOnEscape = true,
|
|
|
|
preferredIndex = 3
|
|
|
|
preferredIndex = 3
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
E.PopupDialogs["IMPORT_RL"] = {
|
|
|
|
E.PopupDialogs["IMPORT_RL"] = {
|
|
|
|
text = L["You have imported settings which may require a UI reload to take effect. Reload now?"],
|
|
|
|
text = L["You have imported settings which may require a UI reload to take effect. Reload now?"],
|
|
|
@@ -537,7 +540,7 @@ E.PopupDialogs["IMPORT_RL"] = {
|
|
|
|
whileDead = 1,
|
|
|
|
whileDead = 1,
|
|
|
|
hideOnEscape = false,
|
|
|
|
hideOnEscape = false,
|
|
|
|
preferredIndex = 3
|
|
|
|
preferredIndex = 3
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local function InitializeCallback()
|
|
|
|
local function InitializeCallback()
|
|
|
|
D:Initialize()
|
|
|
|
D:Initialize()
|
|
|
|