Skip to content

Commit

Permalink
Update v3.0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Jul 1, 2024
2 parents 61808cb + d61a922 commit 6a5e788
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 39 deletions.
4 changes: 2 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.1.8</AssemblyVersion>
<FileVersion>3.0.1.8</FileVersion>
<AssemblyVersion>3.0.2.1</AssemblyVersion>
<FileVersion>3.0.2.1</FileVersion>
<LangVersion>9.0</LangVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<UseWPF>true</UseWPF>
Expand Down
7 changes: 5 additions & 2 deletions FFXIV_TexTools/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
</Menu.ItemsPanel>
<MenuItem Header="{Binding Source={x:Static resx:UIStrings.Mods}}">
<MenuItem x:Name="Menu_ModList" Header="{Binding Source={x:Static resx:UIStrings.Manage_ModList}}" Click="Menu_ModList_Click"/>
<MenuItem Header="All Mods...">
<MenuItem x:Name="Menu_EnableAll" Header="{Binding Source={x:Static resx:UIStrings.Enable_All_Mods}}" Command="{Binding EnableAllModsCommand}"/>
<MenuItem x:Name="Menu_DisableAll" Header="{Binding Source={x:Static resx:UIStrings.Disable_All_Mods}}" Command="{Binding DisableAllModsCommand}"/>
<MenuItem x:Name="Menu_DeleteAll" Header="Delete All Mods" Click="Menu_StartOver_Click"/>
</MenuItem>

<MenuItem x:Name="Menu_CreateModPack" Header="{Binding Source={x:Static resx:UIStrings.Create_Modpack}}">
<MenuItem x:Name="Menu_MakeModpackWizard" Header="Advanced" Click="Menu_MakeModpackWizard_Click"/>
Expand All @@ -68,8 +73,6 @@
<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 x:Name="Menu_DisableAll" Header="{Binding Source={x:Static resx:UIStrings.Disable_All_Mods}}" Command="{Binding DisableAllModsCommand}"/>
<MenuItem x:Name="Menu_DeleteAll" Header="Delete All Mods" Click="Menu_StartOver_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
2 changes: 1 addition & 1 deletion FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public async Task ReloadItem()
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void ItemSelect_ItemSelected(object sender, IItem item)
private async void ItemSelect_ItemSelected(IItem item, XivDependencyRoot root)
{
try
{
Expand Down
20 changes: 11 additions & 9 deletions FFXIV_TexTools/Views/Controls/ItemSelectControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ public bool ExpandCharacterMenu
private bool _READY = false;
private bool _SILENT = false;

public delegate void ItemEventHandler(IItem item, XivDependencyRoot root);

// Fired when tree finishes loading.
public event EventHandler ItemsLoaded;

// Fired whenever the selected item actually changes. (NULLs and Duplicates are filtered out)
public event EventHandler<IItem> ItemSelected;
public event ItemEventHandler ItemSelected;

// Fired any time the UI selection event fires, regardless of the selection.
public event EventHandler<IItem> RawItemSelected;
public event ItemEventHandler RawItemSelected;

// Fired whenever the user clicks the confirmation, or double clicks an item.
public event EventHandler<IItem> ItemConfirmed;
Expand All @@ -89,7 +91,7 @@ public bool ExpandCharacterMenu
public Func<string, string, object, Task> LockUiFunction;
public Func<object, Task> UnlockUiFunction;

public Func<IItem, bool> ExtraSearchFunction;
public Func<IItem, XivDependencyRoot, bool> ExtraSearchFunction;

public bool StartExpanded = false;

Expand Down Expand Up @@ -648,7 +650,7 @@ private void CategoryTree_Selected(object sender, System.Windows.RoutedPropertyC


if (RawItemSelected != null) {
RawItemSelected.Invoke(null, item);
RawItemSelected.Invoke(item, element.Root);
}

// If we re-selected the same item, selection doesn't escape this controller (didn't actually change).
Expand All @@ -657,7 +659,7 @@ private void CategoryTree_Selected(object sender, System.Windows.RoutedPropertyC
_selectedItem = item;
if (ItemSelected != null)
{
ItemSelected.Invoke(this, _selectedItem);
ItemSelected.Invoke(_selectedItem, element.Root);
}
}

Expand Down Expand Up @@ -708,15 +710,15 @@ private void SelectItem(IItem item)
_selectedItem = item;

// Manually invoke this in case the item isn't in the filter currently.
ItemSelected.Invoke(this, _selectedItem);
ItemSelected.Invoke(_selectedItem, e.Root);
}
else
{
// Item was not in the tree.
if (_selectedItem != item)
{
_selectedItem = item;
ItemSelected.Invoke(this, _selectedItem);
ItemSelected.Invoke(_selectedItem, e.Root);
}

}
Expand Down Expand Up @@ -785,7 +787,7 @@ private void AcceptSelection()
if (!_READY) return;
if (SelectedItem != null && ItemConfirmed != null)
{
ItemConfirmed.Invoke(this, _selectedItem);
ItemConfirmed.Invoke(null, _selectedItem);
}
}

Expand Down Expand Up @@ -887,7 +889,7 @@ private bool SearchFilter(object o)
}

