Skip to content

Commit

Permalink
Update v3.0.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Jul 13, 2024
2 parents 56f4385 + abebf39 commit 57a354c
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 42 deletions.
34 changes: 33 additions & 1 deletion ConsoleTools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,45 @@ public static async Task<int> HandleConsoleArgs()
{
code = await UnwrapFile();
}
else if (cmd == "/list")
{
code = await ListRoot();
}
else
{
await ShowHelp();
Console.WriteLine("Unknown Command: " + cmd);
code = -1;
}

return code;
}

private static async Task<int> ListRoot()
{
if (_Args.Length < 2)
{
return -1;
}

var rootSt = _Args[1];
var rootInfo = XivCache.GetFileNameRootInfo(rootSt, true);

if (!rootInfo.IsValid())
{
Console.WriteLine("Given Root ID is not valid: " + rootSt);
return -1;
}
var root = new XivDependencyRoot(rootInfo);

var files = await root.GetAllFiles();

foreach(var file in files)
{
Console.WriteLine(file);
}
return 0;
}

public static async Task<int> HandleUpgrade()
{
if (_Args.Length < 3)
Expand Down Expand Up @@ -322,6 +352,8 @@ public static async Task<int> ShowHelp()
System.Console.WriteLine("");
System.Console.WriteLine("\t/unwrap [SourceFilePath] [DestFilePath] [IntendedFfxivFilePath] - Unwraps a given on-disk SqPacked or Flat FFXIV file into the given format. FF Path only needed for MDLs Skeleton/Texture info.");
System.Console.WriteLine("");
System.Console.WriteLine("\t/list [RootId] - List the entire collection of files associated with a given root ID. ( Ex. c0101h0010 )");
System.Console.WriteLine("");
System.Console.WriteLine("== FORMATS ==");
System.Console.WriteLine("\tModpacks may be read or written in .ttmp2, .pmp, or unzipped PMP folder path formats.");
System.Console.WriteLine("\tImages may be saved as DDS, TEX, TGA, PNG, BMP.");
Expand Down
6 changes: 3 additions & 3 deletions FFXIV_TexTools/FFXIV_TexTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<Product>FFXIV_TexTools</Product>
<Copyright>Copyright © 2024</Copyright>

<ApplicationVersion>3.0.5.5</ApplicationVersion>
<AssemblyVersion>3.0.5.5</AssemblyVersion>
<FileVersion>3.0.5.5</FileVersion>
<ApplicationVersion>3.0.5.6</ApplicationVersion>
<AssemblyVersion>3.0.5.6</AssemblyVersion>
<FileVersion>3.0.5.6</FileVersion>

<LangVersion>9.0</LangVersion>
<UseWPF>true</UseWPF>
Expand Down
7 changes: 7 additions & 0 deletions FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ private void AutoUpdater_ApplicationExitEvent()
}
public MainWindow(string[] args)
{

var hasPenumbra = PenumbraAPI.IsPenumbraInstalled();

_Args = args;
_mainWindow = this;

Expand Down Expand Up @@ -1518,6 +1521,10 @@ private async void Menu_StartOver_Click(object sender, RoutedEventArgs e)
if(MainWindow.UserTransaction.ModifiedFiles.Count > 0)
{
var r = FlexibleMessageBox.Show(ViewHelpers.GetWin32Window(this), "Your current transaction must be closed in order to proceed.\n\nYou will lose any active changes if you continue.", "Transaction Cancel Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (r != System.Windows.Forms.DialogResult.OK)
{
return;
}
}
await ModTransaction.CancelTransaction(MainWindow.UserTransaction, true);
}
Expand Down
20 changes: 18 additions & 2 deletions FFXIV_TexTools/Models/PenumbraUpgradeStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using FFXIV_TexTools.Helpers;
using System.Diagnostics;
using xivModdingFramework.Mods;
using xivModdingFramework.Exd.FileTypes;

namespace FFXIV_TexTools.Models
{
Expand Down Expand Up @@ -49,8 +50,23 @@ public async Task<EUpgradeResult> ProcessMod(string baseDir, string targetDir, s
{
if (source != target)
{
IOUtil.RecursiveDeleteDirectory(target);
IOUtil.CopyFolder(source, target);
try
{
IOUtil.RecursiveDeleteDirectory(target);
}
catch(Exception ex2)
{
throw new Exception("Unable to delete directory for failed conversion, possibly due to security issue: " + target + "\n"+ ex2.Message + "\n\nOriginal Conversion Failure: " + ex.Message);
}

try
{
IOUtil.CopyFolder(source, target);
}
catch (Exception ex2)
{
throw new Exception("Unable to copy failed mod directory to destination.\nFrom: " + source + "\nTo: " + target + "\n" + ex2.Message + "\n\nOriginal Conversion Failure: " + ex.Message);
}
}
}
res = EUpgradeResult.Failure;
Expand Down
1 change: 1 addition & 0 deletions FFXIV_TexTools/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public async Task DoPostPatchCleanup()
{
// Original offset moved. Just update the mod entry.
var m = mod;
Dat.AssertOriginalOffsetIsSafe(mod.DataFile, currentOffset);
m.OriginalOffset8x = currentOffset;
await tx.UpdateMod(mod, mod.FilePath);
} else if(currentOK && !moddedOk && !originalOk)
Expand Down
8 changes: 2 additions & 6 deletions FFXIV_TexTools/Views/Controls/FileListControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@

<Grid x:Name="InfoGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Select All" VerticalAlignment="Center" Margin="10,0,10,0" Click="SelectAll_Click"/>
<Button Grid.Column="1" Content="Clear All" VerticalAlignment="Center" Margin="10,0,10,0" Click="ClearAll_Click"/>
<Button Grid.Column="2" Content="Select Visible" VerticalAlignment="Center" Margin="10,0,10,0" Click="SelectVisible_Click"/>
<Button Grid.Column="3" Content="Clear Visible" VerticalAlignment="Center" Margin="10,0,10,0" Click="ClearVisible_Click"/>
<Button Grid.Column="0" Content="{Binding Path=SelectAllText, FallbackValue=Select All}" VerticalAlignment="Center" Margin="10,0,10,0" Click="SelectAll_Click"/>
<Button Grid.Column="1" Content="{Binding Path=ClearAllText, FallbackValue=Clear All}" VerticalAlignment="Center" Margin="10,0,10,0" Click="ClearAll_Click"/>
<Label Grid.Column="4" HorizontalAlignment="Left" VerticalAlignment="Center" Content="{Binding Path=SelectedCountLabel}"></Label>
</Grid>
</Grid>
Expand Down
76 changes: 65 additions & 11 deletions FFXIV_TexTools/Views/Controls/FileListControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,32 @@ public ICollectionView VisibleFiles {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(VisibleFiles)));
}
}
private string _SelectAllText = "Select All";
public string SelectAllText
{
get
{
return _SelectAllText;
}
set
{
_SelectAllText = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectAllText)));
}
}
private string _ClearAllText = "Clear All";
public string ClearAllText
{
get
{
return _ClearAllText;
}
set
{
_ClearAllText = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ClearAllText)));
}
}

