Skip to content

Commit

Permalink
修复 Legacy Forge 的安装和启动问题
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Sep 14, 2024
1 parent 9769b5f commit ce78c9b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="using:Natsurainko.FluentLauncher.XamlHelpers.Behaviors"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Natsurainko.FluentLauncher.XamlHelpers.Converters">
xmlns:converters="using:Natsurainko.FluentLauncher.XamlHelpers.Converters"
xmlns:i="using:Microsoft.Xaml.Interactivity">

<converters:BoolToVisibilityConverter x:Key="InvertedBoolToVisibilityConverter" Inverted="True" />
<converters:TaskStateConverter x:Key="TaskStateConverter" />
Expand Down Expand Up @@ -195,6 +197,13 @@
Style="{ThemeResource AccentButtonStyle}"
Visibility="{Binding CanLaunch, Converter={ThemeResource BoolToVisibilityConverter}}">
<TextBlock x:Uid="Buttons_Launch" Text="Launch" />

<i:Interaction.Behaviors>
<behaviors:AncestorBindingBehavior
AncestorType="ScrollViewer"
Binding="{Binding DataContext.NavigationService}"
TargetPropertyName="CommandParameter" />
</i:Interaction.Behaviors>
</Button>
</StackPanel>
</Grid>
Expand Down Expand Up @@ -400,9 +409,9 @@

<Grid Visibility="{Binding ShowException, Converter={ThemeResource BoolToVisibilityConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock
Expand Down
5 changes: 4 additions & 1 deletion Natsurainko.FluentLauncher/Services/Launch/LaunchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ async Task ResolveDependencies(
// Natives decompression
if (!CanSkipNativesDecompression(instance))
{
var (_, nativeLibs) = instance.GetRequiredLibraries();
var (_, nativeLibs) = instance is ModifiedMinecraftInstance { HasInheritance: true } modifiedMinecraftInstance
? modifiedMinecraftInstance.InheritedMinecraftInstance.GetRequiredLibraries()
: instance.GetRequiredLibraries();

UnzipUtils.BatchUnzip(
Path.Combine(instance.MinecraftFolderPath, "versions", instance.InstanceId, "natives"),
nativeLibs.Select(x => x.FullPath));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentLauncher.Infra.UI.Navigation;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
Expand Down Expand Up @@ -455,7 +456,12 @@ void NotifyException()
}

[RelayCommand(CanExecute = nameof(CanLaunch))]
void Launch() => App.GetService<LaunchService>().LaunchFromUI(_minecraftInstance);
void Launch(INavigationService navigationService)
{
navigationService.NavigateTo("Tasks/Launch");
App.GetService<LaunchService>().LaunchFromUI(_minecraftInstance);

}
}

#endregion
Expand Down
12 changes: 5 additions & 7 deletions Natsurainko.FluentLauncher/ViewModels/Tasks/DownloadViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ namespace Natsurainko.FluentLauncher.ViewModels.Tasks;

internal partial class DownloadViewModel : ObservableObject, INavigationAware
{
private readonly DownloadService _downloadService;
private readonly INavigationService _navigationService;

public ReadOnlyObservableCollection<TaskViewModel> Tasks { get; }

public INavigationService NavigationService { get; init; }


public DownloadViewModel(DownloadService downloadService, INavigationService navigationService)
{
_downloadService = downloadService;
_navigationService = navigationService;

NavigationService = navigationService;
Tasks = new(downloadService.DownloadTasks);
}

[RelayCommand]
void GoToDownload() => _navigationService.NavigateTo("Download/Navigation");
void GoToDownload() => NavigationService.NavigateTo("Download/Navigation");
}

0 comments on commit ce78c9b

Please sign in to comment.