mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Implement mod reset
This commit is contained in:
@@ -43,13 +43,11 @@ namespace ZuneModdingHelper.Pages
|
|||||||
mod.ZuneInstallDir = _modConfig.ZuneInstallDir;
|
mod.ZuneInstallDir = _modConfig.ZuneInstallDir;
|
||||||
|
|
||||||
// Stage 0: Initialize mod
|
// Stage 0: Initialize mod
|
||||||
progDialog.Title = ($"Installing '{mod.Title}'");
|
|
||||||
progDialog.Description = ("Preparing to install...");
|
|
||||||
await mod.Init();
|
await mod.Init();
|
||||||
++progDialog.Progress;
|
++progDialog.Progress;
|
||||||
|
|
||||||
// Stage 1: Display AbstractUI for options
|
// Stage 1: Display AbstractUI for options
|
||||||
progDialog.Description = ("Awaiting options...");
|
progDialog.Description = $"Awaiting options for '{mod.Title}'...";
|
||||||
if (mod.OptionsUI != null)
|
if (mod.OptionsUI != null)
|
||||||
{
|
{
|
||||||
var optionsDialog = new AbstractUIGroupDialog(mod.OptionsUI);
|
var optionsDialog = new AbstractUIGroupDialog(mod.OptionsUI);
|
||||||
@@ -65,7 +63,7 @@ namespace ZuneModdingHelper.Pages
|
|||||||
++progDialog.Progress;
|
++progDialog.Progress;
|
||||||
|
|
||||||
// Stage 2: Apply mod
|
// Stage 2: Apply mod
|
||||||
progDialog.Description = ("Applying mod...");
|
progDialog.Description = $"Applying '{mod.Title}'...";
|
||||||
string applyResult = await mod.Apply();
|
string applyResult = await mod.Apply();
|
||||||
if (applyResult != null)
|
if (applyResult != null)
|
||||||
{
|
{
|
||||||
@@ -86,7 +84,7 @@ namespace ZuneModdingHelper.Pages
|
|||||||
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(new()
|
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(new()
|
||||||
{
|
{
|
||||||
Title = MOD_MANAGER_TITLE,
|
Title = MOD_MANAGER_TITLE,
|
||||||
Description = $"Installed '{mod.Title}'",
|
Description = $"Successfully applied '{mod.Title}'",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,38 +93,53 @@ namespace ZuneModdingHelper.Pages
|
|||||||
if (!TryGetModFromControl(sender, out var mod))
|
if (!TryGetModFromControl(sender, out var mod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//var progDialog = await this.ShowProgressAsync("Getting ready...", "Preparing to reset mod", settings: defaultMetroDialogSettings);
|
ProgressDialogViewModel progDialog = new()
|
||||||
//Mod.ZuneInstallDir = ZuneInstallDirBox.Text;
|
{
|
||||||
|
Title = MOD_MANAGER_TITLE,
|
||||||
|
Description = $"Preparing to reset '{mod.Title}'...",
|
||||||
|
ShowAffirmativeButton = false,
|
||||||
|
IsIndeterminate = true,
|
||||||
|
Maximum = 2,
|
||||||
|
};
|
||||||
|
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(progDialog));
|
||||||
|
|
||||||
//progDialog.Maximum = 2;
|
mod.ZuneInstallDir = _modConfig.ZuneInstallDir;
|
||||||
//int numCompleted = 0;
|
|
||||||
|
|
||||||
//progDialog.SetTitle("Resetting mod...");
|
await mod.Init();
|
||||||
//progDialog.SetMessage($"Setting up '{mod.Title}'");
|
++progDialog.Progress;
|
||||||
//await mod.Init();
|
|
||||||
//progDialog.SetProgress(++numCompleted);
|
|
||||||
|
|
||||||
//// TODO: Implement AbstractUI display for reset options
|
// TODO: Implement AbstractUI display for reset options
|
||||||
////if (mod.OptionsUI != null)
|
//if (mod.OptionsUI != null)
|
||||||
////{
|
|
||||||
//// var optionsDialog = new AbstractUIGroupDialog();
|
|
||||||
//// optionsDialog.OptionsUIPresenter.ViewModel = new AbstractUICollectionViewModel(mod.OptionsUI);
|
|
||||||
//// optionsDialog.ShowDialog();
|
|
||||||
////}
|
|
||||||
|
|
||||||
//progDialog.SetMessage($"Resetting '{mod.Title}'");
|
|
||||||
//string resetResult = await mod.Reset();
|
|
||||||
//if (resetResult != null)
|
|
||||||
//{
|
//{
|
||||||
// await progDialog.CloseAsync();
|
// var optionsDialog = new AbstractUIGroupDialog();
|
||||||
// await this.ShowMessageAsync("Completed", $"Failed to reset '{mod.Title}':\r\n{resetResult}", settings: defaultMetroDialogSettings);
|
// optionsDialog.OptionsUIPresenter.ViewModel = new AbstractUICollectionViewModel(mod.OptionsUI);
|
||||||
// return;
|
// optionsDialog.ShowDialog();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//progDialog.SetProgress(++numCompleted);
|
progDialog.Description = $"Resetting '{mod.Title}'...";
|
||||||
|
string resetResult = await mod.Reset();
|
||||||
|
if (resetResult != null)
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Send<CloseDialogMessage>();
|
||||||
|
|
||||||
//await progDialog.CloseAsync();
|
DialogViewModel errorDialog = new()
|
||||||
//await this.ShowMessageAsync("Completed", $"Successfully reset '{mod.Title}'", settings: defaultMetroDialogSettings);
|
{
|
||||||
|
Title = MOD_MANAGER_TITLE,
|
||||||
|
Description = $"Failed to reset '{mod.Title}'.\r\n{resetResult}",
|
||||||
|
};
|
||||||
|
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(errorDialog));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
++progDialog.Progress;
|
||||||
|
|
||||||
|
WeakReferenceMessenger.Default.Send<CloseDialogMessage>();
|
||||||
|
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(new()
|
||||||
|
{
|
||||||
|
Title = MOD_MANAGER_TITLE,
|
||||||
|
Description = $"Successfully reset '{mod.Title}'",
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryGetModFromControl(object sender, out Mod mod)
|
private static bool TryGetModFromControl(object sender, out Mod mod)
|
||||||
|
|||||||
Reference in New Issue
Block a user