Commit 9074c4f4 authored by Darth Predator's avatar Darth Predator

Added lib ElvUIPligin support

parent c5315537
## Interface: 50200
## Title: |cff1784d1ElvUI |r Aura Bars Mover
## Title: ElvUI: Aura Bars Mover
## Author: Darth Predator
## Version: 1.03
## Notes: Moveble unit aura bars for |cff1784d1ElvUI|r.
......@@ -10,5 +10,7 @@
## OptionalDeps: ElvUI_SLE
## DefaultState: Enabled
LibElvUIPlugin-1.0\locales\load_locales.xml
LibElvUIPlugin-1.0\LibElvUIPlugin-1.0.lua
core.lua
options.lua
\ No newline at end of file
if not ElvUI then return end
local MAJOR, MINOR = "LibElvUIPlugin-1.0", 7
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end
lib.plugins = {}
lib.index = 0
--
-- GLOBALS:
--
local E = ElvUI[1]
local L = ElvUI[2]
local _
--
-- Plugin table format:
-- { name (string) - The name of the plugin,
-- version (string) - The version of the plugin,
-- optionCallback (string) - The callback to call when ElvUI_Config is loaded
-- }
--
--
-- RegisterPlugin(name,callback)
-- Registers a module with the given name and option callback, pulls version info from metadata
--
function lib:RegisterPlugin(name,callback)
local plugin = {}
plugin.name = name
plugin.version = name == MAJOR and MINOR or GetAddOnMetadata(name, "Version")
plugin.callback = callback
lib.plugins[name] = plugin
local enabled, loadable = select(4,GetAddOnInfo("ElvUI_Config"))
if enabled and loadable then
if not lib.ConfigFrame then
local configFrame = CreateFrame("Frame")
configFrame:RegisterEvent("ADDON_LOADED")
configFrame:SetScript("OnEvent", function(self,event,addon)
if addon == "ElvUI_Config" then
for _, plugin in pairs(lib.plugins) do
if(plugin.callback) then
plugin.callback()
end
end
end
end)
lib.ConfigFrame = configFrame
end
else
-- Need to update plugins list
if name ~= MAJOR then
E.Options.args.plugins.args.plugins.name = lib:GeneratePluginList()
end
callback()
end
lib:SetupVersionCheck(plugin)
lib.index = lib.index + 1
return plugin
end
function lib:SetupVersionCheck(plugin)
local prefix = "EPVC"..lib.index
E["Send"..plugin.name.."VersionCheck"] = function()
local _, instanceType = IsInInstance()
if IsInRaid() then
SendAddonMessage(prefix, plugin.version, (not IsInRaid(LE_PARTY_CATEGORY_HOME) and IsInRaid(LE_PARTY_CATEGORY_INSTANCE)) and "INSTANCE_CHAT" or "RAID")
elseif IsInGroup() then
SendAddonMessage(prefix, plugin.version, (not IsInGroup(LE_PARTY_CATEGORY_HOME) and IsInGroup(LE_PARTY_CATEGORY_INSTANCE)) and "INSTANCE_CHAT" or "PARTY")
end
if E["Send"..plugin.name.."MSGTimer"] then
E:CancelTimer(E["Send"..plugin.name.."MSGTimer"])
E["Send"..plugin.name.."MSGTimer"] = nil
end
end
RegisterAddonMessagePrefix(prefix)
local function SendRecieve(self, event, mprefix, message, channel, sender)
if event == "CHAT_MSG_ADDON" then
if sender == E.myname or not sender or mprefix ~= prefix then return end
if not E[plugin.name.."recievedOutOfDateMessage"] then
if plugin.version ~= 'BETA' and tonumber(message) ~= nil and tonumber(message) > tonumber(plugin.version) then
plugin.old = true
plugin.newversion = tonumber(message)
E:Print(L["Your version of "] .. plugin.name .. L[" is out of date. You can download the latest version from http://www.tukui.org"])
E[plugin.name.."recievedOutOfDateMessage"] = true
end
end
else
E["Send"..plugin.name.."MSGTimer"] = E:ScheduleTimer("Send"..plugin.name.."VersionCheck", 12)
end
end
local f = CreateFrame('Frame')
f:RegisterEvent("GROUP_ROSTER_UPDATE")
f:RegisterEvent("CHAT_MSG_ADDON")
f:SetScript('OnEvent', SendRecieve)
end
function lib:GetPluginOptions()
E.Options.args.plugins = {
order = 10000,
type = "group",
name = L["Plugins"],
guiInline = false,
args = {
pluginheader = {
order = 1,
type = "header",
name = "LibElvUIPlugin-1.0."..MINOR..L[" - Plugins Loaded (Green means you have current version, Red means out of date)"],
},
plugins = {
order = 2,
type = "description",
name = lib:GeneratePluginList(),
},
}
}
end
function lib:GeneratePluginList()
list = ""
for _, plugin in pairs(lib.plugins) do
if plugin.name ~= MAJOR then
local author = GetAddOnMetadata(plugin.name, "Author")
local Pname = GetAddOnMetadata(plugin.name, "Title")
local color = plugin.old and E:RGBToHex(1,0,0) or E:RGBToHex(0,1,0)
list = list .. color .. Pname .. " " ..L["Version"].." " .. plugin.version
if author then
list = list .. " "..L["by"].." " .. author
end
if plugin.old then
list = list .. L[" (Newest: "] .. plugin.newversion .. ")"
end
list = list .. "|r\n"
end
end
return list
end
lib:RegisterPlugin(MAJOR, lib.GetPluginOptions)
\ No newline at end of file
## Interface: 50100
## LoadOnDemand: 1
## Title: Lib: LibElvUIPlugin-1.0
## Notes:
## Author: Sortokk
locales\load_locales.xml
LibStub.lua
LibElvUIPlugin-1.0.lua
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
-- English localization file for enUS and enGB.
local AceLocale = LibStub:GetLibrary("AceLocale-3.0");
local L = AceLocale:NewLocale("ElvUI", "enUS", true);
if not L then return; end
L[" - Plugins Loaded (Green means you have current version, Red means out of date)"] = true
L["Plugins"] = true
L["Your version of "] = true
L[" is out of date. You can download the latest version from http://www.tukui.org"] = true
L["by"] = true
L[" (Newest: "] = true
\ No newline at end of file
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="english.lua"/>
<Script file="russian.lua"/>
</Ui>
\ No newline at end of file
--Russian localization
local AceLocale = LibStub:GetLibrary("AceLocale-3.0")
local L = AceLocale:NewLocale("ElvUI", "ruRU")
if not L then return; end
L[" - Plugins Loaded (Green means you have current version, Red means out of date)"] = " - загруженные плагины (зеленый означает, что у вас последняя версия, красный - устаревшая)"
L["Plugins"] = "Плагины"
L["Your version of "] = "Ваша версия "
L[" is out of date. You can download the latest version from http://www.tukui.org"] = " устарела. Вы можете скачать последнюю версию на http://www.tukui.org"
L["by"] = "от"
L[" (Newest: "] = " (Последняя: "
......@@ -3,6 +3,8 @@ local ABM = E:NewModule('AuraMover', 'AceHook-3.0', 'AceEvent-3.0');
local UF = E:GetModule('UnitFrames');
local targetInsert = false
local focusInsert = false
local EP = LibStub("LibElvUIPlugin-1.0")
local addon = ...
P.unitframe.units.player.abw = E.db.unitframe.units.player.width
P.unitframe.units.target.abw = E.db.unitframe.units.target.width
......@@ -270,6 +272,7 @@ function UF:Update_FocusFrame(frame, db)
end
function ABM:Initialize()
EP:RegisterPlugin(addon,ABM.GetOptions)
ABM:PlayerABmove()
ABM:TargetABmove()
ABM:FocusABmove()
......
local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
local UF = E:GetModule('UnitFrames');
local ABM = E:GetModule('AuraMover')
local function configTable()
function ABM:GetOptions()
E.Options.args.unitframe.args.player.args.aurabar.args.width = {
order = 25,
type = "range",
......@@ -29,12 +30,3 @@ E.Options.args.unitframe.args.focus.args.aurabar.args.width = {
set = function(info, value) E.db.unitframe.units.focus.abw = value; UF:CreateAndUpdateUF('focus') end,
}
end
local ConfFrame = CreateFrame('Frame')
ConfFrame:RegisterEvent('ADDON_LOADED')
ConfFrame:SetScript('OnEvent',function(self, event, addon)
if addon == 'ElvUI_Config' then
configTable()
ConfFrame:UnregisterEvent('ADDON_LOADED')
end
end)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment