This commit is contained in:
Crum
2018-01-18 17:14:26 -06:00
parent c1828828df
commit e03c4b9eb3
9 changed files with 205 additions and 209 deletions
@@ -8,7 +8,6 @@ License: MIT
]] ]]
local MAJOR_VERSION = "LibBabble-Zone-3.0" local MAJOR_VERSION = "LibBabble-Zone-3.0"
--local MINOR_VERSION = 90000 + tonumber(("$Revision: 107 $"):match("%d+"))
local MINOR_VERSION = 90000 + tonumber(string.match("$Revision: 107 $", "%d+")) local MINOR_VERSION = 90000 + tonumber(string.match("$Revision: 107 $", "%d+"))
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
+174 -171
View File
@@ -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()
@@ -1,9 +1,9 @@
--- **AceSerializer-3.0** can serialize any variable (except functions or userdata) into a string format, --- **AceSerializer-3.0** can serialize any variable (except functions or userdata) into a string format,
-- that can be send over the addon comm channel. AceSerializer was designed to keep all data intact, especially -- that can be send over the addon comm channel. AceSerializer was designed to keep all data intact, especially
-- very large numbers or floating point numbers, and table structures. The only caveat currently is, that multiple -- very large numbers or floating point numbers, and table structures. The only caveat currently is, that multiple
-- references to the same table will be send individually. -- references to the same table will be send individually.
-- --
-- **AceSerializer-3.0** can be embeded into your addon, either explicitly by calling AceSerializer:Embed(MyAddon) or by -- **AceSerializer-3.0** can be embeded into your addon, either explicitly by calling AceSerializer:Embed(MyAddon) or by
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
-- and can be accessed directly, without having to explicitly call AceSerializer itself.\\ -- and can be accessed directly, without having to explicitly call AceSerializer itself.\\
-- It is recommended to embed AceSerializer, otherwise you'll have to specify a custom `self` on all calls you -- It is recommended to embed AceSerializer, otherwise you'll have to specify a custom `self` on all calls you
@@ -40,7 +40,7 @@ local function SerializeStringHelper(ch) -- Used by SerializeValue for strings
return "\126\122" return "\126\122"
elseif n<=32 then -- nonprint + space elseif n<=32 then -- nonprint + space
return "\126"..strchar(n+64) return "\126"..strchar(n+64)
elseif n==94 then -- value separator elseif n==94 then -- value separator
return "\126\125" return "\126\125"
elseif n==126 then -- our own escape character elseif n==126 then -- our own escape character
return "\126\124" return "\126\124"
@@ -54,12 +54,12 @@ end
local function SerializeValue(v, res, nres) local function SerializeValue(v, res, nres)
-- We use "^" as a value separator, followed by one byte for type indicator -- We use "^" as a value separator, followed by one byte for type indicator
local t=type(v) local t=type(v)
if t=="string" then -- ^S = string (escaped to remove nonprints, "^"s, etc) if t=="string" then -- ^S = string (escaped to remove nonprints, "^"s, etc)
res[nres+1] = "^S" res[nres+1] = "^S"
res[nres+2] = gsub(v,"[%c \94\126\127]", SerializeStringHelper) res[nres+2] = gsub(v,"[%c \94\126\127]", SerializeStringHelper)
nres=nres+2 nres=nres+2
elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components) elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components)
local str = tostring(v) local str = tostring(v)
if tonumber(str)==v --[[not in 4.3 or str==serNaN]] then if tonumber(str)==v --[[not in 4.3 or str==serNaN]] then
@@ -79,7 +79,7 @@ local function SerializeValue(v, res, nres)
res[nres+4] = tostring(e-53) -- adjust exponent to counteract mantissa manipulation res[nres+4] = tostring(e-53) -- adjust exponent to counteract mantissa manipulation
nres=nres+4 nres=nres+4
end end
elseif t=="table" then -- ^T...^t = table (list of key,value pairs) elseif t=="table" then -- ^T...^t = table (list of key,value pairs)
nres=nres+1 nres=nres+1
res[nres] = "^T" res[nres] = "^T"
@@ -89,7 +89,7 @@ local function SerializeValue(v, res, nres)
end end
nres=nres+1 nres=nres+1
res[nres] = "^t" res[nres] = "^t"
elseif t=="boolean" then -- ^B = true, ^b = false elseif t=="boolean" then -- ^B = true, ^b = false
nres=nres+1 nres=nres+1
if v then if v then
@@ -97,15 +97,15 @@ local function SerializeValue(v, res, nres)
else else
res[nres] = "^b" -- false res[nres] = "^b" -- false
end end
elseif t=="nil" then -- ^Z = nil (zero, "N" was taken :P) elseif t=="nil" then -- ^Z = nil (zero, "N" was taken :P)
nres=nres+1 nres=nres+1
res[nres] = "^Z" res[nres] = "^Z"
else else
error(MAJOR..": Cannot serialize a value of type '"..t.."'") -- can't produce error on right level, this is wildly recursive error(MAJOR..": Cannot serialize a value of type '"..t.."'") -- can't produce error on right level, this is wildly recursive
end end
return nres return nres
end end
@@ -127,7 +127,7 @@ function AceSerializer:Serialize(...)
end end
serializeTbl[nres+1] = "^^" -- "^^" = End of serialized data serializeTbl[nres+1] = "^^" -- "^^" = End of serialized data
return tconcat(serializeTbl, "", 1, nres+1) return tconcat(serializeTbl, "", 1, nres+1)
end end
@@ -174,9 +174,9 @@ local function DeserializeValue(iter,single,ctl,data)
ctl,data = iter() ctl,data = iter()
end end
if not ctl then if not ctl then
error("Supplied data misses AceSerializer terminator ('^^')") error("Supplied data misses AceSerializer terminator ('^^')")
end end
if ctl=="^^" then if ctl=="^^" then
-- ignore extraneous data -- ignore extraneous data
@@ -184,7 +184,7 @@ local function DeserializeValue(iter,single,ctl,data)
end end
local res local res
if ctl=="^S" then if ctl=="^S" then
res = gsub(data, "~.", DeserializeStringHelper) res = gsub(data, "~.", DeserializeStringHelper)
elseif ctl=="^N" then elseif ctl=="^N" then
@@ -217,7 +217,7 @@ local function DeserializeValue(iter,single,ctl,data)
ctl,data = iter() ctl,data = iter()
if ctl=="^t" then break end -- ignore ^t's data if ctl=="^t" then break end -- ignore ^t's data
k = DeserializeValue(iter,true,ctl,data) k = DeserializeValue(iter,true,ctl,data)
if k==nil then if k==nil then
error("Invalid AceSerializer table format (no table end marker)") error("Invalid AceSerializer table format (no table end marker)")
end end
ctl,data = iter() ctl,data = iter()
@@ -230,7 +230,7 @@ local function DeserializeValue(iter,single,ctl,data)
else else
error("Invalid AceSerializer control code '"..ctl.."'") error("Invalid AceSerializer control code '"..ctl.."'")
end end
if not single then if not single then
return res,DeserializeValue(iter) return res,DeserializeValue(iter)
else else
+1 -1
View File
@@ -723,7 +723,7 @@ function B:VendorGrays(delete, _, getValue)
for s = 1, GetContainerNumSlots(b) do for s = 1, GetContainerNumSlots(b) do
local l = GetContainerItemLink(b, s) local l = GetContainerItemLink(b, s)
if l and find(l,"ff9d9d9d") then if l and find(l,"ff9d9d9d") then
local p = LIP:GetSellValue(l) * select(2, GetContainerItemInfo(b, s)) -- local p = LIP:GetSellValue(l) * select(2, GetContainerItemInfo(b, s))
if delete then if delete then
if find(l,"ff9d9d9d") then if find(l,"ff9d9d9d") then
+3 -3
View File
@@ -694,7 +694,7 @@ end
local hyperLinkEntered local hyperLinkEntered
function CH:OnHyperlinkEnter() function CH:OnHyperlinkEnter()
local linkToken = match(arg1, "(%a+):(%d+)") local linkToken = match(arg1, "([^:]+)")
if hyperlinkTypes[linkToken] then if hyperlinkTypes[linkToken] then
ShowUIPanel(GameTooltip) ShowUIPanel(GameTooltip)
GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:SetOwner(this, "ANCHOR_CURSOR")
@@ -705,7 +705,7 @@ function CH:OnHyperlinkEnter()
end end
function CH:OnHyperlinkLeave() function CH:OnHyperlinkLeave()
local linkToken = match(arg1, "(%a+):(%d+)") local linkToken = match(arg1, "([^:]+)")
if hyperlinkTypes[linkToken] then if hyperlinkTypes[linkToken] then
HideUIPanel(GameTooltip) HideUIPanel(GameTooltip)
hyperLinkEntered = nil hyperLinkEntered = nil
@@ -1708,7 +1708,7 @@ function CH:Initialize()
end end
local S = E:GetModule("Skins") local S = E:GetModule("Skins")
--S:HandleNextPrevButton(CombatLogQuickButtonFrame_CustomAdditionalFilterButton, true)
local frame = CreateFrame("Frame", "CopyChatFrame", E.UIParent) local frame = CreateFrame("Frame", "CopyChatFrame", E.UIParent)
tinsert(UISpecialFrames, "CopyChatFrame") tinsert(UISpecialFrames, "CopyChatFrame")
E:SetTemplate(frame, "Transparent") E:SetTemplate(frame, "Transparent")
+1 -6
View File
@@ -6,10 +6,8 @@ E.Misc = M
--Lua functions --Lua functions
local format, gsub = string.format, string.gsub local format, gsub = string.format, string.gsub
--WoW API / Variables --WoW API / Variables
local CanGuildBankRepair = CanGuildBankRepair
local CanMerchantRepair = CanMerchantRepair local CanMerchantRepair = CanMerchantRepair
local GetFriendInfo = GetFriendInfo local GetFriendInfo = GetFriendInfo
local GetGuildBankWithdrawMoney = GetGuildBankWithdrawMoney
local GetGuildRosterInfo = GetGuildRosterInfo local GetGuildRosterInfo = GetGuildRosterInfo
local GetNumFriends = GetNumFriends local GetNumFriends = GetNumFriends
local GetNumGuildMembers = GetNumGuildMembers local GetNumGuildMembers = GetNumGuildMembers
@@ -18,7 +16,6 @@ local GetNumRaidMembers = GetNumRaidMembers
local GetPartyMember = GetPartyMember local GetPartyMember = GetPartyMember
local GetRepairAllCost = GetRepairAllCost local GetRepairAllCost = GetRepairAllCost
local GuildRoster = GuildRoster local GuildRoster = GuildRoster
local InCombatLockdown = InCombatLockdown
local IsInGuild = IsInGuild local IsInGuild = IsInGuild
local IsInInstance = IsInInstance local IsInInstance = IsInInstance
local IsShiftKeyDown = IsShiftKeyDown local IsShiftKeyDown = IsShiftKeyDown
@@ -97,8 +94,6 @@ function M:MERCHANT_SHOW()
end end
function M:DisbandRaidGroup() function M:DisbandRaidGroup()
if InCombatLockdown() then return end -- Prevent user error in combat
if UnitInRaid("player") then if UnitInRaid("player") then
for i = 1, GetNumRaidMembers() do for i = 1, GetNumRaidMembers() do
local name, _, _, _, _, _, _, online = GetRaidRosterInfo(i) local name, _, _, _, _, _, _, online = GetRaidRosterInfo(i)
@@ -182,7 +177,7 @@ function M:Initialize()
self:RegisterEvent("MERCHANT_SHOW") self:RegisterEvent("MERCHANT_SHOW")
self:RegisterEvent("PLAYER_REGEN_DISABLED", "ErrorFrameToggle") self:RegisterEvent("PLAYER_REGEN_DISABLED", "ErrorFrameToggle")
self:RegisterEvent("PLAYER_REGEN_ENABLED", "ErrorFrameToggle") self:RegisterEvent("PLAYER_REGEN_ENABLED", "ErrorFrameToggle")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") -- self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE", "PVPMessageEnhancement") self:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE", "PVPMessageEnhancement")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "PVPMessageEnhancement") self:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "PVPMessageEnhancement")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL", "PVPMessageEnhancement") self:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL", "PVPMessageEnhancement")
@@ -5,7 +5,7 @@ local mod = E:NewModule("NamePlates", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3
local _G = _G local _G = _G
local pairs, tonumber = pairs, tonumber local pairs, tonumber = pairs, tonumber
local select = select local select = select
local gsub, split = string.gsub, string.split local gsub, match, split = string.gsub, string.match, string.split
local twipe = table.wipe local twipe = table.wipe
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
@@ -82,7 +82,7 @@ function mod:CheckBGHealers()
for i = 1, GetNumBattlefieldScores() do for i = 1, GetNumBattlefieldScores() do
name, _, _, _, _, _, _, _, _, class, damageDone, healingDone = GetBattlefieldScore(i) name, _, _, _, _, _, _, _, _, class, damageDone, healingDone = GetBattlefieldScore(i)
if name and class and healClasses[class] then if name and class and healClasses[class] then
name = name:match("(.+)%-.+") or name name = match(name, "(.+)%-.+") or name
if name and healingDone > (damageDone * 2) then if name and healingDone > (damageDone * 2) then
self.Healers[name] = true self.Healers[name] = true
elseif name and self.Healers[name] then elseif name and self.Healers[name] then
@@ -712,7 +712,7 @@ end
if queryList[name] then if queryList[name] then
local frame = queryList[name] local frame = queryList[name]
if frame.UnitType then if frame.UnitType then
if frame.UnitType == "ENEMY_NPC" then if frame.UnitType == "ENEMY_NPC" then
frame.UnitType = "ENEMY_PLAYER" frame.UnitType = "ENEMY_PLAYER"
end end
@@ -223,7 +223,7 @@ local function LoadSkin()
end end
E:StripTextures(button) E:StripTextures(button)
E:StyleButton(button, false ,true) E:StyleButton(button, false, true)
_G["BrowseButton"..i.."Highlight"] = button:GetHighlightTexture() _G["BrowseButton"..i.."Highlight"] = button:GetHighlightTexture()
button:GetHighlightTexture():ClearAllPoints() button:GetHighlightTexture():ClearAllPoints()
button:GetHighlightTexture():SetPoint("TOPLEFT", icon, "TOPRIGHT", 2, 0) button:GetHighlightTexture():SetPoint("TOPLEFT", icon, "TOPRIGHT", 2, 0)
+6 -7
View File
@@ -288,7 +288,6 @@ local function ExportImport_Open(mode)
box.editBox:HighlightText() box.editBox:HighlightText()
end end
box.scrollFrame:UpdateScrollChildRect() box.scrollFrame:UpdateScrollChildRect()
print(box.scrollFrame:GetName())
end) end)
elseif mode == "import" then elseif mode == "import" then
frame:SetTitle(L["Import Profile"]) frame:SetTitle(L["Import Profile"])
@@ -416,14 +415,14 @@ 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(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
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)
elseif(server) then elseif server then
D:Distribute(name, true) D:Distribute(name, true)
end end
end end
@@ -434,14 +433,14 @@ 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(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
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)
elseif(server) then elseif server then
D:Distribute(name, true, true) D:Distribute(name, true, true)
end end
end, end,