Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/oobe redesign #185

Merged
merged 22 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Natsurainko.FluentLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ private static IPageProvider BuildPageProvider(IServiceProvider sp) => WinUIPage
// OOBE
.WithPage<Views.OOBE.OOBENavigationPage, ViewModels.OOBE.OOBEViewModel>("OOBENavigationPage")
.WithPage<Views.OOBE.AccountPage>("OOBEAccountPage")
.WithPage<Views.OOBE.BasicPage>("OOBEBasicPage")
.WithPage<Views.OOBE.MinecraftFolderPage>("OOBEMinecraftFolderPage")
.WithPage<Views.OOBE.JavaPage>("OOBEJavaPage")
.WithPage<Views.OOBE.GetStartedPage>("OOBEGetStartedPage")
.WithPage<Views.OOBE.LanguagePage>("OOBELanguagePage")

Expand Down
35 changes: 18 additions & 17 deletions Natsurainko.FluentLauncher/Dictionaries/NotifyStyleDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@
MinWidth="100"
MinHeight="75"
MaxWidth="500"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Background="{ThemeResource SolidBackgroundFillColorTertiaryBrush}"
BorderBrush="{ThemeResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8">
<Border.Background>
<AcrylicBrush
TintColor="{ThemeResource AcrylicTintColor}"
TintLuminosityOpacity="0.25"
TintOpacity="0.25" />
</Border.Background>
<Grid Padding="0,15">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down Expand Up @@ -70,15 +65,10 @@
<Border
MinWidth="100"
MaxWidth="500"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Background="{ThemeResource SolidBackgroundFillColorTertiaryBrush}"
BorderBrush="{ThemeResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8">
<Border.Background>
<AcrylicBrush
TintColor="{ThemeResource AcrylicTintColor}"
TintLuminosityOpacity="0.25"
TintOpacity="0.25" />
</Border.Background>
<Grid Margin="15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
Expand Down Expand Up @@ -115,11 +105,12 @@
<DataTemplate x:Key="NormalMessageNotifyTemplate">
<ScrollViewer>
<StackPanel Padding="20,0" Spacing="5">
<TextBlock Text="{Binding Text}" />
<TextBlock Text="{Binding Text}" TextWrapping="WrapWholeWords" />
<TextBlock
Foreground="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"
Style="{ThemeResource CaptionTextBlockStyle}"
Text="{Binding Description}" />
Text="{Binding Description}"
TextWrapping="WrapWholeWords" />
</StackPanel>
</ScrollViewer>
</DataTemplate>
Expand Down Expand Up @@ -151,7 +142,7 @@
<DataTemplate x:Key="AuthenticationSuccessfulNotifyTemplate">
<StackPanel Padding="20,0" Spacing="5">
<TextBlock FontWeight="SemiBold">
<Run Text="Welcome Back," />
<Run x:Uid="Notifications_AccountAddWelcome" Text="Welcome Back," />
<Run Text="{Binding Name}" />
</TextBlock>
<ListViewItem Margin="-10,0" Padding="20,10">
Expand Down Expand Up @@ -195,4 +186,14 @@
</ListViewItem>
</StackPanel>
</DataTemplate>

<DataTemplate x:Key="NoMinecraftFolderNotifyTemplate">
<StackPanel Padding="20,0" Spacing="5">
<HyperlinkButton
x:Uid="Notifications_NavigateMinecraftFolder"
Command="{Binding}"
Content="Go To Settings" />
</StackPanel>
</DataTemplate>

</ResourceDictionary>
4 changes: 4 additions & 0 deletions Natsurainko.FluentLauncher/Natsurainko.FluentLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<None Remove="Views\Downloads\ResourcesSearchPage.xaml" />
<None Remove="Views\Home\NewHomePage.xaml" />
<None Remove="Views\NotifyStyleDictionary.xaml" />
<None Remove="Views\OOBE\JavaPage.xaml" />
</ItemGroup>

