reworked program startup and settings. client seletions is WIP
This commit is contained in:
parent
d36d925d33
commit
b243a150f5
@ -1,4 +1,5 @@
|
|||||||
using EftPatchHelper.Helpers;
|
using EftPatchHelper.Helpers;
|
||||||
|
using EftPatchHelper.Model;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace EftPatchHelper.EftInfo
|
namespace EftPatchHelper.EftInfo
|
||||||
|
@ -8,7 +8,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Spectre.Console" Version="0.43.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Spectre.Console" Version="0.44.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="settings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
21
EftPatchHelper/EftPatchHelper/Extensions/BoolExtensions.cs
Normal file
21
EftPatchHelper/EftPatchHelper/Extensions/BoolExtensions.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Spectre.Console;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Extensions
|
||||||
|
{
|
||||||
|
public static class BoolExtensions
|
||||||
|
{
|
||||||
|
public static void ValidateOrExit(this bool toValidate)
|
||||||
|
{
|
||||||
|
if(!toValidate)
|
||||||
|
{
|
||||||
|
AnsiConsole.Prompt(new TextPrompt<string>("Press [blue]enter[/] to close ...").AllowEmpty());
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,24 @@
|
|||||||
using EftPatchHelper.EftInfo;
|
using EftPatchHelper.EftInfo;
|
||||||
|
using EftPatchHelper.Model;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace EftPatchHelper.Helpers
|
namespace EftPatchHelper.Helpers
|
||||||
{
|
{
|
||||||
public static class EftClientSelector
|
public class EftClientSelector
|
||||||
{
|
{
|
||||||
private static List<EftClient> clientList = new List<EftClient>();
|
private List<EftClient> _clientList = new List<EftClient>();
|
||||||
|
private Settings _settings;
|
||||||
|
|
||||||
public static string? GetLiveVersion(Settings settings)
|
public EftClientSelector(Settings settings)
|
||||||
|
{
|
||||||
|
_settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? GetLiveVersion()
|
||||||
{
|
{
|
||||||
// Get eft live version
|
// Get eft live version
|
||||||
string eftVersion = FileVersionInfo.GetVersionInfo(Path.Join(settings.LiveEftPath, "EscapeFromTarkov.exe")).ProductVersion?.Replace('-', '.');
|
string eftVersion = FileVersionInfo.GetVersionInfo(Path.Join(_settings.LiveEftPath, "EscapeFromTarkov.exe")).ProductVersion?.Replace('-', '.');
|
||||||
|
|
||||||
//remove leading 0 from version number
|
//remove leading 0 from version number
|
||||||
if (eftVersion != null && eftVersion.StartsWith("0."))
|
if (eftVersion != null && eftVersion.StartsWith("0."))
|
||||||
@ -24,32 +31,32 @@ namespace EftPatchHelper.Helpers
|
|||||||
return string.Join('.', fixedVersion);
|
return string.Join('.', fixedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EftClient GetClient(string Version)
|
public EftClient GetClient(string Version)
|
||||||
{
|
{
|
||||||
return clientList.Where(x => x.Version == Version).FirstOrDefault();
|
return _clientList.Where(x => x.Version == Version).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadClientList(Settings settings)
|
public void LoadClientList()
|
||||||
{
|
{
|
||||||
clientList.Clear();
|
_clientList.Clear();
|
||||||
|
|
||||||
string? eftVersion = GetLiveVersion(settings);
|
string? eftVersion = GetLiveVersion();
|
||||||
|
|
||||||
if (eftVersion != null)
|
if (eftVersion != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
// add eft live version to version options
|
// add eft live version to version options
|
||||||
clientList.Add(new EftClient()
|
_clientList.Add(new EftClient()
|
||||||
{
|
{
|
||||||
FolderPath = settings.LiveEftPath,
|
FolderPath = _settings.LiveEftPath,
|
||||||
Version = eftVersion,
|
Version = eftVersion,
|
||||||
PrepPath = Path.Join(settings.PrepFolderPath, eftVersion),
|
PrepPath = Path.Join(_settings.PrepFolderPath, eftVersion),
|
||||||
Location = EftClientLocation.Live
|
Location = EftClientLocation.Live
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// add backup folders to version options
|
// add backup folders to version options
|
||||||
foreach (string backup in Directory.GetDirectories(settings.BackupFolderPath))
|
foreach (string backup in Directory.GetDirectories(_settings.BackupFolderPath))
|
||||||
{
|
{
|
||||||
DirectoryInfo backupDir = new DirectoryInfo(backup);
|
DirectoryInfo backupDir = new DirectoryInfo(backup);
|
||||||
|
|
||||||
@ -58,17 +65,17 @@ namespace EftPatchHelper.Helpers
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
clientList.Add(new EftClient()
|
_clientList.Add(new EftClient()
|
||||||
{
|
{
|
||||||
FolderPath = backupDir.FullName,
|
FolderPath = backupDir.FullName,
|
||||||
Version = backupDir.Name,
|
Version = backupDir.Name,
|
||||||
PrepPath = Path.Join(settings.PrepFolderPath, backupDir.Name),
|
PrepPath = Path.Join(_settings.PrepFolderPath, backupDir.Name),
|
||||||
Location = EftClientLocation.Backup
|
Location = EftClientLocation.Backup
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EftClient GetClientSelection(string Prompt)
|
public EftClient GetClientSelection(string Prompt)
|
||||||
{
|
{
|
||||||
SelectionPrompt<EftClient> clientPrompt = new SelectionPrompt<EftClient>()
|
SelectionPrompt<EftClient> clientPrompt = new SelectionPrompt<EftClient>()
|
||||||
{
|
{
|
||||||
@ -78,7 +85,7 @@ namespace EftPatchHelper.Helpers
|
|||||||
Converter = (x) => x.DisplayName
|
Converter = (x) => x.DisplayName
|
||||||
};
|
};
|
||||||
|
|
||||||
clientPrompt.AddChoices(clientList);
|
clientPrompt.AddChoices(_clientList);
|
||||||
|
|
||||||
return clientPrompt.Show(AnsiConsole.Console);
|
return clientPrompt.Show(AnsiConsole.Console);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Interfaces
|
||||||
|
{
|
||||||
|
public interface IClientSelectionTask : ITaskable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
12
EftPatchHelper/EftPatchHelper/Interfaces/ISettingsTask.cs
Normal file
12
EftPatchHelper/EftPatchHelper/Interfaces/ISettingsTask.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Interfaces
|
||||||
|
{
|
||||||
|
public interface ISettingsTask : ITaskable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
13
EftPatchHelper/EftPatchHelper/Interfaces/ITaskable.cs
Normal file
13
EftPatchHelper/EftPatchHelper/Interfaces/ITaskable.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using EftPatchHelper.Model;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Interfaces
|
||||||
|
{
|
||||||
|
public interface ITaskable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Runs a predefined task
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Returns true if the task succeeded, otherwise false</returns>
|
||||||
|
public bool Run();
|
||||||
|
}
|
||||||
|
}
|
13
EftPatchHelper/EftPatchHelper/Model/Options.cs
Normal file
13
EftPatchHelper/EftPatchHelper/Model/Options.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Model
|
||||||
|
{
|
||||||
|
public class Options
|
||||||
|
{
|
||||||
|
public bool PromptToOverwriteDirectories = true;
|
||||||
|
}
|
||||||
|
}
|
12
EftPatchHelper/EftPatchHelper/Model/PatcherExitCode.cs
Normal file
12
EftPatchHelper/EftPatchHelper/Model/PatcherExitCode.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace EftPatchHelper.Model
|
||||||
|
{
|
||||||
|
public enum PatcherExitCode
|
||||||
|
{
|
||||||
|
ProgramClosed = 0,
|
||||||
|
Success = 10,
|
||||||
|
EftExeNotFound = 11,
|
||||||
|
NoPatchFolder = 12,
|
||||||
|
MissingFile = 13,
|
||||||
|
MissingDir = 14
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,32 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace EftPatchHelper
|
namespace EftPatchHelper.Model
|
||||||
{
|
{
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public static string settingsFile = Path.Join(Directory.GetCurrentDirectory(), "settings.json");
|
public static string settingsFile = Path.Join(Directory.GetCurrentDirectory(), "settings.json");
|
||||||
|
|
||||||
[JsonPropertyName("target_eft_version")]
|
[JsonPropertyName("targetEftVersion")]
|
||||||
public string TargetEftVersion { get; set; } = "";
|
public string TargetEftVersion { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("prep_folder_path")]
|
[JsonPropertyName("prepFolderPath")]
|
||||||
public string PrepFolderPath { get; set; } = "";
|
public string PrepFolderPath { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("backup_folder_path")]
|
[JsonPropertyName("backupFolderPath")]
|
||||||
public string BackupFolderPath { get; set; } = "";
|
public string BackupFolderPath { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("live_eft_path")]
|
[JsonPropertyName("liveEftPath")]
|
||||||
public string LiveEftPath { get; set; } = "";
|
public string LiveEftPath { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("auto_zip")]
|
[JsonPropertyName("autoZip")]
|
||||||
public bool AutoZip { get; set; } = true;
|
public bool AutoZip { get; set; } = true;
|
||||||
|
|
||||||
[JsonPropertyName("patcher_exe_path")]
|
[JsonPropertyName("autoClose")]
|
||||||
|
public bool AutoClose { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("patcherExePath")]
|
||||||
public string PatcherEXEPath { get; set; } = "";
|
public string PatcherEXEPath { get; set; } = "";
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
@ -35,14 +38,14 @@ namespace EftPatchHelper
|
|||||||
File.WriteAllText(settingsFile, json);
|
File.WriteAllText(settingsFile, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Settings? Load()
|
//public static Settings? Load()
|
||||||
{
|
//{
|
||||||
if (!File.Exists(settingsFile)) return null;
|
// if (!File.Exists(settingsFile)) return null;
|
||||||
|
|
||||||
string json = File.ReadAllText(settingsFile);
|
// string json = File.ReadAllText(settingsFile);
|
||||||
|
|
||||||
return JsonSerializer.Deserialize<Settings>(json);
|
// return JsonSerializer.Deserialize<Settings>(json);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
@ -1,117 +1,175 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
using EftPatchHelper;
|
using EftPatchHelper.Extensions;
|
||||||
using EftPatchHelper.EftInfo;
|
|
||||||
using EftPatchHelper.Helpers;
|
using EftPatchHelper.Helpers;
|
||||||
|
using EftPatchHelper.Interfaces;
|
||||||
|
using EftPatchHelper.Model;
|
||||||
|
using EftPatchHelper.Tasks;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
Settings? settings = Settings.Load();
|
namespace EftPatchHelper
|
||||||
|
|
||||||
|
|
||||||
// check settings file exists
|
|
||||||
if(settings == null)
|
|
||||||
{
|
{
|
||||||
settings = new Settings();
|
public class Program
|
||||||
settings.Save();
|
|
||||||
|
|
||||||
AnsiConsole.MarkupLine($"Settings file was create here: \n[blue]{Settings.settingsFile}[/]\n\nPlease update it and try again.");
|
|
||||||
AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
|
||||||
Console.ReadLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate settings
|
|
||||||
if(!settings.Validate())
|
|
||||||
{
|
|
||||||
AnsiConsole.MarkupLine($"[red]Settings file seems to be missing some information, please fix it[/]\n\nPath to file:\n[blue]{Settings.settingsFile}[/]\n\n");
|
|
||||||
AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
|
||||||
Console.ReadLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fancy
|
|
||||||
AnsiConsole.Write(new FigletText("EFT Patch Helper").Centered().Color(Color.Blue));
|
|
||||||
|
|
||||||
// show some settings information
|
|
||||||
AnsiConsole.WriteLine();
|
|
||||||
AnsiConsole.MarkupLine($"Current target version is [purple]{settings.TargetEftVersion}[/]");
|
|
||||||
AnsiConsole.MarkupLine($"Prep folder path is [purple]{settings.PrepFolderPath}[/]");
|
|
||||||
AnsiConsole.MarkupLine($"Backup folder path is [purple]{settings.BackupFolderPath}[/]");
|
|
||||||
AnsiConsole.WriteLine();
|
|
||||||
|
|
||||||
EftClientSelector.LoadClientList(settings);
|
|
||||||
|
|
||||||
EftClient targetClient = EftClientSelector.GetClient(settings.TargetEftVersion);
|
|
||||||
EftClient sourceClient;
|
|
||||||
|
|
||||||
AnsiConsole.WriteLine();
|
|
||||||
bool promptToOverwrite = new ConfirmationPrompt("Prompt to overwrite directories?").Show(AnsiConsole.Console);
|
|
||||||
|
|
||||||
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;
|
ITaskable _settingsTasks;
|
||||||
|
ITaskable _clientSelectionTasks;
|
||||||
|
|
||||||
settings.Save();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Program(
|
||||||
|
ISettingsTask settingsTasks,
|
||||||
|
IClientSelectionTask clientSelectionTasks
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_settingsTasks = settingsTasks;
|
||||||
|
_clientSelectionTasks = clientSelectionTasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
_settingsTasks.Run().ValidateOrExit();
|
||||||
|
_clientSelectionTasks.Run().ValidateOrExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IHost ConfigureHost(string[] args)
|
||||||
|
{
|
||||||
|
return Host.CreateDefaultBuilder(args).ConfigureServices((_, services) =>
|
||||||
|
{
|
||||||
|
services.AddSingleton<Options>();
|
||||||
|
services.AddSingleton<Settings>(serviceProvider =>
|
||||||
|
{
|
||||||
|
var configuration = serviceProvider.GetRequiredService<IConfiguration>();
|
||||||
|
var settings = configuration.Get<Settings>();
|
||||||
|
if (settings == null) throw new Exception("Failed to retrieve settings");
|
||||||
|
return settings;
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddScoped<EftClientSelector>();
|
||||||
|
|
||||||
|
services.AddTransient<ISettingsTask, StartupSettingsTask>();
|
||||||
|
services.AddTransient<IClientSelectionTask, ClientSelectionTask>();
|
||||||
|
services.AddTransient<Program>();
|
||||||
|
})
|
||||||
|
.ConfigureAppConfiguration((_, config) =>
|
||||||
|
{
|
||||||
|
config.AddJsonFile(Settings.settingsFile, optional: true, reloadOnChange: true);
|
||||||
|
})
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceClient = EftClientSelector.GetClientSelection("Select [blue]Source[/] Version");
|
//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
|
////backup data if needed
|
||||||
targetClient.Backup(settings, !promptToOverwrite);
|
//targetClient.Backup(settings, !promptToOverwrite);
|
||||||
sourceClient.Backup(settings, !promptToOverwrite);
|
//sourceClient.Backup(settings, !promptToOverwrite);
|
||||||
|
|
||||||
//copy source to prep directory
|
////copy source to prep directory
|
||||||
AnsiConsole.WriteLine();
|
//AnsiConsole.WriteLine();
|
||||||
AnsiConsole.MarkupLine("[gray]Copying[/] [blue]source[/][gray] to prep area ...[/]");
|
//AnsiConsole.MarkupLine("[gray]Copying[/] [blue]source[/][gray] to prep area ...[/]");
|
||||||
|
|
||||||
FolderCopy sourceCopy = new FolderCopy(sourceClient.FolderPath, sourceClient.PrepPath);
|
//FolderCopy sourceCopy = new FolderCopy(sourceClient.FolderPath, sourceClient.PrepPath);
|
||||||
|
|
||||||
sourceCopy.Start(!promptToOverwrite);
|
//sourceCopy.Start(!promptToOverwrite);
|
||||||
|
|
||||||
//copy target to prep directory
|
////copy target to prep directory
|
||||||
AnsiConsole.MarkupLine("[gray]Copying[/] [blue]target[/][gray] to prep area ...[/]");
|
//AnsiConsole.MarkupLine("[gray]Copying[/] [blue]target[/][gray] to prep area ...[/]");
|
||||||
|
|
||||||
FolderCopy targetCopy = new FolderCopy(targetClient.FolderPath, targetClient.PrepPath);
|
//FolderCopy targetCopy = new FolderCopy(targetClient.FolderPath, targetClient.PrepPath);
|
||||||
|
|
||||||
targetCopy.Start(!promptToOverwrite);
|
//targetCopy.Start(!promptToOverwrite);
|
||||||
|
|
||||||
// clean prep source and target folders of uneeded data
|
//// clean prep source and target folders of uneeded data
|
||||||
FolderCleaner.Clean(sourceClient.PrepPath);
|
//FolderCleaner.Clean(sourceClient.PrepPath);
|
||||||
|
|
||||||
FolderCleaner.Clean(targetClient.PrepPath);
|
//FolderCleaner.Clean(targetClient.PrepPath);
|
||||||
|
|
||||||
// start patcher
|
//// start patcher
|
||||||
if(File.Exists(settings.PatcherEXEPath))
|
//if(File.Exists(settings.PatcherEXEPath))
|
||||||
{
|
//{
|
||||||
string patcherOutputName = $"Patcher_{sourceClient.Version}_to_{targetClient.Version}";
|
// string patcherOutputName = $"Patcher_{sourceClient.Version}_to_{targetClient.Version}";
|
||||||
|
|
||||||
AnsiConsole.Markup("Starting patcher ... ");
|
// AnsiConsole.Markup("Starting patcher ... ");
|
||||||
|
|
||||||
Process.Start(new ProcessStartInfo()
|
// var genProc = Process.Start(new ProcessStartInfo()
|
||||||
{
|
// {
|
||||||
FileName = settings.PatcherEXEPath,
|
// FileName = settings.PatcherEXEPath,
|
||||||
WorkingDirectory = new FileInfo(settings.PatcherEXEPath).Directory?.FullName ?? Directory.GetCurrentDirectory(),
|
// WorkingDirectory = new FileInfo(settings.PatcherEXEPath).Directory?.FullName ?? Directory.GetCurrentDirectory(),
|
||||||
ArgumentList = {$"OutputFolderName::{patcherOutputName}", $"SourceFolderPath::{sourceClient.PrepPath}", $"TargetFolderPath::{targetClient.PrepPath}", $"AutoZip::{settings.AutoZip}"}
|
// ArgumentList =
|
||||||
});
|
// {
|
||||||
}
|
// $"OutputFolderName::{patcherOutputName}",
|
||||||
|
// $"SourceFolderPath::{sourceClient.PrepPath}",
|
||||||
|
// $"TargetFolderPath::{targetClient.PrepPath}",
|
||||||
|
// $"AutoZip::{settings.AutoZip}",
|
||||||
|
// $"AutoClose::{settings.AutoClose}"
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
AnsiConsole.MarkupLine("[green]done[/]");
|
// genProc?.WaitForExit();
|
||||||
|
|
||||||
AnsiConsole.WriteLine();
|
// switch((PatcherExitCode)genProc.ExitCode)
|
||||||
|
// {
|
||||||
|
// case PatcherExitCode.ProgramClosed:
|
||||||
|
// {
|
||||||
|
|
||||||
// done
|
// break;
|
||||||
AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
// }
|
||||||
|
// case PatcherExitCode.Success:
|
||||||
|
// {
|
||||||
|
|
||||||
Console.ReadLine();
|
// break;
|
||||||
|
// }
|
||||||
|
// case PatcherExitCode.MissingDir:
|
||||||
|
// {
|
||||||
|
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// default:
|
||||||
|
// {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//AnsiConsole.MarkupLine("[green]done[/]");
|
||||||
|
|
||||||
|
//AnsiConsole.WriteLine();
|
||||||
|
|
||||||
|
//// done
|
||||||
|
//AnsiConsole.MarkupLine("Press [blue]Enter[/] to close ...");
|
||||||
|
|
||||||
|
//Console.ReadLine();
|
25
EftPatchHelper/EftPatchHelper/Tasks/ClientSelectionTask.cs
Normal file
25
EftPatchHelper/EftPatchHelper/Tasks/ClientSelectionTask.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using EftPatchHelper.Helpers;
|
||||||
|
using EftPatchHelper.Interfaces;
|
||||||
|
using EftPatchHelper.Model;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Tasks
|
||||||
|
{
|
||||||
|
public class ClientSelectionTask : IClientSelectionTask
|
||||||
|
{
|
||||||
|
private Settings _settings;
|
||||||
|
private Options _options;
|
||||||
|
private EftClientSelector _clientSelector;
|
||||||
|
|
||||||
|
public ClientSelectionTask(Settings settings, Options options, EftClientSelector clientSelector)
|
||||||
|
{
|
||||||
|
_settings = settings;
|
||||||
|
_options = options;
|
||||||
|
_clientSelector = clientSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Run()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
EftPatchHelper/EftPatchHelper/Tasks/StartupSettingsTask.cs
Normal file
77
EftPatchHelper/EftPatchHelper/Tasks/StartupSettingsTask.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using EftPatchHelper.Extensions;
|
||||||
|
using EftPatchHelper.Interfaces;
|
||||||
|
using EftPatchHelper.Model;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
|
namespace EftPatchHelper.Tasks
|
||||||
|
{
|
||||||
|
public class StartupSettingsTask : ISettingsTask
|
||||||
|
{
|
||||||
|
private Settings? _settings { get; set; }
|
||||||
|
private Options _options { get; set; }
|
||||||
|
public StartupSettingsTask(Settings? settings, Options options)
|
||||||
|
{
|
||||||
|
_settings = settings;
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrintSummary()
|
||||||
|
{
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
|
||||||
|
// show some settings information
|
||||||
|
Table settingsTable = new Table()
|
||||||
|
.Alignment(Justify.Center)
|
||||||
|
.HorizontalBorder()
|
||||||
|
.HideHeaders()
|
||||||
|
.BorderStyle(Style.Parse("blue"))
|
||||||
|
.AddColumn("Data")
|
||||||
|
.AddColumn("Value")
|
||||||
|
.AddRow("Current target version", $"[purple]{_settings?.TargetEftVersion}[/]")
|
||||||
|
.AddRow("Prep folder path", $"[purple]{_settings?.PrepFolderPath}[/]")
|
||||||
|
.AddRow("Backup folder path", $"[purple]{_settings?.BackupFolderPath}[/]");
|
||||||
|
|
||||||
|
AnsiConsole.Write(settingsTable);
|
||||||
|
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ValidateSettings()
|
||||||
|
{
|
||||||
|
// check settings file exists
|
||||||
|
if (_settings == null)
|
||||||
|
{
|
||||||
|
_settings = new Settings();
|
||||||
|
_settings.Save();
|
||||||
|
|
||||||
|
AnsiConsole.MarkupLine($"Settings file was create here: \n[blue]{Settings.settingsFile}[/]\n\nPlease update it and try again.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate settings
|
||||||
|
if (!_settings.Validate())
|
||||||
|
{
|
||||||
|
AnsiConsole.MarkupLine($"[red]Settings file seems to be missing some information, please fix it[/]\n\nPath to file:\n[blue]{Settings.settingsFile}[/]\n\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfirmOptions()
|
||||||
|
{
|
||||||
|
_options.PromptToOverwriteDirectories = new ConfirmationPrompt("Prompt to overwrite directories?").Show(AnsiConsole.Console);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Run()
|
||||||
|
{
|
||||||
|
ValidateSettings().ValidateOrExit();
|
||||||
|
|
||||||
|
ConfirmOptions();
|
||||||
|
|
||||||
|
PrintSummary();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
EftPatchHelper/EftPatchHelper/settings.json
Normal file
9
EftPatchHelper/EftPatchHelper/settings.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"targetEftVersion": "C:\\users\\johno\\desktop\\tmp",
|
||||||
|
"prepFolderPath": "C:\\users\\johno\\desktop\\tmp",
|
||||||
|
"backupFolderPath": "C:\\users\\johno\\desktop\\tmp",
|
||||||
|
"liveEftPath": "C:\\users\\johno\\desktop\\tmp",
|
||||||
|
"patcherExePath": "C:\\users\\johno\\desktop\\tmp",
|
||||||
|
"autoZip": true,
|
||||||
|
"autoClose": false
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user