public FileListControl()
{
Expand All @@ -296,14 +322,14 @@ public FileListControl()
InitializeComponent();

}
public void SetFiles(IEnumerable<string> files)
public void SetFiles(IEnumerable<string> files, bool selected = true)
{
_Files = new ObservableCollection<UiWrappedFile>();
var dist = files.Distinct();
var tx = MainWindow.DefaultTransaction;
foreach (var file in dist)
{
var uif = new UiWrappedFile(file, null, true, tx);
var uif = new UiWrappedFile(file, null, selected, tx);
uif.PropertyChanged += Uif_PropertyChanged;
_Files.Add(uif);
}
Expand Down Expand Up @@ -364,6 +390,16 @@ private void UpdateVisible()
{
this.Invoke(() =>
{
if (string.IsNullOrWhiteSpace(_SearchText))
{
SelectAllText = "Select All";
ClearAllText = "Clear All";
} else
{
SelectAllText = "Select Visible";
ClearAllText = "Clear Visible";
}

_VisibleFiles.Refresh();
});
}
Expand Down Expand Up @@ -475,35 +511,53 @@ private void Header_Click(object sender, RoutedEventArgs e)
}
}

private void SelectAll_Click(object sender, RoutedEventArgs e)
public void SelectAll()
{
foreach (UiWrappedFile file in _Files)
{
file.Selected = true;
}
}

private void ClearAll_Click(object sender, RoutedEventArgs e)
public void ClearAll()
{
foreach (UiWrappedFile file in _Files)
{
file.Selected = false;
}
}

private void SelectVisible_Click(object sender, RoutedEventArgs e)
private void SelectAll_Click(object sender, RoutedEventArgs e)
{
foreach (UiWrappedFile file in VisibleFiles)

if (string.IsNullOrWhiteSpace(_SearchText))
{
file.Selected = true;
foreach (UiWrappedFile file in _Files)
{
file.Selected = true;
}
} else
{
foreach (UiWrappedFile file in VisibleFiles)
{
file.Selected = true;
}
}
}