<!-- NuGet Packages -->
Expand Down Expand Up @@ -283,6 +284,9 @@
<Page Update="Views\CoreInstallWizard\EnterCoreSettingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\OOBE\JavaPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
Expand Down
36 changes: 35 additions & 1 deletion Natsurainko.FluentLauncher/Services/Launch/GameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,41 @@ public override void ActivateMinecraftFolder(string folder)
}
}

public void RefreshCurrentFolder() => InitFolder();
public void AddMinecraftFolder(string folder)
{
_minecraftFolders.Add(folder);
ActivateMinecraftFolder(folder);
}

public void RemoveMinecraftFolder(string folder)
{
_minecraftFolders.Remove(folder);

if (ActiveMinecraftFolder == folder)
{
ActiveMinecraftFolder = null;

if (MinecraftFolders.Any())
{
ActivateMinecraftFolder(MinecraftFolders.First());
}
}

RefreshCurrentFolder();
}

public void RefreshCurrentFolder()
{
if (!MinecraftFolders.Any())
{
_gameInfos.Clear();
ActiveGameInfo = null;

return;
}

InitFolder();
}

protected override void InitFolder()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public partial class SettingsService : SettingsContainer, IFluentCoreSettingsSer
[SettingItem(typeof(string), "CurrentLanguage", Default = "en-US, English", Converter = typeof(JsonStringConverter<string>))] // TODO: remove default value; set to system language if null
[SettingItem(typeof(int), "NavigationViewDisplayMode", Default = 0, Converter = typeof(JsonStringConverter<int>))]
[SettingItem(typeof(int), "DisplayTheme", Default = 0, Converter = typeof(JsonStringConverter<int>))]
[SettingItem(typeof(int), "BackgroundMode", Default = 0, Converter = typeof(JsonStringConverter<int>))]
[SettingItem(typeof(bool), "UseNewHomePage", Default = false, Converter = typeof(JsonStringConverter<bool>))]
[SettingItem(typeof(int), "BackgroundMode", Default = 1, Converter = typeof(JsonStringConverter<int>))]
[SettingItem(typeof(bool), "UseNewHomePage", Default = true, Converter = typeof(JsonStringConverter<bool>))]
[SettingItem(typeof(double), "TintLuminosityOpacity", Default = 0.64, Converter = typeof(JsonStringConverter<double>))]
[SettingItem(typeof(double), "TintOpacity", Default = 0, Converter = typeof(JsonStringConverter<double>))]
[SettingItem(typeof(bool), "EnableDefaultAcrylicBrush", Default = true, Converter = typeof(JsonStringConverter<bool>))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void ApplyBackgroundBeforePageInit(ShellPage page)
if (File.Exists(_settingsService.ImageFilePath))
{
page.Resources.Add("NavigationViewContentBackground", new SolidColorBrush(Colors.Transparent));
page.Resources.Add("NavigationViewContentGridCornerRadius", new CornerRadius(0));
//page.Resources.Add("NavigationViewContentGridCornerRadius", new CornerRadius(0));
page.Resources.Add("NavigationViewContentGridBorderThickness", new Thickness(0));

using var fileStream = File.OpenRead(_settingsService.ImageFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@
var vm = CurrentFrameDataContext as ConfirmProfileViewModel;
var account = vm.SelectedAccount;

_accountService.AddAccount(account);

Check warning on line 103 in Natsurainko.FluentLauncher/ViewModels/Common/AuthenticationWizardDialogViewModel.cs

View workflow job for this annotation

GitHub Actions / Build (x64)

'AccountService.AddAccount(Account)' is obsolete

Check warning on line 103 in Natsurainko.FluentLauncher/ViewModels/Common/AuthenticationWizardDialogViewModel.cs

View workflow job for this annotation

GitHub Actions / Build (arm64)

'AccountService.AddAccount(Account)' is obsolete
_accountService.Activate(account);

_dialog.Hide();

_notificationService.NotifyWithSpecialContent(
$"Added Successfully",
ResourceUtils.GetValue("Notifications", "_AccountAddSuccessful"),
"AuthenticationSuccessfulNotifyTemplate",
account, "\uE73E");
}
Expand Down
30 changes: 27 additions & 3 deletions Natsurainko.FluentLauncher/ViewModels/Cores/CoresViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using Natsurainko.FluentLauncher.Classes.Data.Launch;
using Natsurainko.FluentLauncher.Services.Launch;
using Natsurainko.FluentLauncher.Services.Settings;
using Natsurainko.FluentLauncher.Services.UI;
using Natsurainko.FluentLauncher.Services.UI.Navigation;
using Natsurainko.FluentLauncher.Utils;
using Nrk.FluentCore.Classes.Datas.Launch;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -17,18 +19,24 @@ namespace Natsurainko.FluentLauncher.ViewModels.Cores;

internal partial class CoresViewModel : ObservableObject, ISettingsViewModel
{
private readonly GameService _gameService;
private bool initSettings = false;

[SettingsProvider]
private readonly SettingsService _settingsService;
private readonly INavigationService _navigationService;
private readonly GameService _gameService;
private readonly NotificationService _notificationService;

public CoresViewModel(GameService gameService, SettingsService settingsService, INavigationService navigationService)
public CoresViewModel(
GameService gameService,
SettingsService settingsService,
INavigationService navigationService,
NotificationService notificationService)
{
_gameService = gameService;
_settingsService = settingsService;
_navigationService = navigationService;
_notificationService = notificationService;

GameInfos = _gameService.GameInfos;

Expand Down Expand Up @@ -100,9 +108,25 @@ public void OpenCoreManage(GameInfo gameInfo)

[RelayCommand]
public void SearchAllMinecraft()
=> _navigationService.NavigateTo("ResourcesSearchPage", new ResourceSearchData
{
if (string.IsNullOrEmpty(_gameService.ActiveMinecraftFolder))
{
_notificationService.NotifyWithSpecialContent(
ResourceUtils.GetValue("Notifications", "_NoMinecraftFolder"),
"NoMinecraftFolderNotifyTemplate",
GoToSettingsCommand, "\uE711");

return;
}

_navigationService.NavigateTo("ResourcesSearchPage", new ResourceSearchData
{
SearchInput = string.Empty,
ResourceType = 0
});
}

[RelayCommand]
public void GoToSettings() => _navigationService.NavigateTo("SettingsNavigationPage", "LaunchSettingsPage");

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
using Microsoft.UI.Xaml;
using Natsurainko.FluentLauncher.Classes.Data.Download;
using Natsurainko.FluentLauncher.Classes.Data.UI;
using Natsurainko.FluentLauncher.Services.Launch;
using Natsurainko.FluentLauncher.Services.Storage;
using Natsurainko.FluentLauncher.Services.UI;
using Natsurainko.FluentLauncher.Services.UI.Navigation;
using Natsurainko.FluentLauncher.Utils;
using Nrk.FluentCore.Classes.Datas.Download;
using System;
using System.Collections.Generic;
Expand All @@ -18,11 +21,19 @@ internal partial class DownloadsViewModel : ObservableObject
{
private readonly InterfaceCacheService _interfaceCacheService;
private readonly INavigationService _navigationService;

public DownloadsViewModel(InterfaceCacheService interfaceCacheService, INavigationService navigationService)
private readonly GameService _gameService;
private readonly NotificationService _notificationService;

public DownloadsViewModel(
InterfaceCacheService interfaceCacheService,
INavigationService navigationService,
GameService gameService,
NotificationService notificationService)
{
_interfaceCacheService = interfaceCacheService;
_navigationService = navigationService;
_gameService = gameService;
_notificationService = notificationService;

Task.Run(async () =>
{
Expand Down Expand Up @@ -120,7 +131,25 @@ public async Task DownloadMinecraft(PublishData resource)
.Where(manifestItem => manifestItem.Id.Equals(resource.Version));

if (manifestItems.Any())
{
if (string.IsNullOrEmpty(_gameService.ActiveMinecraftFolder))
{
_notificationService.NotifyWithSpecialContent(
ResourceUtils.GetValue("Notifications", "_NoMinecraftFolder"),
"NoMinecraftFolderNotifyTemplate",
GoToSettingsCommand, "\uE711");

return;
}

_navigationService.NavigateTo("CoreInstallWizardPage", manifestItems.First());
}
else _notificationService.NotifyWithoutContent(
ResourceUtils.GetValue("Notifications", "_CoreNotInSourceList"),
icon: "\uE9CE");
}

[RelayCommand]
public void GoToSettings() => _navigationService.NavigateTo("SettingsNavigationPage", "LaunchSettingsPage");

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void INavigationAware.OnNavigatedTo(object parameter)
var urls = isCurse ? ((CurseResource)parameter).ScreenshotUrls : ((ModrinthResource)parameter).ScreenshotUrls;
object id = isCurse ? ((CurseResource)parameter).Id : ((ModrinthResource)parameter).Id;

if (urls.Any())
if (urls.Any())
ScreenshotsBorderVisbility = Visibility.Visible;

Task.Run(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
using CommunityToolkit.Mvvm.Input;
using Microsoft.UI.Xaml;
using Natsurainko.FluentLauncher.Classes.Data.Download;
using Natsurainko.FluentLauncher.Services.Launch;
using Natsurainko.FluentLauncher.Services.Storage;
using Natsurainko.FluentLauncher.Services.UI;
using Natsurainko.FluentLauncher.Services.UI.Navigation;
using Natsurainko.FluentLauncher.Utils;
using Nrk.FluentCore.Classes.Datas.Download;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -16,11 +19,19 @@ internal partial class ResourcesSearchViewModel : ObservableObject, INavigationA
{
private readonly InterfaceCacheService _interfaceCacheService;
private readonly INavigationService _navigationService;

public ResourcesSearchViewModel(InterfaceCacheService interfaceCacheServicel, INavigationService navigationService)
private readonly GameService _gameService;
private readonly NotificationService _notificationService;

public ResourcesSearchViewModel(
InterfaceCacheService interfaceCacheServicel,
INavigationService navigationService,
GameService gameService,
NotificationService notificationService)
{
_interfaceCacheService = interfaceCacheServicel;
_navigationService = navigationService;
_gameService = gameService;
_notificationService = notificationService;
}

[ObservableProperty]
Expand Down Expand Up @@ -120,5 +131,21 @@ private void Search()
public void NavigateResourcePage(object resource) => _navigationService.NavigateTo("ResourceItemPage", resource);

[RelayCommand]
public void NavigateCoreInstallWizardPage(object resource) => _navigationService.NavigateTo("CoreInstallWizardPage", resource);
public void NavigateCoreInstallWizardPage(object resource)
{
if (string.IsNullOrEmpty(_gameService.ActiveMinecraftFolder))
{
_notificationService.NotifyWithSpecialContent(
ResourceUtils.GetValue("Notifications", "_NoMinecraftFolder"),
"NoMinecraftFolderNotifyTemplate",
GoToSettingsCommand, "\uE711");

return;
}

_navigationService.NavigateTo("CoreInstallWizardPage", resource);
}

[RelayCommand]
public void GoToSettings() => _navigationService.NavigateTo("SettingsNavigationPage", "LaunchSettingsPage");
}
4 changes: 3 additions & 1 deletion Natsurainko.FluentLauncher/ViewModels/Home/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public HomeViewModel(GameService gameService, AccountService accountService, Lau

public Visibility AccountTag => ActiveAccount is null ? Visibility.Collapsed : Visibility.Visible;

[RelayCommand]
[RelayCommand(CanExecute = nameof(CanExecuteLaunch))]
public void Launch()
{
_launchService.LaunchGame(ActiveGameInfo);
Expand All @@ -84,4 +84,6 @@ protected override void OnPropertyChanged(PropertyChangedEventArgs e)
if (e.PropertyName == nameof(ActiveGameInfo) && ActiveGameInfo is not null)
_gameService.ActivateGameInfo(ActiveGameInfo);
}

private bool CanExecuteLaunch() => ActiveGameInfo is not null;
}
Loading
Loading