Skip to content

Commit

Permalink
Make window buttons look prettier in Retail (#782)
Browse files Browse the repository at this point in the history
* Make window buttons look prettier in Retail

This updates the maximize, minimize, and resize buttons on the main
frame to use newer art assets in retail clients. The button positioning
has been slightly altered to no longer bleed outside the frame.

On classic clients the old assets are used, as the newer art doesn't
exist there.

For the resize button this doesn't update the styling of
the TRP3_ResizeButton template itself. The new templates use a different
frame size and I didn't want to spend any time going through and
correcting every single usage of the resize button template.

* Mirror disabled texture for resize

* Remove resize init from art template

The art template should just be for art; it shouldn't implicitly
initialize resizing.

* Use single extensible template for styled buttons

Rather than creating one art template per button type (and one
mixin each for client overrides) a new "styled button" template
has been added that will configure regions of a button according to
a named visual style like "CloseButton".

* Load StyledButton.xml a bit earlier

* Use new styles for all Close/Resize buttons

There's other buttons in the UI that haven't been touched still for
stuff like module options and profile actions; these might get improved
in a bit or may not.

* Update remaining buttons

This largely impacts the "action" buttons that used the minimize
assets elsewhere, like in the register list.
  • Loading branch information
Meorawr committed Jul 11, 2023
1 parent 778d2f0 commit f295caf
Show file tree
Hide file tree
Showing 20 changed files with 413 additions and 87 deletions.
7 changes: 6 additions & 1 deletion .luacheckrc
Expand Up @@ -325,6 +325,12 @@ stds.wow = {
},
},

C_Texture = {
fields = {
"GetAtlasInfo",
},
},

