remove temp folder structure

This commit is contained in:
Crum
2018-02-19 21:03:21 -06:00
parent 85a2a5bcf7
commit 611f11aff9
408 changed files with 0 additions and 0 deletions
+463
View File
@@ -0,0 +1,463 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local CC = E:NewModule("ClassCache", "AceEvent-3.0");
local LW = LibStub:GetLibrary("LibWho-2.0");
--Cache global variables
--Lua functions
local split, upper = string.split, string.upper
local wipe = table.wipe
local pairs = pairs
local select = select
--WoW API / Variables
local GetBattlefieldScore = GetBattlefieldScore
local GetFriendInfo = GetFriendInfo
local GetGuildRosterInfo = GetGuildRosterInfo
local GetNumBattlefieldScores = GetNumBattlefieldScores
local GetNumFriends = GetNumFriends
local GetNumGuildMembers = GetNumGuildMembers
local GetNumPartyMembers = GetNumPartyMembers
local GetNumRaidMembers = GetNumRaidMembers
local GetTime = GetTime
local IsInGuild = IsInGuild
local UnitClass = UnitClass
local UnitExists = UnitExists
local UnitIsPlayer = UnitIsPlayer
local UnitName = UnitName
local UNKNOWN = UNKNOWN
local GAME_LOCALE = GetLocale()
local ENGLISH_CLASS_NAMES
local function GetEnglishClassName(class)
if class == UNKNOWN then
return class
elseif GAME_LOCALE == "enUS" then
return upper(class)
end
if not ENGLISH_CLASS_NAMES then
ENGLISH_CLASS_NAMES = {}
for english, localized in pairs(LOCALIZED_CLASS_NAMES_MALE) do
ENGLISH_CLASS_NAMES[localized] = english
end
for english, localized in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do
ENGLISH_CLASS_NAMES[localized] = english
end
end
return ENGLISH_CLASS_NAMES[class]
end
local function WhoCallback(result)
if result then
if result.NoLocaleClass then
CC:CachePlayer(result.Name, result.NoLocaleClass)
CC:SendMessage("ClassCacheQueryResult", result.Name, result.NoLocaleClass)
end
end
end
function CC:GetClassByName(name, realm)
if not name or name == "" then return end
if realm and realm == "" then return end
if E.db.general.classCacheStoreInDB then
if realm then
if self.cache[realm] and self.cache[realm][name] then
return self.cache[realm][name]
else
return
end
else
if self.cache[E.myrealm][name] then
return self.cache[E.myrealm][name]
end
end
else
if realm then
if self.tempCache[realm] and self.tempCache[realm][name] then
return self.tempCache[realm][name]
else
return
end
else
if self.tempCache[E.myrealm][name] then
return self.tempCache[E.myrealm][name]
end
end
end
if E.db.general.classCacheRequestInfo then
local result = LW:UserInfo(name, {
queue = LW.WHOLIB_QUEUE_QUIET,
timeout = 0,
callback = function(result)
WhoCallback(result)
end
})
if result and result.NoLocaleClass then
self:CachePlayer(result.Name, result.NoLocaleClass)
return result.NoLocaleClass
end
end
end
function CC:CachePlayer(name, class, realm)
if not (name and class and class ~= UNKNOWN) then return end
if realm and realm == "" then return end
if E.db.general.classCacheStoreInDB then
if realm and not self.cache[realm] then
self.cache[realm] = {}
end
if realm then
self.cache[realm][name] = class
else
self.cache[E.myrealm][name] = class
end
else
if realm and not self.tempCache[realm] then
self.tempCache[realm] = {}
end
if realm then
self.tempCache[realm][name] = class
else
self.tempCache[E.myrealm][name] = class
end
end
end
function CC:SwitchCacheType(init)
if E.db.general.classCacheStoreInDB then
if not self.cache[E.myrealm] then
self.cache[E.myrealm] = {}
end
if not self.cache[E.myrealm][E.myname] then
self.cache[E.myrealm][E.myname] = E.myclass
end
if not init then
for realm in pairs(self.tempCache) do
if not self.cache[realm] then
self.cache[realm] = {}
end
for name, class in pairs(self.tempCache[realm]) do
self.cache[realm][name] = class
end
end
end
else
if not self.tempCache[E.myrealm] then
self.tempCache[E.myrealm] = {}
end
if not self.tempCache[E.myrealm][E.myname] then
self.tempCache[E.myrealm][E.myname] = E.myclass
end
if not init then
for realm in pairs(self.cache) do
if not self.cache[realm] then
self.tempCache[realm] = {}
end
for name, class in pairs(self.cache[realm]) do
self.tempCache[realm][name] = class
end
end
end
end
end
function CC:GetCacheTable()
if E.db.general.classCacheStoreInDB then
return self.cache
else
return self.tempCache
end
end
function CC:GetCacheSize(global)
if global and not (self.cacheDBCalculationTime + 30 < GetTime()) then
return self.cacheDBSize > 1, self.cacheDBSize
elseif not global and not (self.cacheLocalCalculationTime + 30 < GetTime()) then
return self.cacheLocalSize > 1, self.cacheLocalSize
end
local size = 0
if global then
for realm in pairs(self.cache) do
for name in pairs(self.cache[realm]) do
size = size + 1
end
end
self.cacheDBSize = size
self.cacheDBCalculationTime = GetTime()
else
for realm in pairs(self.tempCache) do
for name in pairs(self.tempCache[realm]) do
size = size + 1
end
end
self.cacheLocalSize = size
self.cacheLocalCalculationTime = GetTime()
end
return size > 1, size
end
function CC:WipeCache(global)
if global then
for realm in pairs(self.cache) do
wipe(realm)
end
wipe(self.cache)
self:SwitchCacheType(true)
self.cacheDBCalculationTime = 0
E:Print(L["Class DB cache wiped."])
else
for realm in pairs(self.tempCache) do
wipe(realm)
end
wipe(self.tempCache)
self:SwitchCacheType(true)
self.cacheLocalCalculationTime = 0
E:Print(L["Class session cache wiped."])
end
end
function CC:PLAYER_ENTERING_WORLD()
local inInstance, instanceType = IsInInstance()
self.inInstance = inInstance
if instanceType == "arena" or instanceType == "pvp" then
self.inBattleground = true
else
self.inBattleground = false
end
if self.inInstance or self.inBattleground then
self.lastNumPlayers = 0
self:UnregisterEvent("PLAYER_TARGET_CHANGED")
self:UnregisterEvent("UPDATE_MOUSEOVER_UNIT")
self:UnregisterEvent("PARTY_MEMBERS_CHANGED")
self:UnregisterEvent("RAID_ROSTER_UPDATE")
self:RegisterEvent("UPDATE_BATTLEFIELD_SCORE")
if self.inBattleground then
self:UPDATE_BATTLEFIELD_SCORE()
end
else
self.lastNumPlayers = 0
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")
self:UnregisterEvent("UPDATE_BATTLEFIELD_SCORE")
end
self:PLAYER_GUILD_UPDATE()
if not self.initUpdate then
if GetNumRaidMembers() > 0 then
self:RAID_ROSTER_UPDATE()
elseif GetNumPartyMembers() > 0 then
self:PARTY_MEMBERS_CHANGED()
end
self:GUILD_ROSTER_UPDATE(nil, true)
self.initUpdate = true
end
end
function CC:PLAYER_GUILD_UPDATE()
if IsInGuild() then
self:RegisterEvent("GUILD_ROSTER_UPDATE")
else
self:UnregisterEvent("RAID_ROSTER_UPDATE")
end
end
function CC:FRIENDLIST_UPDATE()
local name, class, _
for i = 1, GetNumFriends() do
name, _, class = GetFriendInfo(i)
if class then
self:CachePlayer(name, GetEnglishClassName(class))
end
end
end
function CC:GUILD_ROSTER_UPDATE(_, update)
if not update then return end
local name, class, _
for i = 1, GetNumGuildMembers() do
name, _, _, _, _, _, _, _, _, _, class = GetGuildRosterInfo(i)
if class then
self:CachePlayer(name, class)
end
end
end
function CC:PARTY_MEMBERS_CHANGED()
local name, realm, class, _
for i = 1, GetNumPartyMembers() do
name, realm = UnitName("party"..i)
_, class = UnitClass("party"..i)
if not class then return end
if self.inBattleground then
self:CachePlayer(name, class, realm)
else
self:CachePlayer(name, class)
end
end
end
function CC:RAID_ROSTER_UPDATE()
local name, realm, class, _
for i = 1, GetNumRaidMembers() do
name, realm = UnitName("raid"..i)
_, class = UnitClass("raid"..i)
if not class then return end
if self.inBattleground then
self:CachePlayer(name, class, realm)
else
self:CachePlayer(name, class)
end
end
end
function CC:PLAYER_TARGET_CHANGED()
if not UnitExists("target") or not UnitIsPlayer("target") then return end
local _, class = UnitClass("target")
if not class then return end
local name, realm = UnitName("target")
if self.inBattleground then
self:CachePlayer(name, class, realm)
else
self:CachePlayer(name, class)
end
end
function CC:UPDATE_MOUSEOVER_UNIT()
if not UnitExists("mouseover") or not UnitIsPlayer("mouseover") then return end
local _, class = UnitClass("mouseover")
if not class then return end
local name, realm = UnitName("mouseover")
if self.inBattleground then
self:CachePlayer(name, class, realm)
else
self:CachePlayer(name, class)
end
end
function CC:UPDATE_BATTLEFIELD_SCORE()
local numPlayers = GetNumBattlefieldScores() or 0
if self.lastNumPlayers == numPlayers then
return
elseif self.lastNumPlayers > numPlayers then
self.lastNumPlayers = numPlayers
return
end
local name, realm, class, _
for i = 1, numPlayers do
name, _, _, _, _, _, _, _, _, class = GetBattlefieldScore(i)
if name and class then
name, realm = split("-", name)
self:CachePlayer(name, class, realm)
end
end
end
function CC:WHOLIB_QUERY_RESULT(_, query, results, complete)
for _, result in pairs(results) do
if result and result.NoLocaleClass then
self:CachePlayer(result.Name, result.NoLocaleClass)
end
end
end
function CC:ToggleModule()
if E.private.general.classCache then
if not self.initialized then
self:SwitchCacheType(true)
self.initialized = true
end
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_GUILD_UPDATE")
self:RegisterEvent("FRIENDLIST_UPDATE")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")
LW.RegisterCallback(self, "WHOLIB_QUERY_RESULT", "WHOLIB_QUERY_RESULT")
else
self:UnregisterAllEvents()
LW.UnregisterAllCallbacks(self)
end
end
function CC:Initialize()
self.cache = E.global.classCache
self.tempCache = {}
self.cacheLocalCalculationTime = 0
self.cacheDBCalculationTime = 0
LW:SetWhoLibDebug(false)
if E.private.general.classCache then
self:ToggleModule()
end
end
local function InitializeCallback()
CC:Initialize()
end
E:RegisterModule(CC:GetName(), InitializeCallback)
+130
View File
@@ -0,0 +1,130 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local _G = _G
local tonumber, type = tonumber, type
local format, lower, match = string.format, string.lower, string.match
--WoW API / Variables
local UIFrameFadeOut, UIFrameFadeIn = UIFrameFadeOut, UIFrameFadeIn
local EnableAddOn, DisableAddOn, DisableAllAddOns = EnableAddOn, DisableAddOn, DisableAllAddOns
local SetCVar = SetCVar
local ReloadUI = ReloadUI
local GetAddOnInfo = GetAddOnInfo
function E:EnableAddon(addon)
local _, _, _, _, _, reason, _ = GetAddOnInfo(addon)
if reason ~= "MISSING" then
EnableAddOn(addon)
ReloadUI()
else
E:Print(format("Addon '%s' not found.", addon))
end
end
function E:DisableAddon(addon)
local _, _, _, _, _, reason, _ = GetAddOnInfo(addon)
if reason ~= "MISSING" then
DisableAddOn(addon)
ReloadUI()
else
E:Print(format("Addon '%s' not found.", addon))
end
end
function FarmMode()
if E.private.general.minimap.enable ~= true then return end
if Minimap:IsShown() then
UIFrameFadeOut(Minimap, 0.3)
UIFrameFadeIn(FarmModeMap, 0.3)
Minimap.fadeInfo.finishedFunc = function() Minimap:Hide() _G.MinimapZoomIn:Click() _G.MinimapZoomOut:Click() Minimap:SetAlpha(1) end
FarmModeMap.enabled = true
else
UIFrameFadeOut(FarmModeMap, 0.3)
UIFrameFadeIn(Minimap, 0.3)
FarmModeMap.fadeInfo.finishedFunc = function() FarmModeMap:Hide() _G.MinimapZoomIn:Click() _G.MinimapZoomOut:Click() Minimap:SetAlpha(1) end
FarmModeMap.enabled = false
end
end
function E:FarmMode(msg)
if E.private.general.minimap.enable ~= true then return end
if msg and type(tonumber(msg)) == "number" and tonumber(msg) <= 500 and tonumber(msg) >= 20 then
E.db.farmSize = tonumber(msg)
FarmModeMap:SetWidth(tonumber(msg))
FarmModeMap:SetHeight(tonumber(msg))
end
FarmMode()
end
function E:Grid(msg)
if msg and type(tonumber(msg)) == "number" and tonumber(msg) <= 256 and tonumber(msg) >= 4 then
E.db.gridSize = msg
E:Grid_Show()
else
if EGrid then
E:Grid_Hide()
else
E:Grid_Show()
end
end
end
function E:LuaError(msg)
msg = lower(msg)
if msg == "on" then
DisableAllAddOns()
EnableAddOn("ElvUI")
EnableAddOn("ElvUI_Config")
SetCVar("ShowErrors", "1")
ReloadUI()
elseif msg == "off" then
SetCVar("ShowErrors", "0")
E:Print("Lua errors off.")
else
E:Print("/luaerror on - /luaerror off")
end
end
function E:BGStats()
local DT = E:GetModule("DataTexts")
DT.ForceHideBGStats = nil
DT:LoadDataTexts()
E:Print(L["Battleground datatexts will now show again if you are inside a battleground."])
end
local function OnCallback(command)
MacroEditBox:GetScript("OnEvent")(MacroEditBox, "EXECUTE_CHAT_LINE", command)
end
function E:DelayScriptCall(msg)
local secs, command = match(msg, "^([^%s]+)%s+(.*)$")
secs = tonumber(secs)
if (not secs) or (getn(command) == 0) then
self:Print("usage: /in <seconds> <command>")
self:Print("example: /in 1.5 /say hi")
else
E:ScheduleTimer(OnCallback, secs, command)
end
end
function E:LoadCommands()
self:RegisterChatCommand("in", "DelayScriptCall")
self:RegisterChatCommand("ec", "ToggleConfig")
self:RegisterChatCommand("elvui", "ToggleConfig")
self:RegisterChatCommand("bgstats", "BGStats")
self:RegisterChatCommand("luaerror", "LuaError")
self:RegisterChatCommand("egrid", "Grid")
self:RegisterChatCommand("moveui", "ToggleConfigMode")
self:RegisterChatCommand("resetui", "ResetUI")
self:RegisterChatCommand("enable", "EnableAddon")
self:RegisterChatCommand("disable", "DisableAddon")
self:RegisterChatCommand("farmmode", "FarmMode")
-- if E:GetModule("ActionBars") and E.private.actionbar.enable then
-- self:RegisterChatCommand("kb", E:GetModule("ActionBars").ActivateBindMode)
-- end
end
+497
View File
@@ -0,0 +1,497 @@
local E, L, V, P, G = unpack(ElvUI); -- Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local _G = _G
local type, ipairs, tonumber = type, ipairs, tonumber
local floor = math.floor
--WoW API / Variables
local CreateFrame = CreateFrame
local IsAddOnLoaded = IsAddOnLoaded
local GetScreenWidth = GetScreenWidth
local GetScreenHeight = GetScreenHeight
local RESET = RESET
local grid
local selectedValue = "ALL"
E.ConfigModeLayouts = {
"ALL",
"GENERAL",
"SOLO",
"PARTY",
"RAID",
"ACTIONBARS"
}
E.ConfigModeLocalizedStrings = {
ALL = ALL,
GENERAL = GENERAL,
SOLO = SOLO,
PARTY = PARTY,
RAID = RAID,
ACTIONBARS = ACTIONBAR_LABEL
}
function E:Grid_Show()
if not grid then
E:Grid_Create()
elseif grid.boxSize ~= E.db.gridSize then
grid:Hide()
E:Grid_Create()
else
grid:Show()
end
end
function E:Grid_Hide()
if grid then
grid:Hide()
end
end
function E:ToggleConfigMode(override, configType)
if override ~= nil and override ~= "" then E.ConfigurationMode = override end
if E.ConfigurationMode ~= true then
if not grid then
E:Grid_Create()
elseif grid.boxSize ~= E.db.gridSize then
grid:Hide()
E:Grid_Create()
else
grid:Show()
end
if not ElvUIMoverPopupWindow then
E:CreateMoverPopup()
end
ElvUIMoverPopupWindow:Show()
if(IsAddOnLoaded("ElvUI_Config")) then
LibStub("AceConfigDialog-3.0"):Close("ElvUI")
GameTooltip:Hide()
end
E.ConfigurationMode = true
else
if ElvUIMoverPopupWindow then
ElvUIMoverPopupWindow:Hide()
end
if grid then
grid:Hide()
end
E.ConfigurationMode = false
end
if type(configType) ~= "string" then
configType = nil
end
self:ToggleMovers(E.ConfigurationMode, configType or "ALL")
end
function E:Grid_Create()
grid = CreateFrame("Frame", "EGrid", UIParent)
grid.boxSize = E.db.gridSize
grid:SetAllPoints(E.UIParent)
grid:Show()
local size = 1
local width = E.eyefinity or GetScreenWidth()
local ratio = width / GetScreenHeight()
local height = GetScreenHeight() * ratio
local wStep = width / E.db.gridSize
local hStep = height / E.db.gridSize
for i = 0, E.db.gridSize do
local tx = grid:CreateTexture(nil, "BACKGROUND")
if i == E.db.gridSize / 2 then
tx:SetTexture(1, 0, 0)
else
tx:SetTexture(0, 0, 0)
end
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", i*wStep - (size/2), 0)
tx:SetPoint("BOTTOMRIGHT", grid, "BOTTOMLEFT", i*wStep + (size/2), 0)
end
height = GetScreenHeight()
do
local tx = grid:CreateTexture(nil, "BACKGROUND")
tx:SetTexture(1, 0, 0)
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2) + (size/2))
tx:SetPoint("BOTTOMRIGHT", grid, "TOPRIGHT", 0, -(height/2 + size/2))
end
for i = 1, floor((height/2)/hStep) do
local tx = grid:CreateTexture(nil, "BACKGROUND")
tx:SetTexture(0, 0, 0)
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2+i*hStep) + (size/2))
tx:SetPoint("BOTTOMRIGHT", grid, "TOPRIGHT", 0, -(height/2+i*hStep + size/2))
tx = grid:CreateTexture(nil, "BACKGROUND")
tx:SetTexture(0, 0, 0)
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2-i*hStep) + (size/2))
tx:SetPoint("BOTTOMRIGHT", grid, "TOPRIGHT", 0, -(height/2-i*hStep + size/2))
end
end
local function ConfigMode_OnClick()
selectedValue = this.value
E:ToggleConfigMode(false, this.value)
UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, this.value)
end
local function ConfigMode_Initialize()
local info = {}
info.func = ConfigMode_OnClick
for _, configMode in ipairs(E.ConfigModeLayouts) do
info.text = E.ConfigModeLocalizedStrings[configMode]
info.value = configMode
UIDropDownMenu_AddButton(info)
end
UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue)
end
function E:NudgeMover(nudgeX, nudgeY)
local mover = ElvUIMoverNudgeWindow.child
local x, y, point = E:CalculateMoverPoints(mover, nudgeX, nudgeY)
mover:ClearAllPoints()
mover:SetPoint(mover.positionOverride or point, E.UIParent, mover.positionOverride and "BOTTOMLEFT" or point, x, y)
E:SaveMoverPosition(mover.name)
E:UpdateNudgeFrame(mover, x, y)
end
function E:UpdateNudgeFrame(mover, x, y)
if not(x and y) then
x, y = E:CalculateMoverPoints(mover)
end
x = E:Round(x, 0)
y = E:Round(y, 0)
ElvUIMoverNudgeWindow.xOffset:SetText(x)
ElvUIMoverNudgeWindow.yOffset:SetText(y)
ElvUIMoverNudgeWindow.xOffset.currentValue = x
ElvUIMoverNudgeWindow.yOffset.currentValue = y
ElvUIMoverNudgeWindowHeader.title:SetText(mover.textString)
end
function E:AssignFrameToNudge()
ElvUIMoverNudgeWindow.child = self
E:UpdateNudgeFrame(self)
end
function E:CreateMoverPopup()
local f = CreateFrame("Frame", "ElvUIMoverPopupWindow", UIParent)
f:SetFrameStrata("DIALOG")
f:SetToplevel(true)
f:EnableMouse(true)
f:SetMovable(true)
f:SetFrameLevel(99)
f:SetClampedToScreen(true)
f:SetWidth(360)
f:SetHeight(170)
E:SetTemplate(f, "Transparent")
f:SetPoint("BOTTOM", UIParent, "CENTER", 0, 100)
f:SetScript("OnHide", function()
if ElvUIMoverPopupWindowDropDown then
UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, "ALL")
end
end)
f:Hide()
local S = E:GetModule("Skins")
local header = CreateFrame("Button", nil, f)
E:SetTemplate(header, "Default", true)
header:SetWidth(100) header:SetHeight(25)
header:SetPoint("CENTER", f, "TOP")
header:SetFrameLevel(header:GetFrameLevel() + 2)
header:EnableMouse(true)
header:RegisterForClicks("AnyUp", "AnyDown")
header:SetScript("OnMouseDown", function() f:StartMoving() end)
header:SetScript("OnMouseUp", function() f:StopMovingOrSizing() end)
local title = header:CreateFontString("OVERLAY")
E:FontTemplate(title)
title:SetPoint("CENTER", header, "CENTER")
title:SetText("ElvUI")
local desc = f:CreateFontString("ARTWORK")
desc:SetFontObject("GameFontHighlight")
desc:SetJustifyV("TOP")
desc:SetJustifyH("LEFT")
desc:SetPoint("TOPLEFT", 18, -32)
desc:SetPoint("BOTTOMRIGHT", -18, 48)
desc:SetText(L["DESC_MOVERCONFIG"])
local snapping = CreateFrame("CheckButton", f:GetName().."CheckButton", f, "OptionsCheckButtonTemplate")
_G[snapping:GetName().."Text"]:SetText(L["Sticky Frames"])
snapping:SetScript("OnShow", function()
this:SetChecked(E.db.general.stickyFrames)
end)
snapping:SetScript("OnClick", function()
E.db.general.stickyFrames = this:GetChecked()
end)
local lock = CreateFrame("Button", f:GetName().."CloseButton", f, "OptionsButtonTemplate")
_G[lock:GetName().."Text"]:SetText(L["Lock"])
lock:SetScript("OnClick", function()
E:ToggleConfigMode(true)
if(IsAddOnLoaded("ElvUI_Config")) then
LibStub("AceConfigDialog-3.0"):Open("ElvUI")
end
selectedValue = "ALL"
UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue)
end)
local align = CreateFrame("EditBox", f:GetName().."EditBox", f, "InputBoxTemplate")
align:SetWidth(32)
align:SetHeight(17)
align:SetAutoFocus(false)
align:SetScript("OnEscapePressed", function()
this:SetText(E.db.gridSize)
this:ClearFocus()
end)
align:SetScript("OnEnterPressed", function()
local text = this:GetText()
if tonumber(text) then
if tonumber(text) <= 256 and tonumber(text) >= 4 then
E.db.gridSize = tonumber(text)
else
this:SetText(E.db.gridSize)
end
else
this:SetText(E.db.gridSize)
end
E:Grid_Show()
this:ClearFocus()
end)
align:SetScript("OnEditFocusLost", function()
this:SetText(E.db.gridSize)
end)
align:SetScript("OnShow", function()
this:ClearFocus()
this:SetText(E.db.gridSize)
end)
align.text = align:CreateFontString(nil, "OVERLAY", "GameFontNormal")
align.text:SetPoint("RIGHT", align, "LEFT", -4, 0)
align.text:SetText(L["Grid Size:"])
--position buttons
snapping:SetPoint("BOTTOMLEFT", 14, 10)
lock:SetPoint("BOTTOMRIGHT", -14, 14)
align:SetPoint("TOPRIGHT", lock, "TOPLEFT", -4, -2)
S:HandleCheckBox(snapping)
S:HandleButton(lock)
S:HandleEditBox(align)
f:RegisterEvent("PLAYER_REGEN_DISABLED")
f:SetScript("OnEvent", function()
if this:IsShown() then
this:Hide()
E:Grid_Hide()
E:ToggleConfigMode(true)
end
end)
local configMode = CreateFrame("Frame", f:GetName().."DropDown", f, "UIDropDownMenuTemplate")
configMode:SetPoint("BOTTOMRIGHT", lock, "TOPRIGHT", 8, -5)
S:HandleDropDownBox(configMode, 148)
configMode.text = configMode:CreateFontString(nil, "OVERLAY", "GameFontNormal")
configMode.text:SetPoint("RIGHT", configMode.backdrop, "LEFT", -2, 0)
configMode.text:SetText(L["Config Mode:"])
UIDropDownMenu_Initialize(configMode, ConfigMode_Initialize)
local nudgeFrame = CreateFrame("Frame", "ElvUIMoverNudgeWindow", E.UIParent)
nudgeFrame:SetFrameStrata("DIALOG")
nudgeFrame:SetWidth(200)
nudgeFrame:SetHeight(110)
E:SetTemplate(nudgeFrame, "Transparent")
nudgeFrame:SetPoint("TOP", ElvUIMoverPopupWindow, "BOTTOM", 0, -15)
nudgeFrame:SetFrameLevel(100)
nudgeFrame:Hide()
nudgeFrame:EnableMouse(true)
nudgeFrame:SetClampedToScreen(true)
HookScript(ElvUIMoverPopupWindow, "OnHide", function() ElvUIMoverNudgeWindow:Hide() end)
header = CreateFrame("Button", "ElvUIMoverNudgeWindowHeader", nudgeFrame)
E:SetTemplate(header, "Default", true)
header:SetWidth(100) header:SetHeight(25)
header:SetPoint("CENTER", nudgeFrame, "TOP")
header:SetFrameLevel(header:GetFrameLevel() + 2)
title = header:CreateFontString("OVERLAY")
E:FontTemplate(title)
title:SetPoint("CENTER", header, "CENTER")
title:SetText(L["Nudge"])
header.title = title
local xOffset = CreateFrame("EditBox", nudgeFrame:GetName().."XEditBox", nudgeFrame, "InputBoxTemplate")
xOffset:SetWidth(50)
xOffset:SetHeight(17)
xOffset:SetAutoFocus(false)
xOffset.currentValue = 0
xOffset:SetScript("OnEscapePressed", function()
this:SetText(E:Round(xOffset.currentValue))
this:ClearFocus()
end)
xOffset:SetScript("OnEnterPressed", function()
local num = this:GetText()
if(tonumber(num)) then
local diff = num - xOffset.currentValue
xOffset.currentValue = num
E:NudgeMover(diff)
end
this:SetText(E:Round(xOffset.currentValue))
this:ClearFocus()
end)
xOffset:SetScript("OnEditFocusLost", function()
this:SetText(E:Round(xOffset.currentValue))
end)
xOffset:SetScript("OnShow", function()
this:ClearFocus()
this:SetText(E:Round(xOffset.currentValue))
end)
xOffset.text = xOffset:CreateFontString(nil, "OVERLAY", "GameFontNormal")
xOffset.text:SetPoint("RIGHT", xOffset, "LEFT", -4, 0)
xOffset.text:SetText("X:")
xOffset:SetPoint("BOTTOMRIGHT", nudgeFrame, "CENTER", -6, 8)
nudgeFrame.xOffset = xOffset
S:HandleEditBox(xOffset)
local yOffset = CreateFrame("EditBox", nudgeFrame:GetName().."YEditBox", nudgeFrame, "InputBoxTemplate")
yOffset:SetWidth(50)
yOffset:SetHeight(17)
yOffset:SetAutoFocus(false)
yOffset.currentValue = 0
yOffset:SetScript("OnEscapePressed", function()
this:SetText(E:Round(yOffset.currentValue))
this:ClearFocus()
end)
yOffset:SetScript("OnEnterPressed", function()
local num = this:GetText()
if(tonumber(num)) then
local diff = num - yOffset.currentValue
yOffset.currentValue = num
E:NudgeMover(nil, diff)
end
this:SetText(E:Round(yOffset.currentValue))
this:ClearFocus()
end)
yOffset:SetScript("OnEditFocusLost", function()
this:SetText(E:Round(yOffset.currentValue))
end)
yOffset:SetScript("OnShow", function()
this:ClearFocus()
this:SetText(E:Round(yOffset.currentValue))
end)
yOffset.text = yOffset:CreateFontString(nil, "OVERLAY", "GameFontNormal")
yOffset.text:SetPoint("RIGHT", yOffset, "LEFT", -4, 0)
yOffset.text:SetText("Y:")
yOffset:SetPoint("BOTTOMLEFT", nudgeFrame, "CENTER", 16, 8)
nudgeFrame.yOffset = yOffset
S:HandleEditBox(yOffset)
local resetButton = CreateFrame("Button", nudgeFrame:GetName().."ResetButton", nudgeFrame, "UIPanelButtonTemplate")
resetButton:SetText(RESET)
resetButton:SetPoint("TOP", nudgeFrame, "CENTER", 0, 2)
resetButton:SetWidth(100)
resetButton:SetHeight(25)
resetButton:SetScript("OnClick", function()
if(ElvUIMoverNudgeWindow.child.textString) then
E:ResetMovers(ElvUIMoverNudgeWindow.child.textString)
E:UpdateNudgeFrame(ElvUIMoverNudgeWindow.child)
end
end)
S:HandleButton(resetButton)
-- Up Button
local upButton = CreateFrame("Button", nudgeFrame:GetName().."PrevButton", nudgeFrame)
upButton:SetWidth(26)
upButton:SetHeight(26)
upButton:SetPoint("BOTTOMRIGHT", nudgeFrame, "BOTTOM", -6, 4)
upButton:SetScript("OnClick", function()
E:NudgeMover(nil, 1)
end)
upButton.icon = upButton:CreateTexture(nil, "ARTWORK")
upButton.icon:SetWidth(13)
upButton.icon:SetHeight(13)
upButton.icon:SetPoint("CENTER", 0, 0)
upButton.icon:SetTexture([[Interface\AddOns\ElvUI\Media\Textures\SquareButtonTextures.blp]])
upButton.icon:SetTexCoord(0.01562500, 0.20312500, 0.01562500, 0.20312500)
S:SquareButton_SetIcon(upButton, "UP")
S:HandleButton(upButton)
-- Down Button
local downButton = CreateFrame("Button", nudgeFrame:GetName().."DownButton", nudgeFrame)
downButton:SetWidth(26)
downButton:SetHeight(26)
downButton:SetPoint("BOTTOMLEFT", nudgeFrame, "BOTTOM", 6, 4)
downButton:SetScript("OnClick", function()
E:NudgeMover(nil, -1)
end)
downButton.icon = downButton:CreateTexture(nil, "ARTWORK")
downButton.icon:SetWidth(13)
downButton.icon:SetHeight(13)
downButton.icon:SetPoint("CENTER", 0, 0)
downButton.icon:SetTexture([[Interface\AddOns\ElvUI\Media\Textures\SquareButtonTextures.blp]])
downButton.icon:SetTexCoord(0.01562500, 0.20312500, 0.01562500, 0.20312500)
S:SquareButton_SetIcon(downButton, "DOWN")
S:HandleButton(downButton)
-- Left Button
local leftButton = CreateFrame("Button", nudgeFrame:GetName().."LeftButton", nudgeFrame)
leftButton:SetWidth(26)
leftButton:SetHeight(26)
leftButton:SetPoint("RIGHT", upButton, "LEFT", -6, 0)
leftButton:SetScript("OnClick", function()
E:NudgeMover(-1)
end)
leftButton.icon = leftButton:CreateTexture(nil, "ARTWORK")
leftButton.icon:SetWidth(13)
leftButton.icon:SetHeight(13)
leftButton.icon:SetPoint("CENTER", 0, 0)
leftButton.icon:SetTexture([[Interface\AddOns\ElvUI\Media\Textures\SquareButtonTextures.blp]])
leftButton.icon:SetTexCoord(0.01562500, 0.20312500, 0.01562500, 0.20312500)
S:SquareButton_SetIcon(leftButton, "LEFT")
S:HandleButton(leftButton)
-- Right Button
local rightButton = CreateFrame("Button", nudgeFrame:GetName().."RightButton", nudgeFrame)
rightButton:SetWidth(26)
rightButton:SetHeight(26)
rightButton:SetPoint("LEFT", downButton, "RIGHT", 6, 0)
rightButton:SetScript("OnClick", function()
E:NudgeMover(1)
end)
rightButton.icon = rightButton:CreateTexture(nil, "ARTWORK")
rightButton.icon:SetWidth(13)
rightButton.icon:SetHeight(13)
rightButton.icon:SetPoint("CENTER", 0, 0)
rightButton.icon:SetTexture([[Interface\AddOns\ElvUI\Media\Textures\SquareButtonTextures.blp]])
rightButton.icon:SetTexCoord(0.01562500, 0.20312500, 0.01562500, 0.20312500)
S:SquareButton_SetIcon(rightButton, "RIGHT")
S:HandleButton(rightButton)
end
+140
View File
@@ -0,0 +1,140 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local floor = math.floor
local format = string.format
local GetTime = GetTime
--WoW API / Variables
local CreateFrame = CreateFrame
local hooksecurefunc = hooksecurefunc
local ICON_SIZE = 36 --the normal size for an icon (don't change this)
local FONT_SIZE = 20 --the base font size to use at a scale of 1
local MIN_SCALE = 0.5 --the minimum scale we want to show cooldown counts at, anything below this will be hidden
local MIN_DURATION = 1.5 --the minimum duration to show cooldown text for
local TimeColors = {
[0] = "|cfffefefe",
[1] = "|cfffefefe",
[2] = "|cfffefefe",
[3] = "|cfffefefe",
[4] = "|cfffe0000"
}
local function Cooldown_OnUpdate(cd, elapsed)
if cd.nextUpdate > 0 then
cd.nextUpdate = cd.nextUpdate - elapsed
return
end
local remain = cd.duration - (GetTime() - cd.start)
if remain > 0.05 then
if (cd.fontScale * cd:GetEffectiveScale() / UIParent:GetScale()) < MIN_SCALE then
cd.text:SetText("")
cd.nextUpdate = 500
else
local timervalue, formatid
timervalue, formatid, cd.nextUpdate = E:GetTimeInfo(remain, E.db.cooldown.threshold)
cd.text:SetText(format("%s%s|r", TimeColors[formatid], format(E.TimeFormats[formatid][2], timervalue)))
end
else
E:Cooldown_StopTimer(cd)
end
end
function E:Cooldown_OnSizeChanged(cd, width)
local fontScale = floor(width +.5) / ICON_SIZE
local override = cd:GetParent():GetParent().SizeOverride
if override then
fontScale = override / FONT_SIZE
end
if fontScale == cd.fontScale then
return
end
cd.fontScale = fontScale
if fontScale < MIN_SCALE and not override then
cd:Hide()
else
cd:Show()
E:FontTemplate(cd.text, nil, fontScale * FONT_SIZE, "OUTLINE")
if cd.enabled then
self:Cooldown_ForceUpdate(cd)
end
end
end
function E:Cooldown_ForceUpdate(cd)
cd.nextUpdate = 0
cd:Show()
end
function E:Cooldown_StopTimer(cd)
cd.enabled = nil
cd:Hide()
end
function E:CreateCooldownTimer(parent)
local scaler = CreateFrame("Frame", nil, parent)
scaler:SetAllPoints()
local timer = CreateFrame("Frame", nil, scaler)
timer:Hide()
timer:SetAllPoints()
timer:SetScript("OnUpdate", function() Cooldown_OnUpdate(this, arg1) end)
local text = timer:CreateFontString(nil, "OVERLAY")
text:SetPoint("CENTER", 1, 1)
text:SetJustifyH("CENTER")
timer.text = text
self:Cooldown_OnSizeChanged(timer, parent:GetWidth(), parent:GetHeight())
parent:SetScript("OnSizeChanged", function() self:Cooldown_OnSizeChanged(timer, parent:GetWidth(), parent:GetHeight()) end)
parent.timer = timer
return timer
end
function E:OnSetCooldown(start, duration, enable)
if self.noOCC then return end
if start > 0 and duration > MIN_DURATION and enable > 0 then
local timer = self.timer or E:CreateCooldownTimer(self)
timer.start = start
timer.duration = duration
timer.enabled = true
timer.nextUpdate = 0
if timer.fontScale >= MIN_SCALE then timer:Show() end
else
local timer = self.timer
if timer then
E:Cooldown_StopTimer(timer)
return
end
end
end
function E:RegisterCooldown(cooldown)
if not E.private.cooldown.enable or cooldown.isHooked then return end
hooksecurefunc("CooldownFrame_SetTimer", E.OnSetCooldown)
cooldown.isHooked = true
end
function E:UpdateCooldownSettings()
local color = self.db.cooldown.expiringColor
TimeColors[4] = E:RGBToHex(color.r, color.g, color.b) -- color for timers that are soon to expire
color = self.db.cooldown.secondsColor
TimeColors[3] = E:RGBToHex(color.r, color.g, color.b) -- color for timers that have seconds remaining
color = self.db.cooldown.minutesColor
TimeColors[2] = E:RGBToHex(color.r, color.g, color.b) -- color for timers that have minutes remaining
color = self.db.cooldown.hoursColor
TimeColors[1] = E:RGBToHex(color.r, color.g, color.b) -- color for timers that have hours remaining
color = self.db.cooldown.daysColor
TimeColors[0] = E:RGBToHex(color.r, color.g, color.b) -- color for timers that have days remaining
end
+18
View File
@@ -0,0 +1,18 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Math.lua"/>
<Script file="core.lua"/>
<Script file="fonts.lua"/>
<Script file="install.lua"/>
<Script file="pixelperfect.lua"/>
<Script file="toolkit.lua"/>
<Script file="Commands.lua"/>
<Script file="StaticPopups.lua"/>
<Script file="Movers.lua"/>
<Script file="Config.lua"/>
<Script file="tutorials.lua"/>
<Script file="distributor.lua"/>
<Script file="dropdown.lua"/>
<Script file="Cooldowns.lua"/>
<Script file="pluginInstaller.lua"/>
<Script file="ClassCache.lua"/>
</Ui>
+421
View File
@@ -0,0 +1,421 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local select, unpack, assert, tonumber, type, pairs = select, unpack, assert, tonumber, type, pairs
local getn, tinsert, tremove = table.getn, tinsert, tremove
local abs, ceil, floor, modf, mod = math.abs, math.ceil, math.floor, math.modf, math.mod
local find, format, byte, len, sub, gsub, upper, split, utf8sub = string.find, string.format, string.byte, string.len, string.sub, string.gsub, string.upper, string.split, string.utf8sub
--WoW API / Variables
local GetScreenWidth, GetScreenHeight = GetScreenWidth, GetScreenHeight
local CreateFrame = CreateFrame
--Return short value of a number
local shortValueDec
function E:ShortValue(v)
shortValueDec = format("%%.%df", E.db.general.decimalLength or 1)
if E.db.general.numberPrefixStyle == "METRIC" then
if abs(v) >= 1e9 then
return format(shortValueDec.."G", v / 1e9)
elseif abs(v) >= 1e6 then
return format(shortValueDec.."M", v / 1e6)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."k", v / 1e3)
else
return format("%s", v)
end
elseif E.db.general.numberPrefixStyle == "CHINESE" then
if abs(v) >= 1e8 then
return format(shortValueDec.."Y", v / 1e8)
elseif abs(v) >= 1e4 then
return format(shortValueDec.."W", v / 1e4)
else
return format("%s", v)
end
elseif E.db.general.numberPrefixStyle == "KOREAN" then
if abs(v) >= 1e8 then
return format(shortValueDec.."", v / 1e8)
elseif abs(v) >= 1e4 then
return format(shortValueDec.."", v / 1e4)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."", v / 1e3)
else
return format("%s", v)
end
elseif E.db.general.numberPrefixStyle == "GERMAN" then
if abs(v) >= 1e9 then
return format(shortValueDec.."Mrd", v / 1e9)
elseif abs(v) >= 1e6 then
return format(shortValueDec.."Mio", v / 1e6)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."Tsd", v / 1e3)
else
return format("%s", v)
end
else
if abs(v) >= 1e9 then
return format(shortValueDec.."B", v / 1e9)
elseif abs(v) >= 1e6 then
return format(shortValueDec.."M", v / 1e6)
elseif abs(v) >= 1e3 then
return format(shortValueDec.."K", v / 1e3)
else
return format("%s", v)
end
end
end
function E:IsEvenNumber(num)
return mod(num, 2) == 0
end
function E:ColorGradient(perc, r1, g1, b1, r2, g2, b2, r3, g3, b3)
if perc >= 1 then
return r3, g3, b3
elseif perc <= 0 then
return r1, g1, b1
end
local segment, relperc = modf(perc)
if segment > 0 then
r1, g1, b1, r2, g2, b2 = r2, g2, b2, r3, g3, b3
end
return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
end
function E:Round(num, idp)
if idp and idp > 0 then
local mult = 10 ^ idp
return floor(num * mult + 0.5) / mult
end
return floor(num + 0.5)
end
function E:Truncate(v, decimals)
return v - (mod(v, 0.1 ^ (decimals or 0)))
end
function E:RGBToHex(r, g, b)
r = r <= 1 and r >= 0 and r or 0
g = g <= 1 and g >= 0 and g or 0
b = b <= 1 and b >= 0 and b or 0
return format("|cff%02x%02x%02x", r*255, g*255, b*255)
end
function E:HexToRGB(hex)
local rhex, ghex, bhex = sub(hex, 1, 2), sub(hex, 3, 4), sub(hex, 5, 6)
return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
end
function E:FramesOverlap(frameA, frameB)
if not frameA or not frameB then return end
local sA, sB = frameA:GetEffectiveScale(), frameB:GetEffectiveScale()
if not sA or not sB then return end
local frameALeft = frameA:GetLeft()
local frameARight = frameA:GetRight()
local frameABottom = frameA:GetBottom()
local frameATop = frameA:GetTop()
local frameBLeft = frameB:GetLeft()
local frameBRight = frameB:GetRight()
local frameBBottom = frameB:GetBottom()
local frameBTop = frameB:GetTop()
if not frameALeft or not frameARight or not frameABottom or not frameATop then return end
if not frameBLeft or not frameBRight or not frameBBottom or not frameBTop then return end
return ((frameALeft*sA) < (frameBRight*sB))
and ((frameBLeft*sB) < (frameARight*sA))
and ((frameABottom*sA) < (frameBTop*sB))
and ((frameBBottom*sB) < (frameATop*sA))
end
function E:GetScreenQuadrant(frame)
local x, y = frame:GetCenter()
local screenWidth = GetScreenWidth()
local screenHeight = GetScreenHeight()
local point
if not frame:GetCenter() then
return "UNKNOWN", frame:GetName()
end
if (x > (screenWidth / 3) and x < (screenWidth / 3)*2) and y > (screenHeight / 3)*2 then
point = "TOP"
elseif x < (screenWidth / 3) and y > (screenHeight / 3)*2 then
point = "TOPLEFT"
elseif x > (screenWidth / 3)*2 and y > (screenHeight / 3)*2 then
point = "TOPRIGHT"
elseif (x > (screenWidth / 3) and x < (screenWidth / 3)*2) and y < (screenHeight / 3) then
point = "BOTTOM"
elseif x < (screenWidth / 3) and y < (screenHeight / 3) then
point = "BOTTOMLEFT"
elseif x > (screenWidth / 3)*2 and y < (screenHeight / 3) then
point = "BOTTOMRIGHT"
elseif x < (screenWidth / 3) and (y > (screenHeight / 3) and y < (screenHeight / 3)*2) then
point = "LEFT"
elseif x > (screenWidth / 3)*2 and y < (screenHeight / 3)*2 and y > (screenHeight / 3) then
point = "RIGHT"
else
point = "CENTER"
end
return point
end
function E:GetXYOffset(position, override)
local default = E.Spacing
local x, y = override or default, override or default
if position == "TOP" then
return 0, y
elseif position == "TOPLEFT" then
return x, y
elseif position == "TOPRIGHT" then
return -x, y
elseif position == "BOTTOM" then
return 0, -y
elseif(position == "BOTTOMLEFT") then
return x, -y
elseif position == "BOTTOMRIGHT" then
return -x, -y
elseif position == "LEFT" then
return -x, 0
elseif position == "RIGHT" then
return x, 0
elseif position == "CENTER" then
return 0, 0
end
end
local styles = {
-- keep percents in this table with `PERCENT` in the key, and `%.1f%%` in the value somewhere.
-- we use these two things to follow our setting for decimal length. they need to be EXACT.
["CURRENT"] = "%s",
["CURRENT_MAX"] = "%s - %s",
["CURRENT_PERCENT"] = "%s - %.1f%%",
["CURRENT_MAX_PERCENT"] = "%s - %s | %.1f%%",
["PERCENT"] = "%.1f%%",
["DEFICIT"] = "-%s"
}
function E:GetFormattedText(style, min, max)
assert(styles[style], "Invalid format style: "..style)
assert(min, "You need to provide a current value. Usage: E:GetFormattedText(style, min, max)")
assert(max, "You need to provide a maximum value. Usage: E:GetFormattedText(style, min, max)")
if max == 0 then max = 1 end
gftDec = E.db.general.decimalLength or 1
if gftDec ~= 1 and find(style, "PERCENT") then
gftUseStyle = gsub(styles[style], "%%%.1f%%%%", "%%."..gftDec.."f%%%%")
else
gftUseStyle = styles[style]
end
if style == "DEFICIT" then
gftDeficit = max - min
return ((gftDeficit > 0) and format(gftUseStyle, E:ShortValue(gftDeficit))) or ""
elseif style == "PERCENT" then
return format(gftUseStyle, min / max * 100)
elseif style == "CURRENT" or ((style == "CURRENT_MAX" or style == "CURRENT_MAX_PERCENT" or style == "CURRENT_PERCENT") and min == max) then
return format(styles["CURRENT"], E:ShortValue(min))
elseif style == "CURRENT_MAX" then
return format(gftUseStyle, E:ShortValue(min), E:ShortValue(max))
elseif style == "CURRENT_PERCENT" then
return format(gftUseStyle, E:ShortValue(min), min / max * 100)
elseif style == "CURRENT_MAX_PERCENT" then
return format(gftUseStyle, E:ShortValue(min), E:ShortValue(max), min / max * 100)
end
end
function E:AbbreviateString(string, allUpper)
local newString = ""
local words = {split(" ", string)}
for _, word in pairs(words) do
word = utf8sub(word, 1, 1)
if(allUpper) then
word = upper(word)
end
newString = newString..word
end
return newString
end
function E:ShortenString(string, numChars, dots)
local bytes = len(string)
if bytes <= numChars then
return string
else
local len, pos = 0, 1
while pos <= bytes do
len = len + 1
local c = byte(string, pos)
if c > 0 and c <= 127 then
pos = pos + 1
elseif c >= 192 and c <= 223 then
pos = pos + 2
elseif c >= 224 and c <= 239 then
pos = pos + 3
elseif c >= 240 and c <= 247 then
pos = pos + 4
end
if len == numChars then break end
end
if len == numChars and pos <= bytes then
return sub(string, 1, pos - 1)..(dots and "..." or "")
else
return string
end
end
end
local waitTable = {}
local waitFrame
function E:Delay(delay, func, ...)
if (type(delay) ~= "number") or (type(func) ~= "function") then
return false
end
if waitFrame == nil then
waitFrame = CreateFrame("Frame", "WaitFrame", E.UIParent)
waitFrame:SetScript("OnUpdate", function()
local waitRecord, waitDelay, waitFunc, waitParams
local i, count = 1, getn(waitTable)
while i <= count do
waitRecord = tremove(waitTable, i)
waitDelay = tremove(waitRecord, 1)
waitFunc = tremove(waitRecord, 1)
waitParams = tremove(waitRecord, 1)
if waitDelay > arg1 then
tinsert(waitTable, i, {waitDelay - arg1, waitFunc, waitParams})
i = i + 1
else
count = count - 1
waitFunc(unpack(waitParams))
end
end
end)
end
tinsert(waitTable, {delay, func, arg})
return true
end
function E:StringTitle(str)
return gsub(str, "(.)", upper, 1)
end
E.TimeColors = {
[0] = "|cffeeeeee",
[1] = "|cffeeeeee",
[2] = "|cffeeeeee",
[3] = "|cffeeeeee",
[4] = "|cfffe0000"
}
E.TimeFormats = {
[0] = {"%dd", "%dd"},
[1] = {"%dh", "%dh"},
[2] = {"%dm", "%dm"},
[3] = {"%ds", "%d"},
[4] = {"%.1fs", "%.1f"}
}
local DAY, HOUR, MINUTE = 86400, 3600, 60
local DAYISH, HOURISH, MINUTEISH = HOUR * 23.5, MINUTE * 59.5, 59.5
local HALFDAYISH, HALFHOURISH, HALFMINUTEISH = DAY/2 + 0.5, HOUR/2 + 0.5, MINUTE/2 + 0.5
function E:GetTimeInfo(s, threshhold)
if s < MINUTE then
if s >= threshhold then
return floor(s), 3, 0.51
else
return s, 4, 0.051
end
elseif s < HOUR then
local minutes = floor((s/MINUTE)+.5)
return ceil(s / MINUTE), 2, minutes > 1 and (s - (minutes*MINUTE - HALFMINUTEISH)) or (s - MINUTEISH)
elseif s < DAY then
local hours = floor((s/HOUR)+.5)
return ceil(s / HOUR), 1, hours > 1 and (s - (hours*HOUR - HALFHOURISH)) or (s - HOURISH)
else
local days = floor((s/DAY)+.5)
return ceil(s / DAY), 0, days > 1 and (s - (days*DAY - HALFDAYISH)) or (s - DAYISH)
end
end
local COLOR_COPPER = "|cffeda55f"
local COLOR_SILVER = "|cffc7c7cf"
local COLOR_GOLD = "|cffffd700"
function E:FormatMoney(amount, style)
local coppername = L.copperabbrev
local silvername = L.silverabbrev
local goldname = L.goldabbrev
local value = abs(amount)
local gold = floor(value / 10000)
local silver = floor(mod(value / 100, 100))
local copper = floor(mod(value, 100))
if not style or style == "SMART" then
local str = ""
if gold > 0 then
str = format("%d%s%s", gold, goldname, (silver > 0 or copper > 0) and " " or "")
end
if silver > 0 then
str = format("%s%d%s%s", str, silver, silvername, copper > 0 and " " or "")
end
if copper > 0 or value == 0 then
str = format("%s%d%s", str, copper, coppername)
end
return str
end
if style == "FULL" then
if gold > 0 then
return format("%d%s %d%s %d%s", gold, goldname, silver, silvername, copper, coppername)
elseif silver > 0 then
return format("%d%s %d%s", silver, silvername, copper, coppername)
else
return format("%d%s", copper, coppername)
end
elseif style == "SHORT" then
if gold > 0 then
return format("%.1f%s", amount / 10000, goldname)
elseif silver > 0 then
return format("%.1f%s", amount / 100, silvername)
else
return format("%d%s", amount, coppername)
end
elseif style == "SHORTINT" then
if gold > 0 then
return format("%d%s", gold, goldname)
elseif silver > 0 then
return format("%d%s", silver, silvername)
else
return format("%d%s", copper, coppername)
end
elseif style == "CONDENSED" then
if gold > 0 then
return format("%s%d|r.%s%02d|r.%s%02d|r", COLOR_GOLD, gold, COLOR_SILVER, silver, COLOR_COPPER, copper)
elseif silver > 0 then
return format("%s%d|r.%s%02d|r", COLOR_SILVER, silver, COLOR_COPPER, copper)
else
return format("%s%d|r", COLOR_COPPER, copper)
end
elseif style == "BLIZZARD" then
if gold > 0 then
return format("%s%s %d%s %d%s", gold, goldname, silver, silvername, copper, coppername)
elseif silver > 0 then
return format("%d%s %d%s", silver, silvername, copper, coppername)
else
return format("%d%s", copper, coppername)
end
end
return self:FormatMoney(amount, "SMART")
end
+499
View File
@@ -0,0 +1,499 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local Sticky = LibStub("LibSimpleSticky-1.0");
--Cache global variables
--Lua functions
local _G = _G
local type, unpack, pairs = type, unpack, pairs
local format, split, find = string.format, string.split, string.find
--WoW API / Variables
local CreateFrame = CreateFrame
E.CreatedMovers = {}
E.DisabledMovers = {}
local function SizeChanged(self)
self.mover:SetWidth(self.dirtyWidth and self.dirtyWidth or self:GetWidth())
self.mover:SetHeight(self.dirtyHeight and self.dirtyHeight or self:GetHeight())
end
local function GetPoint(obj)
local point, anchor, secondaryPoint, x, y = obj:GetPoint()
if not anchor then anchor = ElvUIParent end
return format("%s,%s,%s,%d,%d", point, anchor:GetName(), secondaryPoint, E:Round(x), E:Round(y))
end
local function UpdateCoords(self)
local mover = self.child;
local x, y, _, nudgePoint, nudgeInversePoint = E:CalculateMoverPoints(mover);
local coordX, coordY = E:GetXYOffset(nudgeInversePoint, 1);
ElvUIMoverNudgeWindow:ClearAllPoints();
ElvUIMoverNudgeWindow:SetPoint(nudgePoint, mover, nudgeInversePoint, coordX, coordY);
E:UpdateNudgeFrame(mover, x, y);
end
local isDragging = false
local coordFrame = CreateFrame("Frame")
coordFrame:SetScript("OnUpdate", function() UpdateCoords(this) end)
coordFrame:Hide()
local function CreateMover(parent, name, text, overlay, snapOffset, postdrag, shouldDisable)
if not parent then return end --If for some reason the parent isnt loaded yet
if E.CreatedMovers[name].Created then return end
if overlay == nil then overlay = true end
local point, anchor, secondaryPoint, x, y = split(",", GetPoint(parent))
local width = parent.dirtyWidth or parent:GetWidth()
local height = parent.dirtyHeight or parent:GetHeight()
local f = CreateFrame("Button", name, E.UIParent)
f:SetClampedToScreen(true)
f:RegisterForDrag("LeftButton", "RightButton")
f:EnableMouseWheel(true)
f:SetMovable(true)
f:SetWidth(width)
f:SetHeight(height)
E:SetTemplate(f, "Transparent", nil, nil, true)
f:Hide()
f.parent = parent
f.name = name
f.textString = text
f.postdrag = postdrag
f.overlay = overlay
f.snapOffset = snapOffset or -2
f.shouldDisable = shouldDisable
f:SetFrameLevel(parent:GetFrameLevel() + 1)
if(overlay == true) then
f:SetFrameStrata("DIALOG")
else
f:SetFrameStrata("BACKGROUND")
end
E.CreatedMovers[name].mover = f
E["snapBars"][getn(E["snapBars"]) + 1] = f
local fs = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(fs)
fs:SetJustifyH("CENTER")
fs:SetPoint("CENTER", f)
fs:SetText(text or name)
fs:SetTextColor(unpack(E["media"].rgbvaluecolor))
f:SetFontString(fs)
f.text = fs
if E.db["movers"] and E.db["movers"][name] then
if type(E.db["movers"][name]) == "table" then
f:SetPoint(E.db["movers"][name]["p"], E.UIParent, E.db["movers"][name]["p2"], E.db["movers"][name]["p3"], E.db["movers"][name]["p4"])
E.db["movers"][name] = GetPoint(f)
f:ClearAllPoints()
end
local delim
local anchorString = E.db["movers"][name]
if find(anchorString, "\031") then
delim = "\031"
elseif find(anchorString, ",") then
delim = ","
end
local point, anchor, secondaryPoint, x, y = split(delim, anchorString)
f:SetPoint(point, anchor, secondaryPoint, x, y)
else
f:SetPoint(point, anchor, secondaryPoint, x, y)
end
local function OnDragStart(self)
if E.db["general"].stickyFrames then
Sticky:StartMoving(self, E["snapBars"], f.snapOffset, f.snapOffset, f.snapOffset, f.snapOffset)
else
self:StartMoving()
end
coordFrame.child = self
coordFrame:Show()
isDragging = true
end
local function OnDragStop(self)
isDragging = false
if E.db["general"].stickyFrames then
Sticky:StopMoving(self)
else
self:StopMovingOrSizing()
end
local x, y, point = E:CalculateMoverPoints(self)
self:ClearAllPoints()
local overridePoint
if(self.positionOverride) then
if(self.positionOverride == "BOTTOM" or self.positionOverride == "TOP") then
overridePoint = "BOTTOM"
else
overridePoint = "BOTTOMLEFT"
end
end
self:SetPoint(self.positionOverride or point, E.UIParent, overridePoint and overridePoint or point, x, y)
if(self.positionOverride) then
self.parent:ClearAllPoints()
self.parent:SetPoint(self.positionOverride, self, self.positionOverride)
end
E:SaveMoverPosition(name)
if ElvUIMoverNudgeWindow then
E:UpdateNudgeFrame(self, x, y)
end
coordFrame.child = nil
coordFrame:Hide()
if postdrag ~= nil and type(postdrag) == "function" then
postdrag(self, E:GetScreenQuadrant(self))
end
self:SetUserPlaced(false)
end
local function OnEnter()
if isDragging then return end
this.text:SetTextColor(1, 1, 1)
ElvUIMoverNudgeWindow:Show()
E.AssignFrameToNudge(this)
coordFrame.child = this
UpdateCoords(coordFrame)
--coordFrame:GetScript("OnUpdate")(coordFrame)
end
local function OnMouseDown(button)
if button == "RightButton" then
isDragging = false
if E.db["general"].stickyFrames then
Sticky:StopMoving(this)
else
this:StopMovingOrSizing()
end
if IsControlKeyDown() and this.textString then
E:ResetMovers(this.textString)
elseif IsShiftKeyDown() then
this:Hide()
end
end
end
local function OnLeave(self)
if isDragging then return end
this.text:SetTextColor(unpack(E["media"].rgbvaluecolor))
end
local function OnShow(self)
this:SetBackdropBorderColor(unpack(E["media"].rgbvaluecolor))
end
local function OnMouseWheel(_, delta)
if(IsShiftKeyDown()) then
E:NudgeMover(delta)
else
E:NudgeMover(nil, delta)
end
end
f:SetScript("OnDragStart", function() OnDragStart(f) end)
f:SetScript("OnMouseUp", E.AssignFrameToNudge)
f:SetScript("OnDragStop", function() OnDragStop(f) end)
f:SetScript("OnEnter", OnEnter)
f:SetScript("OnMouseDown", OnMouseDown)
f:SetScript("OnLeave", OnLeave)
f:SetScript("OnShow", OnShow)
f:SetScript("OnMouseWheel", OnMouseWheel)
parent:SetScript("OnSizeChanged", function() SizeChanged(parent) end)
parent.mover = f
parent:ClearAllPoints()
parent:SetPoint(point, f, 0, 0)
if postdrag ~= nil and type(postdrag) == "function" then
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function()
postdrag(f, E:GetScreenQuadrant(f))
this:UnregisterAllEvents()
end)
end
E.CreatedMovers[name].Created = true
end
function E:CalculateMoverPoints(mover, nudgeX, nudgeY)
local screenWidth, screenHeight, screenCenter = E.UIParent:GetRight(), E.UIParent:GetTop(), E.UIParent:GetCenter()
local x, y = mover:GetCenter()
local LEFT = screenWidth / 3
local RIGHT = screenWidth * 2 / 3
local TOP = screenHeight / 2
local point, nudgePoint, nudgeInversePoint
if(y >= TOP) then
point = "TOP"
nudgePoint = "TOP"
nudgeInversePoint = "BOTTOM"
y = -(screenHeight - mover:GetTop())
else
point = "BOTTOM"
nudgePoint = "BOTTOM"
nudgeInversePoint = "TOP"
y = mover:GetBottom()
end
if(x >= RIGHT) then
point = point .. "RIGHT"
nudgePoint = "RIGHT"
nudgeInversePoint = "LEFT"
x = mover:GetRight() - screenWidth
elseif(x <= LEFT) then
point = point .. "LEFT"
nudgePoint = "LEFT"
nudgeInversePoint = "RIGHT"
x = mover:GetLeft()
else
x = x - screenCenter
end
if(mover.positionOverride) then
if(mover.positionOverride == "TOPLEFT") then
x = mover:GetLeft() - E.diffGetLeft
y = mover:GetTop() - E.diffGetTop
elseif(mover.positionOverride == "TOPRIGHT") then
x = mover:GetRight() - E.diffGetRight
y = mover:GetTop() - E.diffGetTop
elseif(mover.positionOverride == "BOTTOMLEFT") then
x = mover:GetLeft() - E.diffGetLeft
y = mover:GetBottom() - E.diffGetBottom
elseif(mover.positionOverride == "BOTTOMRIGHT") then
x = mover:GetRight() - E.diffGetRight
y = mover:GetBottom() - E.diffGetBottom
elseif(mover.positionOverride == "BOTTOM") then
x = mover:GetCenter() - screenCenter
y = mover:GetBottom() - E.diffGetBottom
elseif(mover.positionOverride == "TOP") then
x = mover:GetCenter() - screenCenter
y = mover:GetTop() - E.diffGetTop
end
end
x = x + (nudgeX or 0)
y = y + (nudgeY or 0)
return x, y, point, nudgePoint, nudgeInversePoint
end
function E:UpdatePositionOverride(name)
if _G[name] and _G[name]:GetScript("OnDragStop") then
_G[name]:GetScript("OnDragStop")(_G[name])
end
end
function E:HasMoverBeenMoved(name)
if E.db["movers"] and E.db["movers"][name] then
return true
else
return false
end
end
function E:SaveMoverPosition(name)
if not _G[name] then return end
if not E.db.movers then E.db.movers = {} end
E.db.movers[name] = GetPoint(_G[name])
end
function E:SetMoverSnapOffset(name, offset)
if not _G[name] or not E.CreatedMovers[name] then return end
E.CreatedMovers[name].mover.snapOffset = offset or -2
E.CreatedMovers[name]["snapoffset"] = offset or -2
end
function E:SaveMoverDefaultPosition(name)
if not _G[name] then return end
E.CreatedMovers[name]["point"] = GetPoint(_G[name])
E.CreatedMovers[name]["postdrag"](_G[name], E:GetScreenQuadrant(_G[name]))
end
function E:CreateMover(parent, name, text, overlay, snapoffset, postdrag, moverTypes, shouldDisable)
if not moverTypes then moverTypes = "ALL,GENERAL" end
if E.CreatedMovers[name] == nil then
E.CreatedMovers[name] = {}
E.CreatedMovers[name]["parent"] = parent
E.CreatedMovers[name]["text"] = text
E.CreatedMovers[name]["overlay"] = overlay
E.CreatedMovers[name]["postdrag"] = postdrag
E.CreatedMovers[name]["snapoffset"] = snapoffset
E.CreatedMovers[name]["point"] = GetPoint(parent)
E.CreatedMovers[name]["shouldDisable"] = shouldDisable
E.CreatedMovers[name]["type"] = {}
local types = {split(",", moverTypes)}
for i = 1, getn(types) do
local moverType = types[i]
E.CreatedMovers[name]["type"][moverType] = true
end
end
CreateMover(parent, name, text, overlay, snapoffset, postdrag, shouldDisable)
end
function E:ToggleMovers(show, moverType)
self.configMode = show
for name, _ in pairs(E.CreatedMovers) do
if not show then
_G[name]:Hide()
else
if E.CreatedMovers[name]["type"][moverType] then
_G[name]:Show()
else
_G[name]:Hide()
end
end
end
end
function E:DisableMover(name)
if(self.DisabledMovers[name]) then return end
if(not self.CreatedMovers[name]) then
error("mover doesn't exist")
end
self.DisabledMovers[name] = {}
for x, y in pairs(self.CreatedMovers[name]) do
self.DisabledMovers[name][x] = y
end
if(self.configMode) then
_G[name]:Hide()
end
self.CreatedMovers[name] = nil
end
function E:EnableMover(name)
if(self.CreatedMovers[name]) then return end
if(not self.DisabledMovers[name]) then
error("mover doesn't exist")
end
self.CreatedMovers[name] = {}
for x, y in pairs(self.DisabledMovers[name]) do
self.CreatedMovers[name][x] = y
end
--Commented out, as it created an issue with trying to reset a mover after having used EnableMover on it. Not sure if this code is even needed anymore.
--[[
if(E.db["movers"] and E.db["movers"][name] and type(E.db["movers"][name]) == "string") then
self.CreatedMovers[name]["point"] = E.db["movers"][name]
end
]]
if(self.configMode) then
_G[name]:Show()
end
self.DisabledMovers[name] = nil
end
function E:ResetMovers(arg)
if arg == "" or arg == nil then
for name, _ in pairs(E.CreatedMovers) do
local f = _G[name]
local point, anchor, secondaryPoint, x, y = split(",", E.CreatedMovers[name]["point"])
f:ClearAllPoints()
f:SetPoint(point, anchor, secondaryPoint, x, y)
for key, value in pairs(E.CreatedMovers[name]) do
if key == "postdrag" and type(value) == "function" then
value(f, E:GetScreenQuadrant(f))
end
end
end
self.db.movers = nil
else
for name, _ in pairs(E.CreatedMovers) do
for key, value in pairs(E.CreatedMovers[name]) do
if key == "text" then
if arg == value then
local f = _G[name]
local point, anchor, secondaryPoint, x, y = split(",", E.CreatedMovers[name]["point"])
f:ClearAllPoints()
f:SetPoint(point, anchor, secondaryPoint, x, y)
if self.db.movers then
self.db.movers[name] = nil
end
if E.CreatedMovers[name]["postdrag"] ~= nil and type(E.CreatedMovers[name]["postdrag"]) == "function" then
E.CreatedMovers[name]["postdrag"](f, E:GetScreenQuadrant(f))
end
end
end
end
end
end
end
--Profile Change
function E:SetMoversPositions()
for name in pairs(E.DisabledMovers) do
local shouldDisable = ((E.DisabledMovers[name].shouldDisable and E.DisabledMovers[name]["shouldDisable"]()) or false)
if not shouldDisable then
E:EnableMover(name)
end
end
for name, _ in pairs(E.CreatedMovers) do
local f = _G[name]
local point, anchor, secondaryPoint, x, y
if E.db["movers"] and E.db["movers"][name] and type(E.db["movers"][name]) == "string" then
local delim
local anchorString = E.db["movers"][name]
if(find(anchorString, "\031")) then
delim = "\031"
elseif(find(anchorString, ",")) then
delim = ","
end
point, anchor, secondaryPoint, x, y = split(delim, anchorString)
f:ClearAllPoints()
f:SetPoint(point, anchor, secondaryPoint, x, y)
elseif f then
point, anchor, secondaryPoint, x, y = split(",", E.CreatedMovers[name]["point"])
f:ClearAllPoints()
f:SetPoint(point, anchor, secondaryPoint, x, y)
end
end
end
--Called from core.lua
function E:LoadMovers()
for n, _ in pairs(E.CreatedMovers) do
local p, t, o, so, pd
for key, value in pairs(E.CreatedMovers[n]) do
if key == "parent" then
p = value
elseif key == "text" then
t = value
elseif key == "overlay" then
o = value
elseif key == "snapoffset" then
so = value
elseif key == "postdrag" then
pd = value
end
end
CreateMover(p, n, t, o, so, pd)
end
end
+932
View File
@@ -0,0 +1,932 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local _G = _G
local pairs, type, unpack, assert = pairs, type, unpack, assert
local getn, tremove, tContains, tinsert, wipe = table.getn, tremove, tContains, tinsert, table.wipe
local lower = string.lower
--WoW API / Variables
local CreateFrame = CreateFrame
local UnitIsDeadOrGhost, InCinematic = UnitIsDeadOrGhost, InCinematic
local GetBindingFromClick, RunBinding = GetBindingFromClick, RunBinding
local PurchaseSlot, GetBankSlotCost = PurchaseSlot, GetBankSlotCost
local MoneyFrame_Update = MoneyFrame_Update
local SetCVar, DisableAddOn = SetCVar, DisableAddOn
local ReloadUI, PlaySound, StopMusic = ReloadUI, PlaySound, StopMusic
local StaticPopup_Resize = StaticPopup_Resize
E.PopupDialogs = {}
E.StaticPopup_DisplayedFrames = {}
E.PopupDialogs["ELVUI_UPDATE_AVAILABLE"] = {
text = L["ElvUI is five or more revisions out of date. You can download the newest version from https://github.com/ElvUI-Vanilla/ElvUI/"],
hasEditBox = 1,
OnShow = function()
this.editBox:SetAutoFocus(false)
this.editBox.width = this.editBox:GetWidth()
this.editBox:SetWidth(220)
this.editBox:SetText("https://github.com/ElvUI-Vanilla/ElvUI")
this.editBox:HighlightText()
-- ChatEdit_FocusActiveWindow()
end,
OnHide = function()
this.editBox:SetWidth(this.editBox.width or 50)
this.editBox.width = nil
end,
hideOnEscape = 1,
button1 = OKAY,
button2 = CLOSE, -- Temporary until further fix
OnAccept = E.noop,
EditBoxOnEnterPressed = function()
-- ChatEdit_FocusActiveWindow()
this:GetParent():Hide()
end,
EditBoxOnEscapePressed = function()
-- ChatEdit_FocusActiveWindow()
this:GetParent():Hide()
end,
EditBoxOnTextChanged = function()
if this:GetText() ~= "https://github.com/ElvUI-Vanilla/ElvUI" then
this:SetText("https://github.com/ElvUI-Vanilla/ElvUI")
end
this:HighlightText()
this:ClearFocus()
-- ChatEdit_FocusActiveWindow()
end,
OnEditFocusGained = function()
this:HighlightText()
end,
showAlert = 1
}
E.PopupDialogs["CLIQUE_ADVERT"] = {
text = L["Using the healer layout it is highly recommended you download the addon Clique if you wish to have the click-to-heal function."],
button1 = YES,
button2 = CLOSE, -- Temporary until further fix
OnAccept = E.noop,
showAlert = 1
}
E.PopupDialogs["CONFIRM_LOSE_BINDING_CHANGES"] = {
text = CONFIRM_LOSE_BINDING_CHANGES,
button1 = OKAY,
button2 = CANCEL,
OnAccept = function()
E:GetModule("ActionBars"):ChangeBindingProfile()
E:GetModule("ActionBars").bindingsChanged = nil
end,
OnCancel = function()
if ElvUIBindPopupWindowCheckButton:GetChecked() then
ElvUIBindPopupWindowCheckButton:SetChecked()
else
ElvUIBindPopupWindowCheckButton:SetChecked(1)
end
end,
timeout = 0,
whileDead = 1,
showAlert = 1
}
E.PopupDialogs["TUKUI_ELVUI_INCOMPATIBLE"] = {
text = L["Oh lord, you have got ElvUI and Tukui both enabled at the same time. Select an addon to disable."],
OnAccept = function() DisableAddOn("ElvUI") ReloadUI() end,
OnCancel = function() DisableAddOn("Tukui") ReloadUI() end,
button1 = "ElvUI",
button2 = "Tukui",
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["DISABLE_INCOMPATIBLE_ADDON"] = {
text = L["Do you swear not to post in technical support about something not working without first disabling the addon/module combination first?"],
OnAccept = function() E.global.ignoreIncompatible = true end,
OnCancel = function() E:StaticPopup_Hide("DISABLE_INCOMPATIBLE_ADDON") E:StaticPopup_Show("INCOMPATIBLE_ADDON", E.PopupDialogs["INCOMPATIBLE_ADDON"].addon, E.PopupDialogs["INCOMPATIBLE_ADDON"].module) end,
button1 = L["I Swear"],
button2 = DECLINE,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["INCOMPATIBLE_ADDON"] = {
text = L["INCOMPATIBLE_ADDON"],
OnAccept = function() DisableAddOn(E.PopupDialogs["INCOMPATIBLE_ADDON"].addon) ReloadUI() end,
OnCancel = function() E.private[lower(E.PopupDialogs["INCOMPATIBLE_ADDON"].module)].enable = false ReloadUI() end,
button3 = L["Disable Warning"],
OnAlt = function ()
E:StaticPopup_Hide("INCOMPATIBLE_ADDON")
E:StaticPopup_Show("DISABLE_INCOMPATIBLE_ADDON")
end,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["PIXELPERFECT_CHANGED"] = {
text = L["You have changed the Thin Border Theme option. You will have to complete the installation process to remove any graphical bugs."],
button1 = ACCEPT,
button2 = CLOSE, -- Temporary until further fix
OnAccept = E.noop,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["CONFIGAURA_SET"] = {
text = L["Because of the mass confusion caused by the new aura system I've implemented a new step to the installation process. This is optional. If you like how your auras are setup go to the last step and click finished to not be prompted again. If for some reason you are prompted repeatedly please restart your game."],
button1 = ACCEPT,
button2 = CLOSE, -- Temporary until further fix
OnAccept = E.noop,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["QUEUE_TAINT"] = {
text = L["You have changed your UIScale, however you still have the AutoScale option enabled in ElvUI. Press accept if you would like to disable the Auto Scale option."],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = ReloadUI,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["FAILED_UISCALE"] = {
text = L["You have changed your UIScale, however you still have the AutoScale option enabled in ElvUI. Press accept if you would like to disable the Auto Scale option."],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function() E.global.general.autoScale = false ReloadUI() end,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["CONFIG_RL"] = {
text = L["One or more of the changes you have made require a ReloadUI."],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = ReloadUI,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["GLOBAL_RL"] = {
text = L["One or more of the changes you have made will effect all characters using this addon. You will have to reload the user interface to see the changes you have made."],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = ReloadUI,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["PRIVATE_RL"] = {
text = L["A setting you have changed will change an option for this character only. This setting that you have changed will be uneffected by changing user profiles. Changing this setting requires that you reload your User Interface."],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = ReloadUI,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["KEYBIND_MODE"] = {
text = L["Hover your mouse over any actionbutton or spellbook button to bind it. Press the escape key or right click to clear the current actionbutton's keybinding."],
button1 = L["Save"],
button2 = L["Discard"],
OnAccept = function() E:GetModule("ActionBars"):DeactivateBindMode(true) end,
OnCancel = function() E:GetModule("ActionBars"):DeactivateBindMode(false) end,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
E.PopupDialogs["DELETE_GRAYS"] = {
text = L["Are you sure you want to delete all your gray items?"],
button1 = YES,
button2 = NO,
OnAccept = function() E:GetModule("Bags"):VendorGrays(true) end,
OnShow = function()
MoneyFrame_Update(this:GetName().."MoneyFrame", E.PopupDialogs["DELETE_GRAYS"].Money)
end,
timeout = 0,
whileDead = 1,
hideOnEscape = false,
hasMoneyFrame = 1
}
E.PopupDialogs["BUY_BANK_SLOT"] = {
text = CONFIRM_BUY_BANK_SLOT,
button1 = YES,
button2 = NO,
OnAccept = PurchaseSlot,
OnShow = function()
MoneyFrame_Update(this:GetName().."MoneyFrame", GetBankSlotCost())
end,
hasMoneyFrame = 1,
timeout = 0,
hideOnEscape = 1
}
E.PopupDialogs["CANNOT_BUY_BANK_SLOT"] = {
text = L["Can't buy anymore slots!"],
button1 = ACCEPT,
button2 = CLOSE, -- Temporary until further fix
timeout = 0,
whileDead = 1
}
E.PopupDialogs["NO_BANK_BAGS"] = {
text = L["You must purchase a bank slot first!"],
button1 = ACCEPT,
button2 = CLOSE, -- Temporary until further fix
timeout = 0,
whileDead = 1
}
E.PopupDialogs["RESETUI_CHECK"] = {
text = L["Are you sure you want to reset every mover back to it's default position?"],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function()
E:ResetAllUI()
end,
timeout = 0,
whileDead = 1
}
E.PopupDialogs["HARLEM_SHAKE"] = {
text = L["ElvUI needs to perform database optimizations please be patient."],
button1 = OKAY,
button2 = CLOSE, -- Temporary until further fix
OnAccept = function()
if E.isMassiveShaking then
E:StopHarlemShake()
else
E:BeginHarlemShake()
return true
end
end,
timeout = 0,
whileDead = 1
}
E.PopupDialogs["HELLO_KITTY"] = {
text = L["ElvUI needs to perform database optimizations please be patient."],
button1 = OKAY,
button2 = CLOSE, -- Temporary until further fix
OnAccept = function()
E:SetupHelloKitty()
end,
timeout = 0,
whileDead = 1
}
E.PopupDialogs["HELLO_KITTY_END"] = {
text = L["Do you enjoy the new ElvUI?"],
button1 = L["Yes, Keep Changes!"],
button2 = L["No, Revert Changes!"],
OnAccept = function()
E:Print(L["Type /hellokitty to revert to old settings."])
StopMusic()
SetCVar("Sound_EnableAllSound", E.oldEnableAllSound)
SetCVar("Sound_EnableMusic", E.oldEnableMusic)
end,
OnCancel = function()
E:RestoreHelloKitty()
StopMusic()
SetCVar("Sound_EnableAllSound", E.oldEnableAllSound)
SetCVar("Sound_EnableMusic", E.oldEnableMusic)
end,
timeout = 0,
whileDead = 1
}
E.PopupDialogs["DISBAND_RAID"] = {
text = L["Are you sure you want to disband the group?"],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function() E:GetModule("Misc"):DisbandRaidGroup() end,
timeout = 0,
whileDead = 1
}
E.PopupDialogs["CONFIRM_LOOT_DISTRIBUTION"] = {
text = CONFIRM_LOOT_DISTRIBUTION,
button1 = YES,
button2 = NO,
timeout = 0,
hideOnEscape = 1
}
E.PopupDialogs["RESET_PROFILE_PROMPT"] = {
text = L["Are you sure you want to reset all the settings on this profile?"],
button1 = YES,
button2 = NO,
timeout = 0,
hideOnEscape = 1,
OnAccept = function() E:ResetProfile() end
}
E.PopupDialogs["APPLY_FONT_WARNING"] = {
text = L["Are you sure you want to apply this font to all ElvUI elements?"],
OnAccept = function()
local font = E.db.general.font
local fontSize = E.db.general.fontSize
E.db.bags.itemLevelFont = font
E.db.bags.itemLevelFontSize = fontSize
E.db.bags.countFont = font
E.db.bags.countFontSize = fontSize
E.db.nameplates.font = font
E.db.nameplates.fontSize = fontSize
E.db.actionbar.font = font
E.db.actionbar.fontSize = fontSize
E.db.auras.font = font
E.db.auras.fontSize = fontSize
E.db.chat.font = font
E.db.chat.fontSize = fontSize
E.db.chat.tabFont = font
E.db.chat.tapFontSize = fontSize
E.db.datatexts.font = font
E.db.datatexts.fontSize = fontSize
E.db.tooltip.font = font
E.db.tooltip.fontSize = fontSize
E.db.tooltip.headerFontSize = fontSize
E.db.tooltip.textFontSize = fontSize
E.db.tooltip.smallTextFontSize = fontSize
E.db.tooltip.healthBar.font = font
E.db.tooltip.healthBar.fontSize = fontSize
E.db.unitframe.font = font
E.db.unitframe.fontSize = fontSize
E.db.unitframe.units.party.rdebuffs.font = font
E.db.unitframe.units.raid.rdebuffs.font = font
E.db.unitframe.units.raid40.rdebuffs.font = font
E:UpdateAll(true)
end,
OnCancel = function() E:StaticPopup_Hide("APPLY_FONT_WARNING") end,
button1 = YES,
button2 = CANCEL,
timeout = 0,
whileDead = 1,
hideOnEscape = false
}
local MAX_STATIC_POPUPS = 4
function E:StaticPopup_OnShow()
PlaySound("igMainMenuOpen")
local dialog = E.PopupDialogs[this.which]
local OnShow = dialog.OnShow
if OnShow then
OnShow(this.data)
end
if dialog.enterClicksFirstButton then
this:SetScript("OnKeyDown", E.StaticPopup_OnKeyDown)
end
end
function E:StaticPopup_EscapePressed()
local closed = nil
for _, frame in pairs(E.StaticPopup_DisplayedFrames) do
if frame:IsShown() and frame.hideOnEscape then
local standardDialog = E.PopupDialogs[frame.which]
if standardDialog then
local OnCancel = standardDialog.OnCancel
local noCancelOnEscape = standardDialog.noCancelOnEscape
if OnCancel and not noCancelOnEscape then
OnCancel(frame, frame.data, "clicked")
end
frame:Hide()
else
E:StaticPopupSpecial_Hide(frame)
end
closed = 1
end
end
return closed
end
function E:StaticPopupSpecial_Hide(frame)
frame:Hide()
E:StaticPopup_CollapseTable()
end
function E:StaticPopup_CollapseTable()
local displayedFrames = E.StaticPopup_DisplayedFrames
local index = getn(displayedFrames)
while((index >= 1) and (not displayedFrames[index]:IsShown())) do
tremove(displayedFrames, index)
index = index - 1
end
end
function E:StaticPopup_SetUpPosition(dialog)
if not tContains(E.StaticPopup_DisplayedFrames, dialog) then
local lastFrame = E.StaticPopup_DisplayedFrames[getn(E.StaticPopup_DisplayedFrames)]
if lastFrame then
dialog:SetPoint("TOP", lastFrame, "BOTTOM", 0, -4)
else
dialog:SetPoint("TOP", E.UIParent, "TOP", 0, -100)
end
tinsert(E.StaticPopup_DisplayedFrames, dialog)
end
end
function E:StaticPopupSpecial_Show(frame)
if frame.exclusive then
E:StaticPopup_HideExclusive()
end
E:StaticPopup_SetUpPosition(frame)
frame:Show()
end
function E:StaticPopupSpecial_Hide(frame)
frame:Hide()
E:StaticPopup_CollapseTable()
end
function E:StaticPopup_IsLastDisplayedFrame(frame)
for i = getn(E.StaticPopup_DisplayedFrames), 1, -1 do
local popup = E.StaticPopup_DisplayedFrames[i]
if popup:IsShown() then
return frame == popup
end
end
return false
end
function E:StaticPopup_OnKeyDown(key)
if GetBindingFromClick(key) == "TOGGLEGAMEMENU" then
return E:StaticPopup_EscapePressed()
elseif GetBindingFromClick(key) == "SCREENSHOT" then
RunBinding("SCREENSHOT")
return
end
local dialog = E.PopupDialogs[this.which]
if dialog then
if arg1 == "ENTER" and dialog.enterClicksFirstButton then
local frameName = this:GetName()
local button
local i = 1
while true do
button = _G[frameName.."Button"..i]
if button then
if button:IsShown() then
E:StaticPopup_OnClick(this, i)
return
end
i = i + 1
else
break
end
end
end
end
end
function E:StaticPopup_OnHide()
PlaySound("igMainMenuClose")
E:StaticPopup_CollapseTable()
local dialog = E.PopupDialogs[this.which]
local OnHide = dialog.OnHide
if OnHide then
OnHide(this.data)
end
if dialog.enterClicksFirstButton then
this:SetScript("OnKeyDown", nil)
end
end
function E:StaticPopup_OnUpdate()
if this.timeleft and this.timeleft > 0 then
local which = this.which
local timeleft = this.timeleft - arg1
if timeleft <= 0 then
if not E.PopupDialogs[which].timeoutInformationalOnly then
this.timeleft = 0
local OnCancel = E.PopupDialogs[which].OnCancel
if OnCancel then
OnCancel(this.data, "timeout")
end
this:Hide()
end
return
end
this.timeleft = timeleft
end
if this.startDelay then
local which = this.which
local timeleft = this.startDelay - arg1
if timeleft <= 0 then
this.startDelay = nil
local text = _G[this:GetName().."Text"]
text:SetText(format(E.PopupDialogs[which].text, text.text_arg1, text.text_arg2))
local button1 = _G[this:GetName().."Button1"]
button1:Enable()
StaticPopup_Resize(this, which)
return
end
this.startDelay = timeleft
end
local onUpdate = E.PopupDialogs[this.which].OnUpdate
if onUpdate then
onUpdate(arg1, this)
end
end
function E:StaticPopup_OnClick(index)
if not self:IsShown() then
return
end
local which = self.which
local info = E.PopupDialogs[which]
if not info then
return nil
end
local hide = true
if index == 1 then
local OnAccept = info.OnAccept
if OnAccept then
hide = not OnAccept(self, self.data, self.data2)
end
elseif index == 3 then
local OnAlt = info.OnAlt
if OnAlt then
OnAlt(self, self.data, "clicked")
end
else
local OnCancel = info.OnCancel
if OnCancel then
hide = not OnCancel(self, self.data, "clicked")
end
end
if hide and (which == self.which) and (index ~= 3 or not info.noCloseOnAlt) then
self:Hide()
end
end
function E:StaticPopup_EditBoxOnEnterPressed()
local EditBoxOnEnterPressed, which, dialog
local parent = this:GetParent()
if parent.which then
which = parent.which
dialog = parent
elseif parent:GetParent().which then
which = parent:GetParent().which
dialog = parent:GetParent()
end
EditBoxOnEnterPressed = E.PopupDialogs[which].EditBoxOnEnterPressed
if EditBoxOnEnterPressed then
EditBoxOnEnterPressed(this, dialog.data)
end
end
function E:StaticPopup_EditBoxOnEscapePressed()
local EditBoxOnEscapePressed = E.PopupDialogs[this:GetParent().which].EditBoxOnEscapePressed
if EditBoxOnEscapePressed then
EditBoxOnEscapePressed(this, this:GetParent().data)
end
end
function E:StaticPopup_EditBoxOnTextChanged(userInput)
local EditBoxOnTextChanged = E.PopupDialogs[this:GetParent().which].EditBoxOnTextChanged
if EditBoxOnTextChanged then
EditBoxOnTextChanged(this, this:GetParent().data)
end
end
function E:StaticPopup_FindVisible(which, data)
local info = E.PopupDialogs[which]
if not info then
return nil
end
for index = 1, MAX_STATIC_POPUPS, 1 do
local frame = _G["ElvUI_StaticPopup"..index]
if (frame:IsShown() and (frame.which == which) and (not info.multiple or (frame.data == data))) then
return frame
end
end
return nil
end
function E:StaticPopup_Resize(dialog, which)
local info = E.PopupDialogs[which]
if not info then
return nil
end
local name = dialog:GetName()
local text = _G[name.."Text"]
local editBox = _G[name.."EditBox"]
local button1 = _G[name.."Button1"]
local maxHeightSoFar, maxWidthSoFar = (dialog.maxHeightSoFar or 0), (dialog.maxWidthSoFar or 0)
local width = 320
if dialog.numButtons == 3 then
width = 440
elseif info.showAlert or info.showAlertGear or info.closeButton then
width = 420
elseif info.editBoxWidth and info.editBoxWidth > 260 then
width = width + (info.editBoxWidth - 260)
end
if width > maxWidthSoFar then
dialog:SetWidth(width)
dialog.maxWidthSoFar = width
end
local height = 32 + text:GetHeight() + 8 + button1:GetHeight()
if info.hasEditBox then
height = height + 8 + editBox:GetHeight()
elseif info.hasMoneyFrame then
height = height + 16
end
if height > maxHeightSoFar then
dialog:SetHeight(height)
dialog.maxHeightSoFar = height
end
end
function E:StaticPopup_OnEvent()
self.maxHeightSoFar = 0
E:StaticPopup_Resize(self, self.which)
end
local tempButtonLocs = {}
function E:StaticPopup_Show(which, text_arg1, text_arg2, data)
local info = E.PopupDialogs[which]
if not info then
return nil
end
if UnitIsDeadOrGhost("player") and not info.whileDead then
if info.OnCancel then
info.OnCancel()
end
return nil
end
if InCinematic() and not info.interruptCinematic then
if info.OnCancel then
info.OnCancel()
end
return nil
end
if info.cancels then
for index = 1, MAX_STATIC_POPUPS, 1 do
local frame = _G["ElvUI_StaticPopup"..index]
if (frame:IsShown() and (frame.which == info.cancels)) then
frame:Hide()
local OnCancel = E.PopupDialogs[frame.which].OnCancel
if OnCancel then
OnCancel(frame, frame.data, "override")
end
end
end
end
local dialog = nil
dialog = E:StaticPopup_FindVisible(which, data)
if dialog then
if not info.noCancelOnReuse then
local OnCancel = info.OnCancel
if OnCancel then
OnCancel(dialog, dialog.data, "override")
end
end
dialog:Hide()
end
if not dialog then
local index = 1
if info.preferredIndex then
index = info.preferredIndex
end
for i = index, MAX_STATIC_POPUPS do
local frame = _G["ElvUI_StaticPopup"..i]
if not frame:IsShown() then
dialog = frame
break
end
end
if not dialog and info.preferredIndex then
for i = 1, info.preferredIndex do
local frame = _G["ElvUI_StaticPopup"..i]
if not frame:IsShown() then
dialog = frame
break
end
end
end
end
if not dialog then
if info.OnCancel then
info.OnCancel()
end
return nil
end
dialog.maxHeightSoFar, dialog.maxWidthSoFar = 0, 0
local name = dialog:GetName()
local text = _G[name.."Text"]
text:SetText(format(info.text, text_arg1, text_arg2))
if info.closeButton then
local closeButton = _G[name.."CloseButton"]
if info.closeButtonIsHide then
closeButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-HideButton-Up")
closeButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-HideButton-Down")
else
closeButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up")
closeButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down")
end
closeButton:Show()
else
_G[name.."CloseButton"]:Hide()
end
local editBox = _G[name.."EditBox"]
if info.hasEditBox then
editBox:Show()
if info.maxLetters then
editBox:SetMaxLetters(info.maxLetters)
end
if info.maxBytes then
editBox:SetMaxBytes(info.maxBytes)
end
editBox:SetText("")
if info.editBoxWidth then
editBox:SetWidth(info.editBoxWidth)
else
editBox:SetWidth(130)
end
else
editBox:Hide()
end
if info.hasMoneyFrame then
_G[name.."MoneyFrame"]:Show()
else
_G[name.."MoneyFrame"]:Hide()
end
dialog.which = which
dialog.timeleft = info.timeout
dialog.hideOnEscape = info.hideOnEscape
dialog.exclusive = info.exclusive
dialog.enterClicksFirstButton = info.enterClicksFirstButton
dialog.data = data
local button1 = _G[name.."Button1"]
local button2 = _G[name.."Button2"]
do
assert(getn(tempButtonLocs) == 0)
tinsert(tempButtonLocs, button1)
tinsert(tempButtonLocs, button2)
for i = getn(tempButtonLocs), 1, -1 do
tempButtonLocs[i]:SetText(info["button"..i])
tempButtonLocs[i]:Hide()
tempButtonLocs[i]:ClearAllPoints()
if not (info["button"..i] and (not info["DisplayButton"..i] or info["DisplayButton"..i](dialog))) then
tremove(tempButtonLocs, i)
end
end
local numButtons = getn(tempButtonLocs)
dialog.numButtons = numButtons
if numButtons == 2 then
tempButtonLocs[1]:SetPoint("BOTTOMRIGHT", dialog, "BOTTOM", -6, 16)
elseif numButtons == 1 then
tempButtonLocs[1]:SetPoint("BOTTOM", dialog, "BOTTOM", 0, 16)
end
for i = 1, numButtons do
if i > 1 then
tempButtonLocs[i]:SetPoint("LEFT", tempButtonLocs[i-1], "RIGHT", 13, 0)
end
local width = tempButtonLocs[i]:GetTextWidth()
if width > 110 then
tempButtonLocs[i]:SetWidth(width + 20)
else
tempButtonLocs[i]:SetWidth(120)
end
tempButtonLocs[i]:Enable()
tempButtonLocs[i]:Show()
end
wipe(tempButtonLocs)
table.setn(tempButtonLocs, 0)
end
local alertIcon = _G[name.."AlertIcon"]
if info.showAlert then
alertIcon:SetTexture("Interface\\DialogFrame\\DialogAlertIcon")
alertIcon:SetPoint("LEFT", 24, 0)
alertIcon:Show()
elseif info.showAlertGear then
alertIcon:SetTexture("Interface\\DialogFrame\\DialogAlertIcon")
alertIcon:SetPoint("LEFT", 24, 0)
alertIcon:Show()
else
alertIcon:SetTexture()
alertIcon:Hide()
end
if info.StartDelay then
dialog.startDelay = info.StartDelay()
button1:Disable()
else
dialog.startDelay = nil
button1:Enable()
end
E:StaticPopup_SetUpPosition(dialog)
dialog:Show()
E:StaticPopup_Resize(dialog, which)
if info.sound then
PlaySound(info.sound)
end
return dialog
end
function E:StaticPopup_Hide(which, data)
for index = 1, MAX_STATIC_POPUPS, 1 do
local dialog = _G["ElvUI_StaticPopup"..index]
if ((dialog.which == which) and (not data or (data == dialog.data))) then
dialog:Hide()
end
end
end
function E:Contruct_StaticPopups()
E.StaticPopupFrames = {}
local S = self:GetModule("Skins")
for index = 1, MAX_STATIC_POPUPS do
E.StaticPopupFrames[index] = CreateFrame("Frame", "ElvUI_StaticPopup"..index, E.UIParent, "StaticPopupTemplate")
E.StaticPopupFrames[index]:SetID(index)
E.StaticPopupFrames[index]:SetScript("OnShow", E.StaticPopup_OnShow)
E.StaticPopupFrames[index]:SetScript("OnHide", E.StaticPopup_OnHide)
E.StaticPopupFrames[index]:SetScript("OnUpdate", E.StaticPopup_OnUpdate)
E.StaticPopupFrames[index]:SetScript("OnEvent", E.StaticPopup_OnEvent)
local name = E.StaticPopupFrames[index]:GetName()
for i = 1, 2 do
local button = _G[name.."Button"..i]
S:HandleButton(button)
button:SetScript("OnClick", function()
E.StaticPopup_OnClick(this:GetParent(), this:GetID())
end)
E.StaticPopupFrames[index]["button"..i] = button
end
_G[name.."EditBox"]:SetScript("OnEnterPressed", E.StaticPopup_EditBoxOnEnterPressed)
_G[name.."EditBox"]:SetScript("OnEscapePressed", E.StaticPopup_EditBoxOnEscapePressed)
_G[name.."EditBox"]:SetScript("OnTextChanged", E.StaticPopup_EditBoxOnTextChanged)
E:SetTemplate(E.StaticPopupFrames[index], "Transparent")
E.StaticPopupFrames[index].text = _G[name.."Text"]
E.StaticPopupFrames[index].editBox = _G[name.."EditBox"]
_G[name.."EditBox"]:DisableDrawLayer("BACKGROUND")
S:HandleEditBox(_G[name.."EditBox"])
S:HandleEditBox(_G[name.."MoneyInputFrameGold"])
S:HandleEditBox(_G[name.."MoneyInputFrameSilver"])
S:HandleEditBox(_G[name.."MoneyInputFrameCopper"])
_G[name.."EditBox"].backdrop:SetPoint("TOPLEFT", -2, -4)
_G[name.."EditBox"].backdrop:SetPoint("BOTTOMRIGHT", 2, 4)
end
E:SecureHook("StaticPopup_Resize", "StaticPopup_SetUpPosition")
E:SecureHook("StaticPopup_OnHide", "StaticPopup_CollapseTable")
end
+1146
View File
File diff suppressed because it is too large Load Diff
+549
View File
@@ -0,0 +1,549 @@
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 LibCompress = LibStub:GetLibrary("LibCompress");
local LibBase64 = LibStub("LibBase64-1.0");
--Cache global variables
--Lua functions
local tonumber, type, pcall, loadstring = tonumber, type, pcall, loadstring
local len, format, split, find = string.len, string.format, string.split, string.find
--WoW API / Variables
local CreateFrame = CreateFrame
local GetNumRaidMembers, UnitInRaid = GetNumRaidMembers, UnitInRaid
local GetNumPartyMembers, UnitInParty = GetNumPartyMembers, UnitInParty
local ACCEPT, CANCEL, YES, NO = ACCEPT, CANCEL, YES, NO
----------------------------------
-- CONSTANTS
----------------------------------
local REQUEST_PREFIX = "ELVUI_REQUEST"
local REPLY_PREFIX = "ELVUI_REPLY"
local TRANSFER_PREFIX = "ELVUI_TRANSFER"
local TRANSFER_COMPLETE_PREFIX = "ELVUI_COMPLETE"
-- The active downloads
local Downloads = {}
local Uploads = {}
function D:Initialize()
self:RegisterComm(REQUEST_PREFIX)
self:RegisterEvent("CHAT_MSG_ADDON")
self.statusBar = CreateFrame("StatusBar", "ElvUI_Download", UIParent)
E:RegisterStatusBar(self.statusBar)
E:CreateBackdrop(self.statusBar, "Default")
self.statusBar:SetStatusBarTexture(E.media.normTex)
self.statusBar:SetStatusBarColor(0.95, 0.15, 0.15)
self.statusBar:SetWidth(250)
self.statusBar:SetWidth(18)
self.statusBar.text = self.statusBar:CreateFontString(nil, "OVERLAY")
E:FontTemplate(self.statusBar.text)
self.statusBar.text:SetPoint("CENTER", 0, 0)
self.statusBar:Hide()
end
-- Used to start uploads
function D:Distribute(target, otherServer, isGlobal)
local profileKey, data
if not isGlobal then
if ElvDB.profileKeys then
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm]
end
data = ElvDB.profiles[profileKey]
else
profileKey = "global"
data = ElvDB.global
end
if not data or not profileKey then return end
local serialData = self:Serialize(data)
local length = len(serialData)
local message = format("%s:%d:%s", profileKey, length, target)
Uploads[profileKey] = {
serialData = serialData,
target = target,
}
if otherServer then
local numParty, numRaid = GetNumPartyMembers(), GetNumRaidMembers()
if numRaid > 0 and UnitInRaid("target") then
self:SendCommMessage(REQUEST_PREFIX, message, "RAID")
elseif numParty > 0 and UnitInParty("target") then
self:SendCommMessage(REQUEST_PREFIX, message, "PARTY")
else
E:Print(L["Must be in group with the player if he isn't on the same server as you."])
return
end
else
self:SendCommMessage(REQUEST_PREFIX, message, "WHISPER", target)
end
self:RegisterComm(REPLY_PREFIX)
E:StaticPopup_Show("DISTRIBUTOR_WAITING")
end
function D:CHAT_MSG_ADDON(_, _, message, _, sender)
if not Downloads[sender] then return end
local cur = len(message)
local max = Downloads[sender].length
Downloads[sender].current = Downloads[sender].current + cur
if Downloads[sender].current > max then
Downloads[sender].current = max
end
self.statusBar:SetValue(Downloads[sender].current)
end
function D:OnCommReceived(prefix, msg, dist, sender)
if prefix == REQUEST_PREFIX then
local profile, length, sendTo = split(":", msg)
if dist ~= "WHISPER" and sendTo ~= E.myname then
return
end
if self.statusBar:IsShown() then
self:SendCommMessage(REPLY_PREFIX, profile..":NO", dist, sender)
return
end
local textString = format(L["%s is attempting to share the profile %s with you. Would you like to accept the request?"], sender, profile)
if profile == "global" then
textString = format(L["%s is attempting to share his filters with you. Would you like to accept the request?"], sender)
end
E.PopupDialogs["DISTRIBUTOR_RESPONSE"] = {
text = textString,
OnAccept = function()
self.statusBar:SetMinMaxValues(0, length)
self.statusBar:SetValue(0)
self.statusBar.text:SetFormattedText(L["Data From: %s"], sender)
E:StaticPopupSpecial_Show(self.statusBar)
self:SendCommMessage(REPLY_PREFIX, profile..":YES", dist, sender)
end,
OnCancel = function()
self:SendCommMessage(REPLY_PREFIX, profile..":NO", dist, sender)
end,
button1 = ACCEPT,
button2 = CANCEL,
timeout = 32,
whileDead = 1,
hideOnEscape = 1,
}
E:StaticPopup_Show("DISTRIBUTOR_RESPONSE")
Downloads[sender] = {
current = 0,
length = tonumber(length),
profile = profile,
}
self:RegisterComm(TRANSFER_PREFIX)
elseif prefix == REPLY_PREFIX then
self:UnregisterComm(REPLY_PREFIX)
E:StaticPopup_Hide("DISTRIBUTOR_WAITING")
local profileKey, response = split(":", msg)
if response == "YES" then
self:RegisterComm(TRANSFER_COMPLETE_PREFIX)
self:SendCommMessage(TRANSFER_PREFIX, Uploads[profileKey].serialData, dist, Uploads[profileKey].target)
Uploads[profileKey] = nil
else
E:StaticPopup_Show("DISTRIBUTOR_REQUEST_DENIED")
Uploads[profileKey] = nil
end
elseif prefix == TRANSFER_PREFIX then
self:UnregisterComm(TRANSFER_PREFIX)
E:StaticPopupSpecial_Hide(self.statusBar)
local profileKey = Downloads[sender].profile
local success, data = self:Deserialize(msg)
if success then
local textString = format(L["Profile download complete from %s, would you like to load the profile %s now?"], sender, profileKey)
if profileKey == "global" then
textString = format(L["Filter download complete from %s, would you like to apply changes now?"], sender)
else
if not ElvDB.profiles[profileKey] then
ElvDB.profiles[profileKey] = data
else
textString = format(L["Profile download complete from %s, but the profile %s already exists. Change the name or else it will overwrite the existing profile."], sender, profileKey)
E.PopupDialogs["DISTRIBUTOR_CONFIRM"] = {
text = textString,
button1 = ACCEPT,
hasEditBox = 1,
editBoxWidth = 350,
maxLetters = 127,
OnAccept = function(self)
ElvDB.profiles[self.editBox:GetText()] = data
LibStub("AceAddon-3.0"):GetAddon("ElvUI").data:SetProfile(self.editBox:GetText())
E:UpdateAll(true)
Downloads[sender] = nil
end,
OnShow = function(self) self.editBox:SetText(profileKey) self.editBox:SetFocus() end,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1,
preferredIndex = 3
}
E:StaticPopup_Show("DISTRIBUTOR_CONFIRM")
self:SendCommMessage(TRANSFER_COMPLETE_PREFIX, "COMPLETE", dist, sender)
return
end
end
E.PopupDialogs["DISTRIBUTOR_CONFIRM"] = {
text = textString,
OnAccept = function()
if profileKey == "global" then
E:CopyTable(ElvDB.global, data)
E:UpdateAll(true)
else
LibStub("AceAddon-3.0"):GetAddon("ElvUI").data:SetProfile(profileKey)
end
Downloads[sender] = nil
end,
OnCancel = function()
Downloads[sender] = nil
end,
button1 = YES,
button2 = NO,
whileDead = 1,
hideOnEscape = 1,
}
E:StaticPopup_Show("DISTRIBUTOR_CONFIRM")
self:SendCommMessage(TRANSFER_COMPLETE_PREFIX, "COMPLETE", dist, sender)
else
E:StaticPopup_Show("DISTRIBUTOR_FAILED")
self:SendCommMessage(TRANSFER_COMPLETE_PREFIX, "FAILED", dist, sender)
end
elseif prefix == TRANSFER_COMPLETE_PREFIX then
self:UnregisterComm(TRANSFER_COMPLETE_PREFIX)
if msg == "COMPLETE" then
E:StaticPopup_Show("DISTRIBUTOR_SUCCESS")
else
E:StaticPopup_Show("DISTRIBUTOR_FAILED")
end
end
end
local function GetProfileData(profileType)
if not profileType or type(profileType) ~= "string" then
E:Print("Bad argument #1 to 'GetProfileData' (string expected)")
return
end
local profileKey
local profileData = {}
if profileType == "profile" then
if ElvDB.profileKeys then
profileKey = ElvDB.profileKeys[E.myname.." - "..E.myrealm]
end
profileData = E:CopyTable(profileData , ElvDB.profiles[profileKey])
profileData = E:RemoveTableDuplicates(profileData, P)
elseif profileType == "private" then
local privateProfileKey = E.myname.." - "..E.myrealm
profileKey = "private"
profileData = E:CopyTable(profileData, ElvPrivateDB.profiles[privateProfileKey])
profileData = E:RemoveTableDuplicates(profileData, V)
elseif profileType == "global" then
profileKey = "global"
profileData = E:CopyTable(profileData, ElvDB.global)
profileData = E:RemoveTableDuplicates(profileData, G)
elseif profileType == "filtersNP" then
profileKey = "filtersNP"
profileData["nameplates"] = {}
profileData["nameplates"]["filter"] = {}
profileData["nameplates"]["filter"] = E:CopyTable(profileData["nameplates"]["filter"], ElvDB.global.nameplates.filter)
profileData = E:RemoveTableDuplicates(profileData, G)
elseif profileType == "filtersUF" then
profileKey = "filtersUF"
profileData["unitframe"] = {}
profileData["unitframe"]["aurafilters"] = {}
profileData["unitframe"]["aurafilters"] = E:CopyTable(profileData["unitframe"]["aurafilters"], ElvDB.global.unitframe.aurafilters)
profileData["unitframe"]["buffwatch"] = {}
profileData["unitframe"]["buffwatch"] = E:CopyTable(profileData["unitframe"]["buffwatch"], ElvDB.global.unitframe.buffwatch)
profileData = E:RemoveTableDuplicates(profileData, G)
elseif profileType == "filtersAll" then
profileKey = "filtersAll"
profileData["nameplates"] = {}
profileData["nameplates"]["filter"] = {}
profileData["nameplates"]["filter"] = E:CopyTable(profileData["nameplates"]["filter"], ElvDB.global.nameplates.filter)
profileData["unitframe"] = {}
profileData["unitframe"]["aurafilters"] = {}
profileData["unitframe"]["aurafilters"] = E:CopyTable(profileData["unitframe"]["aurafilters"], ElvDB.global.unitframe.aurafilters)
profileData["unitframe"]["buffwatch"] = {}
profileData["unitframe"]["buffwatch"] = E:CopyTable(profileData["unitframe"]["buffwatch"], ElvDB.global.unitframe.buffwatch)
profileData = E:RemoveTableDuplicates(profileData, G)
end
return profileKey, profileData
end
local function GetProfileExport(profileType, exportFormat)
local profileExport, exportString
local profileKey, profileData = GetProfileData(profileType)
if not profileKey or not profileData or (profileData and type(profileData) ~= "table") then
E:Print("Error getting data from 'GetProfileData'")
return
end
if exportFormat == "text" then
local serialData = D:Serialize(profileData)
exportString = D:CreateProfileExport(serialData, profileType, profileKey)
local compressedData = LibCompress:Compress(exportString)
local encodedData = LibBase64:Encode(compressedData)
profileExport = encodedData
elseif exportFormat == "luaTable" then
exportString = E:TableToLuaString(profileData)
profileExport = D:CreateProfileExport(exportString, profileType, profileKey)
elseif exportFormat == "luaPlugin" then
profileExport = E:ProfileTableToPluginFormat(profileData, profileType)
end
return profileKey, profileExport
end
function D:CreateProfileExport(dataString, profileType, profileKey)
local returnString
if profileType == "profile" then
returnString = format("%s::%s::%s", dataString, profileType, profileKey)
else
returnString = format("%s::%s", dataString, profileType)
end
return returnString
end
function D:GetImportStringType(dataString)
local stringType = ""
if LibBase64:IsBase64(dataString) then
stringType = "Base64"
elseif find(dataString, "{") then
stringType = "Table"
end
return stringType
end
function D:Decode(dataString)
local profileInfo, profileType, profileKey, profileData, message
local stringType = self:GetImportStringType(dataString)
if stringType == "Base64" then
local decodedData = LibBase64:Decode(dataString)
local decompressedData, message = LibCompress:Decompress(decodedData)
if not decompressedData then
E:Print("Error decompressing data:", message)
return
end
local serializedData, success
serializedData, profileInfo = E:StringSplitMultiDelim(decompressedData, "^^::")
if not profileInfo then
E:Print("Error importing profile. String is invalid or corrupted!")
return
end
serializedData = format("%s%s", serializedData, "^^")
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::")
success, profileData = D:Deserialize(serializedData)
if not success then
E:Print("Error deserializing:", profileData)
return
end
elseif stringType == "Table" then
local profileDataAsString
profileDataAsString, profileInfo = E:StringSplitMultiDelim(dataString, "}::")
if not profileInfo then
E:Print("Error extracting profile info. Invalid import string!")
return
end
if not profileDataAsString then
E:Print("Error extracting profile data. Invalid import string!")
return
end
profileDataAsString = format("%s%s", profileDataAsString, "}")
profileType, profileKey = E:StringSplitMultiDelim(profileInfo, "::")
local profileToTable = loadstring(format("%s %s", "return", profileDataAsString))
if profileToTable then
message, profileData = pcall(profileToTable)
end
if not profileData or type(profileData) ~= "table" then
E:Print("Error converting lua string to table:", message)
return
end
end
return profileType, profileKey, profileData
end
local function SetImportedProfile(profileType, profileKey, profileData, force)
D.profileType = nil
D.profileKey = nil
D.profileData = nil
if profileType == "profile" then
if not ElvDB.profiles[profileKey] or force then
if force and E.data.keys.profile == profileKey then
local tempKey = profileKey.."_Temp"
E.data.keys.profile = tempKey
end
ElvDB.profiles[profileKey] = profileData
E.data:SetProfile(profileKey)
else
D.profileType = profileType
D.profileKey = profileKey
D.profileData = profileData
E:StaticPopup_Show("IMPORT_PROFILE_EXISTS")
return
end
elseif profileType == "private" then
local profileKey = ElvPrivateDB.profileKeys[E.myname.." - "..E.myrealm]
ElvPrivateDB.profiles[profileKey] = profileData
E:StaticPopup_Show("IMPORT_RL")
elseif profileType == "global" then
E:CopyTable(ElvDB.global, profileData)
E:StaticPopup_Show("IMPORT_RL")
elseif profileType == "filtersNP" then
E:CopyTable(ElvDB.global.nameplates, profileData.nameplates)
elseif profileType == "filtersUF" then
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe)
elseif profileType == "filtersAll" then
E:CopyTable(ElvDB.global.nameplates, profileData.nameplates)
E:CopyTable(ElvDB.global.unitframe, profileData.unitframe)
end
E:UpdateAll(true)
end
function D:ExportProfile(profileType, exportFormat)
if not profileType or not exportFormat then
E:Print("Bad argument to 'ExportProfile' (string expected)")
return
end
local profileKey, profileExport = GetProfileExport(profileType, exportFormat)
return profileKey, profileExport
end
function D:ImportProfile(dataString)
print(self)
local profileType, profileKey, profileData = self:Decode(dataString)
if not profileData or type(profileData) ~= "table" then
E:Print("Error: something went wrong when converting string to table!")
return
end
if profileType and ((profileType == "profile" and profileKey) or profileType ~= "profile") then
SetImportedProfile(profileType, profileKey, profileData)
end
return true
end
E.PopupDialogs["DISTRIBUTOR_SUCCESS"] = {
text = L["Your profile was successfully recieved by the player."],
whileDead = 1,
hideOnEscape = 1,
button1 = OKAY,
}
E.PopupDialogs["DISTRIBUTOR_WAITING"] = {
text = L["Profile request sent. Waiting for response from player."],
whileDead = 1,
hideOnEscape = 1,
timeout = 35,
}
E.PopupDialogs["DISTRIBUTOR_REQUEST_DENIED"] = {
text = L["Request was denied by user."],
whileDead = 1,
hideOnEscape = 1,
button1 = OKAY,
}
E.PopupDialogs["DISTRIBUTOR_FAILED"] = {
text = L["Lord! It's a miracle! The download up and vanished like a fart in the wind! Try Again!"],
whileDead = 1,
hideOnEscape = 1,
button1 = OKAY,
}
E.PopupDialogs["DISTRIBUTOR_RESPONSE"] = {}
E.PopupDialogs["DISTRIBUTOR_CONFIRM"] = {}
E.PopupDialogs["IMPORT_PROFILE_EXISTS"] = {
text = L["The profile you tried to import already exists. Choose a new name or accept to overwrite the existing profile."],
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = 1,
editBoxWidth = 350,
maxLetters = 127,
OnAccept = function(self)
local profileType = D.profileType
local profileKey = self.editBox:GetText()
local profileData = D.profileData
SetImportedProfile(profileType, profileKey, profileData, true)
end,
EditBoxOnTextChanged = function(self)
if self:GetText() == "" then
self:GetParent().button1:Disable()
else
self:GetParent().button1:Enable()
end
end,
OnShow = function() this.editBox:SetText(D.profileKey) this.editBox:SetFocus() end,
timeout = 0,
whileDead = 1,
hideOnEscape = true,
preferredIndex = 3
}
E.PopupDialogs["IMPORT_RL"] = {
text = L["You have imported settings which may require a UI reload to take effect. Reload now?"],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = ReloadUI,
timeout = 0,
whileDead = 1,
hideOnEscape = false,
preferredIndex = 3
}
local function InitializeCallback()
D:Initialize()
end
E:RegisterModule(D:GetName(), InitializeCallback)
+89
View File
@@ -0,0 +1,89 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local tinsert = tinsert
--WoW API / Variables
local CreateFrame = CreateFrame
local ToggleFrame = ToggleFrame
local GetCursorPosition = GetCursorPosition
local PADDING = 10
local BUTTON_HEIGHT = 16
local BUTTON_WIDTH = 135
local function OnClick(btn)
btn.func()
btn:GetParent():Hide()
end
local function OnEnter(btn)
btn.hoverTex:Show()
end
local function OnLeave(btn)
btn.hoverTex:Hide()
end
function E:DropDown(list, frame, xOffset, yOffset)
if not frame.buttons then
frame.buttons = {}
frame:SetFrameStrata("DIALOG")
frame:SetClampedToScreen(true)
tinsert(UISpecialFrames, frame:GetName())
frame:Hide()
end
xOffset = xOffset or 0
yOffset = yOffset or 0
for i = 1, getn(frame.buttons) do
frame.buttons[i]:Hide()
end
for i = 1, getn(list) do
if not frame.buttons[i] then
frame.buttons[i] = CreateFrame("Button", nil, frame)
frame.buttons[i].hoverTex = frame.buttons[i]:CreateTexture(nil, "OVERLAY")
frame.buttons[i].hoverTex:SetAllPoints()
frame.buttons[i].hoverTex:SetTexture([[Interface\QuestFrame\UI-QuestTitleHighlight]])
frame.buttons[i].hoverTex:SetBlendMode("ADD")
frame.buttons[i].hoverTex:Hide()
frame.buttons[i].text = frame.buttons[i]:CreateFontString(nil, "BORDER")
frame.buttons[i].text:SetAllPoints()
frame.buttons[i].text:FontTemplate()
frame.buttons[i].text:SetJustifyH("LEFT")
frame.buttons[i]:SetScript("OnEnter", OnEnter)
frame.buttons[i]:SetScript("OnLeave", OnLeave)
end
frame.buttons[i]:Show()
frame.buttons[i]:SetHeight(BUTTON_HEIGHT)
frame.buttons[i]:SetWidth(BUTTON_WIDTH)
frame.buttons[i].text:SetText(list[i].text)
frame.buttons[i].func = list[i].func
frame.buttons[i]:SetScript("OnClick", OnClick)
if i == 1 then
frame.buttons[i]:SetPoint("TOPLEFT", frame, "TOPLEFT", PADDING, -PADDING)
else
frame.buttons[i]:SetPoint("TOPLEFT", frame.buttons[i-1], "BOTTOMLEFT")
end
end
frame:SetHeight((getn(list) * BUTTON_HEIGHT) + PADDING * 2)
frame:SetWidth(BUTTON_WIDTH + PADDING * 2)
local UIScale = UIParent:GetScale()
local x, y = GetCursorPosition()
x = x/UIScale
y = y/UIScale
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x + xOffset, y + yOffset)
ToggleFrame(frame)
end
+90
View File
@@ -0,0 +1,90 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local LSM = LibStub("LibSharedMedia-3.0");
--Cache global variables
--Lua functions
--WoW API / Variables
local SetCVar = SetCVar
local function SetFont(obj, font, size, style, r, g, b, sr, sg, sb, sox, soy)
if(not obj) then return end
obj:SetFont(font, size, style)
if sr and sg and sb then obj:SetShadowColor(sr, sg, sb) end
if sox and soy then obj:SetShadowOffset(sox, soy) end
if r and g and b then obj:SetTextColor(r, g, b)
elseif r then obj:SetAlpha(r) end
end
function E:UpdateBlizzardFonts()
local NORMAL = self["media"].normFont
local COMBAT = LSM:Fetch("font", self.private.general.dmgfont)
local NUMBER = self["media"].normFont
local NAMEFONT = LSM:Fetch("font", self.private.general.namefont)
local MONOCHROME = ""
UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 12
CHAT_FONT_HEIGHTS = {10, 12, 13, 14, 15, 16, 17, 18, 19, 20}
UNIT_NAME_FONT = NAMEFONT
NAMEPLATE_FONT = NAMEFONT
DAMAGE_TEXT_FONT = COMBAT
STANDARD_TEXT_FONT = NORMAL
if self.db.general.font == "Homespun" then
MONOCHROME = "MONOCHROME"
end
if self.eyefinity then
-- damage are huge on eyefinity, so we disable it
InterfaceOptionsCombatTextPanelTargetDamage:Hide()
InterfaceOptionsCombatTextPanelPeriodicDamage:Hide()
InterfaceOptionsCombatTextPanelPetDamage:Hide()
InterfaceOptionsCombatTextPanelHealing:Hide()
SetCVar("CombatLogPeriodicSpells",0)
SetCVar("PetMeleeDamage",0)
SetCVar("CombatDamage",0)
SetCVar("CombatHealing",0)
-- set an invisible font for xp, honor kill, etc
local INVISIBLE = "Interface\\Addons\\ElvUI\\Media\\Fonts\\Invisible.ttf"
COMBAT = INVISIBLE
end
if(self.private.general.replaceBlizzFonts) then
SetFont(SystemFont, NORMAL, self.db.general.fontSize);
SetFont(GameFontNormal, NORMAL, self.db.general.fontSize);
SetFont(GameFontNormalSmall, NORMAL, self.db.general.fontSize);
SetFont(GameFontNormalLarge, NORMAL, self.db.general.fontSize);
SetFont(GameFontNormalHuge, NORMAL, 25, MONOCHROME .. "OUTLINE");
SetFont(BossEmoteNormalHuge, NORMAL, 25, MONOCHROME .. "OUTLINE");
SetFont(GameFontBlack, NORMAL, self.db.general.fontSize);
SetFont(NumberFontNormal, NUMBER, self.db.general.fontSize, MONOCHROME .. "OUTLINE");
SetFont(NumberFontNormalSmall, NUMBER, self.db.general.fontSize);
SetFont(NumberFontNormalLarge, NUMBER, self.db.general.fontSize);
SetFont(NumberFontNormalHuge, NUMBER, self.db.general.fontSize);
SetFont(ChatFontNormal, NORMAL, self.db.general.fontSize);
SetFont(ChatFontSmall, NORMAL, self.db.general.fontSize);
SetFont(QuestTitleFont, NORMAL, self.db.general.fontSize + 8);
SetFont(QuestFont, NORMAL, self.db.general.fontSize);
SetFont(QuestFontHighlight, NORMAL, self.db.general.fontSize);
SetFont(ItemTextFontNormal, NORMAL, self.db.general.fontSize);
SetFont(ItemTextFontNormal, NORMAL, self.db.general.fontSize);
SetFont(MailTextFontNormal, NORMAL, self.db.general.fontSize);
SetFont(SubSpellFont, NORMAL, self.db.general.fontSize);
SetFont(DialogButtonNormalText, NORMAL, self.db.general.fontSize);
SetFont(ZoneTextFont, NORMAL, 32, MONOCHROME .. "OUTLINE");
SetFont(SubZoneTextFont, NORMAL, 25, MONOCHROME .. "OUTLINE");
SetFont(PVPInfoTextFont, NORMAL, 22, MONOCHROME .. "OUTLINE");
SetFont(TextStatusBarText, NORMAL, self.db.general.fontSize);
SetFont(TextStatusBarTextSmall, NORMAL, self.db.general.fontSize);
-- SetFont(GameTooltipText, NORMAL, self.db.general.fontSize);
-- SetFont(GameTooltipTextSmall, NORMAL, self.db.general.fontSize);
-- SetFont(GameTooltipHeaderText, NORMAL, self.db.general.fontSize);
SetFont(WorldMapTextFont, NORMAL, 32, MONOCHROME .. "OUTLINE");
SetFont(InvoiceTextFontNormal, NORMAL, self.db.general.fontSize);
SetFont(InvoiceTextFontSmall, NORMAL, self.db.general.fontSize);
SetFont(CombatTextFont, COMBAT, 25, MONOCHROME .. "OUTLINE");
end
end
File diff suppressed because it is too large Load Diff
+133
View File
@@ -0,0 +1,133 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local abs, floor, min, max = math.abs, math.floor, math.min, math.max;
local match = string.match;
--WoW API / Variables
local IsMacClient = IsMacClient;
local GetCVar, SetCVar = GetCVar, SetCVar;
local GetScreenHeight, GetScreenWidth = GetScreenHeight, GetScreenWidth;
local scale
function E:UIScale(event)
if IsMacClient() and self.global.screenheight and self.global.screenwidth and (self.screenheight ~= self.global.screenheight or self.screenwidth ~= self.global.screenwidth) then
self.screenheight = self.global.screenheight
self.screenwidth = self.global.screenwidth
end
if(GetCVar("UIScale")) then
self.global.uiScale = GetCVar("UIScale");
end
local minScale = self.global.general.minUiScale or 0.64;
if(self.global.general.autoScale) then
scale = max(minScale, min(1.00, 768/self.screenheight));
else
scale = max(minScale, min(1.00, self.global.uiScale or UIParent:GetScale() or 768/self.screenheight));
end
if self.screenwidth < 1600 then
self.lowversion = true;
elseif self.screenwidth >= 3840 and self.global.general.eyefinity then
local width = self.screenwidth;
local height = self.screenheight;
-- because some user enable bezel compensation, we need to find the real width of a single monitor.
-- I don't know how it really work, but i'm assuming they add pixel to width to compensate the bezel. :P
-- HQ resolution
if width >= 9840 then width = 3280; end -- WQSXGA
if width >= 7680 and width < 9840 then width = 2560; end -- WQXGA
if width >= 5760 and width < 7680 then width = 1920; end -- WUXGA & HDTV
if width >= 5040 and width < 5760 then width = 1680; end -- WSXGA+
-- adding height condition here to be sure it work with bezel compensation because WSXGA+ and UXGA/HD+ got approx same width
if width >= 4800 and width < 5760 and height == 900 then width = 1600; end -- UXGA & HD+
-- low resolution screen
if width >= 4320 and width < 4800 then width = 1440; end -- WSXGA
if width >= 4080 and width < 4320 then width = 1360; end -- WXGA
if width >= 3840 and width < 4080 then width = 1224; end -- SXGA & SXGA (UVGA) & WXGA & HDTV
-- yep, now set ElvUI to lower resolution if screen #1 width < 1600
if width < 1600 then
self.lowversion = true;
end
-- register a constant, we will need it later for launch.lua
self.eyefinity = width;
end
self.mult = 768/match(GetCVar("gxResolution"), "%d+x(%d+)")/scale;
self.Spacing = self.PixelMode and 0 or self.mult;
self.Border = (self.PixelMode and self.mult or self.mult*2);
--Set UIScale, NOTE: SetCVar for UIScale can cause taints so only do this when we need to..
if E.Round and E:Round(UIParent:GetScale(), 5) ~= E:Round(scale, 5) and (event == "PLAYER_LOGIN") then
SetCVar("UseUIScale", 1);
SetCVar("UIScale", scale);
WorldMapFrame.hasTaint = true;
end
if (event == "PLAYER_LOGIN" or event == "UPDATE_FLOATING_CHAT_WINDOWS") then
if IsMacClient() then
self.global.screenheight = floor(GetScreenHeight()*100+.5)/100
self.global.screenwidth = floor(GetScreenWidth()*100+.5)/100
end
--Resize self.UIParent if Eyefinity is on.
if self.eyefinity then
local width = self.eyefinity;
local height = self.screenheight;
-- if autoscale is off, find a new width value of self.UIParent for screen #1.
if not self.global.general.autoScale or height > 1200 then
local h = UIParent:GetHeight();
local ratio = self.screenheight / h;
local w = self.eyefinity / ratio;
width = w;
height = h;
end
self.UIParent:SetWidth(width);
self.UIParent:SetHeight(height);
else
--[[Eyefinity Test mode
Resize the E.UIParent to be smaller than it should be, all objects inside should relocate.
Dragging moveable frames outside the box and reloading the UI ensures that they are saving position correctly.
]]
--self.UIParent:SetSize(UIParent:GetWidth() - 250, UIParent:GetHeight() - 250);
self.UIParent:SetWidth(GetScreenWidth());
self.UIParent:SetHeight(GetScreenHeight());
end
self.UIParent:ClearAllPoints();
self.UIParent:SetPoint("CENTER", UIParent);
self.diffGetLeft = E:Round(abs(UIParent:GetLeft() - self.UIParent:GetLeft()));
self.diffGetRight = E:Round(abs(UIParent:GetRight() - self.UIParent:GetRight()));
self.diffGetTop = E:Round(abs(UIParent:GetTop() - self.UIParent:GetTop()));
self.diffGetBottom = E:Round(abs(UIParent:GetBottom() - self.UIParent:GetBottom()));
local change
if E.Round then
change = abs((E:Round(UIParent:GetScale(), 5) * 100) - (E:Round(scale, 5) * 100))
end
if event == "UPDATE_FLOATING_CHAT_WINDOWS" and change and change > 1 and self.global.general.autoScale then
E:StaticPopup_Show("FAILED_UISCALE")
elseif event == "UPDATE_FLOATING_CHAT_WINDOWS" and change and change > 1 then
E:StaticPopup_Show("CONFIG_RL")
end
self:UnregisterEvent("PLAYER_LOGIN")
end
end
-- pixel perfect script of custom ui scale.
function E:Scale(x)
return self.mult*floor(x/self.mult+.5);
end
+480
View File
@@ -0,0 +1,480 @@
--Plugins pass their info using the table like:
--[[
addon = {
Title = "Your Own Title",
Name = "AddOnName",
tutorialImage = "TexturePath",
Pages = {
[1] = function1,
[2] = function2,
[3] = function3,
},
StepTitles = {
[1] = "Title 1",
[2] = "Title 2",
[3] = "Title 3",
},
StepTitlesColor = {r,g,b},
StepTitlesColorSelected = {r,g,b},
StepTitleWidth = 140,
StepTitleButtonWidth = 130,
StepTitleTextJustification = "CENTER",
}
E:GetModule("PluginInstaller"):Queue(addon)
Title is wat displayed on top of the window. By default it's ""ElvUI Plugin Installation""
Name is how your installation will be showin in "pending list", Default is "Unknown"
tutorialImage is a path to your own texture to use in frame. if not specified, then it will use ElvUI's one
Pages is a table to set up pages of your install where numbers are representing actual pages' order and function is what previously was used to set layout. For example
function function1()
PluginInstallFrame.SubTitle:SetText("Title Text")
PluginInstallFrame.Desc1:SetText("Desc 1 Tet")
PluginInstallFrame.Desc2:SetText("Desc 2 Tet")
PluginInstallFrame.Desc3:SetText("Desc 3 Tet")
PluginInstallFrame.Option1:Show()
PluginInstallFrame.Option1:SetScript("OnClick", function() <Do Some Stuff> end)
PluginInstallFrame.Option1:SetText("Text 1")
PluginInstallFrame.Option2:Show()
PluginInstallFrame.Option2:SetScript("OnClick", function() <Do Some Other Stuff> end)
PluginInstallFrame.Option2:SetText("Text 2")
end
StepTitles - a table to specify "titles" for your install steps. If specified and number of lines here = number of pages then you'll get an additional frame to the right of main frame
with a list of steps (current one being highlighted), clicking on those will open respective step. BenikUI style of doing stuff.
StepTitlesColor - a table with color values to color "titles" when they are not active
StepTitlesColorSelected - a table with color values to color "titles" when they are active
StepTitleWidth - Width of the steps frame on the right side
StepTitleButtonWidth - Width of each step button in the steps frame
StepTitleTextJustification - The justification of the text on each step button ("LEFT", "RIGHT", "CENTER"). Default: "CENTER"
]]
local E, L, V, P, G, _ = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local PI = E:NewModule("PluginInstaller");
--Cache global variables
--Lua functions
local _G = _G
local pairs, unpack = pairs, unpack
local tinsert, tremove = tinsert, tremove
local format = string.format
--WoW API / Variables
local CreateFrame = CreateFrame
local PlaySoundFile = PlaySoundFile
local UIFrameFadeOut = UIFrameFadeOut
local CreateAnimationGroup = CreateAnimationGroup
local CONTINUE, PREV, UNKNOWN = CONTINUE, PREV, UNKNOWN
--Global variables that we don't cache, list them here for the mikk's Find Globals script
-- GLOBALS: PluginInstallFrame
--Installation Functions
PI.Installs = {}
local f
local BUTTON_HEIGHT = 20
local function ResetAll()
f.Next:Disable()
f.Prev:Disable()
f.Option1:Hide()
f.Option1:SetScript("OnClick", nil)
f.Option1:SetText("")
f.Option2:Hide()
f.Option2:SetScript("OnClick", nil)
f.Option2:SetText("")
f.Option3:Hide()
f.Option3:SetScript("OnClick", nil)
f.Option3:SetText("")
f.Option4:Hide()
f.Option4:SetScript("OnClick", nil)
f.Option4:SetText("")
f.SubTitle:SetText("")
f.Desc1:SetText("")
f.Desc2:SetText("")
f.Desc3:SetText("")
f.Desc4:SetText("")
f:SetWidth(550)
f:SetHeight(400)
if f.StepTitles then
for i = 1, getn(f.side.Lines) do f.side.Lines[i].text:SetText("") end
end
end
local function SetPage(PageNum, PrevPage)
f.CurrentPage = PageNum
f.PrevPage = PrevPage
ResetAll()
f.Status.anim.progress:SetChange(PageNum)
f.Status.anim.progress:Play()
local r, g, b = E:ColorGradient(f.CurrentPage / f.MaxPage, 1, 0, 0, 1, 1, 0, 0, 1, 0)
f.Status:SetStatusBarColor(r, g, b)
if PageNum == f.MaxPage then
f.Next:Disable()
else
f.Next:Enable()
end
if PageNum == 1 then
f.Prev:Disable()
else
f.Prev:Enable()
end
f.Pages[f.CurrentPage]()
f.Status.text:SetFormattedText("%d / %d", f.CurrentPage, f.MaxPage)
if f.StepTitles then
for i = 1, getn(f.side.Lines) do
local b = f.side.Lines[i]
local color
b.text:SetText(f.StepTitles[i])
if i == f.CurrentPage then
color = f.StepTitlesColorSelected or {.09,.52,.82}
else
color = f.StepTitlesColor or {1,1,1}
end
b.text:SetTextColor(color[1] or color.r, color[2] or color.g, color[3] or color.b)
end
end
end
local function NextPage()
if f.CurrentPage ~= f.MaxPage then
f.CurrentPage = f.CurrentPage + 1
SetPage(f.CurrentPage, f.CurrentPage - 1)
end
end
local function PreviousPage()
if f.CurrentPage ~= 1 then
f.CurrentPage = f.CurrentPage - 1
SetPage(f.CurrentPage, f.CurrentPage + 1)
end
end
function PI:CreateStepComplete()
local imsg = CreateFrame("Frame", "PluginInstallStepComplete", E.UIParent)
imsg:SetWidth(418)
imsg:SetHeight(72)
imsg:SetPoint("TOP", 0, -190)
imsg:Hide()
imsg:SetScript("OnShow", function(self)
if self.message then
PlaySoundFile([[Sound\Interface\LevelUp.wav]])
self.text:SetText(self.message)
UIFrameFadeOut(self, 3.5, 1, 0)
E:Delay(4, function() self:Hide() end)
self.message = nil
else
self:Hide()
end
end)
imsg.firstShow = false
imsg.bg = imsg:CreateTexture(nil, "BACKGROUND")
imsg.bg:SetTexture([[Interface\LevelUp\LevelUpTex]])
imsg.bg:SetPoint("BOTTOM", 0, 0)
imsg.bg:SetWidth(326)
imsg.bg:SetHeight(103)
imsg.bg:SetTexCoord(0.00195313, 0.63867188, 0.03710938, 0.23828125)
imsg.bg:SetVertexColor(1, 1, 1, 0.6)
imsg.lineTop = imsg:CreateTexture(nil, "BACKGROUND")
imsg.lineTop:SetDrawLayer("BACKGROUND", 2)
imsg.lineTop:SetTexture([[Interface\LevelUp\LevelUpTex]])
imsg.lineTop:SetPoint("TOP", 0, 0)
imsg.lineTop:SetWidth(418)
imsg.lineTop:SetHeight(7)
imsg.lineTop:SetTexCoord(0.00195313, 0.81835938, 0.01953125, 0.03320313)
imsg.lineBottom = imsg:CreateTexture(nil, "BACKGROUND")
imsg.lineBottom:SetDrawLayer("BACKGROUND", 2)
imsg.lineBottom:SetTexture([[Interface\LevelUp\LevelUpTex]])
imsg.lineBottom:SetPoint("BOTTOM", 0, 0)
imsg.lineBottom:SetWidth(418)
imsg.lineBottom:SetHeight(7)
imsg.lineBottom:SetTexCoord(0.00195313, 0.81835938, 0.01953125, 0.03320313)
imsg.text = imsg:CreateFontString(nil, "ARTWORK")
E:FontTemplate(imsg.text, E["media"].normFont, 32, "OUTLINE")
imsg.text:SetPoint("BOTTOM", 0, 12)
imsg.text:SetTextColor(1, 0.82, 0)
imsg.text:SetJustifyH("CENTER")
end
function PI:CreateFrame()
f = CreateFrame("Button", "PluginInstallFrame", E.UIParent)
f.SetPage = SetPage
f:SetWidth(550)
f:SetHeight(400)
E:SetTemplate(f, "Transparent")
f:SetPoint("CENTER", 0, 0)
f:SetFrameStrata("TOOLTIP")
f.Title = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.Title, nil, 17, nil)
f.Title:SetPoint("TOP", 0, -5)
f.Next = CreateFrame("Button", "PluginInstallNextButton", f, "UIPanelButtonTemplate")
E:StripTextures(f.Next)
E:SetTemplate(f.Next, "Default", true)
f.Next:SetWidth(110)
f.Next:SetHeight(25)
f.Next:SetPoint("BOTTOMRIGHT", -5, 5)
f.Next:SetText(CONTINUE)
f.Next:Disable()
f.Next:SetScript("OnClick", NextPage)
E.Skins:HandleButton(f.Next, true)
f.Prev = CreateFrame("Button", "PluginInstallPrevButton", f, "UIPanelButtonTemplate")
E:StripTextures(f.Prev)
E:SetTemplate(f.Prev, "Default", true)
f.Prev:SetWidth(110)
f.Prev:SetHeight(25)
f.Prev:SetPoint("BOTTOMLEFT", 5, 5)
f.Prev:SetText(PREV)
f.Prev:Disable()
f.Prev:SetScript("OnClick", PreviousPage)
E.Skins:HandleButton(f.Prev, true)
f.Status = CreateFrame("StatusBar", "PluginInstallStatus", f)
f.Status:SetFrameLevel(f.Status:GetFrameLevel() + 2)
E:CreateBackdrop(f.Status, "Default", true)
f.Status:SetStatusBarTexture(E["media"].normTex)
f.Status:SetStatusBarColor(unpack(E["media"].rgbvaluecolor))
f.Status:SetPoint("TOPLEFT", f.Prev, "TOPRIGHT", 6, -2)
f.Status:SetPoint("BOTTOMRIGHT", f.Next, "BOTTOMLEFT", -6, 2)
-- Setup StatusBar Animation
f.Status.anim = CreateAnimationGroup(f.Status)
f.Status.anim.progress = f.Status.anim:CreateAnimation("Progress")
f.Status.anim.progress:SetSmoothing("Out")
f.Status.anim.progress:SetDuration(.3)
f.Status.text = f.Status:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.Status.text)
f.Status.text:SetPoint("CENTER", 0, 0)
f.Option1 = CreateFrame("Button", "PluginInstallOption1Button", f, "UIPanelButtonTemplate")
E:StripTextures(f.Option1)
f.Option1:SetWidth(160)
f.Option1:SetHeight(30)
f.Option1:SetPoint("BOTTOM", 0, 45)
f.Option1:SetText("")
f.Option1:Hide()
E.Skins:HandleButton(f.Option1, true)
f.Option2 = CreateFrame("Button", "PluginInstallOption2Button", f, "UIPanelButtonTemplate")
E:StripTextures(f.Option2)
f.Option2:SetWidth(160)
f.Option2:SetHeight(30)
f.Option2:SetPoint("BOTTOMLEFT", f, "BOTTOM", 4, 45)
f.Option2:SetText("")
f.Option2:Hide()
f.Option2:SetScript("OnShow", function() f.Option1:SetWidth(110); f.Option1:ClearAllPoints(); f.Option1:SetPoint("BOTTOMRIGHT", f, "BOTTOM", -4, 45) end)
f.Option2:SetScript("OnHide", function() f.Option1:SetWidth(160); f.Option1:ClearAllPoints(); f.Option1:SetPoint("BOTTOM", 0, 45) end)
E.Skins:HandleButton(f.Option2, true)
f.Option3 = CreateFrame("Button", "PluginInstallOption3Button", f, "UIPanelButtonTemplate")
E:StripTextures(f.Option3)
f.Option3:SetWidth(100)
f.Option3:SetHeight(30)
f.Option3:SetPoint("LEFT", f.Option2, "RIGHT", 4, 0)
f.Option3:SetText("")
f.Option3:Hide()
f.Option3:SetScript("OnShow", function() f.Option1:SetWidth(100); f.Option1:ClearAllPoints(); f.Option1:SetPoint("RIGHT", f.Option2, "LEFT", -4, 0); f.Option2:SetWidth(100); f.Option2:ClearAllPoints(); f.Option2:SetPoint("BOTTOM", f, "BOTTOM", 0, 45) end)
f.Option3:SetScript("OnHide", function() f.Option1:SetWidth(160); f.Option1:ClearAllPoints(); f.Option1:SetPoint("BOTTOM", 0, 45); f.Option2:SetWidth(110); f.Option2:ClearAllPoints(); f.Option2:SetPoint("BOTTOMLEFT", f, "BOTTOM", 4, 45) end)
E.Skins:HandleButton(f.Option3, true)
f.Option4 = CreateFrame("Button", "PluginInstallOption4Button", f, "UIPanelButtonTemplate")
E:StripTextures(f.Option4)
f.Option4:SetWidth(100)
f.Option4:SetHeight(30)
f.Option4:SetPoint("LEFT", f.Option3, "RIGHT", 4, 0)
f.Option4:SetText("")
f.Option4:Hide()
f.Option4:SetScript("OnShow", function()
f.Option1:SetWidth(100)
f.Option2:SetWidth(100)
f.Option1:ClearAllPoints();
f.Option1:SetPoint("RIGHT", f.Option2, "LEFT", -4, 0);
f.Option2:ClearAllPoints();
f.Option2:SetPoint("BOTTOMRIGHT", f, "BOTTOM", -4, 45)
end)
f.Option4:SetScript("OnHide", function() f.Option1:SetWidth(160); f.Option1:ClearAllPoints(); f.Option1:SetPoint("BOTTOM", 0, 45); f.Option2:SetWidth(110); f.Option2:ClearAllPoints(); f.Option2:SetPoint("BOTTOMLEFT", f, "BOTTOM", 4, 45) end)
E.Skins:HandleButton(f.Option4, true)
f.SubTitle = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.SubTitle, nil, 15, nil)
f.SubTitle:SetPoint("TOP", 0, -40)
f.Desc1 = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.Desc1)
f.Desc1:SetPoint("TOPLEFT", 20, -75)
f.Desc1:SetWidth(f:GetWidth() - 40)
f.Desc2 = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.Desc2)
f.Desc2:SetPoint("TOP", f.Desc1, "BOTTOM", 0, -20)
f.Desc2:SetWidth(f:GetWidth() - 40)
f.Desc3 = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.Desc3)
f.Desc3:SetPoint("TOP", f.Desc2, "BOTTOM", 0, -20)
f.Desc3:SetWidth(f:GetWidth() - 40)
f.Desc4 = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.Desc4)
f.Desc4:SetPoint("TOP", f.Desc3, "BOTTOM", 0, -20)
f.Desc4:SetWidth(f:GetWidth() - 40)
local close = CreateFrame("Button", "PluginInstallCloseButton", f, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", f, "TOPRIGHT")
close:SetScript("OnClick", function() f:Hide() end)
E.Skins:HandleCloseButton(close)
f.pending = CreateFrame("Frame", "PluginInstallPendingButton", f)
f.pending:SetWidth(20)
f.pending:SetHeight(20)
f.pending:SetPoint("TOPLEFT", f, "TOPLEFT", 8, -8)
f.pending.tex = f.pending:CreateTexture(nil, "OVERLAY")
f.pending.tex:SetPoint("TOPLEFT", f.pending, "TOPLEFT", 2, -2)
f.pending.tex:SetPoint("BOTTOMRIGHT", f.pending, "BOTTOMRIGHT", -2, 2)
f.pending.tex:SetTexture([[Interface\OptionsFrame\UI-OptionsFrame-NewFeatureIcon]])
E:CreateBackdrop(f.pending, "Transparent")
f.pending:SetScript("OnEnter", function(self)
_G["GameTooltip"]:SetOwner(self, "ANCHOR_BOTTOMLEFT", E.PixelMode and -7 or -9);
_G["GameTooltip"]:AddLine(L["List of installations in queue:"], 1, 1, 1)
_G["GameTooltip"]:AddLine(" ")
for i = 1, getn(PI.Installs) do
_G["GameTooltip"]:AddDoubleLine(format("%d. %s", i, (PI.Installs[i].Name or UNKNOWN)), i == 1 and format("|cff00FF00%s|r", L["In Progress"]) or format("|cffFF0000%s|r", L["Pending"]))
end
_G["GameTooltip"]:Show()
end)
f.pending:SetScript("OnLeave", function()
_G["GameTooltip"]:Hide()
end)
f.tutorialImage = f:CreateTexture("PluginInstallTutorialImage", "OVERLAY")
f.tutorialImage:SetWidth(256)
f.tutorialImage:SetHeight(128)
f.tutorialImage:SetPoint("BOTTOM", 0, 70)
f.side = CreateFrame("Frame", "PluginInstallTitleFrame", f)
E:SetTemplate(f.side, "Transparent")
f.side:SetPoint("TOPLEFT", f, "TOPRIGHT", E.PixelMode and 1 or 3, 0)
f.side:SetPoint("BOTTOMLEFT", f, "BOTTOMRIGHT", E.PixelMode and 1 or 3, 0)
f.side:SetWidth(140)
f.side.text = f.side:CreateFontString(nil, "OVERLAY")
f.side.text:SetPoint("TOP", f.side, "TOP", 0, -4)
f.side.text:SetFont(E["media"].normFont, 18, "OUTLINE")
f.side.text:SetText(L["Steps"])
f.side.Lines = {} --Table to keep shown lines
f.side:Hide()
for i = 1, 18 do
local button = CreateFrame("Button", nil, f)
if i == 1 then
button:SetPoint("TOP", f.side.text, "BOTTOM", 0, -6)
else
button:SetPoint("TOP", f.side.Lines[i - 1], "BOTTOM")
end
button:SetWidth(130)
button:SetHeight(BUTTON_HEIGHT)
button.text = button:CreateFontString(nil, "OVERLAY")
button.text:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
button.text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
button.text:SetFont(E["media"].normFont, 14, "OUTLINE")
button:SetScript("OnClick", function() if i <= f.MaxPage then SetPage(i, f.CurrentPage) end end)
button.text:SetText("")
f.side.Lines[i] = button
button:Hide()
end
f:Hide()
f:SetScript("OnHide", function() PI:CloseInstall() end)
end
function PI:Queue(addon)
local addonIsQueued = false
for _, v in pairs(self.Installs) do
if v.Name == addon.Name then
addonIsQueued = true
end
end
if not addonIsQueued then
tinsert(self.Installs, getn(self.Installs)+1, addon)
self:RunInstall()
end
end
function PI:CloseInstall()
tremove(self.Installs, 1)
f.side:Hide()
for i = 1, getn(f.side.Lines) do
f.side.Lines[i].text:SetText("")
f.side.Lines[i]:Hide()
end
if getn(self.Installs) > 0 then E:Delay(1, function() PI:RunInstall() end) end
end
function PI:RunInstall()
if not E.private.install_complete then return end
if self.Installs[1] and not PluginInstallFrame:IsShown() and not (_G["ElvUIInstallFrame"] and _G["ElvUIInstallFrame"]:IsShown()) then
f.StepTitles = nil
f.StepTitlesColor = nil
f.StepTitlesColorSelected = nil
local db = self.Installs[1]
f.CurrentPage = 0
f.MaxPage = getn(db.Pages)
f.Title:SetText(db.Title or L["ElvUI Plugin Installation"])
f.Status:SetMinMaxValues(0, f.MaxPage)
f.Status.text:SetText(f.CurrentPage.." / "..f.MaxPage)
f.tutorialImage:SetTexture(db.tutorialImage or [[Interface\AddOns\ElvUI\media\textures\logo.tga]])
f.Pages = db.Pages
PluginInstallFrame:Show()
f:SetPoint("CENTER")
if db.StepTitles and getn(db.StepTitles) == f.MaxPage then
f:SetPoint("CENTER", E.UIParent, "CENTER", -((db.StepTitleWidth or 140)/2), 0)
f.side:SetWidth(db.StepTitleWidth or 140)
f.side:Show()
for i = 1, getn(f.side.Lines) do
if db.StepTitles[i] then
f.side.Lines[i]:SetWidth(db.StepTitleButtonWidth or 130)
f.side.Lines[i].text:SetJustifyH(db.StepTitleTextJustification or "CENTER")
f.side.Lines[i]:Show()
end
end
f.StepTitles = db.StepTitles
f.StepTitlesColor = db.StepTitlesColor
f.StepTitlesColorSelected = db.StepTitlesColorSelected
end
NextPage()
end
if getn(self.Installs) > 1 then
f.pending:Show()
-- E:Flash(f.pending, 0.53, true)
else
f.pending:Hide()
-- E:StopFlash(f.pending)
end
end
function PI:Initialize()
PI:CreateStepComplete()
PI:CreateFrame()
end
local function InitializeCallback()
PI:Initialize()
end
E:RegisterModule(PI:GetName(), InitializeCallback)
+312
View File
@@ -0,0 +1,312 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local LSM = LibStub("LibSharedMedia-3.0");
--Cache global variables
--Lua functions
local _G = _G
local unpack, type = unpack, type
--WoW API / Variables
local CreateFrame = CreateFrame
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
--Preload shit..
E.mult = 1
local backdropr, backdropg, backdropb, backdropa, borderr, borderg, borderb = 0, 0, 0, 1, 0, 0, 0
local function GetTemplate(t, isUnitFrameElement)
backdropa = 1
if t == "ClassColor" then
if(CUSTOM_CLASS_COLORS) then
borderr, borderg, borderb = CUSTOM_CLASS_COLORS[E.myclass].r, CUSTOM_CLASS_COLORS[E.myclass].g, CUSTOM_CLASS_COLORS[E.myclass].b
else
borderr, borderg, borderb = RAID_CLASS_COLORS[E.myclass].r, RAID_CLASS_COLORS[E.myclass].g, RAID_CLASS_COLORS[E.myclass].b
end
if t ~= "Transparent" then
backdropr, backdropg, backdropb = unpack(E["media"].backdropcolor)
else
backdropr, backdropg, backdropb, backdropa = unpack(E["media"].backdropfadecolor)
end
elseif t == "Transparent" then
if isUnitFrameElement then
borderr, borderg, borderb = unpack(E["media"].bordercolor)
else
borderr, borderg, borderb = unpack(E["media"].bordercolor)
end
backdropr, backdropg, backdropb, backdropa = unpack(E["media"].backdropfadecolor)
else
if isUnitFrameElement then
borderr, borderg, borderb = unpack(E["media"].bordercolor)
else
borderr, borderg, borderb = unpack(E["media"].bordercolor)
end
backdropr, backdropg, backdropb = unpack(E["media"].backdropcolor)
end
end
function E:Size(frame, width, height)
assert(width)
frame:SetSize(E:Scale(width), E:Scale(height or width))
end
function E:Width(frame, width)
frame:SetWidth(E:Scale(width))
end
function E:Height(frame, height)
assert(height)
frame:SetHeight(E:Scale(height))
end
function E:Point(obj, arg1, arg2, arg3, arg4, arg5)
if(arg2 == nil) then
arg2 = obj:GetParent()
end
if type(arg1)=="number" then arg1 = E:Scale(arg1) end
if type(arg2)=="number" then arg2 = E:Scale(arg2) end
if type(arg3)=="number" then arg3 = E:Scale(arg3) end
if type(arg4)=="number" then arg4 = E:Scale(arg4) end
if type(arg5)=="number" then arg5 = E:Scale(arg5) end
obj:SetPoint(arg1, arg2, arg3, arg4, arg5)
end
function E:SetOutside(obj, anchor, xOffset, yOffset, anchor2)
xOffset = xOffset or E.Border
yOffset = yOffset or E.Border
anchor = anchor or obj:GetParent()
assert(anchor)
if obj:GetPoint() then
obj:ClearAllPoints()
end
obj:SetPoint("TOPLEFT", anchor, "TOPLEFT", -xOffset, yOffset)
obj:SetPoint("BOTTOMRIGHT", anchor2 or anchor, "BOTTOMRIGHT", xOffset, -yOffset)
end
function E:SetInside(obj, anchor, xOffset, yOffset, anchor2)
xOffset = xOffset or E.Border
yOffset = yOffset or E.Border
anchor = anchor or obj:GetParent()
assert(anchor)
if obj:GetPoint() then
obj:ClearAllPoints()
end
obj:SetPoint("TOPLEFT", anchor, "TOPLEFT", xOffset, -yOffset)
obj:SetPoint("BOTTOMRIGHT", anchor2 or anchor, "BOTTOMRIGHT", -xOffset, yOffset)
end
function E:SetTemplate(f, t, glossTex, ignoreUpdates, forcePixelMode, isUnitFrameElement)
GetTemplate(t, isUnitFrameElement)
if(t) then
f.template = t
end
if(glossTex) then
f.glossTex = glossTex
end
if(ignoreUpdates) then
f.ignoreUpdates = ignoreUpdates
end
if(forcePixelMode) then
f.forcePixelMode = forcePixelMode
end
local bgFile = E.media.blankTex
if(glossTex) then
bgFile = E.media.glossTex
end
if(isUnitFrameElement) then
f.isUnitFrameElement = isUnitFrameElement
end
if(t ~= "NoBackdrop") then
if(E.private.general.pixelPerfect or f.forcePixelMode) then
f:SetBackdrop({
bgFile = bgFile,
edgeFile = E["media"].blankTex,
tile = false, tileSize = 0, edgeSize = E.mult,
insets = {left = 0, right = 0, top = 0, bottom = 0}
})
else
f:SetBackdrop({
bgFile = bgFile,
edgeFile = E["media"].blankTex,
tile = false, tileSize = 0, edgeSize = E.mult,
insets = {left = -E.mult, right = -E.mult, top = -E.mult, bottom = -E.mult}
})
end
if not f.oborder and not f.iborder and not E.private.general.pixelPerfect and not f.forcePixelMode then
local border = CreateFrame("Frame", nil, f)
E:SetInside(border, f, E.mult, E.mult)
border:SetBackdrop({
edgeFile = E["media"].blankTex,
edgeSize = E.mult,
insets = {left = E.mult, right = E.mult, top = E.mult, bottom = E.mult}
})
border:SetBackdropBorderColor(0, 0, 0, 1)
f.iborder = border
if f.oborder then return end
border = CreateFrame("Frame", nil, f)
E:SetOutside(border, f, E.mult, E.mult)
border:SetFrameLevel(f:GetFrameLevel() + 1)
border:SetBackdrop({
edgeFile = E["media"].blankTex,
edgeSize = E.mult,
insets = {left = E.mult, right = E.mult, top = E.mult, bottom = E.mult}
})
border:SetBackdropBorderColor(0, 0, 0, 1)
f.oborder = border
end
else
f:SetBackdrop(nil)
end
f:SetBackdropColor(backdropr, backdropg, backdropb, backdropa)
f:SetBackdropBorderColor(borderr, borderg, borderb)
if(not f.ignoreUpdates) then
if f.isUnitFrameElement then
E["unitFrameElements"][f] = true
else
E["frames"][f] = true
end
end
end
function E:CreateBackdrop(f, t, tex, ignoreUpdates, forcePixelMode, isUnitFrameElement)
if not f then return end
if(not t) then t = "Default" end
local b = CreateFrame("Frame", nil, f)
if(f.forcePixelMode or forcePixelMode) then
E:SetOutside(b, nil, E.mult, E.mult)
else
E:SetOutside(b)
end
E:SetTemplate(b, t, tex, ignoreUpdates, forcePixelMode, isUnitFrameElement)
if(f:GetFrameLevel() - 1 >= 0) then
b:SetFrameLevel(f:GetFrameLevel() - 1)
else
b:SetFrameLevel(0)
end
f.backdrop = b
end
function E:CreateShadow(f)
if f.shadow then return end
borderr, borderg, borderb = 0, 0, 0
backdropr, backdropg, backdropb = 0, 0, 0
local shadow = CreateFrame("Frame", nil, f)
shadow:SetFrameLevel(1)
shadow:SetFrameStrata(f:GetFrameStrata())
E:SetOutside(shadow, f, 3, 3)
shadow:SetBackdrop({
edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(3),
insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}
})
shadow:SetBackdropColor(backdropr, backdropg, backdropb, 0)
shadow:SetBackdropBorderColor(borderr, borderg, borderb, 0.9)
f.shadow = shadow
end
function E:Kill(object)
if object.UnregisterAllEvents then
object:UnregisterAllEvents()
object:SetParent(E.HiddenFrame)
else
object.Show = object.Hide
end
object:Hide()
end
function E:StripTextures(object, kill)
for _, region in ipairs({object:GetRegions()}) do
if region and region:GetObjectType() == "Texture" then
if kill and type(kill) == "boolean" then
E:Kill(region)
elseif region:GetDrawLayer() == kill then
region:SetTexture(nil)
elseif kill and type(kill) == "string" and region:GetTexture() ~= kill then
region:SetTexture(nil)
else
region:SetTexture(nil)
end
end
end
end
function E:FontTemplate(fs, font, fontSize, fontStyle)
fs.font = font
fs.fontSize = fontSize
fs.fontStyle = fontStyle
font = font or LSM:Fetch("font", E.db["general"].font)
fontSize = fontSize or E.db.general.fontSize
if fontStyle == "OUTLINE" and (E.db.general.font == "Homespun") then
if (fontSize > 10 and not fs.fontSize) then
fontStyle = "MONOCHROMEOUTLINE"
fontSize = 10
end
end
fs:SetFont(font, fontSize, fontStyle)
if fontStyle and (fontStyle ~= "NONE") then
fs:SetShadowColor(0, 0, 0, 0.2)
else
fs:SetShadowColor(0, 0, 0, 1)
end
fs:SetShadowOffset((E.mult or 1), -(E.mult or 1))
E["texts"][fs] = true
end
function E:StyleButton(button, noHover, noPushed, noChecked)
if button.SetHighlightTexture and not button.hover and not noHover then
local hover = button:CreateTexture()
hover:SetTexture(1, 1, 1, 0.3)
E:SetInside(hover)
button.hover = hover
button:SetHighlightTexture(hover)
end
if button.SetPushedTexture and not button.pushed and not noPushed then
local pushed = button:CreateTexture()
pushed:SetTexture(0.9, 0.8, 0.1, 0.3)
E:SetInside(pushed)
button.pushed = pushed
button:SetPushedTexture(pushed)
end
if button.SetCheckedTexture and not button.checked and not noChecked then
local checked = button:CreateTexture()
checked:SetTexture(1, 1, 1)
E:SetInside(checked)
checked:SetAlpha(0.3)
button.checked = checked
button:SetCheckedTexture(checked)
end
local cooldown = button:GetName() and _G[button:GetName().."Cooldown"]
if cooldown then
cooldown:ClearAllPoints()
E:SetInside(cooldown)
end
end
+121
View File
@@ -0,0 +1,121 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local _G = _G
--WoW API / Variables
local CreateFrame = CreateFrame
local DISABLE = DISABLE
local HIDE = HIDE
E.TutorialList = {
L["For technical support visit us at https://github.com/ElvUI-Vanilla/ElvUI"],
L["You can toggle the microbar by using your middle mouse button on the minimap you can also accomplish this by enabling the actual microbar located in the actionbar settings."],
L["A raid marker feature is available by pressing Escape -> Keybinds scroll to the bottom under ElvUI and setting a keybind for the raid marker."],
L["You can set your keybinds quickly by typing /kb."],
L["The focus unit can be set by typing /focus when you are targeting the unit you want to focus. It is recommended you make a macro to do this."],
L["ElvUI has a dual spec feature which allows you to load different profiles based on your current spec on the fly. You can enable this from the profiles tab."],
L["You can access copy chat and chat menu functions by mouse over the top right corner of chat panel and left/right click on the button that will appear."],
L["If you are experiencing issues with ElvUI try disabling all your addons except ElvUI, remember ElvUI is a full UI replacement addon, you cannot run two addons that do the same thing."],
L["If you accidently remove a chat frame you can always go the in-game configuration menu, press install, go to the chat portion and reset them."],
L["To setup which channels appear in which chat frame, right click the chat tab and go to settings."],
L["You can use the /resetui command to reset all of your movers. You can also use the command to reset a specific mover, /resetui <mover name>.\nExample: /resetui Player Frame"],
L["To move abilities on the actionbars by default hold shift + drag. You can change the modifier key from the actionbar options menu."],
L["You can see someones average item level of their gear by holding shift and mousing over them. It should appear inside the tooltip."]
}
function E:SetNextTutorial()
self.db.currentTutorial = self.db.currentTutorial or 0
self.db.currentTutorial = self.db.currentTutorial + 1
if self.db.currentTutorial > getn(E.TutorialList) then
self.db.currentTutorial = 1
end
ElvUITutorialWindow.desc:SetText(E.TutorialList[self.db.currentTutorial])
end
function E:SetPrevTutorial()
self.db.currentTutorial = self.db.currentTutorial or 0
self.db.currentTutorial = self.db.currentTutorial - 1
if self.db.currentTutorial <= 0 then
self.db.currentTutorial = getn(E.TutorialList)
end
ElvUITutorialWindow.desc:SetText(E.TutorialList[self.db.currentTutorial])
end
function E:SpawnTutorialFrame()
local f = CreateFrame("Frame", "ElvUITutorialWindow", UIParent)
f:SetFrameStrata("DIALOG")
f:SetToplevel(true)
f:SetClampedToScreen(true)
f:SetWidth(360)
f:SetHeight(110)
E:SetTemplate(f, "Transparent")
f:Hide()
local S = E:GetModule("Skins")
local header = CreateFrame("Button", nil, f)
E:SetTemplate(header, "Default", true)
header:SetWidth(120); header:SetHeight(25)
header:SetPoint("CENTER", f, "TOP")
header:SetFrameLevel(header:GetFrameLevel() + 2)
local title = header:CreateFontString("OVERLAY")
E:FontTemplate(title)
title:SetPoint("CENTER", header, "CENTER")
title:SetText("ElvUI")
local desc = f:CreateFontString("ARTWORK")
desc:SetFontObject("GameFontHighlight")
desc:SetJustifyV("TOP")
desc:SetJustifyH("LEFT")
desc:SetPoint("TOPLEFT", 18, -32)
desc:SetPoint("BOTTOMRIGHT", -18, 30)
f.desc = desc
f.disableButton = CreateFrame("CheckButton", f:GetName().."DisableButton", f, "OptionsCheckButtonTemplate")
_G[f.disableButton:GetName() .. "Text"]:SetText(DISABLE)
f.disableButton:SetPoint("BOTTOMLEFT", 1, 1)
S:HandleCheckBox(f.disableButton)
f.disableButton:SetScript("OnShow", function() this:SetChecked(E.db.hideTutorial) end)
f.disableButton:SetScript("OnClick", function() E.db.hideTutorial = this:GetChecked() end)
f.hideButton = CreateFrame("Button", f:GetName().."HideButton", f, "OptionsButtonTemplate")
f.hideButton:SetPoint("BOTTOMRIGHT", -5, 5)
S:HandleButton(f.hideButton)
_G[f.hideButton:GetName() .. "Text"]:SetText(HIDE)
f.hideButton:SetScript("OnClick", function() E:StaticPopupSpecial_Hide(this:GetParent()) end)
f.nextButton = CreateFrame("Button", f:GetName().."NextButton", f, "OptionsButtonTemplate")
f.nextButton:SetPoint("RIGHT", f.hideButton, "LEFT", -4, 0)
f.nextButton:SetWidth(20)
S:HandleButton(f.nextButton)
_G[f.nextButton:GetName() .. "Text"]:SetText(">")
f.nextButton:SetScript("OnClick", function() E:SetNextTutorial() end)
f.prevButton = CreateFrame("Button", f:GetName().."PrevButton", f, "OptionsButtonTemplate")
f.prevButton:SetPoint("RIGHT", f.nextButton, "LEFT", -4, 0)
f.prevButton:SetWidth(20)
S:HandleButton(f.prevButton)
_G[f.prevButton:GetName() .. "Text"]:SetText("<")
f.prevButton:SetScript("OnClick", function() E:SetPrevTutorial() end)
return f
end
function E:Tutorials(forceShow)
if (not forceShow and self.db.hideTutorial) or (not forceShow and not self.private.install_complete) then return end
local f = ElvUITutorialWindow
if not f then
f = E:SpawnTutorialFrame()
end
E:StaticPopupSpecial_Show(f)
self:SetNextTutorial()
end