diff --git a/WheelWizard/Views/Layout.axaml b/WheelWizard/Views/Layout.axaml index 82aa4958..3ee845c5 100644 --- a/WheelWizard/Views/Layout.axaml +++ b/WheelWizard/Views/Layout.axaml @@ -8,12 +8,13 @@ xmlns:pages="clr-namespace:WheelWizard.Views.Pages" xmlns:components="clr-namespace:WheelWizard.Views.Components" xmlns:patterns="clr-namespace:WheelWizard.Views.Patterns" + xmlns:miiVars="using:WheelWizard.MiiImages.Domain" Height="876" Width="656" WindowStartupLocation="CenterScreen" SystemDecorations="None" ExtendClientAreaToDecorationsHint="True" ExtendClientAreaChromeHints="NoChrome" CanResize='False' Background="Transparent"> - - - - - - - - - @@ -64,57 +57,45 @@ Margin="{StaticResource EdgeGap}" /> - - - - + + + + + - - - - - - - - - - - - + + + + + - @@ -135,7 +116,11 @@ + Text="{loc:T page_title.rooms}" x:Name="RoomsButton" + BoxText="0" + BoxIconData="{StaticResource UserCouple}" + BoxIconSize="14" + BoxTip="{loc:T hover.players_online.0}" /> @@ -157,34 +142,149 @@ Text="Kitchen Sink" x:Name="KitchenSinkButton" /> - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + friend.IsOnline)); } + public void UpdateSidebarProfile() => SidebarCurrentUserProfile.Refresh(); + public void UpdatePlayerAndRoomCount(RRLiveRooms sender) { var playerCount = sender.PlayerCount; - var roomCount = sender.RoomCount; - PlayerCountBox.Text = playerCount.ToString(); - PlayerCountBox.TipText = t("hover.players_online.n", playerCount); - RoomCountBox.Text = roomCount.ToString(); - RoomCountBox.TipText = t("hover.rooms_online.n", roomCount); + RoomsButton.BoxText = playerCount.ToString(); + RoomsButton.BoxTip = t("hover.players_online.n", playerCount); UpdateFriendCount(); } + public void UpdateLiveAlert() => UpdateLiveAlert(WhWzStatusManager.Instance); + private void UpdateLiveAlert(WhWzStatusManager sender) { var hasVariant = sender.Status?.Variant != null && sender.Status.Variant != WhWzStatusVariant.None; @@ -272,6 +276,7 @@ private void UpdateLiveAlert(WhWzStatusManager sender) ToolTip.SetTip(LiveStatusBorder, sender.Status!.Message); LiveStatusBorder.Classes.Clear(); + LiveStatusBorder.Classes.Add("BottomSidebarIcon"); // If custom icon is provided, use it instead of variant if (hasCustomIcon) @@ -362,15 +367,51 @@ private void UpdateTestingButtonVisibility() TestingButton.IsVisible = SettingsService.Get(SettingsService.TESTING_MODE_ENABLED); } + private void SidebarInfoButton_OnPointerPressed(object? sender, PointerPressedEventArgs e) + { + SidebarInfoContextMenu.Open(); + e.Handled = true; + } + + private void SidebarProfileBlock_OnPointerEntered(object? sender, PointerEventArgs e) + { + SidebarProfileBlock.Background = GetResourceBrush("Neutral800"); + SidebarProfileBlock.BorderBrush = GetResourceBrush("Primary400"); + SidebarProfileHoverEffect.IsVisible = true; + } + + private void SidebarProfileBlock_OnPointerExited(object? sender, PointerEventArgs e) + { + SidebarProfileBlock.Background = Brushes.Transparent; + SidebarProfileBlock.BorderBrush = GetResourceBrush("Neutral600"); + SidebarProfileHoverEffect.IsVisible = false; + } + + private void SidebarProfileBlock_OnPointerMoved(object? sender, PointerEventArgs e) + { + var position = e.GetPosition(sender as Control); + SidebarProfileHoverEffect.Margin = new( + position.X - (SidebarProfileHoverEffect.Width / 2), + position.Y - (SidebarProfileHoverEffect.Height / 2), + 0, + 0 + ); + } + + private static IBrush GetResourceBrush(string resourceName) => + new SolidColorBrush((Color)Application.Current!.FindResource(resourceName)!); + private void CloseButton_Click(object? sender, RoutedEventArgs e) => Close(); private void MinimizeButton_Click(object? sender, RoutedEventArgs e) => WindowState = WindowState.Minimized; - private void Discord_Click(object sender, EventArgs e) => ViewUtils.OpenLink(BrandingService.Branding.DiscordUrl.ToString()); + private void Discord_Click(object? sender, RoutedEventArgs e) => ViewUtils.OpenLink(BrandingService.Branding.DiscordUrl.ToString()); + + private void Github_Click(object? sender, RoutedEventArgs e) => ViewUtils.OpenLink(BrandingService.Branding.RepositoryUrl.ToString()); - private void Github_Click(object sender, EventArgs e) => ViewUtils.OpenLink(BrandingService.Branding.RepositoryUrl.ToString()); + private void Support_Click(object? sender, RoutedEventArgs e) => ViewUtils.OpenLink(BrandingService.Branding.SupportUrl.ToString()); - private void Support_Click(object sender, EventArgs e) => ViewUtils.OpenLink(BrandingService.Branding.SupportUrl.ToString()); + private void About_Click(object? sender, RoutedEventArgs e) => NavigationManager.NavigateTo(new AppInfo()); private void CloseSnackbar_OnClick(object? sender, EventArgs e) { diff --git a/WheelWizard/Views/Pages/FriendsPage.axaml b/WheelWizard/Views/Pages/FriendsPage.axaml index eacddb7a..02b39f45 100644 --- a/WheelWizard/Views/Pages/FriendsPage.axaml +++ b/WheelWizard/Views/Pages/FriendsPage.axaml @@ -44,10 +44,6 @@ - - - - - diff --git a/WheelWizard/Views/Pages/LeaderboardPage.axaml b/WheelWizard/Views/Pages/LeaderboardPage.axaml index 369373e4..25b0be4a 100644 --- a/WheelWizard/Views/Pages/LeaderboardPage.axaml +++ b/WheelWizard/Views/Pages/LeaderboardPage.axaml @@ -77,26 +77,10 @@ HorizontalAlignment="Stretch" VerticalAlignment="Bottom" /> - - - - - - - + _loadedPlayerCount.ToString(); - public string RemainingCountText => $"{RemainingPlayers.Count} players"; public LeaderboardPlayerItem? PodiumFirst @@ -268,9 +265,6 @@ private async Task ReloadLeaderboardAsync() if (cancellationToken.IsCancellationRequested) return; - _loadedPlayerCount = mappedPlayers.Count; - OnPropertyChanged(nameof(TotalPlayerCountText)); - PodiumFirst = mappedPlayers.ElementAtOrDefault(0); PodiumSecond = mappedPlayers.ElementAtOrDefault(1); PodiumThird = mappedPlayers.ElementAtOrDefault(2); @@ -409,9 +403,6 @@ private void ClearLeaderboardData() PodiumSecond = null; PodiumThird = null; RemainingPlayers.Clear(); - _loadedPlayerCount = 0; - - OnPropertyChanged(nameof(TotalPlayerCountText)); OnPropertyChanged(nameof(RemainingCountText)); } diff --git a/WheelWizard/Views/Pages/MiiListPage.axaml b/WheelWizard/Views/Pages/MiiListPage.axaml index beaf8a37..f49261ee 100644 --- a/WheelWizard/Views/Pages/MiiListPage.axaml +++ b/WheelWizard/Views/Pages/MiiListPage.axaml @@ -16,73 +16,77 @@ - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/WheelWizard/Views/Pages/SettingsPage.axaml.cs b/WheelWizard/Views/Pages/SettingsPage.axaml.cs index 0e9ba539..085bd867 100644 --- a/WheelWizard/Views/Pages/SettingsPage.axaml.cs +++ b/WheelWizard/Views/Pages/SettingsPage.axaml.cs @@ -19,6 +19,7 @@ public SettingsPage(UserControl initialSettingsPage) #endif SettingsContent.Content = initialSettingsPage; + SetCheckedTopBarButton(initialSettingsPage); } private void TopBarRadio_OnClick(object? sender, RoutedEventArgs e) @@ -39,5 +40,16 @@ private void TopBarRadio_OnClick(object? sender, RoutedEventArgs e) SettingsContent.Content = instance; } + private void SetCheckedTopBarButton(UserControl settingsPage) + { + foreach (var child in SettingPages.Children) + { + if (child is not RadioButton radioButton) + continue; + + radioButton.IsChecked = radioButton.Tag?.ToString() == settingsPage.GetType().Name; + } + } + private void DevButton_OnClick(object? sender, RoutedEventArgs e) => new DevToolWindow().Show(); } diff --git a/WheelWizard/Views/Pages/UserProfilePage.axaml b/WheelWizard/Views/Pages/UserProfilePage.axaml index caea2562..71b7345c 100644 --- a/WheelWizard/Views/Pages/UserProfilePage.axaml +++ b/WheelWizard/Views/Pages/UserProfilePage.axaml @@ -35,6 +35,67 @@ + + + + + + + + + + + + @@ -47,42 +108,18 @@ - - - - - - - - - - - - - + - + @@ -90,9 +127,38 @@ Background="{StaticResource Neutral900}" BorderThickness="1" CornerRadius="{StaticResource GlobalCornerRadius}" BorderBrush="{StaticResource Neutral900}" x:Name="CurrentUserProfile" ClipToBounds="true"> - + + + + + + + + + + + + - @@ -112,7 +178,7 @@ - @@ -170,7 +236,7 @@ - + x:Name="CurrentUserCarousel" Height="250" /> diff --git a/WheelWizard/Views/Pages/UserProfilePage.axaml.cs b/WheelWizard/Views/Pages/UserProfilePage.axaml.cs index ea87d8ef..ca60bbf2 100644 --- a/WheelWizard/Views/Pages/UserProfilePage.axaml.cs +++ b/WheelWizard/Views/Pages/UserProfilePage.axaml.cs @@ -25,6 +25,7 @@ namespace WheelWizard.Views.Pages; public partial class UserProfilePage : UserControlBase, INotifyPropertyChanged { private const int ProfileCarouselPageCount = 2; + private const int ProfileSelectorMaxCharacters = 12; private LicenseProfile? currentPlayer; private Mii? _currentMii; @@ -187,17 +188,26 @@ private void ResetMiiTopBar() var noLicense = miiName == SettingValues.NoLicense; radioButton.IsEnabled = !noLicense; - radioButton.Content = miiName switch + var displayName = miiName switch { SettingValues.NoName => t("state.no_name"), SettingValues.NoLicense => t("state.no_license"), _ => miiName, }; + radioButton.Content = TrimProfileSelectorText(displayName); } UpdateCarouselIndicators(); } + private static string TrimProfileSelectorText(string? text) + { + if (string.IsNullOrEmpty(text) || text.Length < ProfileSelectorMaxCharacters) + return text ?? string.Empty; + + return $"{text[..(ProfileSelectorMaxCharacters - 1)]}..."; + } + private void UpdatePage() { PrimaryCheckBox.IsChecked = FocusedUser == _currentUserIndex; @@ -250,7 +260,9 @@ private void SetUserAsPrimary() // since Avalonia has some weird ass cashing, It might just be that that is because this method is actually deprecated //now we refresh the sidebar friend amount - ViewUtils.GetLayout().UpdateFriendCount(); + var layout = ViewUtils.GetLayout(); + layout.UpdateFriendCount(); + layout.UpdateSidebarProfile(); ViewUtils.ShowSnackbar(t("snackbar_success.profile_set_primary")); } @@ -275,7 +287,9 @@ private void RegionDropdown_SelectionChanged(object? sender, SelectionChangedEve ViewMii(0); // Just in case you have current user set as 4. and you change to a region where there are only 3 users. SetUserAsPrimary(); UpdatePage(); - ViewUtils.GetLayout().UpdateFriendCount(); + var layout = ViewUtils.GetLayout(); + layout.UpdateFriendCount(); + layout.UpdateSidebarProfile(); } private void TopBarRadio_OnClick(object? sender, RoutedEventArgs e) @@ -325,6 +339,7 @@ private async void OpenMiiSelector_Click(object? sender, RoutedEventArgs e) CurrentMii = selectedMii; GameLicenseService.LoadLicense(); UpdatePage(); + UpdateSidebarProfileIfCurrentUser(); ViewUtils.ShowSnackbar(t("message_success.mii_changed")); } @@ -390,6 +405,15 @@ private async void RenameMii_OnClick(object? sender, EventArgs e) //reload game data, since multiple licenses can use the same mii GameLicenseService.LoadLicense(); UpdatePage(); + UpdateSidebarProfileIfCurrentUser(); + } + + private void UpdateSidebarProfileIfCurrentUser() + { + if (FocusedUser != _currentUserIndex) + return; + + ViewUtils.GetLayout().UpdateSidebarProfile(); } private void MoveCarouselPage(int offset) diff --git a/WheelWizard/Views/Patterns/CurrentUserProfile.axaml b/WheelWizard/Views/Patterns/CurrentUserProfile.axaml index ac759fb2..1517ad46 100644 --- a/WheelWizard/Views/Patterns/CurrentUserProfile.axaml +++ b/WheelWizard/Views/Patterns/CurrentUserProfile.axaml @@ -1,46 +1,34 @@  - - - + + - + + Foreground="{StaticResource Neutral400}" + Margin="10,0,0,0" /> - - - - - - - - - - - \ No newline at end of file + + + diff --git a/WheelWizard/Views/Patterns/CurrentUserProfile.axaml.cs b/WheelWizard/Views/Patterns/CurrentUserProfile.axaml.cs index 9012d4a6..13cec9f4 100644 --- a/WheelWizard/Views/Patterns/CurrentUserProfile.axaml.cs +++ b/WheelWizard/Views/Patterns/CurrentUserProfile.axaml.cs @@ -51,6 +51,11 @@ public CurrentUserProfile() InitializeComponent(); DataContext = this; + Refresh(); + } + + public void Refresh() + { GameLicenseService.RefreshOnlineStatus(); GameLicenseService.LoadLicense(); diff --git a/WheelWizard/Views/Patterns/SidebarRadioButton.axaml b/WheelWizard/Views/Patterns/SidebarRadioButton.axaml index 9b5bc454..d34f3c78 100644 --- a/WheelWizard/Views/Patterns/SidebarRadioButton.axaml +++ b/WheelWizard/Views/Patterns/SidebarRadioButton.axaml @@ -34,7 +34,7 @@ + diff --git a/WheelWizard/Views/Patterns/SidebarRadioButton.axaml.cs b/WheelWizard/Views/Patterns/SidebarRadioButton.axaml.cs index 5e052614..5518fa8f 100644 --- a/WheelWizard/Views/Patterns/SidebarRadioButton.axaml.cs +++ b/WheelWizard/Views/Patterns/SidebarRadioButton.axaml.cs @@ -53,6 +53,26 @@ public string BoxTip set => SetValue(BoxTipProperty, value); } + public static readonly StyledProperty BoxIconDataProperty = AvaloniaProperty.Register( + nameof(BoxIconData) + ); + + public Geometry BoxIconData + { + get => GetValue(BoxIconDataProperty); + set => SetValue(BoxIconDataProperty, value); + } + + public static readonly StyledProperty BoxIconSizeProperty = AvaloniaProperty.Register( + nameof(BoxIconSize) + ); + + public double BoxIconSize + { + get => GetValue(BoxIconSizeProperty); + set => SetValue(BoxIconSizeProperty, value); + } + //todo: after patches is more stable, uncomment this // public static readonly StyledProperty WarningVisibleProperty = AvaloniaProperty.Register( diff --git a/WheelWizard/Views/ViewUtils.cs b/WheelWizard/Views/ViewUtils.cs index 43b88d44..720c8514 100644 --- a/WheelWizard/Views/ViewUtils.cs +++ b/WheelWizard/Views/ViewUtils.cs @@ -80,6 +80,7 @@ public static void RefreshWindow() } newWindow.UpdatePlayerAndRoomCount(RRLiveRooms.Instance); + newWindow.UpdateLiveAlert(); } public static T? FindParent(object? child, int maxSearchDepth = 10)