C_Timer = {
fields = {
"After",
Expand Down Expand Up @@ -510,7 +516,6 @@ stds.wow = {
"UIDROPDOWNMENU_INIT_MENU",
"UIDROPDOWNMENU_MENU_LEVEL",
"UIDROPDOWNMENU_MENU_VALUE",
"UIPanelCloseButton_SetBorderAtlas",
"UnitAffectingCombat",
"UnitAura",
"UnitBattlePetLevel",
Expand Down
36 changes: 12 additions & 24 deletions totalRP3/Modules/ChatLinks/ChatLinks.xml
Expand Up @@ -11,42 +11,30 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Button name="TRP3_ChatLinkActionButton" inherits="UIPanelButtonTemplate" virtual="true" hidden="true" mixin="TRP3_ChatLinkActionButtonMixin">
<Size x="100" y="20"/>
<Scripts>
<OnLoad method="OnLoad" />
<OnClick method="OnClick" />
<OnLoad method="OnLoad"/>
<OnClick method="OnClick"/>
</Scripts>
</Button>

<GameTooltip name="TRP3_RefTooltip" inherits="TRP3_TooltipTemplate" parent="UIParent" enableMouse="true" toplevel="true" movable="true" frameStrata="TOOLTIP" hidden="true" mixin="TRP3_ChatLinkTooltipMixin">
<Size>
<AbsDimension x="128" y="64"/>
</Size>
<Size x="128" y="64"/>
<Anchors>
<Anchor point="BOTTOM">
<Offset>
<AbsDimension x="0" y="80"/>
</Offset>
</Anchor>
<Anchor point="BOTTOM" y="80"/>
</Anchors>
<Frames>
<Button>
<Size>
<AbsDimension x="32" y="32"/>
</Size>
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT">
<Offset>
<AbsDimension x="1" y="0"/>
</Offset>
</Anchor>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
<Scripts>
<OnClick>
TRP3_RefTooltip:Hide();
</OnClick>
</Scripts>
<NormalTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Up"/>
<PushedTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Down"/>
<HighlightTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Highlight" alphaMode="ADD"/>
</Button>

<Button parentKey="Button1" inherits="TRP3_ChatLinkActionButton">
Expand Down Expand Up @@ -76,8 +64,8 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
</Button>
</Frames>
<Scripts>
<OnLoad method="OnLoad" inherit="prepend" />
<OnUpdate method="OnUpdate" />
<OnLoad method="OnLoad" inherit="prepend"/>
<OnUpdate method="OnUpdate"/>
</Scripts>
</GameTooltip>

Expand Down
9 changes: 8 additions & 1 deletion totalRP3/Modules/Dashboard/Dashboard.xml
Expand Up @@ -179,10 +179,17 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
</Layer>
</Layers>
<Frames>
<Button parentKey="Close" inherits="UIPanelCloseButton">
<Button parentKey="Close" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
<Scripts>
<OnClick function="HideParentPanel"/>
</Scripts>
</Button>
<EditBox parentKey="name" inherits="TRP3_TitledHelpEditBox">
<Size y="18"/>
Expand Down
12 changes: 6 additions & 6 deletions totalRP3/Modules/Modules.xml
Expand Up @@ -44,14 +44,14 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Anchor point="TOPLEFT" x="13" y="-7"/>
</Anchors>
</Button>
<Button name="$parentAction">
<Size x="32" y="32"/>
<Button name="$parentAction" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="MinimizeButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-4" y="-4"/>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
<NormalTexture file="Interface\Buttons\UI-Panel-SmallerButton-Up"/>
<PushedTexture file="Interface\Buttons\UI-Panel-SmallerButton-Down"/>
<HighlightTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Highlight" alphaMode="ADD"/>
</Button>
</Frames>
</Frame>
Expand Down
10 changes: 7 additions & 3 deletions totalRP3/Modules/Register/Characters/RegisterUIMisc.xml
Expand Up @@ -275,9 +275,13 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
</Anchors>
</Frame>

<Button inherits="UIPanelCloseButton">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="0" y="0"/>
<Anchor point="TOPRIGHT"/>
</Anchors>
<Scripts>
<OnClick>
Expand All @@ -297,7 +301,7 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<KeyValue key="minHeight" value="150" type="number"/>
</KeyValues>
<Anchors>
<Anchor point="BOTTOMRIGHT" x="0" y="0"/>
<Anchor point="BOTTOMRIGHT"/>
</Anchors>
</Button>
</Frames>
Expand Down
12 changes: 10 additions & 2 deletions totalRP3/Modules/Register/Filter/RegisterMatureFilter.xml
Expand Up @@ -146,7 +146,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Anchor point="CENTER" x="0" y="0"/>
</Anchors>
<Frames>
<Button inherits="UIPanelCloseButton">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down Expand Up @@ -229,7 +233,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
</Layer>
</Layers>
<Frames>
<Button inherits="UIPanelCloseButton">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down
6 changes: 5 additions & 1 deletion totalRP3/UI/Browsers/Colors.xml
Expand Up @@ -28,7 +28,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">

</Layers>
<Frames>
<Button inherits="UIPanelCloseButton">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down
6 changes: 5 additions & 1 deletion totalRP3/UI/Browsers/Companions.xml
Expand Up @@ -15,7 +15,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Anchor point="CENTER" x="0" y="0"/>
</Anchors>
<Frames>
<Button name="TRP3_CompanionBrowserClose" inherits="UIPanelCloseButton">
<Button name="TRP3_CompanionBrowserClose" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down
6 changes: 5 additions & 1 deletion totalRP3/UI/Browsers/Icons.xml
Expand Up @@ -45,7 +45,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
</OnHide>
</Scripts>
<Frames>
<Button name="TRP3_IconBrowserClose" inherits="UIPanelCloseButton">
<Button name="TRP3_IconBrowserClose" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down
6 changes: 5 additions & 1 deletion totalRP3/UI/Browsers/Images.xml
Expand Up @@ -15,7 +15,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Anchor point="CENTER" x="0" y="0"/>
</Anchors>
<Frames>
<Button inherits="UIPanelCloseButton">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down
6 changes: 5 additions & 1 deletion totalRP3/UI/Browsers/Musics.xml
Expand Up @@ -66,7 +66,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Anchor point="CENTER" x="0" y="0"/>
</Anchors>
<Frames>
<Button inherits="UIPanelCloseButton">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-5" y="-5"/>
</Anchors>
Expand Down
1 change: 0 additions & 1 deletion totalRP3/UI/Browsers/PetBrowser.lua
Expand Up @@ -156,7 +156,6 @@ function TRP3_PetBrowserMixin:OnLoad()
self.tooltipFrame = self.tooltipFrame or TRP3_MainTooltip;

-- Dynamic UI styling.
UIPanelCloseButton_SetBorderAtlas(self.CloseButton, "UI-Frame-GenericMetal-ExitButtonBorder", -1, 1);
self.AcceptButton:SetText(L.UI_PET_BROWSER_ACCEPT);

-- Icon grid layout setup.
Expand Down
6 changes: 5 additions & 1 deletion totalRP3/UI/Browsers/PetBrowser.xml
Expand Up @@ -184,7 +184,11 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<OnClick>CallMethodOnNearestAncestor(self, "Accept");</OnClick>
</Scripts>
</Button>
<Button parentKey="CloseButton" inherits="UIPanelCloseButtonNoScripts">
<Button parentKey="CloseButton" inherits="TRP3_StyledButtonTemplate">
<Size x="24" y="24"/>
<KeyValues>
<KeyValue key="styleName" value="CloseButton" type="string"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT" x="-8" y="-8"/>
</Anchors>
Expand Down
67 changes: 67 additions & 0 deletions totalRP3/UI/Main.lua
Expand Up @@ -11,6 +11,7 @@ TRP3_MainFrameMixin = {};
function TRP3_MainFrameMixin:OnLoad()
self.windowState = WindowState.Normal;
TRP3_Addon.RegisterCallback(self, "CONFIGURATION_CHANGED", "OnConfigurationChanged");
TRP3_API.ui.frame.initResize(self.Resize);
end

function TRP3_MainFrameMixin:OnConfigurationChanged(_, key)
Expand Down Expand Up @@ -74,3 +75,69 @@ function TRP3_MainFrameMixin:UpdateWindowStateButtons()
self.Minimize:SetShown(state == WindowState.Maximized and ShouldShowWindowStateButtons());
self.Maximize:SetShown(state == WindowState.Normal and ShouldShowWindowStateButtons());
end

local function ResetTexCoords(texture)
texture:SetTexCoord(0, 1, 0, 1);
end

local function MirrorTexCoordsAlongHorizontalAxis(region)
local x1, y1, x2, y2, x3, y3, x4, y4 = region:GetTexCoord();
region:SetTexCoord(x3, y3, x4, y4, x1, y1, x2, y2);
end

TRP3_WindowCloseButtonArtMixin = {};

function TRP3_WindowCloseButtonArtMixin:OnLoad()
if C_Texture.GetAtlasInfo("RedButton-Exit") then
ResetTexCoords(self:GetNormalTexture());
ResetTexCoords(self:GetPushedTexture());
ResetTexCoords(self:GetDisabledTexture());
ResetTexCoords(self:GetHighlightTexture());
self:SetNormalAtlas("RedButton-Exit");
self:SetPushedAtlas("RedButton-Exit-Pressed");
self:SetDisabledAtlas("RedButton-Exit-Disabled");
self:SetHighlightAtlas("RedButton-Highlight", "ADD");
end
end

TRP3_WindowMaximizeButtonArtMixin = {};

function TRP3_WindowMaximizeButtonArtMixin:OnLoad()
if C_Texture.GetAtlasInfo("RedButton-Expand") then
ResetTexCoords(self:GetNormalTexture());
ResetTexCoords(self:GetPushedTexture());
ResetTexCoords(self:GetDisabledTexture());
ResetTexCoords(self:GetHighlightTexture());
self:SetNormalAtlas("RedButton-Expand");
self:SetPushedAtlas("RedButton-Expand-Pressed");
self:SetDisabledAtlas("RedButton-Expand-Disabled");
self:SetHighlightAtlas("RedButton-Highlight", "ADD");
end
end

TRP3_WindowMinimizeButtonArtMixin = {};

function TRP3_WindowMinimizeButtonArtMixin:OnLoad()
if C_Texture.GetAtlasInfo("RedButton-Condense") then
ResetTexCoords(self:GetNormalTexture());
ResetTexCoords(self:GetPushedTexture());
ResetTexCoords(self:GetDisabledTexture());
ResetTexCoords(self:GetHighlightTexture());
self:SetNormalAtlas("RedButton-Condense");
self:SetPushedAtlas("RedButton-Condense-Pressed");
self:SetDisabledAtlas("RedButton-Condense-Disabled");
self:SetHighlightAtlas("RedButton-Highlight", "ADD");
end
end

TRP3_WindowResizeButtonArtMixin = {};

function TRP3_WindowResizeButtonArtMixin:OnLoad()
TRP3_WindowMinimizeButtonArtMixin.OnLoad(self);

if C_Texture.GetAtlasInfo("RedButton-Condense") then
MirrorTexCoordsAlongHorizontalAxis(self:GetNormalTexture());
MirrorTexCoordsAlongHorizontalAxis(self:GetPushedTexture());
MirrorTexCoordsAlongHorizontalAxis(self:GetDisabledTexture());
end
end

0 comments on commit f295caf

Please sign in to comment.