mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Added reset button for each mod; Minor UI tweaks
This commit is contained in:
@@ -45,12 +45,19 @@ namespace ZuneModCore.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override Task<string?> Reset()
|
public override Task<string?> Reset()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Copy backup to application folder
|
// Copy backup to application folder
|
||||||
File.Copy(Path.Combine(StorageDirectory, "WMVCORE.original.dll"), WMVCORE_PATH, true);
|
File.Copy(Path.Combine(StorageDirectory, "WMVCORE.original.dll"), WMVCORE_PATH, true);
|
||||||
|
|
||||||
return Task.FromResult<string?>(null);
|
return Task.FromResult<string?>(null);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Task.FromResult(ex.Message)!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override IReadOnlyList<Type>? DependentMods => null;
|
public override IReadOnlyList<Type>? DependentMods => null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ namespace ZuneModCore.Mods
|
|||||||
|
|
||||||
return Task.FromResult<string?>(null);
|
return Task.FromResult<string?>(null);
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
return Task.FromResult<string?>($"Failed to open '{zsDllInfo.FullName}'. Verify that the Zune software is not running and try again.");
|
return Task.FromResult<string?>($"Unable to replace '{zsDllInfo.FullName}'. Verify that the Zune software is not running and try again.");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -91,9 +91,12 @@ namespace ZuneModCore.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override Task<string?> Reset()
|
public override Task<string?> Reset()
|
||||||
|
{
|
||||||
|
string zsDllPath = Path.Combine(ZuneInstallDir, "ZuneService.dll");
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Copy backup to application folder
|
// Copy backup to application folder
|
||||||
File.Copy(Path.Combine(StorageDirectory, "ZuneService.original.dll"), Path.Combine(ZuneInstallDir, "ZuneService.dll"), true);
|
File.Copy(Path.Combine(StorageDirectory, "ZuneService.original.dll"), zsDllPath, true);
|
||||||
|
|
||||||
// Disable all feature overrides affected by new servers
|
// Disable all feature overrides affected by new servers
|
||||||
SetFeatureOverride("Apps", false);
|
SetFeatureOverride("Apps", false);
|
||||||
@@ -108,5 +111,14 @@ namespace ZuneModCore.Mods
|
|||||||
|
|
||||||
return Task.FromResult<string?>(null);
|
return Task.FromResult<string?>(null);
|
||||||
}
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
return Task.FromResult<string?>($"Unable to replace '{zsDllPath}'. Verify that the Zune software is not running and try again.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Task.FromResult<string?>(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace ZuneModCore
|
|||||||
if (regKey == null)
|
if (regKey == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
regKey.DeleteValue(name);
|
regKey.DeleteValue(name, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,18 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" FontSize="16" TextTrimming="CharacterEllipsis"/>
|
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" FontSize="16" TextTrimming="CharacterEllipsis"/>
|
||||||
<TextBlock Text="{Binding Description}" Grid.Row="1" FontSize="12" TextWrapping="Wrap"/>
|
<TextBlock Text="{Binding Description}" Grid.Row="1" FontSize="14" TextWrapping="Wrap"/>
|
||||||
|
|
||||||
|
<Button x:Name="ModResetButton" Grid.Column="1" Grid.RowSpan="2" VerticalAlignment="Center"
|
||||||
|
Click="ModResetButton_Click">
|
||||||
|
<mah:FontIcon Glyph="" FontFamily="Segoe MDL2 Assets" />
|
||||||
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
<!--<Border Padding="8" Margin="8" Background="White">
|
<!--<Border Padding="8" Margin="8" Background="White">
|
||||||
|
|
||||||
@@ -49,11 +58,11 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock Text="Zune Software install directory:" Margin="4,4,0,0"/>
|
<TextBlock Text="Zune Software install directory:" FontSize="14" Margin="4,4,0,2"/>
|
||||||
<TextBox x:Name="ZuneInstallDirBox" Grid.Row="1" Margin="4,0,0,4"/>
|
<TextBox x:Name="ZuneInstallDirBox" Grid.Row="1" Margin="4,0,0,4"/>
|
||||||
|
|
||||||
<Button x:Name="InstallModsButton" Content="Install" ToolTip="Install selected mods" Click="InstallModsButton_Click"
|
<Button x:Name="InstallModsButton" Content="Install" ToolTip="Install selected mods" Click="InstallModsButton_Click"
|
||||||
Grid.RowSpan="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4"/>
|
Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Right" Margin="4,0,4,4"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</mah:MetroWindow>
|
</mah:MetroWindow>
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ namespace ZuneModdingHelper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : MetroWindow
|
public partial class MainWindow : MetroWindow
|
||||||
{
|
{
|
||||||
|
private readonly MetroDialogSettings defaultMetroDialogSettings = new()
|
||||||
|
{
|
||||||
|
ColorScheme = MetroDialogColorScheme.Accented,
|
||||||
|
AnimateShow = true,
|
||||||
|
AnimateHide = true,
|
||||||
|
AffirmativeButtonText = "Close"
|
||||||
|
};
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -41,7 +49,7 @@ namespace ZuneModdingHelper
|
|||||||
|
|
||||||
private async void InstallModsButton_Click(object sender, RoutedEventArgs e)
|
private async void InstallModsButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var progDialog = await this.ShowProgressAsync("Getting ready...", "Preparing to apply mods");
|
var progDialog = await this.ShowProgressAsync("Getting ready...", "Preparing to apply mods", settings: defaultMetroDialogSettings);
|
||||||
Mod.ZuneInstallDir = ZuneInstallDirBox.Text;
|
Mod.ZuneInstallDir = ZuneInstallDirBox.Text;
|
||||||
var selectedMods = ModList.SelectedItems.Cast<Mod>();
|
var selectedMods = ModList.SelectedItems.Cast<Mod>();
|
||||||
|
|
||||||
@@ -75,8 +83,45 @@ namespace ZuneModdingHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
await progDialog.CloseAsync();
|
await progDialog.CloseAsync();
|
||||||
await this.ShowMessageAsync("Completed", "Finished installing selected mods",
|
await this.ShowMessageAsync("Completed", "Finished installing selected mods", settings: defaultMetroDialogSettings);
|
||||||
settings: new MetroDialogSettings() { AffirmativeButtonText = "Close" });
|
}
|
||||||
|
|
||||||
|
private async void ModResetButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is FrameworkElement elem && elem.DataContext is Mod mod)
|
||||||
|
{
|
||||||
|
var progDialog = await this.ShowProgressAsync("Getting ready...", "Preparing to reset mod", settings: defaultMetroDialogSettings);
|
||||||
|
Mod.ZuneInstallDir = ZuneInstallDirBox.Text;
|
||||||
|
|
||||||
|
progDialog.Maximum = 2;
|
||||||
|
int numCompleted = 0;
|
||||||
|
|
||||||
|
progDialog.SetTitle("Resetting mod...");
|
||||||
|
progDialog.SetMessage($"Setting up '{mod.Title}'");
|
||||||
|
await mod.Init();
|
||||||
|
progDialog.SetProgress(++numCompleted);
|
||||||
|
|
||||||
|
// TODO: Implement AbstractUI display for options
|
||||||
|
//if (mod.OptionsUI != null)
|
||||||
|
//{
|
||||||
|
// var optionsDialog = new AbstractUIGroupDialog();
|
||||||
|
// optionsDialog.OptionsUIPresenter.ViewModel = new AbstractUIElementGroupViewModel(mod.OptionsUI);
|
||||||
|
// optionsDialog.ShowDialog();
|
||||||
|
//}
|
||||||
|
|
||||||
|
progDialog.SetMessage($"Resetting '{mod.Title}'");
|
||||||
|
string applyResult = await mod.Reset();
|
||||||
|
if (applyResult != null)
|
||||||
|
{
|
||||||
|
await progDialog.CloseAsync();
|
||||||
|
await this.ShowMessageAsync("Completed", $"Failed to reset '{mod.Title}':\r\n{applyResult}", settings: defaultMetroDialogSettings);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
progDialog.SetProgress(++numCompleted);
|
||||||
|
await progDialog.CloseAsync();
|
||||||
|
await this.ShowMessageAsync("Completed", $"Successfully reset '{mod.Title}'", settings: defaultMetroDialogSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user