mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update
This commit is contained in:
+89
-8
@@ -1,12 +1,36 @@
|
||||
ElvUI = {}
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local pairs, unpack = pairs, unpack
|
||||
local getn, wipe = table.getn, wipe
|
||||
local format, strsplit = string.format, string.split
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local GetAddOnInfo = GetAddOnInfo
|
||||
local GetAddOnMetadata = GetAddOnMetadata
|
||||
local HideUIPanel = HideUIPanel
|
||||
local IsAddOnLoaded = IsAddOnLoaded
|
||||
local LoadAddOn = LoadAddOn
|
||||
local ReloadUI = ReloadUI
|
||||
local GameMenuFrame = GameMenuFrame
|
||||
local GameMenuButtonLogout = GameMenuButtonLogout
|
||||
|
||||
BINDING_HEADER_ELVUI = GetAddOnMetadata("ElvUI", "Title")
|
||||
|
||||
local AddOnName, Engine = "ElvUI", {}
|
||||
local AddOnName, Engine = "ElvUI", ElvUI
|
||||
local AddOn = LibStub("AceAddon-3.0"):NewAddon(AddOnName, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0")
|
||||
AddOn.callbacks = AddOn.callbacks or
|
||||
LibStub("CallbackHandler-1.0"):New(AddOn)
|
||||
AddOn.DF = {} AddOn.DF["profile"] = {} AddOn.DF["global"] = {} AddOn.privateVars = {} AddOn.privateVars["profile"] = {} -- Defaults
|
||||
|
||||
AddOn.callbacks = AddOn.callbacks or LibStub("CallbackHandler-1.0"):New(AddOn)
|
||||
|
||||
-- Defaults
|
||||
AddOn.DF = {}
|
||||
AddOn.DF["profile"] = {}
|
||||
AddOn.DF["global"] = {}
|
||||
AddOn.privateVars = {}
|
||||
AddOn.privateVars["profile"] = {}
|
||||
|
||||
AddOn.Options = {
|
||||
type = "group",
|
||||
name = AddOnName,
|
||||
@@ -27,6 +51,10 @@ function AddOn:OnInitialize()
|
||||
ElvCharacterDB = {}
|
||||
end
|
||||
|
||||
ElvCharacterData = nil --Depreciated
|
||||
ElvPrivateData = nil --Depreciated
|
||||
ElvData = nil --Depreciated
|
||||
|
||||
self.db = tcopy(self.DF.profile, true)
|
||||
self.global = tcopy(self.DF.global, true)
|
||||
if ElvDB then
|
||||
@@ -77,7 +105,7 @@ function AddOn:OnInitialize()
|
||||
GameMenuButton:SetWidth(GameMenuButtonLogout:GetWidth())
|
||||
GameMenuButton:SetHeight(GameMenuButtonLogout:GetHeight())
|
||||
|
||||
GameMenuButton:SetText(self:ColorizedName(AddOnName))
|
||||
GameMenuButton:SetText(self.title)
|
||||
GameMenuButton:SetScript("OnClick", function()
|
||||
AddOn:ToggleConfig()
|
||||
HideUIPanel(GameMenuFrame)
|
||||
@@ -86,7 +114,7 @@ function AddOn:OnInitialize()
|
||||
|
||||
HookScript(GameMenuFrame, "OnShow", function()
|
||||
if not GameMenuFrame.isElvUI then
|
||||
GameMenuFrame:SetHeight(GameMenuFrame:GetHeight() + GameMenuButtonLogout:GetHeight() + 1)
|
||||
GameMenuFrame:SetHeight(GameMenuFrame:GetHeight() + GameMenuButtonLogout:GetHeight() + 17)
|
||||
GameMenuFrame.isElvUI = true
|
||||
end
|
||||
local _, relTo = GameMenuButtonLogout:GetPoint()
|
||||
@@ -123,7 +151,14 @@ function AddOn:ToggleConfig()
|
||||
if not IsAddOnLoaded("ElvUI_Config") then
|
||||
local _, _, _, _, _, reason = GetAddOnInfo("ElvUI_Config")
|
||||
if reason ~= "MISSING" and reason ~= "DISABLED" then
|
||||
self.GUIFrame = false
|
||||
LoadAddOn("ElvUI_Config")
|
||||
--For some reason, GetAddOnInfo reason is "DEMAND_LOADED" even if the addon is disabled.
|
||||
--Workaround: Try to load addon and check if it is loaded right after.
|
||||
if not IsAddOnLoaded("ElvUI_Config") then
|
||||
self:Print("|cffff0000Error -- Addon 'ElvUI_Config' not found or is disabled.|r")
|
||||
return
|
||||
end
|
||||
if GetAddOnMetadata("ElvUI_Config", "Version") ~= "1.01" then
|
||||
self:StaticPopup_Show("CLIENT_UPDATE_REQUEST")
|
||||
end
|
||||
@@ -134,10 +169,56 @@ function AddOn:ToggleConfig()
|
||||
end
|
||||
|
||||
local ACD = LibStub("AceConfigDialog-3.0")
|
||||
local ConfigOpen = ACD.OpenFrames[AddOnName]
|
||||
|
||||
local pages, msgStr
|
||||
if msg and msg ~= "" then
|
||||
pages = {strsplit(",", msg)}
|
||||
msgStr = gsub(msg, ",","\001")
|
||||
end
|
||||
|
||||
local mode = "Close"
|
||||
if not ACD.OpenFrames[AddOnName] then
|
||||
mode = "Open"
|
||||
if not ConfigOpen or (pages ~= nil) then
|
||||
if pages ~= nil then
|
||||
local pageCount, index, mainSel = getn(pages)
|
||||
if pageCount > 1 then
|
||||
wipe(pageNodes)
|
||||
index = 0
|
||||
|
||||
local main, mainNode, mainSelStr, sub, subNode, subSel
|
||||
for i = 1, pageCount do
|
||||
if i == 1 then
|
||||
main = pages[i] and ACD.Status and ACD.Status.ElvUI
|
||||
mainSel = main and main.status and main.status.groups and main.status.groups.selected
|
||||
mainSelStr = mainSel and (gsub("^"..mainSel, "([%(%)%.%%%+%-%*%?%[%^%$])","%%%1").."\001")
|
||||
mainNode = main and main.children and main.children[pages[i]]
|
||||
pageNodes[index + 1], pageNodes[index + 2] = main, mainNode
|
||||
else
|
||||
sub = pages[i] and pageNodes[i] and ((i == pageCount and pageNodes[i]) or pageNodes[i].children[pages[i]])
|
||||
subSel = sub and sub.status and sub.status.groups and sub.status.groups.selected
|
||||
subNode = (mainSelStr and match(msgStr, gsub(mainSelStr..pages[i], "([%(%)%.%%%+%-%*%?%[%^%$])","%%%1").."$") and (subSel and subSel == pages[i])) or ((i == pageCount and not subSel) and mainSel and mainSel == msgStr)
|
||||
pageNodes[index + 1], pageNodes[index + 2] = sub, subNode
|
||||
end
|
||||
index = index + 2
|
||||
end
|
||||
else
|
||||
local main = pages[1] and ACD.Status and ACD.Status.ElvUI
|
||||
mainSel = main and main.status and main.status.groups and main.status.groups.selected
|
||||
end
|
||||
|
||||
if ConfigOpen and ((not index and mainSel and mainSel == msg) or (index and pageNodes and pageNodes[index])) then
|
||||
mode = "Close"
|
||||
else
|
||||
mode = "Open"
|
||||
end
|
||||
else
|
||||
mode = "Open"
|
||||
end
|
||||
end
|
||||
ACD[mode](ACD, AddOnName)
|
||||
|
||||
if pages and (mode == "Open") then
|
||||
ACD:SelectGroup(AddOnName, unpack(pages))
|
||||
end
|
||||
|
||||
if mode == "Open" then
|
||||
|
||||
Reference in New Issue
Block a user