// If we have an extra search criteria supplied by an outside function, it has to pass that, too.
iMatch = ((ExtraSearchFunction(e.Item) || subHits) && iMatch);
iMatch = ((ExtraSearchFunction(e.Item, e.Root) || subHits) && iMatch);

}
}
Expand Down
11 changes: 6 additions & 5 deletions FFXIV_TexTools/Views/Controls/PopupItemSelection.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using xivModdingFramework.Cache;
using xivModdingFramework.Items.Interfaces;

namespace FFXIV_TexTools.Views.Controls
Expand All @@ -24,7 +25,7 @@ public partial class PopupItemSelection
{
public static PopupItemSelection CurrentPopup;
public IItem SelectedItem;
private Func<IItem, bool> _selectFunction;
private Func<IItem, XivDependencyRoot, bool> _selectFunction;


public static ItemSelectControl ItemSelect;
Expand Down Expand Up @@ -53,7 +54,7 @@ public async Task UnlockUi(object sender)
}
#endregion

public PopupItemSelection(Func<IItem, bool> ExtraFilterFunction = null, Func<IItem, bool> AllowSelectFunction = null)
public PopupItemSelection(Func<IItem, XivDependencyRoot, bool> ExtraFilterFunction = null, Func<IItem, XivDependencyRoot, bool> AllowSelectFunction = null)
{
InitializeComponent();
CurrentPopup = this;
Expand Down Expand Up @@ -104,11 +105,11 @@ private static void ItemSelect_ItemConfirmed(object sender, IItem e)
CurrentPopup.DialogResult = true;
}

