Merge remote-tracking branch 'refs/remotes/Exter-N/feature/texture-stuff'

# Conflicts:
#	Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs
This commit is contained in:
Ottermandias 2023-08-25 18:05:17 +02:00
commit 4f71065d67
2 changed files with 28 additions and 23 deletions

View file

@ -15,12 +15,12 @@ public partial class CombinedTexture
{ {
private enum CombineOp private enum CombineOp
{ {
LeftMultiply = -4,
LeftCopy = -3, LeftCopy = -3,
RightCopy = -2, RightCopy = -2,
Invalid = -1, Invalid = -1,
Over = 0, Over = 0,
Under = 1, Under = 1,
LeftMultiply = 2,
RightMultiply = 3, RightMultiply = 3,
CopyChannels = 4, CopyChannels = 4,
} }
@ -47,7 +47,6 @@ public partial class CombinedTexture
{ {
"Overlay over Input", "Overlay over Input",
"Input over Overlay", "Input over Overlay",
"Ignore Overlay",
"Replace Input", "Replace Input",
"Copy Channels", "Copy Channels",
}; };
@ -55,9 +54,8 @@ public partial class CombinedTexture
private static readonly IReadOnlyList<string> CombineOpTooltips = new string[] private static readonly IReadOnlyList<string> CombineOpTooltips = new string[]
{ {
"Standard composition.\nApply the overlay over the input.", "Standard composition.\nApply the overlay over the input.",
"Standard composition, reversed.\nApply the input over the overlay.", "Standard composition, reversed.\nApply the input over the overlay ; can be used to fix some wrong imports.",
"Use only the input, and ignore the overlay.", "Completely replace the input with the overlay.\nCan be used to select the destination file as input and the source file as overlay.",
"Completely replace the input with the overlay.",
"Replace some input channels with those from the overlay.\nUseful for Multi maps.", "Replace some input channels with those from the overlay.\nUseful for Multi maps.",
}; };

View file

@ -5,7 +5,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Interface;
using ImGuiNET; using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
@ -127,23 +126,14 @@ public partial class ModEditWindow
} }
ImGui.SameLine(); ImGui.SameLine();
if (ImGui.Button("Save as TEX, DDS or PNG", buttonSize2)) if (ImGui.Button("Save as TEX", buttonSize2))
{ OpenSaveAsDialog(".tex");
var fileName = Path.GetFileNameWithoutExtension(_left.Path.Length > 0 ? _left.Path : _right.Path);
_fileDialog.OpenSavePicker("Save Texture as TEX, DDS or PNG...", "Textures{.png,.dds,.tex},.tex,.dds,.png", fileName, ".tex", if (ImGui.Button("Export as PNG", buttonSize2))
(a, b) => OpenSaveAsDialog(".png");
{ ImGui.SameLine();
if (a) if (ImGui.Button("Export as DDS", buttonSize2))
{ OpenSaveAsDialog(".dds");
_center.SaveAs(null, _textures, b, (CombinedTexture.TextureSaveType)_currentSaveAs, _addMipMaps);
if (b == _left.Path)
AddReloadTask(_left.Path, false);
else if (b == _right.Path)
AddReloadTask(_right.Path, true);
}
}, _mod!.ModPath.FullName, _forceTextureStartPath);
_forceTextureStartPath = false;
}
ImGui.NewLine(); ImGui.NewLine();
@ -206,6 +196,23 @@ public partial class ModEditWindow
_center.Draw(_textures, imageSize); _center.Draw(_textures, imageSize);
} }
private void OpenSaveAsDialog(string defaultExtension)
{
var fileName = Path.GetFileNameWithoutExtension(_left.Path.Length > 0 ? _left.Path : _right.Path);
_fileDialog.OpenSavePicker("Save Texture as TEX, DDS or PNG...", "Textures{.png,.dds,.tex},.tex,.dds,.png", fileName, defaultExtension, (a, b) =>
{
if (a)
{
_center.SaveAs(null, _textures, b, (CombinedTexture.TextureSaveType)_currentSaveAs, _addMipMaps);
if (b == _left.Path)
AddReloadTask(_left.Path, false);
else if (b == _right.Path)
AddReloadTask(_right.Path, true);
}
}, _mod!.ModPath.FullName, _forceTextureStartPath);
_forceTextureStartPath = false;
}
private void AddReloadTask(string path, bool right) private void AddReloadTask(string path, bool right)
{ {
_center.SaveTask.ContinueWith(t => _center.SaveTask.ContinueWith(t =>