Skip to content

Commit

Permalink
Refactored game menu skinning and added new UI elements
Browse files Browse the repository at this point in the history
- Renamed Blizzard.lua to Base.lua for better clarity
- Simplified the conditions for enabling the game menu button
- Refactored how the game menu button is created and its functionality
- Added a new GameMenu.lua file that creates a custom skinned game menu with animations, logo button, and other visual enhancements
- Updated loader.xml to include the new GameMenu.lua file
- Added several new image assets used in the custom skinned game menu
  • Loading branch information
Wutname1 committed Aug 1, 2024
1 parent 3bbcbec commit 44642ab
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 19 deletions.
37 changes: 19 additions & 18 deletions Core/Skins/Blizzard.lua → Core/Skins/Blizzard/Base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,33 @@ local function SUI_PositionGameMenuButton()

if GameMenuFrame.Header then GameMenuFrame.Header.Text:SetTextColor(1, 1, 1) end

GameMenuFrame.SUI:SetFormattedText('|cffffffffSpartan|cffe21f1fUI|r')
GameMenuFrame.SUI:SetFormattedText('SpartanUI')
end

local function OnEnable()
if SUI:IsAddonDisabled('Skinner') and SUI:IsAddonDisabled('ConsolePortUI_Menu') then
if SUI:IsAddonDisabled('Skinner') and SUI:IsAddonDisabled('ConsolePort') then
if GameMenuFrame.SUI then return end

if SUI:IsAddonDisabled('Skinner') and SUI:IsAddonDisabled('ConsolePortUI_Menu') then
local button = CreateFrame('Button', 'SUI_GameMenuButton', GameMenuFrame, 'MainMenuFrameButtonTemplate')
button:SetScript('OnClick', function()
SUI:GetModule('Handler.Options'):ToggleOptions()
if not InCombatLockdown() then HideUIPanel(GameMenuFrame) end
end)
button:SetSize(200, 35)
local button = CreateFrame('Button', 'SUI_GameMenuButton', GameMenuFrame, 'MainMenuFrameButtonTemplate')
button:SetScript('OnClick', function()
SUI.Options:ToggleOptions()
if not InCombatLockdown() then HideUIPanel(GameMenuFrame) end
end)
button:SetSize(200, 35)

GameMenuFrame.SUI = button
GameMenuFrame.MenuButtons = GameMenuFrame.MenuButtons or {}
GameMenuFrame.SUI = button
GameMenuFrame.MenuButtons = GameMenuFrame.MenuButtons or {}

---@class SUI.Module.Handler.Skins
local SkinModule = SUI:GetModule('Handler.Skins')
if not SkinModule.DB.Blizzard then SkinModule.DB.Blizzard = {} end
if not SkinModule.DB.Blizzard.GameMenuScale then SkinModule.DB.Blizzard.GameMenuScale = 0.8 end
GameMenuFrame:SetScale(SkinModule.DB.Blizzard.GameMenuScale)
---@class SUI.Module.Handler.Skins
local SkinModule = SUI:GetModule('Handler.Skins')
if not SkinModule.DB.Blizzard then SkinModule.DB.Blizzard = {} end
if not SkinModule.DB.Blizzard.GameMenuScale then SkinModule.DB.Blizzard.GameMenuScale = 0.8 end
GameMenuFrame:SetScale(SkinModule.DB.Blizzard.GameMenuScale)

hooksecurefunc(GameMenuFrame, 'Layout', SUI_PositionGameMenuButton)
end
hooksecurefunc(GameMenuFrame, 'Layout', SUI_PositionGameMenuButton)

SUIMenuSkin:ACTIVE_PLAYER_SPECIALIZATION_CHANGED()
SUIMenuSkin:OnDataLoaded()
end
end

Expand Down
230 changes: 230 additions & 0 deletions Core/Skins/Blizzard/GameMenu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
local GameMenu = GameMenuFrame
---@class SUIMenuSkin : Frame
local MenuSkin = _G['SUIMenuSkin'] or CreateFrame('Frame', 'SUIMenuSkin', UIParent)
local function CreateMenuSkin()
MenuSkin:SetSize(330, 450)
MenuSkin:SetFrameStrata('BACKGROUND')
MenuSkin:Hide()

-- Gradient
MenuSkin.Gradient = MenuSkin:CreateTexture(nil, 'BACKGROUND', nil, 2)
MenuSkin.Gradient:SetAllPoints()
MenuSkin.Gradient:SetTexture('Interface\\AddOns\\SpartanUI\\images\\Menu\\Gradient.jpg')
MenuSkin.Gradient:SetAlpha(0.4)

-- Background
MenuSkin.Background = MenuSkin:CreateTexture(nil, 'BACKGROUND')
MenuSkin.Background:SetPoint('CENTER')

-- Mask
MenuSkin.Mask = MenuSkin:CreateMaskTexture()
MenuSkin.Mask:SetTexture('Interface\\AddOns\\SpartanUI\\images\\Menu\\RingMask.png')
MenuSkin.Mask:SetAllPoints(MenuSkin.Gradient)
MenuSkin.Background:AddMaskTexture(MenuSkin.Mask)
MenuSkin.Gradient:AddMaskTexture(MenuSkin.Mask)

