Skip to content

Commit

Permalink
Update v3.0.6.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Jul 16, 2024
2 parents 1b4df56 + b33dcd5 commit 91de5aa
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 131 deletions.
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.6.4</ApplicationVersion>
<AssemblyVersion>3.0.6.4</AssemblyVersion>
<FileVersion>3.0.6.4</FileVersion>
<ApplicationVersion>3.0.6.7</ApplicationVersion>
<AssemblyVersion>3.0.6.7</AssemblyVersion>
<FileVersion>3.0.6.7</FileVersion>

<LangVersion>9.0</LangVersion>
<UseWPF>true</UseWPF>
Expand Down
1 change: 1 addition & 0 deletions FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,7 @@ private async void MetroWindow_Closing(object sender, System.ComponentModel.Canc
{
if(!ViewHelpers.ShowConfirmation(this, "Unsaved Transaction Confirmation", "You have an open transaction, are you sure you wish to close TexTools?\n\nAny un-commited changes will be lost."))
{
e.Cancel = true;
return;
}
}
Expand Down
251 changes: 160 additions & 91 deletions FFXIV_TexTools/ViewModels/ColorsetEditorViewModel.cs

Large diffs are not rendered by default.

27 changes: 18 additions & 9 deletions FFXIV_TexTools/Views/FileControls/ColorsetFileControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Grid x:Name="MaterialGrid" Visibility="Visible">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="700"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
Expand Down Expand Up @@ -323,12 +323,22 @@
<Label Content="Preview Dye #" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.ColumnSpan="2" Margin="10,0" Grid.Row="0"/>
<ComboBox x:Name="DyePreviewIdBox" VerticalAlignment="Center" HorizontalAlignment="Left" Width="150" SelectionChanged="DyePreviewIdBox_SelectionChanged" Grid.ColumnSpan="2" Margin="100,0,0,0" Grid.Row="0"/>
<Button x:Name="CopyDyeValuesButton" Content="Dye Selected Row" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="1" Width="150" Margin="10,0,0,0" Click="CopyDyeValuesButton_Click"></Button>
<Button x:Name="CopyAllDyeValuesButton" Content="Dye All Rows" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Width="150" Click="CopyAllDyeValuesButton_Click"></Button>
<Button x:Name="CopyAllDyeValuesButton" Content="Dye All Rows" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Width="150" Click="CopyAllDyeValuesButton_Click">
<Button.ContextMenu>
<ContextMenu x:Name="DyeContextMenu">
<MenuItem Header="Dye Channel 1" Click="DyeChannel1_Click"/>
<MenuItem Header="Dye Channel 2" Click="DyeChannel2_Click"/>
<MenuItem Header="Dye Channel 3" Click="DyeChannel3_Click"/>
<MenuItem Header="Dye Channel 4" Click="DyeChannel4_Click"/>
<MenuItem Header="Dye All Channels" Click="DyeAllChannels_Click"/>
</ContextMenu>
</Button.ContextMenu>
</Button>

<hx:Viewport3DX
x:Name="ColorsetRowViewport"
Grid.Row="2"
Grid.ColumnSpan="2"
Grid.ColumnSpan="2"
EffectsManager="{Binding EffectsManager}"
Camera="{Binding Camera}"
ZoomExtentsWhenLoaded="True"
Expand All @@ -340,12 +350,11 @@
<MouseBinding Command="hx:ViewportCommands.Zoom" Gesture="MiddleClick" />
<MouseBinding Command="hx:ViewportCommands.Pan" Gesture="LeftClick" />
</hx:Viewport3DX.InputBindings>
<hx:DirectionalLight3D IsRendering="True" Direction="0, 0, -1" Color="White" />
<hx:DirectionalLight3D IsRendering="True" Direction="0, 0, 1" Color="White" />
<hx:DirectionalLight3D IsRendering="True" Direction="0, 1, 0" Color="White" />
<hx:DirectionalLight3D IsRendering="True" Direction="0, -1, 0" Color="White" />
<hx:DirectionalLight3D IsRendering="True" Direction="1, 0, 0" Color="White" />
<hx:DirectionalLight3D IsRendering="True" Direction="-1, 0, 0" Color="White" />

<hx:DirectionalLight3D
Direction="0,0,-1"
Color="#AAAAAAAA" IsRendering="True" />

<hx:GroupModel3D ItemsSource="{Binding Models}"/>
</hx:Viewport3DX>
<Canvas Grid.Row="2" Name="AlternateViewportCanvas" Visibility="Hidden" IsHitTestVisible="False"/>
Expand Down
73 changes: 52 additions & 21 deletions FFXIV_TexTools/Views/FileControls/ColorsetFileControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,14 @@ private async Task UpdateViewport()
await _vm.SetColorsetRow(RowId, _columnCount, dyeId);
}

