From bea3981ae96ca28a31a24e6994e249b2e2453a18 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Mon, 25 Nov 2024 19:00:31 -0800 Subject: [PATCH 1/4] update stylegroup if different --- .../Controls/StyledButtonGroup.cs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/Content.Client/UserInterface/Controls/StyledButtonGroup.cs b/Content.Client/UserInterface/Controls/StyledButtonGroup.cs index ad7e75902ce..e05eb3f7005 100644 --- a/Content.Client/UserInterface/Controls/StyledButtonGroup.cs +++ b/Content.Client/UserInterface/Controls/StyledButtonGroup.cs @@ -23,21 +23,35 @@ public StyledButtonGroup() public void UpdateStyles() { var children = Children.Where(c => c.Visible && c is Button).ToArray(); - for (var i = 0; i < children.Length; i++) + var len = children.Length; + + for (var i = 0; i < len; i++) { var child = children[i]; var button = (child as Button)!; - button.RemoveStyleClass(ButtonOpenRight); - button.RemoveStyleClass(ButtonOpenLeft); - button.RemoveStyleClass(ButtonOpenBoth); - if (i == 0) - button.AddStyleClass(children.Length == 1 ? "" : ButtonOpenRight); - else if (i == children.Length - 1) - button.AddStyleClass(ButtonOpenLeft); + TryUpdateStyle(button, len == 1 ? "" : ButtonOpenRight); + else if (i == len - 1) + TryUpdateStyle(button, ButtonOpenLeft); else - button.AddStyleClass(ButtonOpenBoth); + TryUpdateStyle(button, ButtonOpenBoth); } } + + private bool TryUpdateStyle(Control control, string style) + { + if (control.HasStyleClass(style)) + return false; + + control.RemoveStyleClass(ButtonOpenRight); + control.RemoveStyleClass(ButtonOpenLeft); + control.RemoveStyleClass(ButtonOpenBoth); + + if (!string.IsNullOrEmpty(style)) + control.AddStyleClass(style); + else + return false; + return true; + } } From e54b9286fed53fb1a8d3953e1a673e61609b05dc Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Mon, 25 Nov 2024 19:08:47 -0800 Subject: [PATCH 2/4] preset loadout selector styles --- .../Lobby/UI/LoadoutPreferenceSelector.xaml | 10 ++++++---- .../Lobby/UI/LoadoutPreferenceSelector.xaml.cs | 17 ++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml b/Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml index e04fdc1c69b..d77fdb66057 100644 --- a/Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml +++ b/Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml @@ -8,7 +8,8 @@ Name="PreferenceButton" Access="Public" ToggleMode="True" - VerticalAlignment="Center" /> + VerticalAlignment="Center" + StyleClasses="OpenRight" />