-- Top Line
MenuSkin.TopLine = MenuSkin:CreateTexture(nil, 'ARTWORK')
MenuSkin.TopLine:SetSize(600, 16)
MenuSkin.TopLine:SetPoint('TOP', 0, 100)

-- Logo Button
MenuSkin.LogoButton = CreateFrame('Button', nil, MenuSkin)
MenuSkin.LogoButton:SetSize(60, 60)
MenuSkin.LogoButton:SetPoint('BOTTOM', 0, -30)

MenuSkin.LogoButton.texture = MenuSkin.LogoButton:CreateTexture(nil, 'ARTWORK')
MenuSkin.LogoButton.texture:SetTexture('Interface\\AddOns\\SpartanUI\\images\\Menu\\SUILogo_white.png')
MenuSkin.LogoButton.texture:SetAllPoints()
MenuSkin.LogoButton.texture:AddMaskTexture(MenuSkin.Mask)

-- Mousedown state texture
MenuSkin.LogoButton.mousedownTexture = MenuSkin.LogoButton:CreateTexture(nil, 'ARTWORK')
MenuSkin.LogoButton.mousedownTexture:SetTexture('Interface\\AddOns\\SpartanUI\\images\\Menu\\SUILogo_black.png')
MenuSkin.LogoButton.mousedownTexture:SetAllPoints()
MenuSkin.LogoButton.mousedownTexture:AddMaskTexture(MenuSkin.Mask)
MenuSkin.LogoButton.mousedownTexture:Hide()

-- Highlight effect
MenuSkin.LogoButton.highlight = MenuSkin.LogoButton:CreateTexture(nil, 'HIGHLIGHT')
MenuSkin.LogoButton.highlight:SetTexture('Interface\\AddOns\\SpartanUI\\images\\Menu\\ItemBorderOuterHighlight.jpg')
MenuSkin.LogoButton.highlight:SetSize(140, 140)
MenuSkin.LogoButton.highlight:SetPoint('CENTER')
MenuSkin.LogoButton.highlight:SetBlendMode('ADD')
MenuSkin.LogoButton.highlight:SetAlpha(0)

MenuSkin.LogoButton:SetScript('OnEnter', function(self)
self.highlight:SetAlpha(0.5)
end)

MenuSkin.LogoButton:SetScript('OnLeave', function(self)
self.highlight:SetAlpha(0)
end)

MenuSkin.LogoButton:SetScript('OnMouseDown', function(self)
self.texture:Hide()
self.highlight:Hide()
self.mousedownTexture:Show()
end)

MenuSkin.LogoButton:SetScript('OnMouseUp', function(self)
self.texture:Show()
self.highlight:Hide()
self.mousedownTexture:Hide()
end)

MenuSkin.LogoButton:SetScript('OnClick', function()
SUI.Options:ToggleOptions()
if not InCombatLockdown() then HideUIPanel(GameMenuFrame) end
end)

-- Bottom Line
MenuSkin.BottomLine = MenuSkin:CreateTexture(nil, 'ARTWORK')
MenuSkin.BottomLine:SetSize(600, 16)
MenuSkin.BottomLine:SetPoint('BOTTOM', 0, -140)

-- Line Mask
MenuSkin.LineMask = MenuSkin:CreateMaskTexture()
MenuSkin.LineMask:SetTexture('Interface\\AddOns\\SpartanUI\\images\\Menu\\SquareMask', 'CLAMPTOBLACKADDITIVE', 'CLAMPTOBLACKADDITIVE')
MenuSkin.LineMask:SetPoint('TOPLEFT', MenuSkin.Gradient, 'TOPLEFT', 100, 0)
MenuSkin.LineMask:SetPoint('BOTTOMRIGHT', MenuSkin.Gradient, 'BOTTOMRIGHT', -100, 0)
MenuSkin.TopLine:AddMaskTexture(MenuSkin.LineMask)
MenuSkin.BottomLine:AddMaskTexture(MenuSkin.LineMask)

return MenuSkin
end

CreateMenuSkin()

MenuSkin:SetFrameStrata(GameMenu:GetFrameStrata())
MenuSkin:SetFrameLevel(GameMenu:GetFrameLevel() - 1)
MenuSkin:RegisterEvent('ACTIVE_PLAYER_SPECIALIZATION_CHANGED')
MenuSkin:RegisterEvent('PLAYER_LOGIN')
---------------------------------------------------------------
-- Settings
---------------------------------------------------------------

function MenuSkin:OnDataLoaded()
self:SetPoint('CENTER', UIParent, 'BOTTOMLEFT', self:GetTargetOffsets(GameMenu))
end

MenuSkin:SetScript('OnEvent', function(event, ...)
if MenuSkin[event] then MenuSkin[event](MenuSkin, ...) end
end)

