Skip to content

Commit

Permalink
Update v3.0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Jul 6, 2024
2 parents 9133672 + 8327af5 commit bf92706
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 19 deletions.
19 changes: 19 additions & 0 deletions FFXIV_TexTools/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,41 @@
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;
}

}

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
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
Expand Down
65 changes: 65 additions & 0 deletions FFXIV_TexTools/Console/ConsoleManager.cs
Original file line number Diff line number Diff line change
@@ -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<bool> 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<int> 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;
}

}
}
5 changes: 3 additions & 2 deletions FFXIV_TexTools/FFXIV_TexTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<AssemblyTitle>FFXIV_TexTools</AssemblyTitle>
<Product>FFXIV_TexTools</Product>
<Copyright>Copyright © 2024</Copyright>
<AssemblyVersion>3.0.3.1</AssemblyVersion>
<FileVersion>3.0.3.1</FileVersion>
<AssemblyVersion>3.0.3.2</AssemblyVersion>
<FileVersion>3.0.3.2</FileVersion>
<LangVersion>9.0</LangVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<UseWPF>true</UseWPF>
Expand Down Expand Up @@ -62,6 +62,7 @@ move $(TargetDir)*.dll $(TargetDir)lib</PostBuildEvent>
<PropertyGroup>
<PostBuildEvent>mkdir $(TargetDir)lib
move $(TargetDir)*.dll $(TargetDir)lib</PostBuildEvent>
<StartupObject>FFXIV_TexTools.EntryPoint</StartupObject>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\Shaders\psCustomMeshBlinnPhong.hlsl" />
Expand Down
25 changes: 19 additions & 6 deletions FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using AutoUpdaterDotNET;
using FFXIV_TexTools.Console;
using FFXIV_TexTools.Helpers;
using FFXIV_TexTools.Properties;
using FFXIV_TexTools.Resources;
Expand Down Expand Up @@ -381,8 +382,7 @@ public MainWindow(string[] args)

if (args != null && args.Length > 0)
{

OnlyImport(args[0]);
_ = HandleArgs(args);
}
else
{
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions FFXIV_TexTools/Resources/UIMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,11 @@ Please set your Index Backups directory in Options &gt; Customize and try again.
<value>ColorSet BMP import is not supported.</value>
</data>
<data name="CreateBackupsMessage" xml:space="preserve">
<value>This will create a backup of all index files.
<value>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.</value>
Are you sure you wish to proceed?</value>
</data>
<data name="CreateBackupsTitle" xml:space="preserve">
<value>Backup Index Files</value>
Expand Down
14 changes: 11 additions & 3 deletions FFXIV_TexTools/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

}

Expand Down
3 changes: 2 additions & 1 deletion FFXIV_TexTools/Views/ModPack/Wizard/WizardData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf92706

Please sign in to comment.