Skip to content

Commit

Permalink
Update v3.0.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Jul 24, 2024
2 parents b737e18 + 02ae07a commit dbe64b6
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 28 deletions.
10 changes: 5 additions & 5 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.8.1</ApplicationVersion>
<AssemblyVersion>3.0.8.1</AssemblyVersion>
<FileVersion>3.0.8.1</FileVersion>
<ApplicationVersion>3.0.8.2</ApplicationVersion>
<AssemblyVersion>3.0.8.2</AssemblyVersion>
<FileVersion>3.0.8.2</FileVersion>

<LangVersion>9.0</LangVersion>
<UseWPF>true</UseWPF>
Expand Down Expand Up @@ -65,7 +65,7 @@
<None Remove="Resources\Shaders\psCustomMeshBlinnPhongOIT.hlsl" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.0" />
<PackageReference Include="Autoupdater.NET.Official" Version="1.9.1" />
<PackageReference Include="BetterFolderBrowser" Version="1.2.0" />
<PackageReference Include="ControlzEx" Version="3.0.2.4" />
<PackageReference Include="Cyotek.Drawing.BitmapFont" Version="2.0.4" />
Expand Down Expand Up @@ -93,7 +93,7 @@
<PackageReference Include="SharpDX.Direct3D9" Version="4.2.0" />
<PackageReference Include="SharpDX.DXGI" Version="4.2.0" />
<PackageReference Include="SharpDX.Mathematics" Version="4.2.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.8" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.9" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
Expand Down
1 change: 1 addition & 0 deletions FFXIV_TexTools/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<MenuItem x:Name="Menu_MakeBackupModpack" Header="Create Backup" Click="Menu_MakeBackupModpack_Click"/>
</MenuItem>
<MenuItem x:Name="Menu_ImportModpack" Header="{Binding Source={x:Static resx:UIStrings.Import_ModPacks}}" Click="Menu_ImportModpack_Click"/>
<MenuItem Header="Import Modpack to Penumbra" Click="Menu_ImportModpackPenumbra_Click"/>
</MenuItem>
<MenuItem Header="{Binding Source={x:Static resx:UIStrings.View}}" StaysOpenOnClick="True">
<MenuItem x:Name="Menu_ProjectManager" Header="Project Manager" Click="Menu_ProjectManager_Click"/>
Expand Down
60 changes: 58 additions & 2 deletions FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,19 @@ private async Task HandleArgs(string[] args)
FlexibleMessageBox.Show("An error occurred while initializing:\n\n" + ex.Message, "Init Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

ImportOnlyWindow.ShowImportDialog(args[0]);
Application.Current.Shutdown();
// Set a unique temp path.
var tempDir = IOUtil.GetUniqueSubfolder(Path.GetTempPath(), "tt_io");
XivCache.FrameworkSettings.TempDirectory = tempDir;

try
{
ImportOnlyWindow.ShowImportDialog(args[0]);
}
finally
{
IOUtil.ClearTempFolder();
Application.Current.Shutdown();
}
}

private void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
Expand Down Expand Up @@ -2133,5 +2144,50 @@ private void ViewBGPart_Click(object sender, RoutedEventArgs e)
{
_ = SimpleItemViewWindow.ShowModel(null, this);
}

private async void Menu_ImportModpackPenumbra_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Filter = ViewHelpers.LoadModpackFilter;
ofd.Title = "Import Modpack to Penumbra...";
if(ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return;
}

var success = false;
await LockUi("Upgrading and Importing Modpack to Penumbra", "Please wait...");
try
{
var modpack = ofd.FileName;
var info = await TTMP.GetModpackInfo(modpack);
var fname = IOUtil.MakePathSafe(info.ModPack.Name);
var dir = PenumbraAPI.GetPenumbraDirectory();

if (string.IsNullOrWhiteSpace(dir))
{
throw new Exception("Penumbra is not installed or the library directory could not be found.");
}
var newPath = IOUtil.GetUniqueSubfolder(dir, fname, true);

var newName = System.IO.Path.GetFileName(newPath);

await ModpackUpgrader.UpgradeModpack(modpack, newPath, true, true);
await PenumbraAPI.ReloadMod(newName);
success = true;
} catch (Exception ex)
{
this.ShowError("Import Error", "An error occurred while upgrading or importing the modpack: " + ex.Message);
}
finally
{
await UnlockUi();
}

