From 9fa3a8952b6d33e3947693957cd6e5b5b4caeac2 Mon Sep 17 00:00:00 2001 From: Exter-N Date: Fri, 25 Aug 2023 18:04:06 +0200 Subject: [PATCH] Textures: Un-merge save buttons, make ignore unselectable --- .../Textures/CombinedTexture.Manipulation.cs | 8 ++-- .../AdvancedWindow/ModEditWindow.Textures.cs | 43 +++++++++++-------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Penumbra/Import/Textures/CombinedTexture.Manipulation.cs b/Penumbra/Import/Textures/CombinedTexture.Manipulation.cs index 2af2a8e4..fed269da 100644 --- a/Penumbra/Import/Textures/CombinedTexture.Manipulation.cs +++ b/Penumbra/Import/Textures/CombinedTexture.Manipulation.cs @@ -15,12 +15,12 @@ public partial class CombinedTexture { private enum CombineOp { + LeftMultiply = -4, LeftCopy = -3, RightCopy = -2, Invalid = -1, Over = 0, Under = 1, - LeftMultiply = 2, RightMultiply = 3, CopyChannels = 4, } @@ -47,7 +47,6 @@ private enum Channels { "Overlay over Input", "Input over Overlay", - "Ignore Overlay", "Replace Input", "Copy Channels", }; @@ -55,9 +54,8 @@ private enum Channels private static readonly IReadOnlyList CombineOpTooltips = new string[] { "Standard composition.\nApply the overlay over the input.", - "Standard composition, reversed.\nApply the input over the overlay.", - "Use only the input, and ignore the overlay.", - "Completely replace the input with the overlay.", + "Standard composition, reversed.\nApply the input over the overlay ; can be used to fix some wrong imports.", + "Completely replace the input with the overlay.\nCan be used to select the destination file as input and the source file as overlay.", "Replace some input channels with those from the overlay.\nUseful for Multi maps.", }; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs index af256f5c..be8bb89b 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs @@ -127,23 +127,14 @@ private void DrawOutputChild(Vector2 size, Vector2 imageSize) } ImGui.SameLine(); - if (ImGui.Button("Save as TEX, DDS or PNG", buttonSize2)) - { - 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", - (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; - } + if (ImGui.Button("Save as TEX", buttonSize2)) + OpenSaveAsDialog(".tex"); + + if (ImGui.Button("Export as PNG", buttonSize2)) + OpenSaveAsDialog(".png"); + ImGui.SameLine(); + if (ImGui.Button("Export as DDS", buttonSize2)) + OpenSaveAsDialog(".dds"); ImGui.NewLine(); @@ -206,6 +197,24 @@ private void DrawOutputChild(Vector2 size, Vector2 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) { _center.SaveTask.ContinueWith(t =>