update distributor (sharing profile works in-game, must be in party)

This commit is contained in:
Crum
2018-11-08 12:05:13 -06:00
parent 83668e2753
commit 105f31881c
+17 -10
View File
@@ -78,7 +78,7 @@ function D:Distribute(target, otherServer, isGlobal)
return return
end end
else else
self:SendCommMessage(REQUEST_PREFIX, message, "WHISPER", target) self:SendCommMessage(REQUEST_PREFIX, message, "PARTY", target)
end end
self:RegisterComm(REPLY_PREFIX) self:RegisterComm(REPLY_PREFIX)
E:StaticPopup_Show("DISTRIBUTOR_WAITING") E:StaticPopup_Show("DISTRIBUTOR_WAITING")
@@ -248,6 +248,7 @@ local function GetProfileData(profileType)
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm] profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm]
end end
--Copy current profile data
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
@@ -338,7 +339,7 @@ function D:GetImportStringType(dataString)
if LibBase64:IsBase64(dataString) then if LibBase64:IsBase64(dataString) then
stringType = "Base64" stringType = "Base64"
elseif find(dataString, "{") then elseif find(dataString, "{") then --Basic check to weed out obviously wrong strings
stringType = "Table" stringType = "Table"
end end
@@ -359,14 +360,14 @@ function D:Decode(dataString)
end end
local serializedData, success local serializedData, success
serializedData, profileInfo = E:StringSplitMultiDelim(decompressedData, "^^::") serializedData, profileInfo = E:StringSplitMultiDelim(decompressedData, "^^::") -- "^^" indicates the end of the AceSerializer string
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, "^^") --Add back the AceSerializer terminator
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::") profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::")
success, profileData = D:Deserialize(serializedData) success, profileData = D:Deserialize(serializedData)
@@ -376,7 +377,7 @@ function D:Decode(dataString)
end end
elseif stringType == "Table" then elseif stringType == "Table" then
local profileDataAsString local profileDataAsString
profileDataAsString, profileInfo = E:StringSplitMultiDelim(dataString, "}::") profileDataAsString, profileInfo = E:StringSplitMultiDelim(dataString, "}::") -- "}::" indicates the end of the table
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!")
@@ -388,7 +389,8 @@ function D:Decode(dataString)
return return
end end
profileDataAsString = format("%s%s", profileDataAsString, "}") profileDataAsString = format("%s%s", profileDataAsString, "}") --Add back the missing "}"
profileDataAsString = gsub(profileDataAsString, "\124\124", "\124") --Remove escape pipe characters
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))
@@ -413,10 +415,13 @@ local function SetImportedProfile(profileType, profileKey, profileData, force)
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
--Overwriting an active profile doesn't update when calling SetProfile
--So make it look like we use a different profile
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
--Calling SetProfile will now update all settings correctly
E.data:SetProfile(profileKey) E.data:SetProfile(profileKey)
else else
D.profileType = profileType D.profileType = profileType
@@ -443,6 +448,7 @@ local function SetImportedProfile(profileType, profileKey, profileData, force)
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe) E:CopyTable(ElvDB.global.unitframe, profileData.unitframe)
end end
--Update all ElvUI modules
E:UpdateAll(true) E:UpdateAll(true)
end end
@@ -453,6 +459,7 @@ function D:ExportProfile(profileType, exportFormat)
end end
local profileKey, profileExport = GetProfileExport(profileType, exportFormat) local profileKey, profileExport = GetProfileExport(profileType, exportFormat)
return profileKey, profileExport return profileKey, profileExport
end end
@@ -475,28 +482,28 @@ E.PopupDialogs["DISTRIBUTOR_SUCCESS"] = {
text = L["Your profile was successfully recieved by the player."], text = L["Your profile was successfully recieved by the player."],
whileDead = 1, whileDead = 1,
hideOnEscape = 1, hideOnEscape = 1,
button1 = OKAY, button1 = OKAY
} }
E.PopupDialogs["DISTRIBUTOR_WAITING"] = { E.PopupDialogs["DISTRIBUTOR_WAITING"] = {
text = L["Profile request sent. Waiting for response from player."], text = L["Profile request sent. Waiting for response from player."],
whileDead = 1, whileDead = 1,
hideOnEscape = 1, hideOnEscape = 1,
timeout = 35, timeout = 35
} }
E.PopupDialogs["DISTRIBUTOR_REQUEST_DENIED"] = { E.PopupDialogs["DISTRIBUTOR_REQUEST_DENIED"] = {
text = L["Request was denied by user."], text = L["Request was denied by user."],
whileDead = 1, whileDead = 1,
hideOnEscape = 1, hideOnEscape = 1,
button1 = OKAY, button1 = OKAY
} }
E.PopupDialogs["DISTRIBUTOR_FAILED"] = { E.PopupDialogs["DISTRIBUTOR_FAILED"] = {
text = L["Lord! It's a miracle! The download up and vanished like a fart in the wind! Try Again!"], text = L["Lord! It's a miracle! The download up and vanished like a fart in the wind! Try Again!"],
whileDead = 1, whileDead = 1,
hideOnEscape = 1, hideOnEscape = 1,
button1 = OKAY, button1 = OKAY
} }
E.PopupDialogs["DISTRIBUTOR_RESPONSE"] = {} E.PopupDialogs["DISTRIBUTOR_RESPONSE"] = {}