diff --git a/FFXIV_TexTools/App.xaml.cs b/FFXIV_TexTools/App.xaml.cs index 17603869..fa755b6c 100644 --- a/FFXIV_TexTools/App.xaml.cs +++ b/FFXIV_TexTools/App.xaml.cs @@ -4,15 +4,29 @@ using MahApps.Metro; using System; using System.Diagnostics; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; using System.Windows.Forms; using System.Windows.Threading; +using static System.Net.Mime.MediaTypeNames; using Application = System.Windows.Application; using Clipboard = System.Windows.Clipboard; namespace FFXIV_TexTools { + public static class EntryPoint + { + [STAThread] + public static int Main(string[] args) + { + var application = new App(); + var r = application.Run(); + return r; + } + + } + /// /// Interaction logic for App.xaml /// @@ -20,6 +34,11 @@ public partial class App : Application { static NVOptimusEnabler nvEnabler = new NVOptimusEnabler(); + public App() + { + InitializeComponent(); + } + protected override void OnStartup(StartupEventArgs e) { // Disable hardware acceleration of all windows if requested diff --git a/FFXIV_TexTools/Console/ConsoleManager.cs b/FFXIV_TexTools/Console/ConsoleManager.cs new file mode 100644 index 00000000..d879d54b --- /dev/null +++ b/FFXIV_TexTools/Console/ConsoleManager.cs @@ -0,0 +1,65 @@ +using FFXIV_TexTools.Helpers; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using xivModdingFramework.Cache; +using xivModdingFramework.General.Enums; + +namespace FFXIV_TexTools.Console +{ + + internal static class ConsoleManager + { + + public static async Task HandleConsoleArgs(string[] args) + { + if(args == null || args.Length < 1 || args[0] != "/c") + { + return false; + } + + var gameDir = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory); + var lang = XivLanguages.GetXivLanguage(Properties.Settings.Default.Application_Language); + await XivCache.SetGameInfo(gameDir, lang, false); + + var cmd = args[1]; + + var code = -1; + if(cmd == "/u") + { + code = await HandleUpgrade(args); + } + + Application.Current.Shutdown(code); + return true; + } + + public static async Task HandleUpgrade(string[] args) + { + if(args.Length < 4) + { + return -1; + } + + var src = args[2]; + var dest = args[3]; + + try + { + await ModpackUpgrader.UpgradeModpack(src, dest); + } catch (Exception ex) + { + Trace.WriteLine(ex); + return -1; + } + return 0; + } + + } +} diff --git a/FFXIV_TexTools/FFXIV_TexTools.csproj b/FFXIV_TexTools/FFXIV_TexTools.csproj index b6572fb4..4df7164b 100644 --- a/FFXIV_TexTools/FFXIV_TexTools.csproj +++ b/FFXIV_TexTools/FFXIV_TexTools.csproj @@ -23,8 +23,8 @@ FFXIV_TexTools FFXIV_TexTools Copyright © 2024 - 3.0.3.1 - 3.0.3.1 + 3.0.3.2 + 3.0.3.2 9.0 bin\$(Configuration)\ true @@ -62,6 +62,7 @@ move $(TargetDir)*.dll $(TargetDir)lib mkdir $(TargetDir)lib move $(TargetDir)*.dll $(TargetDir)lib + FFXIV_TexTools.EntryPoint diff --git a/FFXIV_TexTools/MainWindow.xaml.cs b/FFXIV_TexTools/MainWindow.xaml.cs index 2a090278..059c3da7 100644 --- a/FFXIV_TexTools/MainWindow.xaml.cs +++ b/FFXIV_TexTools/MainWindow.xaml.cs @@ -14,6 +14,7 @@ // along with this program. If not, see . using AutoUpdaterDotNET; +using FFXIV_TexTools.Console; using FFXIV_TexTools.Helpers; using FFXIV_TexTools.Properties; using FFXIV_TexTools.Resources; @@ -381,8 +382,7 @@ public MainWindow(string[] args) if (args != null && args.Length > 0) { - - OnlyImport(args[0]); + _ = HandleArgs(args); } else { @@ -402,6 +402,16 @@ public MainWindow(string[] args) KeyDown += OnKeyDown; } + private async Task HandleArgs(string[] args) + { + if(await ConsoleManager.HandleConsoleArgs(args)) + { + return; + } + + OnlyImport(args[0]); + } + private void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (ItemView != null) @@ -1589,15 +1599,18 @@ private async void Menu_Backup_Click(object sender, RoutedEventArgs e) { needsWrite = await Modding.AnyModsEnabled(); } - catch(Exception ex) + catch (Exception ex) { // This should never error, but safety. Trace.WriteLine(ex); } - if(!this.CheckUnsafeOperation(needsWrite, true)) - { - return; + var rtx = ModTransaction.BeginReadonlyTransaction(); + if (await Modding.AnyModsEnabled(rtx)) { + if (!this.CheckUnsafeOperation(needsWrite, true)) + { + return; + } } if (result == System.Windows.Forms.DialogResult.Yes) diff --git a/FFXIV_TexTools/Resources/UIMessages.resx b/FFXIV_TexTools/Resources/UIMessages.resx index 00f35ff2..1ded8d4e 100644 --- a/FFXIV_TexTools/Resources/UIMessages.resx +++ b/FFXIV_TexTools/Resources/UIMessages.resx @@ -156,14 +156,11 @@ Please set your Index Backups directory in Options > Customize and try again. ColorSet BMP import is not supported. - This will create a backup of all index files. + This will create a backup of all index files for use when removing all mods. +If you have mods enabled, this will automatically disable them (and re-enable them after). -Do you want to Backup Now? - - -Warning: -In order to create a clean backup, all active modifications will be set to disabled, they will have to be re-enabled manually. +Are you sure you wish to proceed? Backup Index Files diff --git a/FFXIV_TexTools/ViewModels/MainViewModel.cs b/FFXIV_TexTools/ViewModels/MainViewModel.cs index 8663fb88..6d1858f4 100644 --- a/FFXIV_TexTools/ViewModels/MainViewModel.cs +++ b/FFXIV_TexTools/ViewModels/MainViewModel.cs @@ -209,6 +209,7 @@ public async Task DoPostPatchCleanup() var modList = await tx.GetModList(); var allMods = modList.GetMods().ToList(); + var anyChanges = false; foreach(var mod in allMods) { var state = await mod.GetState(tx); @@ -218,6 +219,7 @@ public async Task DoPostPatchCleanup() // Mod is fine. Can continue on as normal. continue; } + anyChanges = true; // An Invalid state mod points to Neither the original, nor the modded offset. var df = IOUtil.GetDataFileFromPath(mod.FilePath); @@ -251,9 +253,15 @@ public async Task DoPostPatchCleanup() await tx.Set8xDataOffset(mod.FilePath, await tx.Get8xDataOffset(mod.FilePath)); } - // We now have a working, valid modlist. Nice. - // Make some fresh backups. - await ModTransaction.CommitTransaction(tx); + if (anyChanges) + { + // We now have a working, valid modlist. Nice. + // Make some fresh backups. + await ModTransaction.CommitTransaction(tx); + } else + { + await ModTransaction.CancelTransaction(tx, true); + } } diff --git a/FFXIV_TexTools/Views/ModPack/Wizard/WizardData.cs b/FFXIV_TexTools/Views/ModPack/Wizard/WizardData.cs index f02b5929..9c3e79bc 100644 --- a/FFXIV_TexTools/Views/ModPack/Wizard/WizardData.cs +++ b/FFXIV_TexTools/Views/ModPack/Wizard/WizardData.cs @@ -1228,8 +1228,9 @@ public async Task WriteModpack(string targetPath) { await WriteWizardPack(targetPath); } - else if (Directory.Exists(targetPath)) + else if (Directory.Exists(targetPath) || !Path.GetFileName(targetPath).Contains(".")) { + Directory.CreateDirectory(targetPath); await WritePmp(targetPath, false); } else diff --git a/lib/xivModdingFramework b/lib/xivModdingFramework index cab144c2..20825119 160000 --- a/lib/xivModdingFramework +++ b/lib/xivModdingFramework @@ -1 +1 @@ -Subproject commit cab144c2d431952922f334299acb55a1fcff65ee +Subproject commit 2082511953559dd9e6b0dd0a50fec6146305b1a5