Disable UI for textures when converting.

This commit is contained in:
Ottermandias 2023-08-22 14:18:29 +02:00
parent ebaa42f311
commit ad830dc56e
4 changed files with 30 additions and 20 deletions

@ -1 +1 @@
Subproject commit ad67dfcd95912d171f2c9576d70d328bdd68b1ca Subproject commit 36df7a87680eecde48801a38271f0ed8696233ed

View file

@ -42,6 +42,7 @@ public class DalamudSubstitutionProvider : IDisposable
public void ResetSubstitutions(IEnumerable<Utf8GamePath> paths) public void ResetSubstitutions(IEnumerable<Utf8GamePath> paths)
{ {
// TODO fix
//var transformed = paths //var transformed = paths
// .Where(p => (p.Path.StartsWith("ui/"u8) || p.Path.StartsWith("common/font/"u8)) && p.Path.EndsWith(".tex"u8)) // .Where(p => (p.Path.StartsWith("ui/"u8) || p.Path.StartsWith("common/font/"u8)) && p.Path.EndsWith(".tex"u8))
// .Select(p => p.ToString()); // .Select(p => p.ToString());

View file

@ -186,8 +186,7 @@ public sealed class TextureManager : SingleTaskQueue, IDisposable
CombinedTexture.TextureSaveType.AsIs when image.Type is TextureType.Dds => AddMipMaps(image.AsDds!, _mipMaps), CombinedTexture.TextureSaveType.AsIs when image.Type is TextureType.Dds => AddMipMaps(image.AsDds!, _mipMaps),
CombinedTexture.TextureSaveType.Bitmap => ConvertToRgbaDds(image, _mipMaps, cancel, rgba, width, height), CombinedTexture.TextureSaveType.Bitmap => ConvertToRgbaDds(image, _mipMaps, cancel, rgba, width, height),
CombinedTexture.TextureSaveType.BC3 => ConvertToCompressedDds(image, _mipMaps, false, cancel, rgba, width, height), CombinedTexture.TextureSaveType.BC3 => ConvertToCompressedDds(image, _mipMaps, false, cancel, rgba, width, height),
CombinedTexture.TextureSaveType.BC7 => CombinedTexture.TextureSaveType.BC7 => ConvertToCompressedDds(image, _mipMaps, true, cancel, rgba, width, height),
ConvertToCompressedDds(image, _mipMaps, true, cancel, rgba, width, height),
_ => throw new Exception("Wrong save type."), _ => throw new Exception("Wrong save type."),
}; };
@ -344,10 +343,11 @@ public sealed class TextureManager : SingleTaskQueue, IDisposable
if (numMips == input.Meta.MipLevels) if (numMips == input.Meta.MipLevels)
return input; return input;
var ec = input.GenerateMipMaps(out var ret, numMips, var flags = (Dalamud.Utility.Util.IsLinux() ? FilterFlags.ForceNonWIC : 0) | FilterFlags.SeparateAlpha;
(Dalamud.Utility.Util.IsLinux() ? FilterFlags.ForceNonWIC : 0) | FilterFlags.SeparateAlpha); var ec = input.GenerateMipMaps(out var ret, numMips, flags);
if (ec != ErrorCode.Ok) if (ec != ErrorCode.Ok)
throw new Exception($"Could not create the requested {numMips} mip maps, maybe retry with the top-right checkbox unchecked:\n{ec}"); throw new Exception(
$"Could not create the requested {numMips} mip maps (input has {input.Meta.MipLevels}) with flags [{flags}], maybe retry with the top-right checkbox unchecked:\n{ec}");
return ret; return ret;
} }

View file

@ -5,11 +5,13 @@ 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;
using OtterTex; using OtterTex;
using Penumbra.Import.Textures; using Penumbra.Import.Textures;
using Penumbra.UI.Classes;
namespace Penumbra.UI.AdvancedWindow; namespace Penumbra.UI.AdvancedWindow;
@ -48,18 +50,21 @@ public partial class ModEditWindow
ImGuiUtil.DrawTextButton(label, new Vector2(-1, 0), ImGui.GetColorU32(ImGuiCol.FrameBg)); ImGuiUtil.DrawTextButton(label, new Vector2(-1, 0), ImGui.GetColorU32(ImGuiCol.FrameBg));
ImGui.NewLine(); ImGui.NewLine();
TextureDrawer.PathInputBox(_textures, tex, ref tex.TmpPath, "##input", "Import Image...", using (var disabled = ImRaii.Disabled(!_center.SaveTask.IsCompleted))
"Can import game paths as well as your own files.", _mod!.ModPath.FullName, _fileDialog, _config.DefaultModImportPath); {
if (_textureSelectCombo.Draw("##combo", TextureDrawer.PathInputBox(_textures, tex, ref tex.TmpPath, "##input", "Import Image...",
"Select the textures included in this mod on your drive or the ones they replace from the game files.", tex.Path, "Can import game paths as well as your own files.", _mod!.ModPath.FullName, _fileDialog, _config.DefaultModImportPath);
_mod.ModPath.FullName.Length + 1, out var newPath) if (_textureSelectCombo.Draw("##combo",
&& newPath != tex.Path) "Select the textures included in this mod on your drive or the ones they replace from the game files.", tex.Path,
tex.Load(_textures, newPath); _mod.ModPath.FullName.Length + 1, out var newPath)
&& newPath != tex.Path)
tex.Load(_textures, newPath);
if (tex == _left) if (tex == _left)
_center.DrawMatrixInputLeft(size.X); _center.DrawMatrixInputLeft(size.X);
else else
_center.DrawMatrixInputRight(size.X); _center.DrawMatrixInputRight(size.X);
}
ImGui.NewLine(); ImGui.NewLine();
using var child2 = ImRaii.Child("image"); using var child2 = ImRaii.Child("image");
@ -177,8 +182,6 @@ public partial class ModEditWindow
{ {
ImGui.NewLine(); ImGui.NewLine();
} }
ImGui.NewLine();
} }
switch (_center.SaveTask.Status) switch (_center.SaveTask.Status)
@ -186,7 +189,8 @@ public partial class ModEditWindow
case TaskStatus.WaitingForActivation: case TaskStatus.WaitingForActivation:
case TaskStatus.WaitingToRun: case TaskStatus.WaitingToRun:
case TaskStatus.Running: case TaskStatus.Running:
ImGui.TextUnformatted("Computing..."); ImGuiUtil.DrawTextButton("Computing...", -Vector2.UnitX, Colors.PressEnterWarningBg);
break; break;
case TaskStatus.Canceled: case TaskStatus.Canceled:
case TaskStatus.Faulted: case TaskStatus.Faulted:
@ -196,8 +200,13 @@ public partial class ModEditWindow
ImGuiUtil.TextWrapped(_center.SaveTask.Exception?.ToString() ?? "Unknown Error"); ImGuiUtil.TextWrapped(_center.SaveTask.Exception?.ToString() ?? "Unknown Error");
break; break;
} }
default:
ImGui.Dummy(new Vector2(1, ImGui.GetFrameHeight()));
break;
} }
ImGui.NewLine();
using var child2 = ImRaii.Child("image"); using var child2 = ImRaii.Child("image");
if (child2) if (child2)
_center.Draw(_textures, imageSize); _center.Draw(_textures, imageSize);