all kinds of stuff
This commit is contained in:
parent
b243a150f5
commit
21bc6e2e4a
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace EftPatchHelper.EftInfo
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.EftInfo
|
|
||||||
{
|
{
|
||||||
public enum EftClientLocation
|
public enum EftClientLocation
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.Extensions
|
namespace EftPatchHelper.Extensions
|
||||||
{
|
{
|
||||||
@ -11,7 +6,7 @@ namespace EftPatchHelper.Extensions
|
|||||||
{
|
{
|
||||||
public static void ValidateOrExit(this bool toValidate)
|
public static void ValidateOrExit(this bool toValidate)
|
||||||
{
|
{
|
||||||
if(!toValidate)
|
if (!toValidate)
|
||||||
{
|
{
|
||||||
AnsiConsole.Prompt(new TextPrompt<string>("Press [blue]enter[/] to close ...").AllowEmpty());
|
AnsiConsole.Prompt(new TextPrompt<string>("Press [blue]enter[/] to close ...").AllowEmpty());
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
@ -47,7 +47,7 @@ namespace EftPatchHelper.Helpers
|
|||||||
|
|
||||||
fsInfo.Refresh();
|
fsInfo.Refresh();
|
||||||
|
|
||||||
if(!fsInfo.Exists)
|
if (!fsInfo.Exists)
|
||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine($"[blue]INFO:[/] [gray]Deleting {fsInfo.Name} ...[/] [green]OK[/]");
|
AnsiConsole.MarkupLine($"[blue]INFO:[/] [gray]Deleting {fsInfo.Name} ...[/] [green]OK[/]");
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace EftPatchHelper.Interfaces
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.Interfaces
|
|
||||||
{
|
{
|
||||||
public interface IClientSelectionTask : ITaskable
|
public interface IClientSelectionTask : ITaskable
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace EftPatchHelper.Interfaces
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.Interfaces
|
|
||||||
{
|
{
|
||||||
public interface ISettingsTask : ITaskable
|
public interface ISettingsTask : ITaskable
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using EftPatchHelper.Model;
|
namespace EftPatchHelper.Interfaces
|
||||||
|
|
||||||
namespace EftPatchHelper.Interfaces
|
|
||||||
{
|
{
|
||||||
public interface ITaskable
|
public interface ITaskable
|
||||||
{
|
{
|
||||||
@ -8,6 +6,6 @@ namespace EftPatchHelper.Interfaces
|
|||||||
/// Runs a predefined task
|
/// Runs a predefined task
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the task succeeded, otherwise false</returns>
|
/// <returns>Returns true if the task succeeded, otherwise false</returns>
|
||||||
public bool Run();
|
public void Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
using System;
|
using EftPatchHelper.EftInfo;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EftPatchHelper.Model
|
namespace EftPatchHelper.Model
|
||||||
{
|
{
|
||||||
public class Options
|
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;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace EftPatchHelper.Model
|
namespace EftPatchHelper.Model
|
||||||
@ -29,35 +30,40 @@ namespace EftPatchHelper.Model
|
|||||||
[JsonPropertyName("patcherExePath")]
|
[JsonPropertyName("patcherExePath")]
|
||||||
public string PatcherEXEPath { get; set; } = "";
|
public string PatcherEXEPath { get; set; } = "";
|
||||||
|
|
||||||
public void Save()
|
public bool Save()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string json = JsonSerializer.Serialize(this, typeof(Settings), new JsonSerializerOptions() { WriteIndented = true });
|
string json = JsonSerializer.Serialize(this, typeof(Settings), new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(json)) return;
|
if (string.IsNullOrWhiteSpace(json))
|
||||||
|
{
|
||||||
File.WriteAllText(settingsFile, json);
|
AnsiConsole.WriteLine("[red]!! Nothing was serialized !![/]");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static Settings? Load()
|
File.WriteAllText(settingsFile, json);
|
||||||
//{
|
|
||||||
// if (!File.Exists(settingsFile)) return null;
|
|
||||||
|
|
||||||
// string json = File.ReadAllText(settingsFile);
|
return true;
|
||||||
|
}
|
||||||
// return JsonSerializer.Deserialize<Settings>(json);
|
catch (Exception ex)
|
||||||
//}
|
{
|
||||||
|
AnsiConsole.WriteException(ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
||||||
if(string.IsNullOrWhiteSpace(TargetEftVersion)) return false;
|
if (string.IsNullOrWhiteSpace(TargetEftVersion)) return false;
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(PrepFolderPath)) return false;
|
if (string.IsNullOrWhiteSpace(PrepFolderPath)) return false;
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(BackupFolderPath)) return false;
|
if (string.IsNullOrWhiteSpace(BackupFolderPath)) return false;
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(LiveEftPath)) return false;
|
if (string.IsNullOrWhiteSpace(LiveEftPath)) return false;
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(PatcherEXEPath)) return false;
|
if (string.IsNullOrWhiteSpace(PatcherEXEPath)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
using EftPatchHelper.Extensions;
|
|
||||||
using EftPatchHelper.Helpers;
|
using EftPatchHelper.Helpers;
|
||||||
using EftPatchHelper.Interfaces;
|
using EftPatchHelper.Interfaces;
|
||||||
using EftPatchHelper.Model;
|
using EftPatchHelper.Model;
|
||||||
@ -15,29 +14,43 @@ namespace EftPatchHelper
|
|||||||
{
|
{
|
||||||
ITaskable _settingsTasks;
|
ITaskable _settingsTasks;
|
||||||
ITaskable _clientSelectionTasks;
|
ITaskable _clientSelectionTasks;
|
||||||
|
ITaskable _fileProcessingTasks;
|
||||||
|
ITaskable _patchGenTasks;
|
||||||
|
ITaskable _patchTestingTasks;
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
// Fancy
|
|
||||||
AnsiConsole.Write(new FigletText("EFT Patch Helper").Centered().Color(Color.Blue));
|
AnsiConsole.Write(new FigletText("EFT Patch Helper").Centered().Color(Color.Blue));
|
||||||
|
|
||||||
var host = ConfigureHost(args);
|
var host = ConfigureHost(args);
|
||||||
host.Services.GetRequiredService<Program>().Run();
|
host.Services.GetRequiredService<Program>().Run();
|
||||||
|
|
||||||
|
AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
||||||
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Program(
|
public Program(
|
||||||
ISettingsTask settingsTasks,
|
ISettingsTask settingsTasks,
|
||||||
IClientSelectionTask clientSelectionTasks
|
IClientSelectionTask clientSelectionTasks,
|
||||||
|
IFileProcessingTasks fileProcessingTasks,
|
||||||
|
IPatchGenTasks patchGenTasks,
|
||||||
|
IPatchTestingTasks patchTestingTasks
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_settingsTasks = settingsTasks;
|
_settingsTasks = settingsTasks;
|
||||||
_clientSelectionTasks = clientSelectionTasks;
|
_clientSelectionTasks = clientSelectionTasks;
|
||||||
|
_fileProcessingTasks = fileProcessingTasks;
|
||||||
|
_patchGenTasks = patchGenTasks;
|
||||||
|
_patchTestingTasks = patchTestingTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
_settingsTasks.Run().ValidateOrExit();
|
_settingsTasks.Run();
|
||||||
_clientSelectionTasks.Run().ValidateOrExit();
|
_clientSelectionTasks.Run();
|
||||||
|
_fileProcessingTasks.Run();
|
||||||
|
_patchGenTasks.Run();
|
||||||
|
_patchTestingTasks.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IHost ConfigureHost(string[] args)
|
private static IHost ConfigureHost(string[] args)
|
||||||
@ -57,6 +70,9 @@ namespace EftPatchHelper
|
|||||||
|
|
||||||
services.AddTransient<ISettingsTask, StartupSettingsTask>();
|
services.AddTransient<ISettingsTask, StartupSettingsTask>();
|
||||||
services.AddTransient<IClientSelectionTask, ClientSelectionTask>();
|
services.AddTransient<IClientSelectionTask, ClientSelectionTask>();
|
||||||
|
services.AddTransient<IFileProcessingTasks, FileProcessingTasks>();
|
||||||
|
services.AddTransient<IPatchGenTasks, PatchGenTasks>();
|
||||||
|
services.AddTransient<IPatchTestingTasks, PatchTestingTasks>();
|
||||||
services.AddTransient<Program>();
|
services.AddTransient<Program>();
|
||||||
})
|
})
|
||||||
.ConfigureAppConfiguration((_, config) =>
|
.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.Interfaces;
|
||||||
using EftPatchHelper.Model;
|
using EftPatchHelper.Model;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace EftPatchHelper.Tasks
|
namespace EftPatchHelper.Tasks
|
||||||
{
|
{
|
||||||
@ -17,9 +19,51 @@ namespace EftPatchHelper.Tasks
|
|||||||
_clientSelector = clientSelector;
|
_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()
|
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();
|
ValidateSettings().ValidateOrExit();
|
||||||
|
|
||||||
ConfirmOptions();
|
ConfirmOptions();
|
||||||
|
|
||||||
PrintSummary();
|
PrintSummary();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user