Skip to content

Commit

Permalink
add feature section in experience setting page #509
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Dec 31, 2023
1 parent 9c19b7c commit 4b40de0
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 20 deletions.
27 changes: 27 additions & 0 deletions src/Starward.Language/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Starward.Language/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1235,4 +1235,13 @@ Do you accept the risk and continue to use it?</value>
<data name="AppearanceSettingPage_AlwaysDisplayNavigationSidebarIcons" xml:space="preserve">
<value>Always display navigation sidebar icons</value>
</data>
<data name="ExperienceSettingPage_Features" xml:space="preserve">
<value>Features</value>
</data>
<data name="ExperienceSettingPage_HideGameAccountSwitcher" xml:space="preserve">
<value>Hide game account switcher</value>
</data>
<data name="ExperienceSettingPage_DisableRedDotReminderForGameNotices" xml:space="preserve">
<value>Disable red dot reminder for game notices</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Starward.Language/Lang.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1234,4 +1234,13 @@
<data name="AppearanceSettingPage_AlwaysDisplayNavigationSidebarIcons" xml:space="preserve">
<value>始终显示导航侧栏图标</value>
</data>
<data name="ExperienceSettingPage_Features" xml:space="preserve">
<value>功能</value>
</data>
<data name="ExperienceSettingPage_HideGameAccountSwitcher" xml:space="preserve">
<value>隐藏游戏账号切换器</value>
</data>
<data name="ExperienceSettingPage_DisableRedDotReminderForGameNotices" xml:space="preserve">
<value>禁用游戏通知的红点提醒</value>
</data>
</root>
33 changes: 14 additions & 19 deletions src/Starward/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ public static string UserDataFolder
}


public static bool DisableNavigationShortcut { get; set; }

public static bool DisableGameNoticeRedHot { get; set; }

public static bool DisableGameAccountSwitcher { get; set; }

public static bool EnableSystemAccentColor { get; set; }




private static void Initialize()
Expand Down Expand Up @@ -148,11 +139,6 @@ private static void Initialize()