private static void ItemSelect_RawItemSelected(object sender, IItem e)
private static void ItemSelect_RawItemSelected(IItem e, XivDependencyRoot root)
{
if (CurrentPopup._selectFunction != null)
{
var result = CurrentPopup._selectFunction(e);
var result = CurrentPopup._selectFunction(e, root);
ItemSelect.SelectButton.IsEnabled = result;

if (result)
Expand All @@ -131,7 +132,7 @@ public static IItem ShowItemSelection(Func<IItem, bool> ExtraFilterFunction = nu

return ShowItemSelection(ExtraFilterFunction, AllowSelectFunction, wind);
}
public static IItem ShowItemSelection(Func<IItem, bool> ExtraFilterFunction = null, Func<IItem, bool> AllowSelectFunction = null, Window owner = null)
public static IItem ShowItemSelection(Func<IItem, XivDependencyRoot, bool> ExtraFilterFunction = null, Func<IItem, XivDependencyRoot, bool> AllowSelectFunction = null, Window owner = null)
{
if(owner == null)
{
Expand Down
4 changes: 2 additions & 2 deletions FFXIV_TexTools/Views/Controls/TextureSamplerSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<Binding Path="DetokenizedPath"></Binding>
</TextBox>

<Button Content="Use Shared Path" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" Width="150" ToolTip="Change the Texture Path to the default variant-shared Texture Path for this texture." Height="28" Click="SharedPath_Click"/>
<Button Content="Use Unique Path" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="70,0,0,0" Width="150" ToolTip="Change the Texture Path to the default variant-exclusive Texture Path for this texture." Height="28" Click="UniquePath_Click"/>
<Button x:Name="SharedButton" Content="Use Shared Path" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" Width="150" ToolTip="Change the Texture Path to the default variant-shared Texture Path for this texture." Height="28" Click="SharedPath_Click"/>
<Button x:Name="UniqueButton" Content="Use Unique Path" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="70,0,0,0" Width="150" ToolTip="Change the Texture Path to the default variant-exclusive Texture Path for this texture." Height="28" Click="UniquePath_Click"/>

<Separator Grid.Row="3" Grid.ColumnSpan="4" Margin="0,2,0,2"></Separator>

Expand Down
18 changes: 16 additions & 2 deletions FFXIV_TexTools/Views/Controls/TextureSamplerSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using SharpDX;
using xivModdingFramework.Textures.FileTypes;
using System.Text.RegularExpressions;
using System.Windows.Shapes;

namespace FFXIV_TexTools.Views.Controls
{
Expand Down Expand Up @@ -214,6 +215,19 @@ public TextureSamplerSettings(XivMtrl mtrl, MtrlTexture tex)
}
MinLoDBox.ItemsSource = MinimumLoDSource;

var msetRegex = new Regex("\\/v[0-9]{4}\\/");

var mtrlPath = mtrl.MTRLPath;
if (mtrlPath != null && msetRegex.IsMatch(mtrlPath))
{
SharedButton.IsEnabled = true;
UniqueButton.IsEnabled = true;
}
else
{
SharedButton.IsEnabled = false;
UniqueButton.IsEnabled = false;
}

// UI config has to go after Initialize.
LoDBiasSlider.Minimum = -8.0f;
Expand Down Expand Up @@ -366,13 +380,13 @@ private void HexInput(object sender, System.Windows.Input.TextCompositionEventAr
private void SharedPath_Click(object sender, RoutedEventArgs e)
{

var path = _Material.GetTextureRootDirectoy() + "/" + _Material.GetDefaultTexureName(_Material.ResolveFullUsage(Texture), false);
var path = _Material.GetTextureRootDirectory() + "/" + _Material.GetDefaultTexureName(_Material.ResolveFullUsage(Texture), false);
TexturePath = path;
}

private void UniquePath_Click(object sender, RoutedEventArgs e)
{
var path = _Material.GetTextureRootDirectoy() + "/" + _Material.GetDefaultTexureName(_Material.ResolveFullUsage(Texture), true);
var path = _Material.GetTextureRootDirectory() + "/" + _Material.GetDefaultTexureName(_Material.ResolveFullUsage(Texture), true);
TexturePath = path;
}
}
Expand Down
36 changes: 34 additions & 2 deletions FFXIV_TexTools/Views/FileControls/MaterialFileControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
using System.CodeDom;
using xivModdingFramework.Helpers;
using SharpDX;
using xivModdingFramework.Models.DataContainers;

namespace FFXIV_TexTools.Views.Controls
{
Expand Down Expand Up @@ -226,6 +227,20 @@ protected override async Task<bool> INTERNAL_LoadFile(byte[] data, string path,
// The incoming data is an uncompressed MTRL file.
var mtrl = Mtrl.GetXivMtrl(data, path);


var msetRegex = new Regex("\\/v[0-9]{4}\\/");

if (path != null && msetRegex.IsMatch(path))
{
NewSharedButton.IsEnabled = true;
NewUniqueButton.IsEnabled = true;
} else
{
NewSharedButton.IsEnabled = false;
NewUniqueButton.IsEnabled = false;
}


Material = mtrl;
return true;
}
Expand Down Expand Up @@ -257,7 +272,24 @@ protected override async Task<bool> INTERNAL_SaveAs(string externalFilePath)

protected override async Task<bool> INTERNAL_WriteModFile(ModTransaction tx)
{
foreach (var tex in Material.Textures)
{
if (string.IsNullOrEmpty(tex.TexturePath)) continue;

tex.TexturePath = tex.TexturePath.ToLower();
if (!IOUtil.IsFFXIVInternalPath(tex.TexturePath))
{
if (!tex.TexturePath.Contains("/") && tex.TexturePath.EndsWith(".tex"))
{
tex.TexturePath = Material.GetTextureRootDirectory() + "/" + tex.TexturePath;
}
}

if (!IOUtil.IsFFXIVInternalPath(tex.TexturePath) || !tex.TexturePath.EndsWith(".tex"))
{
throw new InvalidDataException("Texture path is not a valid FFXIV texture path: " + tex.TexturePath);
}
}

// We override this in order to use MTRL's import function, which checks for missing texture files, etc.
await Mtrl.ImportMtrl(Material, ReferenceItem, XivStrings.TexTools, true, tx);
Expand Down Expand Up @@ -501,7 +533,7 @@ private void NewSharedButton_Click(object sender, RoutedEventArgs e)
}
foreach (var tex in Material.Textures)
{
var path = Material.GetTextureRootDirectoy() + "/" + Material.GetDefaultTexureName(Material.ResolveFullUsage(tex), false);
var path = Material.GetTextureRootDirectory() + "/" + Material.GetDefaultTexureName(Material.ResolveFullUsage(tex), false);
tex.TexturePath = path;
}
UnsavedChanges = true;
Expand All @@ -516,7 +548,7 @@ private void NewUniqueButton_Click(object sender, RoutedEventArgs e)
}
foreach (var tex in Material.Textures)
{
var path = Material.GetTextureRootDirectoy() + "/" + Material.GetDefaultTexureName(Material.ResolveFullUsage(tex), true);
var path = Material.GetTextureRootDirectory() + "/" + Material.GetDefaultTexureName(Material.ResolveFullUsage(tex), true);
tex.TexturePath = path;
}
UnsavedChanges = true;
Expand Down
11 changes: 11 additions & 0 deletions FFXIV_TexTools/Views/FileControls/ModelFileControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ protected override async Task<bool> INTERNAL_WriteModFile(ModTransaction tx)
{
// We override this to perform material validation first.
Model.Source = InternalFilePath;

foreach (var mtrl in Model.Materials)
{
if (string.IsNullOrEmpty(mtrl)) continue;

if (!IOUtil.IsFFXIVInternalPath(mtrl) || !mtrl.EndsWith(".mtrl"))
{
throw new InvalidDataException("Material path is not a valid FFXIV material path: " + mtrl);
}
}

await Mdl.FillMissingMaterials(Model, ReferenceItem, XivStrings.TexTools, tx);
return await base.INTERNAL_WriteModFile(tx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private bool DestinationOk(XivDependencyRoot fullRoot)

return true;
}
private void ItemSelect_RawItemSelected(object sender, IItem item)
private void ItemSelect_RawItemSelected(IItem item, XivDependencyRoot root)
{
if(item == null)
{
Expand All @@ -205,7 +205,6 @@ private void ItemSelect_RawItemSelected(object sender, IItem item)
return;
}

var root = item.GetRoot();
if (!IsSupported(root))
{
ItemSelect.SelectButton.IsEnabled = false;
Expand All @@ -231,14 +230,13 @@ private void ItemSelect_RawItemSelected(object sender, IItem item)
}

#region Item List Filters
private bool Filter(IItem item)
private bool Filter(IItem item, XivDependencyRoot root)
{
if (item == null)
{
return false;
}

var root = item.GetRoot();
if (!IsSupported(root))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ public StandardModpackCreatorItemSelect(StandardModpackCreator window, StandardM
ItemSelect.UnlockUiFunction = _window.UnlockUi;
ItemSelect.ExtraSearchFunction = Filter;

ItemSelect_RawItemSelected(this, ItemSelect.SelectedItem);
if (ItemSelect.SelectedItem != null)
{
ItemSelect_RawItemSelected(ItemSelect.SelectedItem, ItemSelect.SelectedItem.GetRoot());
} else
{
ItemSelect_RawItemSelected(null, null);
}

foreach (var entry in vm.Entries)
{
Expand Down Expand Up @@ -94,7 +100,7 @@ private void StandardModpackCreatorItemSelect_Unloaded(object sender, RoutedEven
/// <summary>
/// Extra search filter criterion. Lets us filter out unsupported items.
/// </summary>
private bool Filter(IItem item) {
private bool Filter(IItem item, XivDependencyRoot root) {

// Character is kind of messy and needs a little work to make support work smoothly in this menu.
// UI Won't ever be supported since there's nothing to connect them together via (that I know of at least -Sel)
Expand All @@ -105,10 +111,10 @@ private bool Filter(IItem item) {
return true;
}

private void ItemSelect_RawItemSelected(object sender, IItem e)
private void ItemSelect_RawItemSelected(IItem e, XivDependencyRoot root)
{
var enable = false;
if (e != null && e.GetRoot() != null) {
if (e != null && root != null) {
enable = true;
}

Expand Down
Loading

0 comments on commit 6a5e788

Please sign in to comment.