This commit is contained in:
Crum
2018-01-08 20:56:48 -06:00
parent 1914e744af
commit badcd649e9
4 changed files with 113 additions and 95 deletions
+2 -2
View File
@@ -728,7 +728,7 @@ local function SetPage(PageNum)
InstallOption3Button:SetText(CLASS) InstallOption3Button:SetText(CLASS)
elseif PageNum == 5 then elseif PageNum == 5 then
f.SubTitle:SetText(L["Resolution"]) f.SubTitle:SetText(L["Resolution"])
f.Desc1:SetText(L["Your current resolution is %s, this is considered a %s resolution."], E.resolution, E.lowversion == true and L["low"] or L["high"]) f.Desc1:SetText(format(L["Your current resolution is %s, this is considered a %s resolution."], E.resolution, E.lowversion == true and L["low"] or L["high"]))
if E.lowversion then if E.lowversion then
f.Desc2:SetText(L["This resolution requires that you change some settings to get everything to fit on your screen."].." "..L["Click the button below to resize your chat frames, unitframes, and reposition your actionbars."].." "..L["You may need to further alter these settings depending how low you resolution is."]) f.Desc2:SetText(L["This resolution requires that you change some settings to get everything to fit on your screen."].." "..L["Click the button below to resize your chat frames, unitframes, and reposition your actionbars."].." "..L["You may need to further alter these settings depending how low you resolution is."])
f.Desc3:SetText(L["Importance: |cff07D400High|r"]) f.Desc3:SetText(L["Importance: |cff07D400High|r"])
@@ -773,7 +773,7 @@ local function SetPage(PageNum)
InstallOption2Button:SetText(L["Icons Only"]) InstallOption2Button:SetText(L["Icons Only"])
elseif PageNum == 8 then elseif PageNum == 8 then
f.SubTitle:SetText(L["Installation Complete"]) f.SubTitle:SetText(L["Installation Complete"])
f.Desc1:SetText(L["You are now finished with the installation process. If you are in need of technical support please visit us at https://github.com/ElvUI-TBC/ElvUI"]) f.Desc1:SetText(L["You are now finished with the installation process. If you are in need of technical support please visit us at https://github.com/ElvUI-Vanilla/ElvUI"])
f.Desc2:SetText(L["Please click the button below so you can setup variables and ReloadUI."]) f.Desc2:SetText(L["Please click the button below so you can setup variables and ReloadUI."])
InstallOption1Button:Show() InstallOption1Button:Show()
InstallOption1Button:SetScript("OnClick", InstallComplete) InstallOption1Button:SetScript("OnClick", InstallComplete)
@@ -10,7 +10,6 @@ local modf = math.modf
local sub = string.sub local sub = string.sub
local format = string.format local format = string.format
local getn = table.getn local getn = table.getn
local gsub = string.gsub
local strlen = string.len local strlen = string.len
local byte = string.byte local byte = string.byte
@@ -20,21 +19,21 @@ if not LibBase64 then
return return
end end
local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" local _chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
local charTable = {} local charTable = {}
local byteToNum = {} local byteToNum = {}
local numToChar = {} local numToChar = {}
for i = 1, strlen(chars) do for i = 1, strlen(_chars) do
charTable[i] = sub(chars, i, i) charTable[i] = sub(_chars, i, i)
end end
for i = 1, getn(charTable) do for i = 1, getn(charTable) do
numToChar[i - 1] = sub(chars, i, i) numToChar[i - 1] = sub(_chars, i, i)
byteToNum[byte(chars, i)] = i - 1 byteToNum[byte(_chars, i)] = i - 1
end end
charTable = nil _chars = nil
local A_byte = byte("A") local A_byte = byte("A")
local Z_byte = byte("Z") local Z_byte = byte("Z")
@@ -107,17 +106,17 @@ function LibBase64:Encode(text, maxLineLength, lineEnding)
local a = modf(num, 2^6) local a = modf(num, 2^6)
t[getn(t+1)] = numToChar[a] t[getn(t)+1] = numToChar[a]
t[getn(t+1)] = numToChar[b] t[getn(t)+1] = numToChar[b]
t[getn(t+1)] = (nilNum >= 2) and "=" or numToChar[c] t[getn(t)+1] = (nilNum >= 2) and "=" or numToChar[c]
t[getn(t+1)] = (nilNum >= 1) and "=" or numToChar[d] t[getn(t)+1] = (nilNum >= 1) and "=" or numToChar[d]
currentLength = currentLength + 4 currentLength = currentLength + 4
if maxLineLength and modf(currentLength, maxLineLength) == 0 then if maxLineLength and modf(currentLength, maxLineLength) == 0 then
t[getn(t+1)] = lineEnding t[getn(t)+1] = lineEnding
end end
end end
@@ -154,7 +153,7 @@ function LibBase64:Decode(text)
error(format("Bad argument #1 to `Decode'. Received an invalid char: %q", sub(text, i, i)), 2) error(format("Bad argument #1 to `Decode'. Received an invalid char: %q", sub(text, i, i)), 2)
end end
t2[getn(t2+1)] = num t2[getn(t2)+1] = num
end end
end end
@@ -181,12 +180,12 @@ function LibBase64:Decode(text)
local a = modf(num, 2^8) local a = modf(num, 2^8)
t[getn(t+1)] = string.char(a) t[getn(t)+1] = string.char(a)
if nilNum < 2 then if nilNum < 2 then
t[getn(t+1)] = string.char(b) t[getn(t)+1] = string.char(b)
end end
if nilNum < 1 then if nilNum < 1 then
t[getn(t+1)] = string.char(c) t[getn(t)+1] = string.char(c)
end end
end end
@@ -208,7 +207,7 @@ function LibBase64:IsBase64(text)
error(format("Bad argument #1 to `IsBase64'. Expected %q, got %q", "string", type(text)), 2) error(format("Bad argument #1 to `IsBase64'. Expected %q, got %q", "string", type(text)), 2)
end end
if modf(strlen(text), 4 ~= 0) then if modf(strlen(text), 4) ~= 0 then
return false return false
end end
@@ -1,16 +1,17 @@
local MAJOR, MINOR = "LibElvUIPlugin-1.0", 13 local MAJOR, MINOR = "LibElvUIPlugin-1.0", 18
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end if not lib then return end
--Cache global variables --Cache global variables
--Lua functions --Lua functions
local pairs, tonumber = pairs, tonumber local pairs, tonumber = pairs, tonumber
local format, strsplit = format, strsplit local format, gsub, strmatch, strsplit = format, gsub, strmatch, strsplit
--WoW API / Variables --WoW API / Variables
local CreateFrame = CreateFrame; local CreateFrame = CreateFrame
local GetNumPartyMembers, GetNumRaidMembers = GetNumPartyMembers, GetNumRaidMembers
local GetAddOnMetadata = GetAddOnMetadata local GetAddOnMetadata = GetAddOnMetadata
local GetNumPartyMembers, GetNumRaidMembers = GetNumPartyMembers, GetNumRaidMembers
local IsAddOnLoaded = IsAddOnLoaded local IsAddOnLoaded = IsAddOnLoaded
local IsInInstance = IsInInstance
local SendAddonMessage = SendAddonMessage local SendAddonMessage = SendAddonMessage
--Global variables that we don't cache, list them here for the mikk's Find Globals script --Global variables that we don't cache, list them here for the mikk's Find Globals script
@@ -21,18 +22,18 @@ lib.index = 0
lib.prefix = "ElvUIPluginVC" lib.prefix = "ElvUIPluginVC"
-- MULTI Language Support (Default Language: English) -- MULTI Language Support (Default Language: English)
local MSG_OUTDATED = "Your version of %s is out of date (latest is version %s). You can download the latest version from https://github.com/ElvUI-Vanilla/ElvUI/" local MSG_OUTDATED = "Your version of %s %s is out of date (latest is version %s). You can download the latest version from https://github.com/ElvUI-Vanilla/ElvUI/"
local HDR_CONFIG = "Plugins" local HDR_CONFIG = "Plugins"
local HDR_INFORMATION = "LibElvUIPlugin-1.0.%d - Plugins Loaded (|cff2BC226Green|r means you have current version, |cffFF0000Red|r means out of date)" local HDR_INFORMATION = "LibElvUIPlugin-1.0.%d - Plugins Loaded (Green means you have current version, Red means out of date)"
local INFO_BY = "by" local INFO_BY = "by"
local INFO_VERSION = "Version:" local INFO_VERSION = "Version:"
local INFO_NEW = "Newest:" local INFO_NEW = "Newest:"
local LIBRARY = "Library" local LIBRARY = "Library"
if GetLocale() == "deDE" then -- German Translation if GetLocale() == "deDE" then -- German Translation
MSG_OUTDATED = "Deine Version von %s ist veraltet (akutelle Version ist %s). Du kannst die aktuelle Version von https://github.com/ElvUI-Vanilla/ElvUI/ herunterrladen." MSG_OUTDATED = "Deine Version von %s %s ist veraltet (akutelle Version ist %s). Du kannst die aktuelle Version von https://github.com/ElvUI-Vanilla/ElvUI/ herunterrladen."
HDR_CONFIG = "Plugins" HDR_CONFIG = "Plugins"
HDR_INFORMATION = "LibElvUIPlugin-1.0.%d - Plugins geladen (|cff2BC226Grün|r bedeutet du hast die aktuelle Version, |cffFF0000Rot|r bedeutet es ist veraltet)" HDR_INFORMATION = "LibElvUIPlugin-1.0.%d - Plugins geladen (Grün bedeutet du hast die aktuelle Version, Rot bedeutet es ist veraltet)"
INFO_BY = "von" INFO_BY = "von"
INFO_VERSION = "Version:" INFO_VERSION = "Version:"
INFO_NEW = "Neuste:" INFO_NEW = "Neuste:"
@@ -40,9 +41,9 @@ if GetLocale() == "deDE" then -- German Translation
end end
if GetLocale() == "ruRU" then -- Russian Translations if GetLocale() == "ruRU" then -- Russian Translations
MSG_OUTDATED = "Ваша версия %s устарела (последняя версия %s). Вы можете скачать последнюю версию на https://github.com/ElvUI-Vanilla/ElvUI/" MSG_OUTDATED = "Ваша версия %s %s устарела (последняя версия %s). Вы можете скачать последнюю версию на https://github.com/ElvUI-Vanilla/ElvUI/"
HDR_CONFIG = "Плагины" HDR_CONFIG = "Плагины"
HDR_INFORMATION = "LibElvUIPlugin-1.0.%d - Загруженные плагины (|cff2BC226Зеленый|r означает, что у вас последняя версия, |cffFF0000Красный|r - устаревшая)" HDR_INFORMATION = "LibElvUIPlugin-1.0.%d - загруженные плагины (зеленый означает, что у вас последняя версия, красный - устаревшая)"
INFO_BY = "от" INFO_BY = "от"
INFO_VERSION = "Версия:" INFO_VERSION = "Версия:"
INFO_NEW = "Последняя:" INFO_NEW = "Последняя:"
@@ -72,11 +73,11 @@ function lib:RegisterPlugin(name,callback, isLib)
local loaded = IsAddOnLoaded("ElvUI_Config") local loaded = IsAddOnLoaded("ElvUI_Config")
if not lib.vcframe then if not lib.vcframe then
local f = CreateFrame('Frame') local f = CreateFrame("Frame")
--f:RegisterEvent("RAID_ROSTER_UPDATE"); f:RegisterEvent("RAID_ROSTER_UPDATE")
--f:RegisterEvent("PARTY_MEMBERS_CHANGED"); f:RegisterEvent("PARTY_MEMBERS_CHANGED")
--f:RegisterEvent("CHAT_MSG_ADDON") f:RegisterEvent("CHAT_MSG_ADDON")
--f:SetScript("OnEvent", lib.VersionCheck) f:SetScript("OnEvent", lib.VersionCheck)
lib.vcframe = f lib.vcframe = f
end end
@@ -84,11 +85,11 @@ function lib:RegisterPlugin(name,callback, isLib)
if not lib.ConfigFrame then if not lib.ConfigFrame then
local configFrame = CreateFrame("Frame") local configFrame = CreateFrame("Frame")
configFrame:RegisterEvent("ADDON_LOADED") configFrame:RegisterEvent("ADDON_LOADED")
configFrame:SetScript("OnEvent", function(self,event,addon) configFrame:SetScript("OnEvent", function(self, event, addon)
if addon == "ElvUI_Config" then if addon == "ElvUI_Config" then
for _, plugin in pairs(lib.plugins) do for _, PlugIn in pairs(lib.plugins) do
if(plugin.callback) then if PlugIn.callback then
plugin.callback() PlugIn.callback()
end end
end end
end end
@@ -147,79 +148,96 @@ local function SendPluginVersionCheck(self)
end end
function lib:VersionCheck(event, prefix, message, channel, sender) function lib:VersionCheck(event, prefix, message, channel, sender)
if(not ElvUI[1].global.general.versionCheck) then return; end if not ElvUI[1].global.general.versionCheck then return end
local E = ElvUI[1] local E = ElvUI[1]
if event == "CHAT_MSG_ADDON" then if event == "CHAT_MSG_ADDON" then
if sender == E.myname or not sender or prefix ~= lib.prefix then return end if not (prefix == lib.prefix and sender and message and not strmatch(message, "^%s-$")) then return end
if sender == E.myname then return end
if not E["pluginRecievedOutOfDateMessage"] then if not E["pluginRecievedOutOfDateMessage"] then
local name, version, plugin, Pname
for _, p in pairs({strsplit(";",message)}) do for _, p in pairs({strsplit(";",message)}) do
local name, version = p:match("([%w_]+)=([%d%p]+)") if not strmatch(p, "^%s-$") then
if lib.plugins[name] then name, version = strmatch(p, "([%w_]+)=([%d%p]+)")
local plugin = lib.plugins[name] if lib.plugins[name] then
if plugin.version ~= "BETA" and version ~= nil and tonumber(version) ~= nil and plugin.version ~= nil and tonumber(plugin.version) ~= nil and tonumber(version) > tonumber(plugin.version) then plugin = lib.plugins[name]
plugin.old = true if plugin.version ~= "BETA" and version and tonumber(version) and plugin.version and tonumber(plugin.version) and tonumber(version) > tonumber(plugin.version) then
plugin.newversion = tonumber(version) plugin.old = true
local Pname = GetAddOnMetadata(plugin.name, "Title") plugin.newversion = tonumber(version)
E:Print(format(MSG_OUTDATED,Pname,plugin.newversion)) Pname = GetAddOnMetadata(plugin.name, "Title")
E["pluginRecievedOutOfDateMessage"] = true E:Print(format(MSG_OUTDATED, Pname, plugin.version, plugin.newversion))
E["pluginRecievedOutOfDateMessage"] = true
end
end end
end end
end end
end end
else else
E.SendPluginVersionCheck = E.SendPluginVersionCheck or SendPluginVersionCheck if not E.SendPluginVersionCheck then
E["ElvUIPluginSendMSGTimer"] = E:ScheduleTimer("SendPluginVersionCheck", 2) E.SendPluginVersionCheck = SendPluginVersionCheck
end
local numRaid, numParty = GetNumRaidMembers(), GetNumPartyMembers() + 1
local num = numRaid > 0 and numRaid or numParty
if num ~= lib.groupSize then
if num > 1 and ((lib.groupSize and num > lib.groupSize) or not lib.groupSize) then
E["ElvUIPluginSendMSGTimer"] = E:ScheduleTimer("SendPluginVersionCheck", 12)
end
lib.groupSize = num
end
end end
end end
function lib:GeneratePluginList() function lib:GeneratePluginList()
local list = "" local list, E = "", ElvUI[1]
local E = ElvUI[1] local author, Pname, color
for _, plugin in pairs(lib.plugins) do for _, plugin in pairs(lib.plugins) do
if plugin.name ~= MAJOR then if plugin.name ~= MAJOR then
local author = GetAddOnMetadata(plugin.name, "Author") author = GetAddOnMetadata(plugin.name, "Author")
local Pname = GetAddOnMetadata(plugin.name, "Title") or plugin.name Pname = GetAddOnMetadata(plugin.name, "Title") or plugin.name
local color = plugin.old and E:RGBToHex(1,0,0) or E:RGBToHex(0,1,0) color = plugin.old and E:RGBToHex(1,0,0) or E:RGBToHex(0,1,0)
list = list..Pname list = list .. Pname
if author then if author then
list = list.." ".. INFO_BY .." "..author list = list .. " ".. INFO_BY .." " .. author
end end
list = list..color.." - "..(plugin.isLib and LIBRARY or INFO_VERSION .." "..plugin.version) list = list .. color .. (plugin.isLib and " " .. LIBRARY or " - " .. INFO_VERSION .. " " .. plugin.version)
if plugin.old then if plugin.old then
list = list.." ("..INFO_NEW .." "..plugin.newversion..")" list = list .. " (" .. INFO_NEW .." " .. plugin.newversion .. ")"
end end
list = list.."|r\n" list = list .. "|r\n"
end end
end end
return list return list
end end
function lib:SendPluginVersionCheck(message) function lib:SendPluginVersionCheck(message)
local plist = {strsplit(";",message)} if (not message) or strmatch(message, "^%s-$") then return end
local m = ""
local delay = 1 local ChatType
local E = ElvUI[1] if GetNumRaidMembers() > 1 then
for _, p in pairs(plist) do local _, instanceType = IsInInstance()
if(getn(m..p..";") < 230) then ChatType = instanceType == "pvp" and "BATTLEGROUND" or "RAID"
m = m..p..";" elseif GetNumPartyMembers() > 0 then
else ChatType = "PARTY"
local numParty, numRaid = GetNumPartyMembers(), GetNumRaidMembers();
if(numRaid > 0) then
E:Delay(delay, SendAddonMessage(lib.prefix, m, "RAID"))
elseif(numParty > 0) then
E:Delay(delay, SendAddonMessage(lib.prefix, m, "PARTY"))
end
m = p..";"
delay = delay + 1
end
end end
-- Send the last message if not ChatType then return end
local numParty, numRaid = GetNumPartyMembers(), GetNumRaidMembers();
if(numRaid > 0) then local maxChar, msgLength = 254 - strlen(lib.prefix), strlen(message)
E:Delay(delay+1, SendAddonMessage(lib.prefix, m, "RAID")) if msgLength > maxChar then
elseif(numParty > 0) then local delay, splitMessage = 0
E:Delay(delay+1, SendAddonMessage(lib.prefix, m, "PARTY"))
for _ = 1, ceil(msgLength/maxChar) do
splitMessage = strmatch(strsub(message, 1, maxChar), ".+;")
if splitMessage then -- incase the string is over `maxChar` but doesnt contain `;`
message = gsub(message, "^"..gsub(splitMessage, '([%-%.%+%[%]%(%)%$%^%%%?%*])','%%%1'), "")
ElvUI[1]:Delay(delay, SendAddonMessage, lib.prefix, splitMessage, ChatType)
delay = delay + 1
end
end
else
SendAddonMessage(lib.prefix, message, ChatType)
end end
end end
+12 -11
View File
@@ -238,7 +238,7 @@ local function ExportImport_Open(mode)
label2:SetWidth(800) label2:SetWidth(800)
frame:AddChild(label2) frame:AddChild(label2)
if(mode == "export") then if mode == "export" then
frame:SetTitle(L["Export Profile"]) frame:SetTitle(L["Export Profile"])
local profileTypeDropdown = AceGUI:Create("Dropdown") local profileTypeDropdown = AceGUI:Create("Dropdown")
@@ -265,7 +265,7 @@ local function ExportImport_Open(mode)
local profileType, exportFormat = profileTypeDropdown:GetValue(), exportFormatDropdown:GetValue() local profileType, exportFormat = profileTypeDropdown:GetValue(), exportFormatDropdown:GetValue()
local profileKey, profileExport = D:ExportProfile(profileType, exportFormat) local profileKey, profileExport = D:ExportProfile(profileType, exportFormat)
if(not profileKey or not profileExport) then if not profileKey or not profileExport then
label1:SetText(L["Error exporting profile!"]) label1:SetText(L["Error exporting profile!"])
else else
label1:SetText(format("%s: %s%s|r", L["Exported"], E.media.hexvaluecolor, profileTypeItems[profileType])) label1:SetText(format("%s: %s%s|r", L["Exported"], E.media.hexvaluecolor, profileTypeItems[profileType]))
@@ -288,8 +288,9 @@ 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"])
local importButton = AceGUI:Create("Button") local importButton = AceGUI:Create("Button")
importButton:SetDisabled(true) importButton:SetDisabled(true)
@@ -301,7 +302,7 @@ local function ExportImport_Open(mode)
local text local text
local success = D:ImportProfile(box:GetText()) local success = D:ImportProfile(box:GetText())
if(success) then if success then
text = L["Profile imported successfully!"] text = L["Profile imported successfully!"]
else else
text = L["Error decoding data. Import string may be corrupted!"] text = L["Error decoding data. Import string may be corrupted!"]
@@ -319,7 +320,7 @@ local function ExportImport_Open(mode)
label2:SetText(" ") label2:SetText(" ")
local decodedText local decodedText
local profileType, profileKey, profileData = D:Decode(box:GetText()) local profileType, profileKey, profileData = D:Decode(box:GetText())
if(profileData) then if profileData then
decodedText = E:TableToLuaString(profileData) decodedText = E:TableToLuaString(profileData)
end end
local importText = D:CreateProfileExport(decodedText, profileType, profileKey) local importText = D:CreateProfileExport(decodedText, profileType, profileKey)
@@ -330,14 +331,14 @@ local function ExportImport_Open(mode)
local oldText = "" local oldText = ""
local function OnTextChanged() local function OnTextChanged()
local text = box:GetText() local text = box:GetText()
if(text == "") then if text == "" then
label1:SetText(" ") label1:SetText(" ")
label2:SetText(" ") label2:SetText(" ")
importButton:SetDisabled(true) importButton:SetDisabled(true)
decodeButton:SetDisabled(true) decodeButton:SetDisabled(true)
elseif(oldText ~= text) then elseif oldText ~= text then
local stringType = D:GetImportStringType(text) local stringType = D:GetImportStringType(text)
if(stringType == "Base64") then if stringType == "Base64" then
decodeButton:SetDisabled(false) decodeButton:SetDisabled(false)
else else
decodeButton:SetDisabled(true) decodeButton:SetDisabled(true)
@@ -351,7 +352,7 @@ local function ExportImport_Open(mode)
decodeButton:SetDisabled(true) decodeButton:SetDisabled(true)
else else
label1:SetText(format("%s: %s%s|r", L["Importing"], E.media.hexvaluecolor, profileTypeItems[profileType] or "")) label1:SetText(format("%s: %s%s|r", L["Importing"], E.media.hexvaluecolor, profileTypeItems[profileType] or ""))
if(profileType == "profile") then if profileType == "profile" then
label2:SetText(format("%s: %s%s|r", L["Profile Name"], E.media.hexvaluecolor, profileKey)) label2:SetText(format("%s: %s%s|r", L["Profile Name"], E.media.hexvaluecolor, profileKey))
end end
importButton:SetDisabled(false) importButton:SetDisabled(false)
@@ -391,10 +392,10 @@ local function ExportImport_Open(mode)
end end
E.Options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(E.data) E.Options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(E.data)
AC.RegisterOptionsTable(P, "ElvProfiles", E.Options.args.profiles) AC.RegisterOptionsTable(E, "ElvProfiles", E.Options.args.profiles)
E.Options.args.profiles.order = -10 E.Options.args.profiles.order = -10
if(not E.Options.args.profiles.plugins) then if not E.Options.args.profiles.plugins then
E.Options.args.profiles.plugins = {} E.Options.args.profiles.plugins = {}
end end