private void ClearVisible_Click(object sender, RoutedEventArgs e)
private void ClearAll_Click(object sender, RoutedEventArgs e)
{
foreach (UiWrappedFile file in VisibleFiles)
if (string.IsNullOrWhiteSpace(_SearchText))
{
file.Selected = false;
foreach (UiWrappedFile file in _Files)
{
file.Selected = false;
}
} else
{
foreach (UiWrappedFile file in VisibleFiles)
{
file.Selected = false;
}
}
}

Expand Down
17 changes: 11 additions & 6 deletions FFXIV_TexTools/Views/FileControls/FileViewControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public enum EFileViewType

public abstract class FileViewControl : System.Windows.Controls.UserControl, INotifyPropertyChanged, IDisposable
{

public const int _DEBOUNCE_TIME = 1000;

public delegate void FileDeletedEventHandler(string internalPath);
public event FileDeletedEventHandler FileDeleted;

Expand Down Expand Up @@ -146,14 +149,14 @@ public FileViewControl()
TxWatcher.UserTxStarted += OnUserTransactionStarted;


DebouncedUpdate = ViewHelpers.Debounce<string>(_UpdateOnMainThread, 200);
DebouncedUpdate = ViewHelpers.CancellableDebounce<string>(_UpdateOnMainThread, _DEBOUNCE_TIME);


IsEnabled = false;
}


private Action<string> DebouncedUpdate;
private Action<string, bool> DebouncedUpdate;

private void OnUserTransactionStarted(ModTransaction tx)
{
Expand Down Expand Up @@ -204,7 +207,7 @@ protected virtual async Task INTERNAL_HandlTxNotification(string changedFile, lo
{
_UpdateQueued = true;
// File was deleted.
DebouncedUpdate(InternalFilePath);
DebouncedUpdate(InternalFilePath, false);
FileDeleted?.Invoke(InternalFilePath);
return;
}
Expand All @@ -215,7 +218,7 @@ await Task.Run(async () =>
if (await ShouldUpdateOnFileChange(changedFile))
{
_UpdateQueued = true;
DebouncedUpdate(InternalFilePath);
DebouncedUpdate(InternalFilePath, false);
}
});
}
Expand All @@ -237,7 +240,6 @@ protected virtual async Task<bool> ShouldUpdateOnFileChange(string changedFile)

private async void _UpdateOnMainThread(string file)
{
Trace.WriteLine("Main Thread Update Called: " + file);
try
{
await await Dispatcher.InvokeAsync(async () =>
Expand Down Expand Up @@ -392,6 +394,10 @@ public void ClearFile()

public abstract void INTERNAL_ClearFile();

public virtual void CancelPendingReload()
{
DebouncedUpdate(null, true);
}

protected bool _LOADING = false;
/// <summary>
Expand All @@ -405,7 +411,6 @@ public void ClearFile()
/// <returns></returns>
public virtual async Task<bool> LoadInternalFile(string internalFile, bool forceOriginal = false, IItem referenceItem = null, byte[] decompData = null)
{

if (_LOADING)
{
// Safety reject.
Expand Down
9 changes: 6 additions & 3 deletions FFXIV_TexTools/Views/FileControls/MaterialFileControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public partial class MaterialFileControl : FileViewControl, INotifyPropertyChang
private bool _MTRL_LOADING = false;

private XivMtrl _Material;

private XivMtrl _OriginalMaterial;
public XivMtrl Material
{
get
Expand Down Expand Up @@ -230,6 +232,7 @@ protected override async Task<bool> INTERNAL_LoadFile(byte[] data, string path,


Material = mtrl;
_OriginalMaterial = (XivMtrl) mtrl.Clone();
return true;
}

Expand Down Expand Up @@ -333,10 +336,10 @@ protected override async Task<bool> ShouldUpdateOnFileChange(string changedFile)
}

var newMtrl = await Mtrl.GetXivMtrl(changedFile, false, tx);

var result = Mtrl.CompareMaterials(Material, newMtrl);
var originalResult = Mtrl.CompareMaterials(_OriginalMaterial, newMtrl);

if (result.OtherDifferences)
if (result.OtherDifferences && originalResult.OtherDifferences)
{
// If parts other than the colorset were changed, we need to prompt a reload.
return true;
Expand All @@ -345,7 +348,7 @@ protected override async Task<bool> ShouldUpdateOnFileChange(string changedFile)
if (!result.ColorsetDifferences)
{
// Nothing actually changed, don't bother reloading.
return true;
return false;
}


Expand Down
Loading

0 comments on commit 57a354c

Please sign in to comment.