-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
304 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<sp:PageBase x:Class="Starward.Pages.Setting.DownloadSettingPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:lang="using:Starward.Language" | ||
xmlns:local="using:Starward.Pages.Setting" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:sp="using:Starward.Pages" | ||
x:DefaultBindMode="OneWay" | ||
mc:Ignorable="d"> | ||
|
||
<ScrollViewer> | ||
<StackPanel Margin="0,0,48,0"> | ||
|
||
|
||
<!-- default install path --> | ||
<TextBlock FontSize="20" | ||
FontWeight="SemiBold" | ||
Text="Default Game Installation Path" /> | ||
<TextBlock Margin="0,12,0,0" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Text="The games will be installed in different subfolders, changing the default path will not move the installed game files." | ||
TextWrapping="Wrap" /> | ||
<StackPanel Margin="0,12,0,0" Orientation="Horizontal"> | ||
<!-- locate folder --> | ||
<Button Height="40" | ||
Padding="16,0,16,0" | ||
BorderThickness="0" | ||
Command="{x:Bind ChangeDefaultInstallPathCommand}" | ||
CornerRadius="8,20,20,8" | ||
Style="{ThemeResource AccentButtonStyle}"> | ||
<StackPanel Orientation="Horizontal" Spacing="8"> | ||
<FontIcon Glyph="" /> | ||
<TextBlock Text="{x:Bind lang:Lang.LauncherPage_Locate}" /> | ||
</StackPanel> | ||
</Button> | ||
<Grid Height="40" | ||
Margin="16,0,0,0" | ||
Background="{ThemeResource CustomAcrylicBrush}" | ||
CornerRadius="20" | ||
Visibility="{x:Bind DefaultInstallPath, Converter={StaticResource ObjectToVisibilityConverter}}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Button Height="40" | ||
Padding="16,0,8,1" | ||
BorderThickness="0" | ||
Command="{x:Bind OpenDefaultInstallPathCommand}" | ||
CornerRadius="0"> | ||
<TextBlock VerticalAlignment="Center" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Text="{x:Bind DefaultInstallPath}" | ||
TextTrimming="CharacterEllipsis" | ||
TextWrapping="Wrap" /> | ||
</Button> | ||
<Button Grid.Column="1" | ||
Height="36" | ||
BorderThickness="0" | ||
Command="{x:Bind DeleteDefaultInstallPathCommand}" | ||
CornerRadius="0"> | ||
<FontIcon Margin="0,2,2,0" | ||
FontSize="16" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Glyph="" /> | ||
</Button> | ||
</Grid> | ||
</StackPanel> | ||
|
||
|
||
|
||
<!-- speed limit --> | ||
<TextBlock Margin="0,20,0,0" | ||
FontSize="20" | ||
FontWeight="SemiBold" | ||
Text="Speed Limit" /> | ||
<TextBlock Margin="0,12,0,0" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Text="The number 0 means no speed limit." | ||
TextWrapping="Wrap" /> | ||
<StackPanel Margin="0,12,0,0" | ||
Orientation="Horizontal" | ||
Spacing="12"> | ||
<NumberBox MinWidth="100" | ||
Minimum="0" | ||
Value="{x:Bind SpeedLimit, Mode=TwoWay}" /> | ||
<TextBlock VerticalAlignment="Center" Text="KB/s" /> | ||
</StackPanel> | ||
|
||
|
||
|
||
</StackPanel> | ||
</ScrollViewer> | ||
|
||
</sp:PageBase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using Microsoft.Extensions.Logging; | ||
using Starward.Helpers; | ||
using Starward.Services.Download; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Windows.Storage; | ||
using Windows.System; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
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 DownloadSettingPage : PageBase | ||
{ | ||
|
||
|
||
private readonly ILogger<DownloadSettingPage> _logger = AppConfig.GetLogger<DownloadSettingPage>(); | ||
|
||
|
||
public DownloadSettingPage() | ||
{ | ||
this.InitializeComponent(); | ||
InitializeDefaultInstallPath(); | ||
} | ||
|
||
|
||
|
||
|
||
private void InitializeDefaultInstallPath() | ||
{ | ||
try | ||
{ | ||
string? path = AppConfig.DefaultGameInstallationPath; | ||
if (Directory.Exists(path)) | ||
{ | ||
DefaultInstallPath = path; | ||
} | ||
else | ||
{ | ||
AppConfig.DefaultGameInstallationPath = null; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, "Get default intall path"); | ||
} | ||
} | ||
|
||
|
||
|
||
[ObservableProperty] | ||
private string? defaultInstallPath; | ||
partial void OnDefaultInstallPathChanged(string? value) | ||
{ | ||
AppConfig.DefaultGameInstallationPath = value; | ||
} | ||
|
||
|
||
|
||
[ObservableProperty] | ||
private int speedLimit = AppConfig.SpeedLimitKBPerSecond; | ||
partial void OnSpeedLimitChanged(int value) | ||
{ | ||
InstallGameManager.SpeedLimitBytesPerSecond = value == 0 ? long.MaxValue : value * 1024; | ||
AppConfig.SpeedLimitKBPerSecond = value; | ||
} | ||
|
||
|
||
|
||
[RelayCommand] | ||
private async Task ChangeDefaultInstallPathAsync() | ||
{ | ||
try | ||
{ | ||
var path = await FileDialogHelper.PickFolderAsync(MainWindow.Current.WindowHandle); | ||
if (Directory.Exists(path)) | ||
{ | ||
DefaultInstallPath = path; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, "Failed to change default install path"); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
[RelayCommand] | ||
private async Task OpenDefaultInstallPathAsync() | ||
{ | ||
|
||
try | ||
{ | ||
if (Directory.Exists(DefaultInstallPath)) | ||
{ | ||
var folder = await StorageFolder.GetFolderFromPathAsync(DefaultInstallPath); | ||
await Launcher.LaunchFolderAsync(folder); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, "Failed to open default install path"); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
[RelayCommand] | ||
private void DeleteDefaultInstallPath() | ||
{ | ||
DefaultInstallPath = null; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.