function MenuSkin:ResetAnimation()
self:ClearAllPoints()
self:SetPoint('CENTER', UIParent, 'CENTER', 0, 0)
self.Gradient:ClearAllPoints()
self.Gradient:SetPoint('TOPLEFT', 0, 0)
self.Gradient:SetPoint('BOTTOMRIGHT', 0, 0)
self.TopLine:ClearAllPoints()
self.TopLine:SetPoint('TOP', 0, 100)
self.BottomLine:ClearAllPoints()
self.BottomLine:SetPoint('BOTTOM', 0, -140)
end

function MenuSkin:OnFrameShown(showMenu)
if showMenu then
self:ResetAnimation()
self:OnDataLoaded()
self:InterpolatePoints(GameMenu)
self:UpdateMasks(false) -- useSquareMask is always false for GameMenu
self:SkinGameMenu()
self:Show()
else
self:Hide()
self:SetScript('OnUpdate', nil) -- Stop any ongoing animation
end
end

function MenuSkin:GetTargetOffsets(target)
local relScale = self:GetEffectiveScale() / target:GetEffectiveScale()
local targetX, targetY = target:GetCenter()
return targetX / relScale, targetY / relScale
end

function MenuSkin:SkinGameMenu()
GameMenu.Border:SetShown(false)
GameMenu.Header:SetShown(false)
end

---------------------------------------------------------------
-- Events
---------------------------------------------------------------
function MenuSkin:ACTIVE_PLAYER_SPECIALIZATION_CHANGED()
-- local visual, isAtlas = MenuSkin:GetSpecializationVisual()
-- if isAtlas then
self.Background:SetTexCoord(0, 1, 0, 1)
-- self.Background:SetAtlas(visual, true)
self.Background:SetAtlas('gearUpdate-BG', true)

self.TopLine:SetTexCoord(0, 1, 1, 0)
self.TopLine:SetAtlas('gearUpdate-glow-filigree', true)
self.TopLine:SetAlpha(0.5)

self.BottomLine:SetAtlas('gearUpdate-glow-filigree', true)
self.BottomLine:SetAlpha(0.5)
end

MenuSkin.PLAYER_LOGIN = MenuSkin.ACTIVE_PLAYER_SPECIALIZATION_CHANGED

---------------------------------------------------------------
-- Callbacks
---------------------------------------------------------------
local x, y = 4, 5
function MenuSkin:InterpolatePoints(center)
local MainFramePosition = { self:GetPoint() }
local gradientEndPoint = { self.Gradient:GetPoint(1) }
local secondGradientPoint = { self.Gradient:GetPoint(2) }
local topLinePosition = { self.TopLine:GetPoint() }
local bottomLinePosition = { self.BottomLine:GetPoint() }
local duration, elapsed = 1.5, 0.0

local targetX, targetY = self:GetTargetOffsets(center)

self:SetScript('OnUpdate', function(self, dt)
elapsed = elapsed + dt
local t = elapsed / duration
gradientEndPoint[x] = Lerp(gradientEndPoint[x], -70, t)
gradientEndPoint[y] = Lerp(gradientEndPoint[y], 120, t)

secondGradientPoint[x] = Lerp(secondGradientPoint[x], 70, t)
secondGradientPoint[y] = Lerp(secondGradientPoint[y], -135, t)

topLinePosition[y] = Lerp(topLinePosition[y], 20, t)
bottomLinePosition[y] = Lerp(bottomLinePosition[y], -70, t)

MainFramePosition[x] = Lerp(MainFramePosition[x], targetX, t)
MainFramePosition[y] = Lerp(MainFramePosition[y], targetY, t)

self:SetPoint(unpack(MainFramePosition))
self.Gradient:SetPoint(unpack(gradientEndPoint))
self.Gradient:SetPoint(unpack(secondGradientPoint))
self.TopLine:SetPoint(unpack(topLinePosition))
self.BottomLine:SetPoint(unpack(bottomLinePosition))
if t >= 1.0 then self:SetScript('OnUpdate', nil) end
end)
end

function MenuSkin:UpdateMasks(useSquareMask)
if self.useSquareMask == useSquareMask then return end
if not useSquareMask then
self.Gradient:AddMaskTexture(self.LineMask)
self.Background:AddMaskTexture(self.LineMask)
else
self.Gradient:RemoveMaskTexture(self.LineMask)
self.Background:RemoveMaskTexture(self.LineMask)
end
self.useSquareMask = useSquareMask
end

-- Set up hooks

GameMenu:HookScript('OnShow', function()
MenuSkin:OnFrameShown(true)
end)
GameMenu:HookScript('OnHide', function()
MenuSkin:OnFrameShown(false)
MenuSkin:ResetAnimation()
end)
3 changes: 2 additions & 1 deletion Core/Skins/loader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
..\..\FrameXML\UI.xsd">
<Script file="Core.lua" />
<Script file="Ace3.lua" />
<Script file="Blizzard.lua" />
<Script file="Blizzard\GameMenu.lua" />
<Script file="Blizzard\Base.lua" />
</Ui>
Binary file added images/Menu/Gradient.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Menu/ItemBorderOuterHighlight.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Menu/RingMask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Menu/SUILogo_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Menu/SUILogo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Menu/SquareMask.BLP
Binary file not shown.

0 comments on commit 44642ab

Please sign in to comment.