Skip to content

Commit

Permalink
Update all
Browse files Browse the repository at this point in the history
  • Loading branch information
iMrShadow committed Aug 19, 2024
1 parent 230d71f commit af00d97
Show file tree
Hide file tree
Showing 128 changed files with 2,624 additions and 14,719 deletions.
66 changes: 22 additions & 44 deletions TelltaleTextureTool/TelltaleTextureTool/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
RequestedThemeVariant="Dark">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Resources>
<Color x:Key="MainPanelColor">#424242</Color>
<Color x:Key="PanelSplitterColor">#303030</Color>
<Color x:Key="ButtonColor">#3e3f52</Color>
<Color x:Key="MainPanelColor">#333333</Color>
<Color x:Key="PanelSplitterColor">#454545</Color>
<Color x:Key="ButtonColor">#1f2124</Color>
</Application.Resources>
<Application.Styles>
<!-- <Style Selector="ads:MsBox"> -->
Expand All @@ -23,10 +23,6 @@
Value="{DynamicResource ButtonColor}" />
</Style>

<Style Selector="Button:disabled">
<Setter Property="Background"
Value="#ffffff" />
</Style>

<!-- this is pointover for expander -->
<Style Selector="Expander:pointerover/template/ToggleButton">
Expand Down Expand Up @@ -59,43 +55,7 @@
<Setter Property="Background"
Value="{DynamicResource ButtonColor}" />
</Style>


<!--<Style Selector="Slider:horizontal/template/ Track#PART_Track.Grid">
<Setter Property="Height" Value="20" />
</Style>
<Style Selector="Slider:horizontal/template/RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="#ff0000" />
</Style>
<Style Selector="Slider:horizontal/template/RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="#ff0000" />
</Style>
<Style Selector="Slider:horizontal/template/ Border#TrackBackground">
<Setter Property="BorderThickness" Value="20" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
</Style>
<Style Selector="Slider/template/">
<Setter Property="BorderThickness" Value="20" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
</Style>
<Style Selector="Slider:horizontal/template/ Border#TrackBackground/template/">
<Setter Property="BorderThickness" Value="20" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
</Style>
--><!--<Style Selector="Slider:horizontal/template/ TickBar">
<Setter Property="BorderThickness" Value="20" />
</Style>--><!--
<Style Selector="Slider:horizontal/template/ Grid#grid">
</Style>
<Style Selector="Slider:horizontal/template/ Thumb#thumb">
<Setter Property="Background" Value="#ff0000" />
</Style>-->


<Style Selector="Slider/template/Grid#SliderContainer">
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Height" Value="50" />
Expand Down Expand Up @@ -185,6 +145,24 @@
<Setter Property="Background" Value="Transparent" />
</Style>

<!--https://github.com/AvaloniaUI/Avalonia/issues/3016--><!--
<Style Selector="ListBox.RadioButtonListBox">
<Setter Property="BorderBrush" Value="Transparent"/>
</Style>
<Style Selector="ListBox.RadioButtonListBox ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="Transparent">
<RadioButton Content="{TemplateBinding ContentPresenter.Content}"
VerticalAlignment="Center"
IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>-->

<FluentTheme>
<FluentTheme.Palettes>
<!-- Palette for Light theme variant -->
Expand Down
10 changes: 5 additions & 5 deletions TelltaleTextureTool/TelltaleTextureTool/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace TelltaleTextureTool;

public static class Converter
{

public static string[] GetExtension(TextureType textureType)
{
return textureType switch
Expand All @@ -32,6 +31,7 @@ public static string[] GetExtension(TextureType textureType)
TextureType.BMP => [Main_Shared.bmpExtension],
TextureType.TIFF => [Main_Shared.tiffExtension, Main_Shared.tifExtension],
TextureType.TGA => [Main_Shared.tgaExtension],
TextureType.HDR => [Main_Shared.hdrExtension],
_ => throw new InvalidEnumArgumentException("Invalid texture type."),
};
}
Expand Down Expand Up @@ -439,21 +439,21 @@ public static void ConvertTextureFromDdsToOthers(string? sourceFilePath, string
//ConvertOptions
if (d3dtxTextureType == T3TextureType.eTxBumpmap || d3dtxTextureType == T3TextureType.eTxNormalMap)
{
DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, DDS_DirectXTexNet.DDSConversionMode.SWIZZLE_ABGR);
// DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, ImageEffect.SWIZZLE_ABGR);
}
else if (d3dtxTextureType == T3TextureType.eTxNormalXYMap)
{
DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, DDS_DirectXTexNet.DDSConversionMode.RESTORE_Z);
// DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, ImageEffect.RESTORE_Z);
}
else
{
DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, DDS_DirectXTexNet.DDSConversionMode.DEFAULT);
// DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, ImageEffect.DEFAULT);
}
}
// If we didn't find a JSON file, use default conversion.
else
{
DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, DDS_DirectXTexNet.DDSConversionMode.DEFAULT);
// DDS_DirectXTexNet.SaveDDSToWIC(sourceFilePath, destinationDirectory, newTextureType, ImageEffect.DEFAULT);
throw new FileNotFoundException(
"No .json file was found for the file.\nDefaulting to classic conversion.");
}
Expand Down
135 changes: 135 additions & 0 deletions TelltaleTextureTool/TelltaleTextureTool/GUI/ImageAdvancedOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
using System.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using TelltaleTextureTool.DirectX;
using TelltaleTextureTool.Main;
using TelltaleTextureTool.TelltaleEnums;
using TelltaleTextureTool.ViewModels;

