Skip to content

Commit

Permalink
game launcher setting dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Dec 23, 2024
1 parent fc806cb commit f28780c
Show file tree
Hide file tree
Showing 15 changed files with 1,439 additions and 18 deletions.
72 changes: 72 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.

24 changes: 24 additions & 0 deletions src/Starward.Language/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1618,4 +1618,28 @@ Do you accept the risk and continue to use it?</value>
<data name="GameLauncherPage_Relocate" xml:space="preserve">
<value>Relocate</value>
</data>
<data name="GameLauncherSettingDialog_RelocateGame" xml:space="preserve">
<value>Relocate Game</value>
</data>
<data name="GameLauncherSettingDialog_Size" xml:space="preserve">
<value>Size</value>
</data>
<data name="GameLauncherSettingDialog_BasticInformation" xml:space="preserve">
<value>Bastic Information</value>
</data>
<data name="GameLauncherSettingDialog_StartupArguments" xml:space="preserve">
<value>Startup Arguments</value>
</data>
<data name="GameLauncherSettingDialog_CustomBackground" xml:space="preserve">
<value>Custom Background</value>
</data>
<data name="GameLauncherSettingDialog_GamePackages" xml:space="preserve">
<value>Game Packages</value>
</data>
<data name="GameLauncherSettingDialog_CommandLineArgument" xml:space="preserve">
<value>Command Line Argument</value>
</data>
<data name="GameLauncherSettingDialog_SeeMoreInformationAboutCommandLineArgument" xml:space="preserve">
<value>See more information about command line argument.</value>
</data>
</root>
26 changes: 25 additions & 1 deletion src/Starward.Language/Lang.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
<value>定位</value>
</data>
<data name="LauncherPage_RepairGame" xml:space="preserve">
<value>一键修复</value>
<value>修复游戏</value>
</data>
<data name="LauncherPage_CustomStartExecutable" xml:space="preserve">
<value>自定义启动程序</value>
Expand Down Expand Up @@ -1618,4 +1618,28 @@
<data name="GameLauncherPage_Relocate" xml:space="preserve">
<value>重新定位</value>
</data>
<data name="GameLauncherSettingDialog_RelocateGame" xml:space="preserve">
<value>重新定位游戏</value>
</data>
<data name="GameLauncherSettingDialog_Size" xml:space="preserve">
<value>大小</value>
</data>
<data name="GameLauncherSettingDialog_BasticInformation" xml:space="preserve">
<value>基本信息</value>
</data>
<data name="GameLauncherSettingDialog_StartupArguments" xml:space="preserve">
<value>启动参数</value>
</data>
<data name="GameLauncherSettingDialog_CustomBackground" xml:space="preserve">
<value>自定义背景</value>
</data>
<data name="GameLauncherSettingDialog_GamePackages" xml:space="preserve">
<value>游戏包体</value>
</data>
<data name="GameLauncherSettingDialog_CommandLineArgument" xml:space="preserve">
<value>命令行参数</value>
</data>
<data name="GameLauncherSettingDialog_SeeMoreInformationAboutCommandLineArgument" xml:space="preserve">
<value>查看有关命令行参数的更多信息</value>
</data>
</root>
4 changes: 2 additions & 2 deletions src/Starward.Language/Lang.zh-TW.resx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
Expand Down Expand Up @@ -555,7 +555,7 @@
<value>定位</value>
</data>
<data name="LauncherPage_RepairGame" xml:space="preserve">
<value>一鍵修復</value>
<value>修復遊戲</value>
</data>
<data name="LauncherPage_CustomStartExecutable" xml:space="preserve">
<value>自訂啟動程式</value>
Expand Down
21 changes: 9 additions & 12 deletions src/Starward/Features/Background/AppBackground.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI.Helpers;
using Microsoft.Extensions.Logging;
using Microsoft.Graphics.Canvas;
Expand Down Expand Up @@ -39,6 +40,8 @@ public sealed partial class AppBackground : UserControl
public AppBackground()
{
this.InitializeComponent();
WeakReferenceMessenger.Default.Register<BackgroundChangedMessage>(this, OnBackgroundChanged);
Unloaded += (_, _) => { DisposeVideoResource(); WeakReferenceMessenger.Default.UnregisterAll(this); };
}


