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:RegisterEvent("CHAT_MSG_ADDON")
self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", UIParent)
self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", E.UIParent)
E:RegisterStatusBar(self.statusBar)
E:CreateBackdrop(self.statusBar, "Default")
self.statusBar:SetStatusBarTexture(E.media.normTex)
@@ -38,7 +38,7 @@ function D:Initialize()
E:Size(self.statusBar, 250, 18)
self.statusBar.text = self.statusBar:CreateFontString(nil, "OVERLAY")
E:FontTemplate(self.statusBar.text)
self.statusBar.text:SetPoint("CENTER", 0, 0)
E:Point(self.statusBar.text, "CENTER", 0, 0)
self.statusBar:Hide()
end
@@ -85,16 +85,19 @@ function D:Distribute(target, otherServer, isGlobal)
end
function D:CHAT_MSG_ADDON()
if not Downloads[arg4] then return end
local cur = len(arg2)
local max = Downloads[arg4].length
Downloads[arg4].current = Downloads[arg4].current + cur
local prefix, message, sender = arg1, arg2, arg4
if Downloads[arg4].current > max then
Downloads[arg4].current = max
if prefix ~= TRANSFER_PREFIX or not Downloads[sender] then return end
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
self.statusBar:SetValue(Downloads[arg4].current)
self.statusBar:SetValue(Downloads[sender].current)
end
function D:OnCommReceived(prefix, msg, dist, sender)
@@ -131,14 +134,14 @@ function D:OnCommReceived(prefix, msg, dist, sender)
button2 = CANCEL,
timeout = 32,
whileDead = 1,
hideOnEscape = 1,
hideOnEscape = 1
}
E:StaticPopup_Show("DISTRIBUTOR_RESPONSE")
Downloads[sender] = {
current = 0,
length = tonumber(length),
profile = profile,
profile = profile
}
self:RegisterComm(TRANSFER_PREFIX)
@@ -184,7 +187,7 @@ function D:OnCommReceived(prefix, msg, dist, sender)
E:UpdateAll(true)
Downloads[sender] = nil
end,
OnShow = function(self) self.editBox:SetText(profileKey) self.editBox:SetFocus() end,
OnShow = function() this.editBox:SetText(profileKey) this.editBox:SetFocus() end,
timeout = 0,
exclusive = 1,
whileDead = 1,
@@ -215,7 +218,7 @@ function D:OnCommReceived(prefix, msg, dist, sender)
button1 = YES,
button2 = NO,
whileDead = 1,
hideOnEscape = 1,
hideOnEscape = 1
}
E:StaticPopup_Show("DISTRIBUTOR_CONFIRM")
@@ -250,6 +253,9 @@ local function GetProfileData(profileType)
--Copy current profile data
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)
elseif profileType == "private" then
local privateProfileKey = E.myname.." - "..E.myrealm
@@ -306,9 +312,7 @@ local function GetProfileExport(profileType, exportFormat)
if exportFormat == "text" then
local serialData = D:Serialize(profileData)
exportString = D:CreateProfileExport(serialData, profileType, profileKey)
local compressedData = LibCompress:Compress(exportString)
local encodedData = LibBase64:Encode(compressedData)
profileExport = encodedData
@@ -522,11 +526,11 @@ E.PopupDialogs["IMPORT_PROFILE_EXISTS"] = {
local profileData = D.profileData
SetImportedProfile(profileType, profileKey, profileData, true)
end,
EditBoxOnTextChanged = function(self)
if self:GetText() == "" then
self:GetParent().button1:Disable()
EditBoxOnTextChanged = function()
if this:GetText() == "" then
this:GetParent().button1:Disable()
else
self:GetParent().button1:Enable()
this:GetParent().button1:Enable()
end
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 AceGUI = LibStub("AceGUI-3.0");
local pairs = pairs;
local tsort, tinsert = table.sort, table.insert;
local format = string.format;
--Cache global variables
--Lua functions
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 UnitIsFriend = UnitIsFriend;
local UnitIsPlayer = UnitIsPlayer;
local UnitIsUnit = UnitIsUnit;
local UnitName = UnitName;
local DEFAULT_WIDTH = 890
local DEFAULT_HEIGHT = 651
local AC = LibStub("AceConfig-3.0")
local ACD = LibStub("AceConfigDialog-3.0")
local ACR = LibStub("AceConfigRegistry-3.0")
local DEFAULT_WIDTH = 890;
local DEFAULT_HEIGHT = 651;
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);
AC.RegisterOptionsTable(E, "ElvUI", E.Options)
ACD:SetDefaultSize("ElvUI", DEFAULT_WIDTH, DEFAULT_HEIGHT)
function E:RefreshGUI()
self:RefreshCustomTextsConfigs();
ACR:NotifyChange("ElvUI");
self:RefreshCustomTextsConfigs()
ACR:NotifyChange("ElvUI")
end
E.Options.args = {
@@ -37,42 +42,42 @@ E.Options.args = {
order = 2,
type = "toggle",
name = L["Login Message"],
get = function(info) return E.db.general.loginmessage; end,
set = function(info, value) E.db.general.loginmessage = value; end
get = function(info) return E.db.general.loginmessage end,
set = function(info, value) E.db.general.loginmessage = value end
},
ToggleTutorial = {
order = 3,
type = "execute",
name = L["Toggle Tutorials"],
func = function() E:Tutorials(true); E:ToggleConfig(); end
func = function() E:Tutorials(true) E:ToggleConfig() end
},
Install = {
order = 4,
type = "execute",
name = L["Install"],
desc = L["Run the installation process."],
func = function() E:Install(); E:ToggleConfig(); end
func = function() E:Install() E:ToggleConfig() end
},
ToggleAnchors = {
order = 5,
type = "execute",
name = L["Toggle Anchors"],
desc = L["Unlock various elements of the UI to be repositioned."],
func = function() E:ToggleConfigMode(); end
func = function() E:ToggleConfigMode() end
},
ResetAllMovers = {
order = 6,
type = "execute",
name = L["Reset Anchors"],
desc = L["Reset all frames to their original positions."],
func = function() E:ResetUI(); end
func = function() E:ResetUI() end
}
}
};
local DONATOR_STRING = "";
local DEVELOPER_STRING = "";
local TESTER_STRING = "";
local LINE_BREAK = "\n";
local DONATOR_STRING = ""
local DEVELOPER_STRING = ""
local TESTER_STRING = ""
local LINE_BREAK = "\n"
local DONATORS = {
"Dandruff",
"Tobur/Tarilya",
@@ -113,7 +118,7 @@ local DONATORS = {
"Pyrokee",
"Portable",
"Ithilyn"
};
}
local DEVELOPERS = {
"Tukz",
@@ -121,7 +126,7 @@ local DEVELOPERS = {
"Nightcracker",
"Omega1970",
"Hydrazine"
};
}
local TESTERS = {
"Tukui Community",
@@ -143,22 +148,22 @@ local TESTERS = {
"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
tinsert(E.CreditsList, donatorName);
DONATOR_STRING = DONATOR_STRING .. LINE_BREAK .. donatorName;
tinsert(E.CreditsList, donatorName)
DONATOR_STRING = DONATOR_STRING .. LINE_BREAK .. donatorName
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
tinsert(E.CreditsList, devName);
DEVELOPER_STRING = DEVELOPER_STRING .. LINE_BREAK .. devName;
tinsert(E.CreditsList, devName)
DEVELOPER_STRING = DEVELOPER_STRING .. LINE_BREAK .. devName
end
tsort(TESTERS, function(a, b) return a < b end)
for _, testerName in pairs(TESTERS) do
tinsert(E.CreditsList, testerName);
TESTER_STRING = TESTER_STRING .. LINE_BREAK .. testerName;
tinsert(E.CreditsList, testerName)
TESTER_STRING = TESTER_STRING .. LINE_BREAK .. testerName
end
E.Options.args.credits = {
@@ -417,10 +422,21 @@ E.Options.args.profiles.plugins["ElvUI"] = {
desc = L["Sends your current profile to your target."],
type = "execute",
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
E:Print(L["You must be targeting a player."])
return
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")
if name and not server or server == "" then
D:Distribute(name)
@@ -435,10 +451,21 @@ E.Options.args.profiles.plugins["ElvUI"] = {
name = L["Share Filters"],
desc = L["Sends your filter settings to your target."],
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
E:Print(L["You must be targeting a player."])
return
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")
if name and not server or server == "" then
D:Distribute(name, false, true)