all kinds of stuff
This commit is contained in:
parent
b243a150f5
commit
21bc6e2e4a
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EftPatchHelper.EftInfo
|
||||
namespace EftPatchHelper.EftInfo
|
||||
{
|
||||
public enum EftClientLocation
|
||||
{
|
||||
|
@ -1,9 +1,4 @@
|
||||
using Spectre.Console;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EftPatchHelper.Extensions
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EftPatchHelper.Interfaces
|
||||
namespace EftPatchHelper.Interfaces
|
||||
{
|
||||
public interface IClientSelectionTask : ITaskable
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EftPatchHelper.Interfaces
|
||||
namespace EftPatchHelper.Interfaces
|
||||
{
|
||||
public interface ISettingsTask : ITaskable
|
||||
{
|
||||
|
@ -1,6 +1,4 @@
|
||||
using EftPatchHelper.Model;
|
||||
|
||||
namespace EftPatchHelper.Interfaces
|
||||
namespace EftPatchHelper.Interfaces
|
||||
{
|
||||
public interface ITaskable
|
||||
{
|
||||
@ -8,6 +6,6 @@ namespace EftPatchHelper.Interfaces
|
||||
/// Runs a predefined task
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the task succeeded, otherwise false</returns>
|
||||
public bool Run();
|
||||
public void Run();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EftPatchHelper.EftInfo;
|
||||
|
||||
namespace EftPatchHelper.Model
|
||||
{
|
||||
public class Options
|
||||
{
|
||||
public bool PromptToOverwriteDirectories = true;
|
||||
public bool IgnoreExistingDirectories = true;
|
||||
public EftClient TargetClient = null;
|
||||
public EftClient SourceClient = null;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using Spectre.Console;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace EftPatchHelper.Model
|
||||
@ -29,23 +30,28 @@ namespace EftPatchHelper.Model
|
||||
[JsonPropertyName("patcherExePath")]
|
||||
public string PatcherEXEPath { get; set; } = "";
|
||||
|
||||
public void Save()
|
||||
public bool Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = JsonSerializer.Serialize(this, typeof(Settings), new JsonSerializerOptions() { WriteIndented = true });
|
||||
|
||||
if (string.IsNullOrWhiteSpace(json)) return;
|
||||
|
||||
File.WriteAllText(settingsFile, json);
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
{
|
||||
AnsiConsole.WriteLine("[red]!! Nothing was serialized !![/]");
|
||||
return false;
|
||||
}
|
||||
|
||||
//public static Settings? Load()
|
||||
//{
|
||||
// if (!File.Exists(settingsFile)) return null;
|
||||
File.WriteAllText(settingsFile, json);
|
||||
|
||||
// string json = File.ReadAllText(settingsFile);
|
||||
|
||||
// return JsonSerializer.Deserialize<Settings>(json);
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.WriteException(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
using EftPatchHelper.Extensions;
|
||||
using EftPatchHelper.Helpers;
|
||||
using EftPatchHelper.Interfaces;
|
||||
using EftPatchHelper.Model;
|
||||
@ -15,29 +14,43 @@ namespace EftPatchHelper
|
||||
{
|
||||
ITaskable _settingsTasks;
|
||||
ITaskable _clientSelectionTasks;
|
||||
ITaskable _fileProcessingTasks;
|
||||
ITaskable _patchGenTasks;
|
||||
ITaskable _patchTestingTasks;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Fancy
|
||||
AnsiConsole.Write(new FigletText("EFT Patch Helper").Centered().Color(Color.Blue));
|
||||
|
||||
var host = ConfigureHost(args);
|
||||
host.Services.GetRequiredService<Program>().Run();
|
||||
|
||||
AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
public Program(
|
||||
ISettingsTask settingsTasks,
|
||||
IClientSelectionTask clientSelectionTasks
|
||||
IClientSelectionTask clientSelectionTasks,
|
||||
IFileProcessingTasks fileProcessingTasks,
|
||||
IPatchGenTasks patchGenTasks,
|
||||
IPatchTestingTasks patchTestingTasks
|
||||
)
|
||||
{
|
||||
_settingsTasks = settingsTasks;
|
||||
_clientSelectionTasks = clientSelectionTasks;
|
||||
_fileProcessingTasks = fileProcessingTasks;
|
||||
_patchGenTasks = patchGenTasks;
|
||||
_patchTestingTasks = patchTestingTasks;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
_settingsTasks.Run().ValidateOrExit();
|
||||
_clientSelectionTasks.Run().ValidateOrExit();
|
||||
_settingsTasks.Run();
|
||||
_clientSelectionTasks.Run();
|
||||
_fileProcessingTasks.Run();
|
||||
_patchGenTasks.Run();
|
||||
_patchTestingTasks.Run();
|
||||
}
|
||||
|
||||
private static IHost ConfigureHost(string[] args)
|
||||
@ -57,6 +70,9 @@ namespace EftPatchHelper
|
||||
|
||||
services.AddTransient<ISettingsTask, StartupSettingsTask>();
|
||||
services.AddTransient<IClientSelectionTask, ClientSelectionTask>();
|
||||
services.AddTransient<IFileProcessingTasks, FileProcessingTasks>();
|
||||
services.AddTransient<IPatchGenTasks, PatchGenTasks>();
|
||||
services.AddTransient<IPatchTestingTasks, PatchTestingTasks>();
|
||||
services.AddTransient<Program>();
|
||||
})
|
||||
.ConfigureAppConfiguration((_, config) =>
|
||||
@ -67,109 +83,3 @@ namespace EftPatchHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//EftClientSelector.LoadClientList(settings);
|
||||
|
||||
//EftClient targetClient = EftClientSelector.GetClient(settings.TargetEftVersion);
|
||||
//EftClient sourceClient;
|
||||
|
||||
//AnsiConsole.WriteLine();
|
||||
//ConfirmationPrompt confirmTarget = new ConfirmationPrompt($"Use version [purple]{_settings.TargetEftVersion}[/] as target?");
|
||||
|
||||
//if (!confirmTarget.Show(AnsiConsole.Console) || targetClient == null)
|
||||
//{
|
||||
// targetClient = EftClientSelector.GetClientSelection("Select [yellow]Target[/] Version");
|
||||
|
||||
// AnsiConsole.WriteLine();
|
||||
// ConfirmationPrompt changeVersion = new ConfirmationPrompt($"Update settings target version to use [purple]{targetClient.Version}[/]?");
|
||||
|
||||
// if (changeVersion.Show(AnsiConsole.Console))
|
||||
// {
|
||||
// settings.TargetEftVersion = targetClient.Version;
|
||||
|
||||
// settings.Save();
|
||||
// }
|
||||
//}
|
||||
|
||||
//sourceClient = EftClientSelector.GetClientSelection("Select [blue]Source[/] Version");
|
||||
|
||||
|
||||
////backup data if needed
|
||||
//targetClient.Backup(settings, !promptToOverwrite);
|
||||
//sourceClient.Backup(settings, !promptToOverwrite);
|
||||
|
||||
////copy source to prep directory
|
||||
//AnsiConsole.WriteLine();
|
||||
//AnsiConsole.MarkupLine("[gray]Copying[/] [blue]source[/][gray] to prep area ...[/]");
|
||||
|
||||
//FolderCopy sourceCopy = new FolderCopy(sourceClient.FolderPath, sourceClient.PrepPath);
|
||||
|
||||
//sourceCopy.Start(!promptToOverwrite);
|
||||
|
||||
////copy target to prep directory
|
||||
//AnsiConsole.MarkupLine("[gray]Copying[/] [blue]target[/][gray] to prep area ...[/]");
|
||||
|
||||
//FolderCopy targetCopy = new FolderCopy(targetClient.FolderPath, targetClient.PrepPath);
|
||||
|
||||
//targetCopy.Start(!promptToOverwrite);
|
||||
|
||||
//// clean prep source and target folders of uneeded data
|
||||
//FolderCleaner.Clean(sourceClient.PrepPath);
|
||||
|
||||
//FolderCleaner.Clean(targetClient.PrepPath);
|
||||
|
||||
//// start patcher
|
||||
//if(File.Exists(settings.PatcherEXEPath))
|
||||
//{
|
||||
// string patcherOutputName = $"Patcher_{sourceClient.Version}_to_{targetClient.Version}";
|
||||
|
||||
// AnsiConsole.Markup("Starting patcher ... ");
|
||||
|
||||
// var genProc = Process.Start(new ProcessStartInfo()
|
||||
// {
|
||||
// FileName = settings.PatcherEXEPath,
|
||||
// WorkingDirectory = new FileInfo(settings.PatcherEXEPath).Directory?.FullName ?? Directory.GetCurrentDirectory(),
|
||||
// ArgumentList =
|
||||
// {
|
||||
// $"OutputFolderName::{patcherOutputName}",
|
||||
// $"SourceFolderPath::{sourceClient.PrepPath}",
|
||||
// $"TargetFolderPath::{targetClient.PrepPath}",
|
||||
// $"AutoZip::{settings.AutoZip}",
|
||||
// $"AutoClose::{settings.AutoClose}"
|
||||
// }
|
||||
// });
|
||||
|
||||
// genProc?.WaitForExit();
|
||||
|
||||
// switch((PatcherExitCode)genProc.ExitCode)
|
||||
// {
|
||||
// case PatcherExitCode.ProgramClosed:
|
||||
// {
|
||||
|
||||
// break;
|
||||
// }
|
||||
// case PatcherExitCode.Success:
|
||||
// {
|
||||
|
||||
// break;
|
||||
// }
|
||||
// case PatcherExitCode.MissingDir:
|
||||
// {
|
||||
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//AnsiConsole.MarkupLine("[green]done[/]");
|
||||
|
||||
//AnsiConsole.WriteLine();
|
||||
|
||||
//// done
|
||||
//AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
||||
|
||||
//Console.ReadLine();
|
@ -1,6 +1,8 @@
|
||||
using EftPatchHelper.Helpers;
|
||||
using EftPatchHelper.Extensions;
|
||||
using EftPatchHelper.Helpers;
|
||||
using EftPatchHelper.Interfaces;
|
||||
using EftPatchHelper.Model;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace EftPatchHelper.Tasks
|
||||
{
|
||||
@ -17,9 +19,51 @@ namespace EftPatchHelper.Tasks
|
||||
_clientSelector = clientSelector;
|
||||
}
|
||||
|
||||
public bool Run()
|
||||
private bool ChangeSettingsTargetVersion()
|
||||
{
|
||||
var targetClient = _clientSelector.GetClientSelection("Select [yellow]Target[/] Version");
|
||||
|
||||
AnsiConsole.WriteLine();
|
||||
ConfirmationPrompt changeVersion = new ConfirmationPrompt($"Update settings target version to use [purple]{targetClient.Version}[/]?");
|
||||
|
||||
if (changeVersion.Show(AnsiConsole.Console))
|
||||
{
|
||||
_settings.TargetEftVersion = targetClient.Version;
|
||||
|
||||
return _settings.Save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ConfirmExistingTargetVersion()
|
||||
{
|
||||
_clientSelector.LoadClientList();
|
||||
|
||||
_options.TargetClient = _clientSelector.GetClient(_settings.TargetEftVersion);
|
||||
|
||||
ConfirmationPrompt confirmTarget = new ConfirmationPrompt($"Use version [purple]{_settings.TargetEftVersion}[/] as target?");
|
||||
|
||||
// If client is null or requested change, return false to ensure change settings target is called.
|
||||
return _options.TargetClient == null || !confirmTarget.Show(AnsiConsole.Console);
|
||||
}
|
||||
|
||||
private bool SelectSourceVersion()
|
||||
{
|
||||
_options.SourceClient = _clientSelector.GetClientSelection("Select [blue]Source[/] Version");
|
||||
|
||||
return _options.SourceClient != null;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (ConfirmExistingTargetVersion())
|
||||
{
|
||||
ChangeSettingsTargetVersion().ValidateOrExit();
|
||||
}
|
||||
|
||||
SelectSourceVersion().ValidateOrExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,18 +60,16 @@ namespace EftPatchHelper.Tasks
|
||||
|
||||
private void ConfirmOptions()
|
||||
{
|
||||
_options.PromptToOverwriteDirectories = new ConfirmationPrompt("Prompt to overwrite directories?").Show(AnsiConsole.Console);
|
||||
_options.IgnoreExistingDirectories = new ConfirmationPrompt("Skip existing directories? (you will be prompted if no)").Show(AnsiConsole.Console);
|
||||
}
|
||||
|
||||
public bool Run()
|
||||
public void Run()
|
||||
{
|
||||
ValidateSettings().ValidateOrExit();
|
||||
|
||||
ConfirmOptions();
|
||||
|
||||
PrintSummary();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user