Expand Down Expand Up @@ -76,10 +79,6 @@ public ImageSource? BackgroundImageSource
}


private string? lastBackgroundFile;



private MediaPlayer? mediaPlayer;

private SoftwareBitmap? softwareBitmap;
Expand Down Expand Up @@ -109,7 +108,6 @@ private void InitializeBackgroundImage()
if (!BackgroundService.FileIsSupportedVideo(file))
{
BackgroundImageSource = new BitmapImage(new Uri(file));
lastBackgroundFile = file;
try
{
string? hex = AppConfig.AccentColor;
Expand All @@ -125,7 +123,6 @@ private void InitializeBackgroundImage()
else
{
BackgroundImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Image/UI_CutScene_1130320101A.png"));
lastBackgroundFile = file;
}
}
catch (Exception ex)
Expand Down Expand Up @@ -155,11 +152,6 @@ public async Task UpdateBackgroundAsync()
}

var file = await _backgroundService.GetBackgroundFileAsync(CurrentGameId);
if (file == lastBackgroundFile)
{
return;
}

DisposeVideoResource();
BackgroundImageSource = null;

Expand All @@ -173,7 +165,6 @@ public async Task UpdateBackgroundAsync()
{
await ChangeBackgroundImageAsync(file, cancelSource.Token);
}
lastBackgroundFile = file;
}
}
catch (COMException ex)
Expand Down Expand Up @@ -303,6 +294,12 @@ private void MediaPlayer_VideoFrameAvailable(MediaPlayer sender, object args)



private async void OnBackgroundChanged(object _, BackgroundChangedMessage message)
{
await UpdateBackgroundAsync();
}




}
6 changes: 6 additions & 0 deletions src/Starward/Features/Background/BackgroundChangedMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Starward.Features.Background;

internal class BackgroundChangedMessage
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Starward.Features.GameLauncher;

internal class GameAnnouncementSettingChangedMessage
{

}
23 changes: 23 additions & 0 deletions src/Starward/Features/GameLauncher/GameBannerAndPost.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private async void GameBannerAndPost_Loaded(object sender, RoutedEventArgs e)
{
WeakReferenceMessenger.Default.Register<MainWindowStateChangedMessage>(this, OnMainWindowStateChanged);
WeakReferenceMessenger.Default.Register<GameNoticeWindowClosedMessage>(this, OnGameNoticeWindowClosed);
WeakReferenceMessenger.Default.Register<GameAnnouncementSettingChangedMessage>(this, OnGameAnnouncementSettingChanged);
await UpdateGameContentAsync();
await UpdateGameNoticeAlertAsync();
}
Expand All @@ -83,6 +84,28 @@ private async void OnGameNoticeWindowClosed(object _, GameNoticeWindowClosedMess
}


private async void OnGameAnnouncementSettingChanged(object _, GameAnnouncementSettingChangedMessage message)
{
if (AppSetting.EnableBannerAndPost)
{
ShowBannerAndPost = true;
await UpdateGameContentAsync();
if (AppSetting.DisableGameNoticeRedHot)
{
IsGameNoticesAlert = false;
}
else
{
await UpdateGameNoticeAlertAsync();
}
}
else
{
ShowBannerAndPost = false;
}
}



public List<GameBanner>? Banners { get; set => SetProperty(ref field, value); }

Expand Down
1 change: 1 addition & 0 deletions src/Starward/Features/GameLauncher/GameLauncherPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<local:StartGameButton HorizontalAlignment="Right"
CanExecute="{x:Bind StartGameButtonCanExecute}"
Command="{x:Bind ClickStartGameButtonCommand}"
SettingCommand="{x:Bind OpenGameLauncherSettingDialogCommand}"
State="{x:Bind GameState}" />

<Border x:Name="Border_TextShadowTarget" Grid.Row="1" />
Expand Down
6 changes: 6 additions & 0 deletions src/Starward/Features/GameLauncher/GameLauncherPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ private async Task StartGameAsync()



[RelayCommand]
private async Task OpenGameLauncherSettingDialogAsync()
{
await new GameLauncherSettingDialog { CurrentGameId = this.CurrentGameId, XamlRoot = this.XamlRoot }.ShowAsync();
}




Expand Down
Loading

0 comments on commit f28780c

Please sign in to comment.