-
-
Notifications
You must be signed in to change notification settings - Fork 99
Preserve exclusion/include list and add Progress bar for local mod installation #667
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
base: master
Are you sure you want to change the base?
Changes from all commits
bfd7cd0
49b3e1e
0cf2938
bdff396
f70880f
0966c60
a00d751
e8e5498
1f7c061
626acef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| namespace Reloaded.Mod.Launcher.Lib.Models.ViewModel.Dialog; | ||
|
|
||
| /// <summary> | ||
| /// ViewModel for downloading an individual package. | ||
| /// </summary> | ||
| [AddINotifyPropertyChangedInterface] | ||
| public class InstallPackageViewModel : INotifyPropertyChanged | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use autogeneration for INotifyPropertyChanged here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the way the rest of the project does this IIRC. Have a quick peek around. |
||
| { | ||
| public string Text { get; set; } | ||
| public string Title { get; set; } | ||
| public double Progress { get; set; } | ||
| public bool IsComplete { get; set; } | ||
|
|
||
| public event PropertyChangedEventHandler PropertyChanged; | ||
|
Check warning on line 14 in source/Reloaded.Mod.Launcher.Lib/Models/ViewModel/Dialog/InstallPackageViewModel.cs
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,23 +103,47 @@ public PublishModDialogViewModel(PathTuple<ModConfig> modTuple) | |
| _modTuple = modTuple; | ||
| PackageName = IOEx.ForceValidFilePath(_modTuple.Config.ModName.Replace(' ', '_')); | ||
| OutputFolder = Path.Combine(Path.GetTempPath(), $"{IOEx.ForceValidFilePath(_modTuple.Config.ModId)}.Publish"); | ||
|
|
||
| // Set default Regexes. | ||
| IgnoreRegexes = new ObservableCollection<StringWrapper>() | ||
| IgnoreRegexes = new ObservableCollection<StringWrapper>( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this not overkill? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might also save you from unnecessarily implementing PropertyChanged in the other place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this still needs moving. |
||
| _modTuple.Config.IgnoreRegexes.Select(x => new StringWrapper { Value = x }) | ||
| ); | ||
| foreach (StringWrapper item in IgnoreRegexes) | ||
| item.PropertyChanged += (_, __) => UpdateConfig(_modTuple.Config.IgnoreRegexes, IgnoreRegexes); | ||
| IgnoreRegexes.CollectionChanged += (s, e) => | ||
| { | ||
| @".*\.json", // Config files | ||
| $"{Regex.Escape($@"{_modTuple.Config.ModId}.nuspec")}" | ||
| if (e.NewItems != null) | ||
| foreach (StringWrapper item in e.NewItems) | ||
| item.PropertyChanged += (_, __) => UpdateConfig(_modTuple.Config.IgnoreRegexes, IgnoreRegexes); | ||
|
|
||
| if (e.OldItems != null) | ||
| foreach (StringWrapper item in e.OldItems) | ||
| item.PropertyChanged -= (_, __) => UpdateConfig(_modTuple.Config.IgnoreRegexes, IgnoreRegexes); | ||
| _modTuple.Config.IgnoreRegexes.Clear(); | ||
| _modTuple.Config.IgnoreRegexes.AddRange(IgnoreRegexes.Select(x => x.Value)); | ||
| }; | ||
|
|
||
| IncludeRegexes = new ObservableCollection<StringWrapper>() | ||
| IncludeRegexes = new ObservableCollection<StringWrapper>( | ||
| _modTuple.Config.IncludeRegexes.Select(x => new StringWrapper { Value = x }) | ||
| ); | ||
| foreach (StringWrapper item in IncludeRegexes) | ||
| item.PropertyChanged += (_, __) => UpdateConfig(_modTuple.Config.IncludeRegexes, IncludeRegexes); | ||
| IncludeRegexes.CollectionChanged += (s, e) => | ||
| { | ||
| Regex.Escape(ModConfig.ConfigFileName), | ||
| @"\.deps\.json", | ||
| @"\.runtimeconfig\.json", | ||
| if (e.NewItems != null) | ||
| foreach (StringWrapper item in e.NewItems) | ||
| item.PropertyChanged += (_, __) => UpdateConfig(_modTuple.Config.IncludeRegexes, IncludeRegexes); | ||
|
|
||
| if (e.OldItems != null) | ||
| foreach (StringWrapper item in e.OldItems) | ||
| item.PropertyChanged -= (_, __) => UpdateConfig(_modTuple.Config.IncludeRegexes, IncludeRegexes); | ||
| _modTuple.Config.IncludeRegexes.Clear(); | ||
| _modTuple.Config.IncludeRegexes.AddRange(IncludeRegexes.Select(x => x.Value)); | ||
| }; | ||
| } | ||
|
|
||
| // Set notifications | ||
| PropertyChanged += ChangeUiVisbilityOnPropertyChanged; | ||
| void UpdateConfig(List<string> list, ObservableCollection<StringWrapper> collection) | ||
| { | ||
| list.Clear(); | ||
| list.AddRange(collection.Select(x => x.Value)); | ||
| _modTuple.SaveAsync(); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -148,8 +172,8 @@ await PublishAsync(new PublishArgs() | |
| PublishTarget = PublishTarget, | ||
| OutputFolder = OutputFolder, | ||
| ModTuple = _modTuple, | ||
| IgnoreRegexes = IgnoreRegexes.Select(x => x.Value).ToList(), | ||
| IncludeRegexes = IncludeRegexes.Select(x => x.Value).ToList(), | ||
| IgnoreRegexes = _modTuple.Config.IgnoreRegexes, | ||
| IncludeRegexes = _modTuple.Config.IncludeRegexes, | ||
| Progress = new Progress<double>(d => BuildProgress = d * 100), | ||
| AutomaticDelta = AutomaticDelta, | ||
| CompressionLevel = CompressionLevel, | ||
|
|
@@ -286,6 +310,11 @@ public void SetOutputFolder() | |
| /// </summary> | ||
| public void SetReadmePath() => ReadmePath = FileSelectors.SelectMarkdownFile(); | ||
|
|
||
| /// <summary> | ||
| /// Lets the user save all changes to the mod config. | ||
| /// </summary> | ||
| public Task SaveAsync() => _modTuple.SaveAsync(); | ||
|
|
||
| private string GetModFolder() => Path.GetDirectoryName(_modTuple.Path)!; | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <default:ReloadedWindow x:Class="Reloaded.Mod.Launcher.Pages.Dialogs.InstallPackageDialog" | ||
| 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:local="clr-namespace:Reloaded.Mod.Launcher.Pages.Dialogs" | ||
| xmlns:converters="clr-namespace:Reloaded.Mod.Launcher.Converters" | ||
| xmlns:default="clr-namespace:Reloaded.WPF.Theme.Default;assembly=Reloaded.WPF.Theme.Default" | ||
| mc:Ignorable="d" | ||
| SizeToContent="Height" | ||
| Width="500" | ||
| Title="{Binding Title}" | ||
| Style="{DynamicResource ReloadedWindow}"> | ||
| <Grid Margin="{DynamicResource PageMarginSmall}" DataContext="{Binding Path=ViewModel, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"> | ||
|
|
||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="Auto"/> | ||
| <RowDefinition Height="*"/> | ||
| <RowDefinition Height="Auto"/> | ||
| </Grid.RowDefinitions> | ||
|
|
||
| <TextBlock HorizontalAlignment="Center" | ||
| Grid.Row="0" | ||
| Text="{Binding Text}" | ||
| Visibility="{Binding Text, Converter={x:Static converters:StringToVisibilityConverter.Instance}}" | ||
| Style="{DynamicResource DefaultTextBlock}" /> | ||
|
|
||
| <Grid Margin="{DynamicResource PanelMargin}" | ||
| Grid.Row="1"/> | ||
|
|
||
| <Grid Margin="{DynamicResource PanelMargin}" Grid.Row="2"> | ||
| <Grid.ColumnDefinitions> | ||
| <ColumnDefinition Width="*" /> | ||
| <ColumnDefinition Width="{DynamicResource GridInterPanelMargin}" /> | ||
| <ColumnDefinition Width="Auto"/> | ||
| </Grid.ColumnDefinitions> | ||
|
|
||
| <ProgressBar Grid.Column="0" | ||
| Height="25" | ||
| Value="{Binding Progress, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" | ||
| Maximum="100" /> | ||
| </Grid> | ||
| </Grid> | ||
| </default:ReloadedWindow> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using Button = System.Windows.Controls.Button; | ||
|
|
||
| namespace Reloaded.Mod.Launcher.Pages.Dialogs; | ||
|
|
||
| /// <summary> | ||
| /// Interaction logic for DownloadPackageDialog.xaml | ||
| /// </summary> | ||
| public partial class InstallPackageDialog : ReloadedWindow | ||
| { | ||
| public new InstallPackageViewModel ViewModel { get; set; } | ||
|
|
||
| /// <inheritdoc /> | ||
| public InstallPackageDialog(InstallPackageViewModel viewModel) | ||
| { | ||
| InitializeComponent(); | ||
| ViewModel = viewModel; | ||
| DataContext = viewModel; | ||
| viewModel.PropertyChanged += (s, e) => | ||
| { | ||
| if (e.PropertyName == nameof(InstallPackageViewModel.IsComplete) && viewModel.IsComplete) | ||
| { | ||
| ActionWrappers.ExecuteWithApplicationDispatcher(this.Close); | ||
| } | ||
| }; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.