namespace TelltaleTextureTool;

public partial class ImageAdvancedOptions : ObservableObject
{

//Private telltale games
[ObservableProperty]
private D3DTXVersion _d3dtxVersion;

[ObservableProperty]
private TextureType _textureType;

[ObservableProperty]
private bool _enableMips = false;

[ObservableProperty]
private bool _autoGenerateMips = false;

[ObservableProperty]
private bool _manualGenerateMips = false;

[ObservableProperty]
private uint _setMips = 1;

[ObservableProperty]
private bool _compression;

[ObservableProperty]
private bool _enableAutomaticCompression;

[ObservableProperty]
private bool _isAutomaticCompression;

[ObservableProperty]
private bool _isManualCompression;

[ObservableProperty]
private T3SurfaceFormat _format;

[ObservableProperty]
private bool _enableNormalMap;

[ObservableProperty]
private bool _encodeDDSHeader;

[ObservableProperty]
private bool _filterValues;

[ObservableProperty]
private bool _enableWrapU;

[ObservableProperty]
private bool _enableWrapV;

[ObservableProperty]
private bool _enableEditing;

[ObservableProperty]
private bool _enableSwizzle;

[ObservableProperty]
private bool _isSwizzle;

[ObservableProperty]
private bool _isDeswizzle;

[ObservableProperty]
private T3PlatformType _platformType = T3PlatformType.ePlatform_All;

[ObservableProperty]
private bool _enableAlpha;

[ObservableProperty]
private T3TextureAlphaMode _alphaFormat;

[ObservableProperty]
private ImageEffect _imageEffect;

// Store a reference to MainViewModel
private readonly MainViewModel _mainViewModel;

public ImageAdvancedOptions(MainViewModel mainViewModel)
{
_mainViewModel = mainViewModel;
}

public ImageAdvancedOptions(ImageAdvancedOptions imageAdvancedOptions)
{
_d3dtxVersion = imageAdvancedOptions._d3dtxVersion;
_textureType = imageAdvancedOptions._textureType;
_enableMips = imageAdvancedOptions._enableMips;
_autoGenerateMips = imageAdvancedOptions._autoGenerateMips;
_manualGenerateMips = imageAdvancedOptions._manualGenerateMips;
_setMips = imageAdvancedOptions._setMips;
_compression = imageAdvancedOptions._compression;
_enableAutomaticCompression = imageAdvancedOptions._enableAutomaticCompression;
_isAutomaticCompression = imageAdvancedOptions._isAutomaticCompression;
_isManualCompression = imageAdvancedOptions._isManualCompression;
_format = imageAdvancedOptions._format;
_enableNormalMap = imageAdvancedOptions._enableNormalMap;
_encodeDDSHeader = imageAdvancedOptions._encodeDDSHeader;
_filterValues = imageAdvancedOptions._filterValues;
_enableWrapU = imageAdvancedOptions._enableWrapU;
_enableWrapV = imageAdvancedOptions._enableWrapV;
_enableEditing = imageAdvancedOptions._enableEditing;
_enableSwizzle = imageAdvancedOptions._enableSwizzle;
_isSwizzle = imageAdvancedOptions._isSwizzle;
_isDeswizzle = imageAdvancedOptions._isDeswizzle;
_platformType = imageAdvancedOptions._platformType;
_enableAlpha = imageAdvancedOptions._enableAlpha;
_alphaFormat = imageAdvancedOptions._alphaFormat;
_imageEffect = imageAdvancedOptions._imageEffect;
_mainViewModel = imageAdvancedOptions._mainViewModel;
}

public ImageAdvancedOptions() { }

// Override OnPropertyChanged to trigger the MainViewModel's command
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);

// Trigger the command in MainViewModel

_mainViewModel.UpdateBitmapCommand.Execute(null);
}

}
36 changes: 0 additions & 36 deletions TelltaleTextureTool/TelltaleTextureTool/GUI/ImageBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,6 @@ namespace TelltaleTextureTool.Utilities;
public static class ImageUtilities
{

/// <summary>
/// Checks if the image from a file path is transparent.
/// </summary>
/// <param name="imageFilePath"></param>
/// <returns></returns>
public static bool IsImageOpaque(string imageFilePath)
{
var image = SixLabors.ImageSharp.Image.Load<Rgba32>(imageFilePath);

bool hasAlpha = false;

image.ProcessPixelRows(pixelAccessor =>
{
for (int y = 0; y < pixelAccessor.Height; y++)
{
Span<Rgba32> pixelRow = pixelAccessor.GetRowSpan(y);

for (int x = 0; x < pixelRow.Length; x++)
{
if (pixelRow[x].A != 255)
{
hasAlpha = true;
break;
}
}

if (hasAlpha)
{
break;
}
}
});

return hasAlpha;
}

/// <summary>
/// Checks if the loaded image has any transparent pixels.
/// </summary>
Expand Down
Loading

0 comments on commit af00d97

Please sign in to comment.