update share profile and filters

This commit is contained in:
Crum
2018-11-08 23:33:39 -06:00
parent 105f31881c
commit b776abf8bd
2 changed files with 90 additions and 59 deletions
+23 -19
View File
@@ -30,7 +30,7 @@ function D:Initialize()
self:RegisterComm(REQUEST_PREFIX) self:RegisterComm(REQUEST_PREFIX)
self:RegisterEvent("CHAT_MSG_ADDON") self:RegisterEvent("CHAT_MSG_ADDON")
self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", UIParent) self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", E.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)
@@ -38,7 +38,7 @@ function D:Initialize()
E:Size(self.statusBar, 250, 18) E:Size(self.statusBar, 250, 18)
self.statusBar.text = self.statusBar:CreateFontString(nil, "OVERLAY") self.statusBar.text = self.statusBar:CreateFontString(nil, "OVERLAY")
E:FontTemplate(self.statusBar.text) E:FontTemplate(self.statusBar.text)
self.statusBar.text:SetPoint("CENTER", 0, 0) E:Point(self.statusBar.text, "CENTER", 0, 0)
self.statusBar:Hide() self.statusBar:Hide()
end end
@@ -85,16 +85,19 @@ function D:Distribute(target, otherServer, isGlobal)
end end
function D:CHAT_MSG_ADDON() function D:CHAT_MSG_ADDON()
if not Downloads[arg4] then return end local prefix, message, sender = arg1, arg2, arg4
local cur = len(arg2)
local max = Downloads[arg4].length
Downloads[arg4].current = Downloads[arg4].current + cur
if Downloads[arg4].current > max then if prefix ~= TRANSFER_PREFIX or not Downloads[sender] then return end
Downloads[arg4].current = max
local cur = len(message)
local max = Downloads[sender].length
Downloads[sender].current = Downloads[sender].current + cur
if Downloads[sender].current > max then
Downloads[sender].current = max
end end
self.statusBar:SetValue(Downloads[arg4].current) self.statusBar:SetValue(Downloads[sender].current)
end end
function D:OnCommReceived(prefix, msg, dist, sender) function D:OnCommReceived(prefix, msg, dist, sender)
@@ -131,14 +134,14 @@ function D:OnCommReceived(prefix, msg, dist, sender)
button2 = CANCEL, button2 = CANCEL,
timeout = 32, timeout = 32,
whileDead = 1, whileDead = 1,
hideOnEscape = 1, hideOnEscape = 1
} }
E:StaticPopup_Show("DISTRIBUTOR_RESPONSE") E:StaticPopup_Show("DISTRIBUTOR_RESPONSE")
Downloads[sender] = { Downloads[sender] = {
current = 0, current = 0,
length = tonumber(length), length = tonumber(length),
profile = profile, profile = profile
} }
self:RegisterComm(TRANSFER_PREFIX) self:RegisterComm(TRANSFER_PREFIX)
@@ -184,7 +187,7 @@ function D:OnCommReceived(prefix, msg, dist, sender)
E:UpdateAll(true) E:UpdateAll(true)
Downloads[sender] = nil Downloads[sender] = nil
end, end,
OnShow = function(self) self.editBox:SetText(profileKey) self.editBox:SetFocus() end, OnShow = function() this.editBox:SetText(profileKey) this.editBox:SetFocus() end,
timeout = 0, timeout = 0,
exclusive = 1, exclusive = 1,
whileDead = 1, whileDead = 1,
@@ -215,7 +218,7 @@ function D:OnCommReceived(prefix, msg, dist, sender)
button1 = YES, button1 = YES,
button2 = NO, button2 = NO,
whileDead = 1, whileDead = 1,
hideOnEscape = 1, hideOnEscape = 1
} }
E:StaticPopup_Show("DISTRIBUTOR_CONFIRM") E:StaticPopup_Show("DISTRIBUTOR_CONFIRM")
@@ -250,6 +253,9 @@ local function GetProfileData(profileType)
--Copy current profile data --Copy current profile data
profileData = E:CopyTable(profileData , ElvDB.profiles[profileKey]) profileData = E:CopyTable(profileData , ElvDB.profiles[profileKey])
--This table will also hold all default values, not just the changed settings.
--This makes the table huge, and will cause the WoW client to lock up for several seconds.
--We compare against the default table and remove all duplicates from our table. The table is now much smaller.
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
@@ -306,9 +312,7 @@ local function GetProfileExport(profileType, exportFormat)
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
@@ -522,11 +526,11 @@ E.PopupDialogs["IMPORT_PROFILE_EXISTS"] = {
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()
if self:GetText() == "" then if this:GetText() == "" then
self:GetParent().button1:Disable() this:GetParent().button1:Disable()
else else
self:GetParent().button1:Enable() this: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,
+67 -40
View File
@@ -1,29 +1,34 @@
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:GetModule("Distributor"); local D = E:GetModule("Distributor");
local AceGUI = LibStub("AceGUI-3.0"); local AceGUI = LibStub("AceGUI-3.0");
local pairs = pairs; --Cache global variables
local tsort, tinsert = table.sort, table.insert; --Lua functions
local format = string.format; local pairs = pairs
local tsort, tinsert = table.sort, table.insert
local format = string.format
--WoW API / Variables
local GetNumPartyMembers = GetNumPartyMembers
local GetNumRaidMembers = GetNumRaidMembers
local UnitExists = UnitExists
local UnitIsFriend = UnitIsFriend
local UnitIsPlayer = UnitIsPlayer
local UnitIsUnit = UnitIsUnit
local UnitName = UnitName
local UnitInParty = UnitInParty
local UnitExists = UnitExists; local DEFAULT_WIDTH = 890
local UnitIsFriend = UnitIsFriend; local DEFAULT_HEIGHT = 651
local UnitIsPlayer = UnitIsPlayer; local AC = LibStub("AceConfig-3.0")
local UnitIsUnit = UnitIsUnit; local ACD = LibStub("AceConfigDialog-3.0")
local UnitName = UnitName; local ACR = LibStub("AceConfigRegistry-3.0")
local DEFAULT_WIDTH = 890; AC.RegisterOptionsTable(E, "ElvUI", E.Options)
local DEFAULT_HEIGHT = 651; ACD:SetDefaultSize("ElvUI", DEFAULT_WIDTH, DEFAULT_HEIGHT)
local AC = LibStub("AceConfig-3.0");
local ACD = LibStub("AceConfigDialog-3.0");
local ACR = LibStub("AceConfigRegistry-3.0");
AC.RegisterOptionsTable(E, "ElvUI", E.Options);
ACD:SetDefaultSize("ElvUI", DEFAULT_WIDTH, DEFAULT_HEIGHT);
function E:RefreshGUI() function E:RefreshGUI()
self:RefreshCustomTextsConfigs(); self:RefreshCustomTextsConfigs()
ACR:NotifyChange("ElvUI"); ACR:NotifyChange("ElvUI")
end end
E.Options.args = { E.Options.args = {
@@ -37,42 +42,42 @@ E.Options.args = {
order = 2, order = 2,
type = "toggle", type = "toggle",
name = L["Login Message"], name = L["Login Message"],
get = function(info) return E.db.general.loginmessage; end, get = function(info) return E.db.general.loginmessage end,
set = function(info, value) E.db.general.loginmessage = value; end set = function(info, value) E.db.general.loginmessage = value end
}, },
ToggleTutorial = { ToggleTutorial = {
order = 3, order = 3,
type = "execute", type = "execute",
name = L["Toggle Tutorials"], name = L["Toggle Tutorials"],
func = function() E:Tutorials(true); E:ToggleConfig(); end func = function() E:Tutorials(true) E:ToggleConfig() end
}, },
Install = { Install = {
order = 4, order = 4,
type = "execute", type = "execute",
name = L["Install"], name = L["Install"],
desc = L["Run the installation process."], desc = L["Run the installation process."],
func = function() E:Install(); E:ToggleConfig(); end func = function() E:Install() E:ToggleConfig() end
}, },
ToggleAnchors = { ToggleAnchors = {
order = 5, order = 5,
type = "execute", type = "execute",
name = L["Toggle Anchors"], name = L["Toggle Anchors"],
desc = L["Unlock various elements of the UI to be repositioned."], desc = L["Unlock various elements of the UI to be repositioned."],
func = function() E:ToggleConfigMode(); end func = function() E:ToggleConfigMode() end
}, },
ResetAllMovers = { ResetAllMovers = {
order = 6, order = 6,
type = "execute", type = "execute",
name = L["Reset Anchors"], name = L["Reset Anchors"],
desc = L["Reset all frames to their original positions."], desc = L["Reset all frames to their original positions."],
func = function() E:ResetUI(); end func = function() E:ResetUI() end
} }
}; }
local DONATOR_STRING = ""; local DONATOR_STRING = ""
local DEVELOPER_STRING = ""; local DEVELOPER_STRING = ""
local TESTER_STRING = ""; local TESTER_STRING = ""
local LINE_BREAK = "\n"; local LINE_BREAK = "\n"
local DONATORS = { local DONATORS = {
"Dandruff", "Dandruff",
"Tobur/Tarilya", "Tobur/Tarilya",
@@ -113,7 +118,7 @@ local DONATORS = {
"Pyrokee", "Pyrokee",
"Portable", "Portable",
"Ithilyn" "Ithilyn"
}; }
local DEVELOPERS = { local DEVELOPERS = {
"Tukz", "Tukz",
@@ -121,7 +126,7 @@ local DEVELOPERS = {
"Nightcracker", "Nightcracker",
"Omega1970", "Omega1970",
"Hydrazine" "Hydrazine"
}; }
local TESTERS = { local TESTERS = {
"Tukui Community", "Tukui Community",
@@ -143,22 +148,22 @@ local TESTERS = {
"Catok" "Catok"
} }
tsort(DONATORS, function(a, b) return a < b end); tsort(DONATORS, function(a, b) return a < b end)
for _, donatorName in pairs(DONATORS) do for _, donatorName in pairs(DONATORS) do
tinsert(E.CreditsList, donatorName); tinsert(E.CreditsList, donatorName)
DONATOR_STRING = DONATOR_STRING .. LINE_BREAK .. donatorName; DONATOR_STRING = DONATOR_STRING .. LINE_BREAK .. donatorName
end end
tsort(DEVELOPERS, function(a,b) return a < b end); tsort(DEVELOPERS, function(a,b) return a < b end)
for _, devName in pairs(DEVELOPERS) do for _, devName in pairs(DEVELOPERS) do
tinsert(E.CreditsList, devName); tinsert(E.CreditsList, devName)
DEVELOPER_STRING = DEVELOPER_STRING .. LINE_BREAK .. devName; DEVELOPER_STRING = DEVELOPER_STRING .. LINE_BREAK .. devName
end end
tsort(TESTERS, function(a, b) return a < b end) tsort(TESTERS, function(a, b) return a < b end)
for _, testerName in pairs(TESTERS) do for _, testerName in pairs(TESTERS) do
tinsert(E.CreditsList, testerName); tinsert(E.CreditsList, testerName)
TESTER_STRING = TESTER_STRING .. LINE_BREAK .. testerName; TESTER_STRING = TESTER_STRING .. LINE_BREAK .. testerName
end end
E.Options.args.credits = { E.Options.args.credits = {
@@ -417,10 +422,21 @@ E.Options.args.profiles.plugins["ElvUI"] = {
desc = L["Sends your current profile to your target."], desc = L["Sends your current profile to your target."],
type = "execute", type = "execute",
func = function() func = function()
if (GetNumPartyMembers() <= 0 or GetNumPartyMembers() <= 0) then
E:Print(L["You must be in a group."])
return
end
if not UnitExists("target") or not UnitIsPlayer("target") or not UnitIsFriend("player", "target") or UnitIsUnit("player", "target") then if not UnitExists("target") or not UnitIsPlayer("target") or not UnitIsFriend("player", "target") or UnitIsUnit("player", "target") then
E:Print(L["You must be targeting a player."]) E:Print(L["You must be targeting a player."])
return return
end end
if not (UnitInParty("target") or UnitInRaid("target")) then
E:Print(L["You must be targeting a player within your group."])
return
end
local name, server = UnitName("target") local name, server = UnitName("target")
if name and not server or server == "" then if name and not server or server == "" then
D:Distribute(name) D:Distribute(name)
@@ -435,10 +451,21 @@ E.Options.args.profiles.plugins["ElvUI"] = {
name = L["Share Filters"], name = L["Share Filters"],
desc = L["Sends your filter settings to your target."], desc = L["Sends your filter settings to your target."],
func = function() func = function()
if (GetNumPartyMembers() <= 0 or GetNumPartyMembers() <= 0) then
E:Print(L["You must be in a group."])
return
end
if not UnitExists("target") or not UnitIsPlayer("target") or not UnitIsFriend("player", "target") or UnitIsUnit("player", "target") then if not UnitExists("target") or not UnitIsPlayer("target") or not UnitIsFriend("player", "target") or UnitIsUnit("player", "target") then
E:Print(L["You must be targeting a player."]) E:Print(L["You must be targeting a player."])
return return
end end
if not (UnitInParty("target") or UnitInRaid("target")) then
E:Print(L["You must be targeting a player within your group."])
return
end
local name, server = UnitName("target") local name, server = UnitName("target")
if name and not server or server == "" then if name and not server or server == "" then
D:Distribute(name, false, true) D:Distribute(name, false, true)