Browse Source

Update Installer & PackageManager pages for new format

pull/14/head
JT 1 year ago
parent
commit
7069bd1027
  1. 4
      StabilityMatrix/InstallerWindow.xaml
  2. 4
      StabilityMatrix/LaunchPage.xaml
  3. 4
      StabilityMatrix/Models/InstalledPackage.cs
  4. 4
      StabilityMatrix/PackageManagerPage.xaml
  5. 26
      StabilityMatrix/ViewModels/InstallerViewModel.cs
  6. 2
      StabilityMatrix/ViewModels/LaunchViewModel.cs

4
StabilityMatrix/InstallerWindow.xaml

@ -215,10 +215,6 @@
</StackPanel>
</StackPanel>
<Label Content="Install Location" Margin="0,16,0,0" />
<ui:TextBox Margin="0,0,0,8"
Text="{Binding InstallPath, UpdateSourceTrigger=PropertyChanged}" />
<Label Content="Display Name" Margin="0,16,0,0" />
<StackPanel Orientation="Horizontal"
Visibility="{Binding ShowDuplicateWarning, Converter={StaticResource BoolToVisConverter}}">

4
StabilityMatrix/LaunchPage.xaml

@ -59,7 +59,9 @@
d:DataContext="{d:DesignInstance Type=models:InstalledPackage,
IsDesignTimeCreatable=True}">
<TextBlock Margin="0,5,0,5" Text="{Binding DisplayName}" />
<TextBlock Margin="0,0,0,5" Text="{Binding FullPath}" />
<TextBlock Margin="0,0,0,5">
<Run Text="{Binding FullPath}"/>
</TextBlock>
</StackPanel>
</Grid>
</Grid>

4
StabilityMatrix/Models/InstalledPackage.cs

@ -34,8 +34,8 @@ public class InstalledPackage
/// <summary>
/// Full path to the package, using LibraryPath and GlobalConfig.LibraryDir.
/// </summary>
// [JsonIgnore]
// public string? FullPath => LibraryPath != null ? System.IO.Path.Combine(GlobalConfig.LibraryDir, LibraryPath) : null;
[JsonIgnore]
public string? FullPath => LibraryPath != null ? System.IO.Path.Combine(GlobalConfig.LibraryDir, LibraryPath) : null;
public string? LaunchCommand { get; set; }
public List<LaunchOption>? LaunchArgs { get; set; }

4
StabilityMatrix/PackageManagerPage.xaml

@ -112,8 +112,8 @@
<TextBlock
FontSize="12"
Margin="0,5,0,5"
Text="{Binding SelectedPackage.Path, FallbackValue=C:\Users\Example\Downloads}" />
<StackPanel Margin="0,16,0,0" Orientation="Horizontal">
Text="{Binding SelectedPackage.FullPath, FallbackValue=Packages\stable-diffusion}" />
<StackPanel Margin="0,16,0,0" Orientation="Horizontal">
<ui:Button
Appearance="Success"
Command="{Binding InstallCommand}"

26
StabilityMatrix/ViewModels/InstallerViewModel.cs

@ -59,9 +59,6 @@ public partial class InstallerViewModel : ObservableObject
[ObservableProperty]
private string installButtonText;
[ObservableProperty]
private string installPath;
[ObservableProperty]
private string installName;
@ -125,12 +122,6 @@ public partial class InstallerViewModel : ObservableObject
SelectedPackage = AvailablePackages[0];
InstallName = SelectedPackage.DisplayName;
// Set InstallPath when library changes
settingsManager.LibraryDirChanged += (_, libraryDir) =>
{
InstallPath = Path.Combine(libraryDir, "Packages");
};
}
public async Task OnLoaded()
@ -255,16 +246,11 @@ public partial class InstallerViewModel : ObservableObject
OnSelectedPackageChanged(SelectedPackage);
}
partial void OnInstallNameChanged(string oldValue, string newValue)
{
var path = Path.GetFullPath($"{InstallPath}\\{newValue}");
ShowDuplicateWarning = settingsManager.Settings.InstalledPackages.Any(p => p.Path.Equals(path));
}
partial void OnInstallPathChanged(string oldValue, string newValue)
partial void OnInstallNameChanged(string? oldValue, string newValue)
{
var path = Path.GetFullPath($"{newValue}\\{InstallName}");
ShowDuplicateWarning = settingsManager.Settings.InstalledPackages.Any(p => p.Path.Equals(path));
ShowDuplicateWarning =
settingsManager.Settings.InstalledPackages.Any(p =>
p.LibraryPath.Equals($"Packages\\{newValue}"));
}
partial void OnSelectedVersionChanged(PackageVersion? value)
@ -303,7 +289,7 @@ public partial class InstallerViewModel : ObservableObject
await InstallGitIfNecessary();
SelectedPackage.InstallLocation = $"{InstallPath}\\{InstallName}";
SelectedPackage.InstallLocation = $"{settingsManager.LibraryDir}\\Packages\\{InstallName}";
SelectedPackage.DisplayName = InstallName;
if (!PyRunner.PipInstalled || !PyRunner.VenvInstalled)
@ -339,7 +325,7 @@ public partial class InstallerViewModel : ObservableObject
var package = new InstalledPackage
{
DisplayName = SelectedPackage.DisplayName,
Path = SelectedPackage.InstallLocation,
LibraryPath = $"Packages\\{InstallName}",
Id = Guid.NewGuid(),
PackageName = SelectedPackage.Name,
PackageVersion = version,

2
StabilityMatrix/ViewModels/LaunchViewModel.cs

@ -203,7 +203,7 @@ public partial class LaunchViewModel : ObservableObject
// Use dynamic parsed args over static
if (package is IArgParsable parsable)
{
var rootPath = activeInstall.Path!;
var rootPath = activeInstall.FullPath!;
var moduleName = parsable.RelativeArgsDefinitionScriptPath;
var parser = new ArgParser(pyRunner, rootPath, moduleName);
definitions = await parser.GetArgsAsync();

Loading…
Cancel
Save