windowSizeMode = Configuration.GetValue<int>(nameof(WindowSizeMode));
language = Configuration.GetValue<string>(nameof(Language));
//DisableNavigationShortcut = Configuration.GetValue<bool>(nameof(DisableNavigationShortcut));
//DisableGameNoticeRedHot = Configuration.GetValue<bool>(nameof(DisableGameNoticeRedHot));
//DisableGameAccountSwitcher = Configuration.GetValue<bool>(nameof(DisableGameAccountSwitcher));
//EnableSystemAccentColor = Configuration.GetValue<bool>(nameof(EnableSystemAccentColor));
//EnableNavigationViewLeftCompact = Configuration.GetValue<bool>(nameof(EnableNavigationViewLeftCompact), true);
string? dir = Configuration.GetValue<string>(nameof(UserDataFolder));
if (!string.IsNullOrWhiteSpace(dir))
{
Expand Down Expand Up @@ -201,11 +187,6 @@ private static void SaveConfiguration()
{nameof(WindowSizeMode)}={WindowSizeMode}
{nameof(Language)}={Language}
{nameof(UserDataFolder)}={dataFolder}
{nameof(DisableNavigationShortcut)}={DisableNavigationShortcut}
{nameof(DisableGameNoticeRedHot)}={DisableGameNoticeRedHot}
{nameof(DisableGameAccountSwitcher)}={DisableGameAccountSwitcher}
{nameof(EnableSystemAccentColor)}={EnableSystemAccentColor}
{nameof(EnableNavigationViewLeftCompact)}={EnableNavigationViewLeftCompact}
""");
}
catch { }
Expand Down Expand Up @@ -434,6 +415,20 @@ public static bool EnableNavigationViewLeftCompact
}


public static bool DisableGameAccountSwitcher
{
get => GetValue<bool>();
set => SetValue(value);
}


public static bool DisableGameNoticeRedHot
{
get => GetValue<bool>();
set => SetValue(value);
}



#endregion

Expand Down
4 changes: 4 additions & 0 deletions src/Starward/Messages/GameAccountSwitcherDisabledChanged.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Starward.Messages;

public record GameAccountSwitcherDisabledChanged(bool IsDisabled);

4 changes: 4 additions & 0 deletions src/Starward/Messages/GameNoticeRedHotDisabledChanged.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Starward.Messages;

public record GameNoticeRedHotDisabledChanged(bool IsDisabled);

18 changes: 17 additions & 1 deletion src/Starward/Pages/LauncherPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
Expand All @@ -14,6 +15,7 @@
using Starward.Core;
using Starward.Core.Launcher;
using Starward.Helpers;
using Starward.Messages;
using Starward.Models;
using Starward.Services;
using System;
Expand Down Expand Up @@ -79,6 +81,13 @@ public LauncherPage()
_timer.Interval = TimeSpan.FromSeconds(5);
_timer.IsRepeating = true;
_timer.Tick += _timer_Tick;

WeakReferenceMessenger.Default.Register<GameAccountSwitcherDisabledChanged>(this, (_, _) =>
{
GetGameAccount();
_ = GetGameNoticesAlertAsync();
});
WeakReferenceMessenger.Default.Register<GameNoticeRedHotDisabledChanged>(this, (_, _) => _ = GetGameNoticesAlertAsync());
}


Expand Down Expand Up @@ -117,6 +126,7 @@ private void Page_Unloaded(object sender, RoutedEventArgs e)
{
_timer.Stop();
GameProcess?.Dispose();
WeakReferenceMessenger.Default.UnregisterAll(this);
}


Expand Down Expand Up @@ -278,6 +288,7 @@ private async Task GetGameNoticesAlertAsync()
{
if (AppConfig.DisableGameNoticeRedHot || AppConfig.DisableGameAccountSwitcher)
{
Image_GameNoticesAlert.Visibility = Visibility.Collapsed;
return;
}
long uid = 0;
Expand All @@ -287,6 +298,7 @@ private async Task GetGameNoticesAlertAsync()
}
if (uid == 0)
{
Image_GameNoticesAlert.Visibility = Visibility.Collapsed;
return;
}
if (await _launcherService.IsNoticesAlertAsync(gameBiz, uid))
Expand Down Expand Up @@ -877,7 +889,11 @@ private void GetGameAccount()
StackPanel_Account.Visibility = Visibility.Collapsed;
return;
}
GameAccountList = _gameService.GetGameAccounts(gameBiz).ToList();
else
{
StackPanel_Account.Visibility = Visibility.Visible;
}
GameAccountList = _gameService.GetGameAccounts(gameBiz);
SelectGameAccount = GameAccountList.FirstOrDefault(x => x.IsLogin);
CanChangeGameAccount = false;
}
Expand Down
15 changes: 15 additions & 0 deletions src/Starward/Pages/Setting/ExperienceSettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@



<!-- features -->
<TextBlock Margin="0,20,0,0"
FontSize="20"
FontWeight="SemiBold"
Text="{x:Bind lang:Lang.ExperienceSettingPage_Features}" />
<ToggleSwitch Margin="0,8,0,0"
IsOn="{x:Bind DisableGameAccountSwitcher, Mode=TwoWay}"
OffContent="{x:Bind lang:Lang.ExperienceSettingPage_HideGameAccountSwitcher}"
OnContent="{x:Bind lang:Lang.ExperienceSettingPage_HideGameAccountSwitcher}" />
<ToggleSwitch IsEnabled="{x:Bind DisableGameAccountSwitcher, Converter={StaticResource BoolReversedConverter}}"
IsOn="{x:Bind DisableGameNoticeRedHot, Mode=TwoWay}"
OffContent="{x:Bind lang:Lang.ExperienceSettingPage_DisableRedDotReminderForGameNotices}"
OnContent="{x:Bind lang:Lang.ExperienceSettingPage_DisableRedDotReminderForGameNotices}" />


</StackPanel>
</ScrollViewer>

Expand Down
31 changes: 31 additions & 0 deletions src/Starward/Pages/Setting/ExperienceSettingPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml.Controls;
using Starward.Messages;
using Starward.Models;
using System;

Expand All @@ -11,6 +14,7 @@ namespace Starward.Pages.Setting;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[INotifyPropertyChanged]
public sealed partial class ExperienceSettingPage : PageBase
{

Expand Down Expand Up @@ -102,5 +106,32 @@ private void ComboBox_CloseWindowOption_SelectionChanged(object sender, Selectio



#region Features



[ObservableProperty]
private bool disableGameAccountSwitcher = AppConfig.DisableGameAccountSwitcher;
partial void OnDisableGameAccountSwitcherChanged(bool value)
{
AppConfig.DisableGameAccountSwitcher = value;
WeakReferenceMessenger.Default.Send(new GameAccountSwitcherDisabledChanged(value));
}


[ObservableProperty]
private bool disableGameNoticeRedHot = AppConfig.DisableGameNoticeRedHot;
partial void OnDisableGameNoticeRedHotChanged(bool value)
{
AppConfig.DisableGameNoticeRedHot = value;
WeakReferenceMessenger.Default.Send(new GameNoticeRedHotDisabledChanged(value));
}




#endregion



}

0 comments on commit 4b40de0

Please sign in to comment.