private byte ColorHalfToByte(Half half)
public static byte ColorHalfToByte(Half half)
{
var b = (byte)Math.Round((Math.Sqrt(half) * 255));

return b;
}

private Half ColorByteToHalf(byte b)
public static Half ColorByteToHalf(byte b)
{
var f = (b / 255.0f);
var half = f * f;
Expand Down Expand Up @@ -1498,7 +1498,7 @@ private async void CopyDyeValuesButton_Click(object sender, RoutedEventArgs e)
{
var dyeId = (int)DyePreviewIdBox.SelectedValue;

ApplyDye(RowId, dyeId);
ApplyDye(RowId, dyeId, -1);

// Reload the UI.
await SetMaterial(Material, RowId);
Expand All @@ -1510,25 +1510,10 @@ private async void CopyDyeValuesButton_Click(object sender, RoutedEventArgs e)
}
private async void CopyAllDyeValuesButton_Click(object sender, RoutedEventArgs e)
{
try
{
var dyeId = (int)DyePreviewIdBox.SelectedValue;

for(int i = 0; i < _rowCount; i++)
{
ApplyDye(i, dyeId);
}

// Reload the UI.
await SetMaterial(Material, RowId);
}
catch (Exception ex)
{
this.ShowError("Unknown Error", "An error occurred:\n\n" + ex.Message);
}
DyeContextMenu.IsOpen = true;
}

private void ApplyDye(int rowId, int dyeId)
private void ApplyDye(int rowId, int dyeId, int channel)
{
ushort dyeTemplateId = STM.GetTemplateKeyFromMaterialData(Material.ColorSetDyeData, rowId);
var template = DyeTemplateFile.GetTemplate(dyeTemplateId);
Expand Down Expand Up @@ -1557,8 +1542,9 @@ private void ApplyDye(int rowId, int dyeId)
var rowData = GetRowData(rowId);
for (int i = 0; i < dyeCount; i++)
{
uint dyeChannel = dyeData << 3 >> 30;
var shifted = (uint)(0x1 << i);
if ((dyeData & shifted) > 0)
if ((dyeData & shifted) > 0 && (dyeChannel == channel || channel < 0))
{
// Apply this template dye value to the row.
var data = template.GetData(i, dyeId);
Expand Down Expand Up @@ -1604,8 +1590,53 @@ protected override void FreeManaged()
if (ColorsetRowViewport != null)
{
ColorsetRowViewport.Dispose();
_vm.Dispose();
}
CopyUpdated -= OnCopyUpdated;
}

private async Task DyeAllRows(int channel)
{
try
{
var dyeId = (int)DyePreviewIdBox.SelectedValue;

for (int i = 0; i < _rowCount; i++)
{
ApplyDye(i, dyeId, channel);
}

// Reload the UI.
await SetMaterial(Material, RowId);
}
catch (Exception ex)
{
this.ShowError("Unknown Error", "An error occurred:\n\n" + ex.Message);
}
}
private void DyeChannel1_Click(object sender, RoutedEventArgs e)
{
_ = DyeAllRows(0);
}

private void DyeChannel2_Click(object sender, RoutedEventArgs e)
{
_ = DyeAllRows(1);
}

private void DyeChannel3_Click(object sender, RoutedEventArgs e)
{
_ = DyeAllRows(2);
}

private void DyeChannel4_Click(object sender, RoutedEventArgs e)
{
_ = DyeAllRows(3);
}

private void DyeAllChannels_Click(object sender, RoutedEventArgs e)
{
_ = DyeAllRows(-1);
}
}
}
12 changes: 11 additions & 1 deletion FFXIV_TexTools/Views/OnboardingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,17 @@ public static void OnboardAndInitialize()
return;
}

InitializeSettings();
try
{
InitializeSettings();
}
catch
{
ViewHelpers.ShowError("Initialization Failure", "TexTools was unable to initialize all startup directories properly.\n\nPlease check your folder paths are valid and accessible.");
DoOnboarding();
return;
}

CheckRerunAdmin();
ValidateModlist();
}
Expand Down
25 changes: 20 additions & 5 deletions FFXIV_TexTools/Views/ViewHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,28 @@ public static void ShowWarning(this UserControl control, string title, string me

public static void ShowError(string title, string message)
{
var wind = MainWindow.GetMainWindow();
if (!IsWindowOpen(wind))
try
{
wind = null;
var wind = MainWindow.GetMainWindow();
if (!IsWindowOpen(wind))
{
wind = null;
}
if (wind == null)
{
FlexibleMessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
else
{
FlexibleMessageBox.Show(wind.Win32Window, message, title, MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}
catch(Exception ex)
{
Trace.WriteLine(ex);
}
FlexibleMessageBox.Show(wind.Win32Window, message, title, MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
public static bool InfoPrompt(this Window wind, string title, string message)
{
Expand Down

0 comments on commit 91de5aa

Please sign in to comment.