Commit f22a3efc authored by Simpy's avatar Simpy 🐹

11.34

parents 7eb26b53 e3c2c860
......@@ -3,7 +3,7 @@
------------------------------------------------------------------------
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Lua functions
local _G = _G
local random, next, unpack, strsub = random, next, unpack, strsub
E.AnimShake = {{-9,7,-7,12}, {-5,9,-9,5}, {-5,7,-7,5}, {-9,9,-9,9}, {-5,7,-7,5}, {-9,7,-9,5}}
......@@ -18,6 +18,29 @@ function E:RandomAnimShake(index)
return random(s[1], s[2]), random(s[3], s[4])
end
--TEST
--[[local t = UIParent:CreateFontString("FontString","OVERLAY","GameTooltipText")
t:SetText(0)
t:SetPoint("CENTER")
t:FontTemplate(nil, 20)
E:SetUpAnimGroup(t, "Number", 10, 5)
local b = CreateFrame("BUTTON", nil, UIParent)
b:SetPoint("CENTER", 0, -100)
b:SetTemplate()
b:SetSize(40,30)
b:EnableMouse(true)
b:SetScript("OnClick", function()
if t:GetText() == 10 then
t.NumberAnim:SetChange(0)
t.NumberAnimGroup:Play()
else
t.NumberAnim:SetChange(10)
t.NumberAnimGroup:Play()
end
end)]]
function E:SetUpAnimGroup(obj, Type, ...)
if not Type then Type = 'Flash' end
......@@ -59,6 +82,29 @@ function E:SetUpAnimGroup(obj, Type, ...)
shake.path[i]:SetOffset(E.AnimShakeH[i], 0)
end
end
elseif Type == "Elastic" then
local width, height, duration, loop = ...
obj.elastic = _G.CreateAnimationGroup(obj)
for i = 1, 4 do
local anim = obj.elastic:CreateAnimation(i < 3 and 'width' or 'height')
anim:SetChange((i==1 and width*0.45) or (i==2 and width) or (i==3 and height*0.45) or height)
anim:SetEasing('inout-elastic')
anim:SetDuration(duration)
obj.elastic[i] = anim
end
obj.elastic[1]:SetScript('OnFinished', function(anim) anim:Stop() obj.elastic[2]:Play() end)
obj.elastic[3]:SetScript('OnFinished', function(anim) anim:Stop() obj.elastic[4]:Play() end)
obj.elastic[2]:SetScript('OnFinished', function(anim) anim:Stop() if loop then obj.elastic[1]:Play() end end)
obj.elastic[4]:SetScript('OnFinished', function(anim) anim:Stop() if loop then obj.elastic[3]:Play() end end)
elseif Type == "Number" then
local endingNumber, duration = ...
obj.NumberAnimGroup = _G.CreateAnimationGroup(obj)
obj.NumberAnim = obj.NumberAnimGroup:CreateAnimation('number')
obj.NumberAnim:SetChange(endingNumber)
obj.NumberAnim:SetEasing('in-circular')
obj.NumberAnim:SetDuration(duration)
else
local x, y, duration, customName = ...
if not customName then customName = 'anim' end
......@@ -88,6 +134,22 @@ function E:SetUpAnimGroup(obj, Type, ...)
end
end
function E:Elasticize(obj)
if not obj.elastic then
E:SetUpAnimGroup(obj, 'Elastic', 128, 64, 2, false)
end
obj.elastic[1]:Play()
obj.elastic[3]:Play()
end
function E:StopElasticize(obj)
if obj.elastic then
obj.elastic[1]:Stop(true)
obj.elastic[3]:Stop(true)
end
end
function E:Shake(obj)
if not obj.shake then
E:SetUpAnimGroup(obj, 'Shake')
......
......@@ -3,21 +3,29 @@ local S = E:GetModule('Skins')
--Lua functions
local _G = _G
local unpack = unpack
local type, ipairs, tonumber = type, ipairs, tonumber
local floor, select = floor, select
local unpack, sort, gsub, wipe = unpack, sort, gsub, wipe
local strupper, ipairs, tonumber = strupper, ipairs, tonumber
local floor, select, type, min = floor, select, type, min
local pairs, tinsert, tContains = pairs, tinsert, tContains
local strsplit = strsplit
--WoW API / Variables
local hooksecurefunc = hooksecurefunc
local EnableAddOn = EnableAddOn
local LoadAddOn = LoadAddOn
local GetAddOnMetadata = GetAddOnMetadata
local GetAddOnInfo = GetAddOnInfo
local GameTooltip = GameTooltip
local CreateFrame = CreateFrame
local IsAddOnLoaded = IsAddOnLoaded
local InCombatLockdown = InCombatLockdown
local IsControlKeyDown = IsControlKeyDown
local IsAltKeyDown = IsAltKeyDown
local EditBox_ClearFocus = EditBox_ClearFocus
local ERR_NOT_IN_COMBAT = ERR_NOT_IN_COMBAT
local RESET = RESET
-- GLOBALS: ElvUIMoverPopupWindow, ElvUIMoverNudgeWindow, ElvUIMoverPopupWindowDropDown
local selectedValue, grid = 'ALL'
local grid
E.ConfigModeLayouts = {
'ALL',
'GENERAL',
......@@ -55,45 +63,41 @@ function E:Grid_Hide()
end
end
function E:ToggleMoveMode(override, configType)
if InCombatLockdown() then return; end
if override ~= nil and override ~= '' then E.ConfigurationMode = override end
function E:ToggleMoveMode(which)
if InCombatLockdown() then return end
local mode = not E.ConfigurationMode
if not which or which == '' then
E.ConfigurationMode = mode
which = 'ALL'
else
mode = true
which = strupper(which)
end
if E.ConfigurationMode ~= true then
self:ToggleMovers(mode, which)
if mode then
E:Grid_Show()
_G.ElvUIGrid:SetAlpha(0.4)
if not ElvUIMoverPopupWindow then
E:CreateMoverPopup()
end
ElvUIMoverPopupWindow:Show()
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, which)
if IsAddOnLoaded('ElvUI_OptionsUI') then
if E.Libs.AceConfigDialog then
E.Libs.AceConfigDialog:Close('ElvUI')
end
if not _G.GameTooltip:IsForbidden() then
_G.GameTooltip:Hide()
end
E:Config_CloseWindow()
end
E.ConfigurationMode = true
else
E:Grid_Hide()
_G.ElvUIGrid:SetAlpha(1)
if ElvUIMoverPopupWindow then
ElvUIMoverPopupWindow: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_GetRegion()
......@@ -179,9 +183,7 @@ function E:Grid_Create()
end
local function ConfigMode_OnClick(self)
selectedValue = self.value
E:ToggleMoveMode(false, self.value)
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, self.value)
E:ToggleMoveMode(self.value)
end
local function ConfigMode_Initialize()
......@@ -194,7 +196,8 @@ local function ConfigMode_Initialize()
_G.UIDropDownMenu_AddButton(info)
end
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue)
local dd = ElvUIMoverPopupWindowDropDown
_G.UIDropDownMenu_SetSelectedValue(dd, dd.selectedValue or 'ALL')
end
function E:NudgeMover(nudgeX, nudgeY)
......@@ -214,8 +217,8 @@ function E:UpdateNudgeFrame(mover, x, y)
x, y = E:CalculateMoverPoints(mover)
end
x = E:Round(x, 0)
y = E:Round(y, 0)
x = E:Round(x)
y = E:Round(y)
local ElvUIMoverNudgeWindow = ElvUIMoverNudgeWindow
ElvUIMoverNudgeWindow.xOffset:SetText(x)
......@@ -242,11 +245,6 @@ function E:CreateMoverPopup()
f:Height(190)
f:SetTemplate('Transparent')
f:Point('BOTTOM', _G.UIParent, 'CENTER', 0, 100)
f:SetScript('OnHide', function()
if ElvUIMoverPopupWindowDropDown then
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, 'ALL')
end
end)
f:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
f:CreateShadow(5)
f:Hide()
......@@ -288,16 +286,16 @@ function E:CreateMoverPopup()
local lock = CreateFrame('Button', f:GetName()..'CloseButton', f, 'OptionsButtonTemplate')
_G[lock:GetName() .. 'Text']:SetText(L["Lock"])
lock:SetScript('OnClick', function()
E:ToggleMoveMode(true)
E:ToggleMoveMode()
if IsAddOnLoaded('ElvUI_OptionsUI') and E.Libs.AceConfigDialog then
E.Libs.AceConfigDialog:Open('ElvUI')
end
if E.ConfigurationToggled then
E.ConfigurationToggled = nil
selectedValue = 'ALL'
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue)
if IsAddOnLoaded('ElvUI_OptionsUI') then
E:Config_OpenWindow()
end
end
end)
local align = CreateFrame('EditBox', f:GetName()..'EditBox', f, 'InputBoxTemplate')
......@@ -349,7 +347,7 @@ function E:CreateMoverPopup()
if mover:IsShown() then
mover:Hide()
E:Grid_Hide()
E:ToggleMoveMode(true)
E:ToggleMoveMode()
end
end)
......@@ -370,7 +368,6 @@ function E:CreateMoverPopup()
nudgeFrame:CreateShadow(5)
nudgeFrame:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
nudgeFrame:SetFrameLevel(500)
nudgeFrame:Hide()
nudgeFrame:EnableMouse(true)
nudgeFrame:SetClampedToScreen(true)
nudgeFrame:SetPropagateKeyboardInput(true)
......@@ -519,3 +516,669 @@ function E:CreateMoverPopup()
S:HandleButton(rightButton)
rightButton:Size(22)
end
function E:Config_ResetSettings()
E.configSavedPositionTop, E.configSavedPositionLeft = nil, nil
E.global.general.AceGUI = E:CopyTable({}, E.DF.global.general.AceGUI)
end
function E:Config_GetPosition()
return E.configSavedPositionTop, E.configSavedPositionLeft
end
function E:Config_GetSize()
return E.global.general.AceGUI.width, E.global.general.AceGUI.height
end
function E:Config_UpdateSize(reset)
local frame = E:Config_GetWindow()
if not frame then return end
local maxWidth, maxHeight = self.UIParent:GetSize()
frame:SetMinResize(800, 600)
frame:SetMaxResize(maxWidth-50, maxHeight-50)
self.Libs.AceConfigDialog:SetDefaultSize(E.name, E:Config_GetDefaultSize())
local status = frame.obj and frame.obj.status
if status then
if reset then
E:Config_ResetSettings()
status.top, status.left = E:Config_GetPosition()
status.width, status.height = E:Config_GetDefaultSize()
frame.obj:ApplyStatus()
else
local top, left = E:Config_GetPosition()
if top and left then
status.top, status.left = top, left
frame.obj:ApplyStatus()
end
end
E:Config_UpdateLeftScroller(frame)
end
end
function E:Config_GetDefaultSize()
local width, height = E:Config_GetSize()
local maxWidth, maxHeight = E.UIParent:GetSize()
width, height = min(maxWidth-50, width), min(maxHeight-50, height)
return width, height
end
function E:Config_StopMoving()
local frame = self and self.GetParent and self:GetParent()
if frame and frame.obj and frame.obj.status then
E.configSavedPositionTop, E.configSavedPositionLeft = E:Round(frame:GetTop(), 2), E:Round(frame:GetLeft(), 2)
E.global.general.AceGUI.width, E.global.general.AceGUI.height = E:Round(frame:GetWidth(), 2), E:Round(frame:GetHeight(), 2)
E:Config_UpdateLeftScroller(frame)
end
end
local function Config_ButtonOnEnter(self)
if GameTooltip:IsForbidden() or not self.desc then return end
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 2)
GameTooltip:AddLine(self.desc, 1, 1, 1, true)
GameTooltip:Show()
end
local function Config_ButtonOnLeave()
if GameTooltip:IsForbidden() then return end
GameTooltip:Hide()
end
local function Config_StripNameColor(name)
if type(name) == 'function' then name = name() end
return E:StripString(name)
end
local function Config_SortButtons(a,b)
local A1, B1 = a[1], b[1]
if A1 and B1 then
if A1 == B1 then
local A3, B3 = a[3], b[3]
if A3 and B3 and (A3.name and B3.name) then
return Config_StripNameColor(A3.name) < Config_StripNameColor(B3.name)
end
end
return A1 < B1
end
end
local function ConfigSliderOnMouseWheel(self, offset)
local _, maxValue = self:GetMinMaxValues()
if maxValue == 0 then return end
local newValue = self:GetValue() - offset
if newValue < 0 then newValue = 0 end
if newValue > maxValue then return end
self:SetValue(newValue)
self.buttons:Point("TOPLEFT", 0, newValue * 36)
end
local function ConfigSliderOnValueChanged(self, value)
self:SetValue(value)
self.buttons:Point("TOPLEFT", 0, value * 36)
end
function E:Config_SetButtonText(btn, noColor)
local name = btn.info.name
if type(name) == 'function' then name = name() end
if noColor then
btn:SetText(name:gsub('|c[fF][fF]%x%x%x%x%x%x',''):gsub('|r',''))
else
btn:SetText(name)
end
end
function E:Config_CreateSeparatorLine(frame, lastButton)
local line = frame.leftHolder.buttons:CreateTexture()
line:SetTexture(E.Media.Textures.White8x8)
line:SetVertexColor(1, .82, 0, .4)
line:Size(179, 2)
line:Point("TOP", lastButton, "BOTTOM", 0, -6)
line.separator = true
return line
end
function E:Config_SetButtonColor(btn, disabled)
if disabled then
btn:Disable()
btn:SetBackdropBorderColor(1, .82, 0, 1)
btn:SetBackdropColor(1, .82, 0, 0.4)
btn.Text:SetTextColor(1, 1, 1)
E:Config_SetButtonText(btn, true)
else
btn:Enable()
local r, g, b = unpack(E.media.bordercolor)
btn:SetBackdropBorderColor(r, g, b, 1)
r, g, b = unpack(E.media.backdropcolor)
btn:SetBackdropColor(r, g, b, 1)
btn.Text:SetTextColor(1, .82, 0)
E:Config_SetButtonText(btn)
end
end
function E:Config_UpdateSliderPosition(btn)
local left = btn and btn.frame and btn.frame.leftHolder
if left and left.slider then
ConfigSliderOnValueChanged(left.slider, btn.sliderValue or 0)
end
end
function E:Config_CreateButton(info, frame, unskinned, ...)
local btn = CreateFrame(...)
btn.frame = frame
btn.desc = info.desc
btn.info = info
if not unskinned then
E.Skins:HandleButton(btn)
end
E:Config_SetButtonText(btn)
E:Config_SetButtonColor(btn, btn.info.key == 'general')
btn:HookScript('OnEnter', Config_ButtonOnEnter)
btn:HookScript('OnLeave', Config_ButtonOnLeave)
btn:SetScript('OnClick', info.func)
btn:Width(btn:GetTextWidth() + 40)
btn.ignoreBorderColors = true
return btn
end
function E:Config_UpdateLeftButtons()
local frame = E:Config_GetWindow()
if not (frame and frame.leftHolder) then return end
local status = frame.obj.status
local selected = status and status.groups.selected
for _, btn in ipairs(frame.leftHolder.buttons) do
if type(btn) == 'table' and btn.IsObjectType and btn:IsObjectType('Button') then
local enabled = btn.info.key == selected
E:Config_SetButtonColor(btn, enabled)
if enabled then
E:Config_UpdateSliderPosition(btn)
end
end
end
end
function E:Config_UpdateLeftScroller(frame)
local left = frame and frame.leftHolder
if not left then return end
local btns = left.buttons
local bottom = btns:GetBottom()
if not bottom then return end
btns:Point("TOPLEFT", 0, 0)
local max = 0
for _, btn in ipairs(btns) do
local button = type(btn) == 'table' and btn.IsObjectType and btn:IsObjectType('Button')
if button then
btn.sliderValue = nil
local btm = btn:GetBottom()
if btm then
if bottom > btm then
max = max + 1
btn.sliderValue = max
end
end
end
end
local slider = left.slider
slider:SetMinMaxValues(0, max)
slider:SetValue(0)
if max == 0 then
slider.thumb:Hide()
else
slider.thumb:Show()
end
end
function E:Config_SaveOldPosition(frame)
if frame.GetNumPoints and not frame.oldPosition then
frame.oldPosition = {}
for i = 1, frame:GetNumPoints() do
tinsert(frame.oldPosition, {frame:GetPoint(i)})
end
end
end
function E:Config_RestoreOldPosition(frame)
local position = frame.oldPosition
if position then
frame:ClearAllPoints()
for i = 1, #position do
frame:Point(unpack(position[i]))
end
end
end
function E:Config_CreateLeftButtons(frame, unskinned, options)
local opts = {}
for key, info in pairs(options) do
if (not info.order or info.order < 6) and not tContains(E.OriginalOptions, key) then
info.order = 6
end
if key == 'profiles' then
info.desc = nil
end
tinsert(opts, {info.order, key, info})
end
sort(opts, Config_SortButtons)
local buttons, last, order = frame.leftHolder.buttons
for index, opt in ipairs(opts) do
local info = opt[3]
local key = opt[2]
if (order == 2 or order == 5) and order < opt[1] then
last = E:Config_CreateSeparatorLine(frame, last)
end
order = opt[1]
info.key = key
info.func = function()
local ACD = E.Libs.AceConfigDialog
if ACD then ACD:SelectGroup("ElvUI", key) end
end
local btn = E:Config_CreateButton(info, frame, unskinned, 'Button', nil, buttons, 'UIPanelButtonTemplate')
btn:Width(177)
if not last then
btn:Point("TOP", buttons, "TOP", 0, 0)
else
btn:Point("TOP", last, "BOTTOM", 0, (last.separator and -6) or -4)
end
buttons[index] = btn
last = btn
end
end
function E:Config_CloseClicked()
if self.originalClose then
self.originalClose:Click()
end
end
function E:Config_CloseWindow()
local ACD = E.Libs.AceConfigDialog
if ACD then
ACD:Close('ElvUI')
end
if not GameTooltip:IsForbidden() then
GameTooltip:Hide()
end
end
function E:Config_OpenWindow()
local ACD = E.Libs.AceConfigDialog
if ACD then
ACD:Open('ElvUI')
local frame = E:Config_GetWindow()