if (success)
{
await this.ShowMessageAsync("Penumbra Import Complete", "The modpack was imported successfully.");
}
}
}
}
1 change: 0 additions & 1 deletion FFXIV_TexTools/ViewModels/FullModelViewport3DViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public async Task UpdateModel(TTModel model, Dictionary<int, ModelTextureData> t
var slot = ViewHelpers.GetModelSlot(model.Source);

SharpDX.BoundingBox? boundingBox = null;
ModelModifiers.CalculateTangents(model);

// Remove any existing models of the same item type
RemoveSlot(slot);
Expand Down
6 changes: 0 additions & 6 deletions FFXIV_TexTools/ViewModels/Viewport3DViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,6 @@ public async Task UpdateModel(TTModel importModel = null, List<ModelTextureData>
// Push all the potentially CPU intense stuff onto a new thread.
await Task.Run(async () =>
{
if (newModel && originalModel != _Model)
{
// Only recalculate if an actually new-new model, since this doesn't change on shape application.
ModelModifiers.CalculateTangents(model);
}
if (newModel)
{
lock (_Geometry)
Expand Down
5 changes: 4 additions & 1 deletion FFXIV_TexTools/Views/Controls/RawFloatValueDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
Red = float.Parse(RedBox.Text);
Green = float.Parse(GreenBox.Text);
Blue = float.Parse(BlueBox.Text);
Alpha = float.Parse(AlphaBox.Text);
if (!string.IsNullOrWhiteSpace(AlphaBox.Text))
{
Alpha = float.Parse(AlphaBox.Text);
}

DialogResult = true;
} catch
Expand Down
4 changes: 3 additions & 1 deletion FFXIV_TexTools/Views/CustomizeSettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>

<Label Grid.Column="0" Grid.Row="0" Margin="5,0" Content="TexTools Branch" VerticalAlignment="Center" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" ToolTip="{StaticResource UpdateBranchTooltip}" ></Label>
Expand All @@ -280,8 +281,9 @@
<Label Grid.Column="0" Grid.Row="2" Margin="5,0" Content="Default to UNSAFE Mode" VerticalAlignment="Center" ToolTip="{StaticResource UnsafeModeTooltip}" HorizontalContentAlignment="Right" VerticalContentAlignment="Center"></Label>
<CheckBox x:Name="UnsafeModeDefault" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="5,0" ToolTip="{StaticResource UnsafeModeTooltip}" IsChecked="{Binding Path=UnsafeMode}"></CheckBox>

<Button Grid.Row="3" Grid.ColumnSpan="2" Content="Enable Windows Long-Path Support" Margin="5,0" Click="EnableLongPaths_Click"/>
<Button Grid.Row="3" Grid.ColumnSpan="2" Content="Enable Windows Long-Path Support" VerticalAlignment="Center" Margin="10,0" Click="EnableLongPaths_Click"/>

<Button Grid.Row="4" Grid.ColumnSpan="2" Content="Regenerate Skeletons" Margin="10,0" Click="RegenSkeletons_Click" VerticalAlignment="Center" />
</Grid>
</GroupBox>
<Button x:Name="CloseButton" Grid.Row="2" Content="{Binding Source={x:Static resx:UIStrings.Close}}" Command="{Binding CloseCustomize}" Margin="10" Click="CloseButton_Click" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="150" />
Expand Down
47 changes: 47 additions & 0 deletions FFXIV_TexTools/Views/CustomizeSettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
using Microsoft.Win32;
using FFXIV_TexTools.Helpers;
using xivModdingFramework.Exd.FileTypes;
using System.Threading.Tasks;
using xivModdingFramework.Models.FileTypes;
using xivModdingFramework.Cache;
using xivModdingFramework.General.Enums;
using System.Collections.Generic;
using System.IO;
using MahApps.Metro.Controls.Dialogs;

namespace FFXIV_TexTools.Views
{
Expand Down Expand Up @@ -67,6 +74,46 @@ private void EnableLongPaths_Click(object sender, RoutedEventArgs e)
ViewHelpers.ShowError("Registry Change Error", "An error occurred while attempting to set Long-Paths enabled:\n\n" + ex.Message);
}
}

private async void RegenSkeletons_Click(object sender, RoutedEventArgs e)
{
if(!this.ShowConfirmation("Regenerate Skeletons Confirmation", "This will purge the skeleton cache, and regenerate it based on the CURRENT system state.\n\nIf you have custom Skeletons installed such as Skelomae, NFLB, or IVCS, those will be reflected in the new skeleton cache.\n\nAre you sure you wish to continue?"))
{
return;
}
var _lock = await this.ShowProgressAsync("Regenerating Skeletons", "Please wait...");
try
{
await RegenerateSkeletons();
} catch(Exception ex)
{
this.ShowError("Skeleton Error", "Failed to regenerate one or more skeletons:\n\n" + ex.Message);
}
finally
{
await _lock.CloseAsync();
}
}

public static async Task RegenerateSkeletons()
{
var cwd = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
var skelFolder = Path.Combine(cwd, Sklb.SkeletonsFolder);
IOUtil.RecursiveDeleteDirectory(skelFolder);

var tx = MainWindow.DefaultTransaction;
var root = new XivDependencyRootInfo() {
PrimaryId = 0,
PrimaryType = xivModdingFramework.Items.Enums.XivItemType.equipment
};

var tasks = new List<Task>();
foreach(var race in XivRaces.PlayableRaces)
{
tasks.Add(Task.Run(async () => { await Sklb.GetBaseSkeletonFile(root, race, tx); }));
}
await Task.WhenAll(tasks);
}
}

public class UrlValidator : ValidationRule
Expand Down
4 changes: 2 additions & 2 deletions FFXIV_TexTools/Views/FileControls/FileViewControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public async Task<bool> LoadFileByDialog(string internalFilePath = null, IItem r
}

var ofd = GetOpenDialog();
var res = ofd.ShowDialog();
var res = ofd.ShowDialog(ViewHelpers.GetWin32Window(this));
if(res != DialogResult.OK)
{
return false;
Expand Down Expand Up @@ -1061,7 +1061,7 @@ public async Task<bool> SaveAsByDialog(string extension = null)
_SaveDialog.Filter = ext.Value + " Files|*" + ext.Key;
}

var res = _SaveDialog.ShowDialog();
var res = _SaveDialog.ShowDialog(ViewHelpers.GetWin32Window(this));
if (res != DialogResult.OK)
{
return false;
Expand Down
10 changes: 9 additions & 1 deletion FFXIV_TexTools/Views/FileControls/MaterialFileControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,16 @@

<Button x:Name="EditColorsetButton" Content="View/Edit Colorset" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Center" Width="150" Grid.Column="1" Click="EditColorset_Click" IsEnabled="{Binding Path=ColorsetEnabled}"></Button>

<Button x:Name="ForceAddColorsetButton" Content="Add Colorset" HorizontalAlignment="Left" Margin="160,0,0,0" VerticalAlignment="Center" Width="150" Grid.Column="1" Click="ForceAddColorset_Click"></Button>

<Image x:Name="ColorsetImage" Source="/FFXIV_TexTools;component/ffxiv2.ico" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Margin="160,0,0,0" Height="80" Width="20" HorizontalAlignment="Left"
RenderOptions.BitmapScalingMode="NearestNeighbor"/>
RenderOptions.BitmapScalingMode="NearestNeighbor">
<Image.ContextMenu>
<ContextMenu>
<MenuItem Header="Force-Add Colorset" Click="ForceAddColorset_Click"/>
</ContextMenu>
</Image.ContextMenu>
</Image>

<Button x:Name="EditShaderFlagsButton" Content="Edit Material Flags" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Center" Width="150" Height="28" Grid.Row="1" Click="EditShaderFlags_Click"/>
<Button x:Name="EditShaderKeysButton" Content="Edit Shader Keys" HorizontalAlignment="Left" Margin="170,0,0,0" VerticalAlignment="Center" Width="150" Height="28" Grid.Row="1" Click="EditShaderKeys_Click"/>
Expand Down
24 changes: 24 additions & 0 deletions FFXIV_TexTools/Views/FileControls/MaterialFileControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,13 @@ private async Task UpdateColorsetImage()
{
if(Material == null || Material.ColorSetDataSize <= 0)
{
ForceAddColorsetButton.Visibility = Visibility.Visible;
ColorsetImage.Source = null;
return;
}
try
{
ForceAddColorsetButton.Visibility = Visibility.Collapsed;

ImageSource imageSource = null;
var pixels = new byte[0];
Expand Down Expand Up @@ -866,5 +868,27 @@ private void SetTilingMode_Click(object sender, RoutedEventArgs e)
TilingModeContextMenu.PlacementTarget = TilingModeButton;
TilingModeContextMenu.IsOpen = true;
}

private void ForceAddColorset_Click(object sender, RoutedEventArgs e)
{
if(Material.ColorSetDataSize != 1024)
{
Material.ColorSetData = new List<Half>(1024);
for(int i = 0; i <32; i++)
{
Material.ColorSetData.AddRange(EndwalkerUpgrade.GetDefaultColorsetRow(Material.ShaderPack));
}
Material.ColorSetDyeData = new byte[128];

if(Material.AdditionalData.Length != 4)
{
Material.AdditionalData = new byte[4];
}
Material.AdditionalData[0] = 0x3C;
Material.AdditionalData[1] = 0x05;

_ = UpdateColorsetImage();
}
}
}
}
4 changes: 2 additions & 2 deletions FFXIV_TexTools/Views/Models/ImportModelEditView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
<Run>Determines if hair materials should show anisotropic specular highlights.</Run>
<LineBreak/>
<LineBreak/>
<Run>This will make the hair 'shinier', and the specular highlights will be skewed based on UV orientation.</Run>
<Run>This will make the hair 'shinier', and the specular highlights will be skewed based on UV orientation and Flow Data Settings.</Run>
<LineBreak/>
<Run>Hair strand UVs should be laid out from Top-Left to Bottom-Right for correct lighting effects with this on.</Run>
<Run>Flow Data may be auto-generated based on UV Layout via the Modify Vertices menus.</Run>
<LineBreak/>
<LineBreak/>
<Run>Turning this off on a hair which is already using it will make the lighting significantly more matte.</Run>
Expand Down
11 changes: 6 additions & 5 deletions FFXIV_TexTools/Views/OnboardingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ public static bool IsGameDirectoryValid(string dir)
{
var di = new DirectoryInfo(dir);
var par = di.Parent.Parent;
var path = Path.GetFullPath(Path.Combine(par.FullName, "ffxiv_dx11.exe"));
if (!File.Exists(path))
if (!File.Exists(Path.Combine(par.FullName, _exe))
&& !File.Exists(Path.Combine(par.FullName, _verFile)))
{
return false;
}
Expand All @@ -499,6 +499,8 @@ public static bool IsGameDirectoryValid(string dir)
return true;
}

const string _exe = "ffxiv_dx11.exe";
const string _verFile = "ffxivgame.ver";

/// <summary>
/// Resolves a valid TexTools desired FFXIV folder from a given user folder, if at all possible.
Expand All @@ -508,13 +510,12 @@ public static bool IsGameDirectoryValid(string dir)
/// <returns></returns>
public static string ResolveFFXIVFolder(string path, bool recursive = false)
{
const string _exe = "ffxiv_dx11.exe";

// Only allow base ffxiv folder selection if it has the EXE in it,
// to avoid issues with users having a parent folder name 'ffxiv'.
if (path.EndsWith("ffxiv"))
{
if (File.Exists(Path.Combine(path, _exe)))
if (File.Exists(Path.Combine(path, _exe))
|| File.Exists(Path.Combine(path, _verFile)))
{
return path;
}
Expand Down
1 change: 1 addition & 0 deletions FFXIV_TexTools/Views/Projects/ProjectWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ private async void NewPenumbra_Click(object sender, RoutedEventArgs e)
}
}
var sfd = new BetterFolderBrowser();
sfd.RootFolder = PenumbraAPI.GetPenumbraDirectory();
if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ private async void Commit_Click(object sender, RoutedEventArgs e)
if(!XivCache.GameWriteEnabled && MainWindow.UserTransaction.Settings.Target == ETransactionTarget.GameFiles)
{
var res = FlexibleMessageBox.Show(ViewHelpers.GetWin32Window(Window.GetWindow(this)),
"You are committing to the live FFXIV game files while SAFE mode is enabled.\n\nAre you SURE this is what you meant to do?", "Safe Mode Write Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
"You are committing to the live FFXIV game files while SAFE mode is enabled.\n\nThis will alter your real, live FFXIV Game Files.\n\nAre you SURE this is what you meant to do?", "Safe Mode Write Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
if(res != System.Windows.Forms.DialogResult.OK)
{
return;
Expand Down

0 comments on commit dbe64b6

Please sign in to comment.