mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 20:54:16 +01:00
Add Texture Conversion IPC and use texture tasks.
This commit is contained in:
parent
af93c2aca9
commit
6e11b36401
9 changed files with 305 additions and 109 deletions
|
|
@ -9,6 +9,8 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Utility;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Api.Helpers;
|
||||
|
|
@ -19,7 +21,6 @@ using Penumbra.Mods.Manager;
|
|||
using Penumbra.Services;
|
||||
using Penumbra.UI;
|
||||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.Util;
|
||||
|
||||
namespace Penumbra.Api;
|
||||
|
||||
|
|
@ -38,6 +39,7 @@ public class IpcTester : IDisposable
|
|||
private readonly Meta _meta;
|
||||
private readonly Mods _mods;
|
||||
private readonly ModSettings _modSettings;
|
||||
private readonly Editing _editing;
|
||||
private readonly Temporary _temporary;
|
||||
|
||||
public IpcTester(Configuration config, DalamudServices dalamud, PenumbraIpcProviders ipcProviders, ModManager modManager,
|
||||
|
|
@ -54,6 +56,7 @@ public class IpcTester : IDisposable
|
|||
_meta = new Meta(dalamud.PluginInterface);
|
||||
_mods = new Mods(dalamud.PluginInterface);
|
||||
_modSettings = new ModSettings(dalamud.PluginInterface);
|
||||
_editing = new Editing(dalamud.PluginInterface);
|
||||
_temporary = new Temporary(dalamud.PluginInterface, modManager, collections, tempMods, tempCollections, saveService, config);
|
||||
UnsubscribeEvents();
|
||||
}
|
||||
|
|
@ -74,6 +77,7 @@ public class IpcTester : IDisposable
|
|||
_meta.Draw();
|
||||
_mods.Draw();
|
||||
_modSettings.Draw();
|
||||
_editing.Draw();
|
||||
_temporary.Draw();
|
||||
_temporary.DrawCollections();
|
||||
_temporary.DrawMods();
|
||||
|
|
@ -402,9 +406,9 @@ public class IpcTester : IDisposable
|
|||
private string _lastRedrawnString = "None";
|
||||
|
||||
public Redrawing(DalamudServices dalamud)
|
||||
{
|
||||
{
|
||||
_dalamud = dalamud;
|
||||
Redrawn = Ipc.GameObjectRedrawn.Subscriber(_dalamud.PluginInterface, SetLastRedrawn);
|
||||
Redrawn = Ipc.GameObjectRedrawn.Subscriber(_dalamud.PluginInterface, SetLastRedrawn);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
|
|
@ -1149,6 +1153,72 @@ public class IpcTester : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private class Editing
|
||||
{
|
||||
private readonly DalamudPluginInterface _pi;
|
||||
|
||||
private string _inputPath = string.Empty;
|
||||
private string _inputPath2 = string.Empty;
|
||||
private string _outputPath = string.Empty;
|
||||
private string _outputPath2 = string.Empty;
|
||||
|
||||
private TextureType _typeSelector;
|
||||
private bool _mipMaps = true;
|
||||
|
||||
private Task? _task1;
|
||||
private Task? _task2;
|
||||
|
||||
public Editing(DalamudPluginInterface pi)
|
||||
=> _pi = pi;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
using var _ = ImRaii.TreeNode("Editing");
|
||||
if (!_)
|
||||
return;
|
||||
|
||||
ImGui.InputTextWithHint("##inputPath", "Input Texture Path...", ref _inputPath, 256);
|
||||
ImGui.InputTextWithHint("##outputPath", "Output Texture Path...", ref _outputPath, 256);
|
||||
ImGui.InputTextWithHint("##inputPath2", "Input Texture Path 2...", ref _inputPath2, 256);
|
||||
ImGui.InputTextWithHint("##outputPath2", "Output Texture Path 2...", ref _outputPath2, 256);
|
||||
TypeCombo();
|
||||
ImGui.Checkbox("Add MipMaps", ref _mipMaps);
|
||||
|
||||
using var table = ImRaii.Table("...", 3, ImGuiTableFlags.SizingFixedFit);
|
||||
if (!table)
|
||||
return;
|
||||
|
||||
DrawIntro(Ipc.ConvertTextureFile.Label, "Convert Texture 1");
|
||||
if (ImGuiUtil.DrawDisabledButton("Save 1", Vector2.Zero, string.Empty, _task1 is { IsCompleted: false }))
|
||||
_task1 = Ipc.ConvertTextureFile.Subscriber(_pi).Invoke(_inputPath, _outputPath, _typeSelector, _mipMaps);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(_task1 == null ? "Not Initiated" : _task1.Status.ToString());
|
||||
if (ImGui.IsItemHovered() && _task1?.Status == TaskStatus.Faulted)
|
||||
ImGui.SetTooltip(_task1.Exception?.ToString());
|
||||
|
||||
DrawIntro(Ipc.ConvertTextureFile.Label, "Convert Texture 2");
|
||||
if (ImGuiUtil.DrawDisabledButton("Save 2", Vector2.Zero, string.Empty, _task2 is { IsCompleted: false }))
|
||||
_task2 = Ipc.ConvertTextureFile.Subscriber(_pi).Invoke(_inputPath2, _outputPath2, _typeSelector, _mipMaps);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(_task2 == null ? "Not Initiated" : _task2.Status.ToString());
|
||||
if (ImGui.IsItemHovered() && _task2?.Status == TaskStatus.Faulted)
|
||||
ImGui.SetTooltip(_task2.Exception?.ToString());
|
||||
}
|
||||
|
||||
private void TypeCombo()
|
||||
{
|
||||
using var combo = ImRaii.Combo("Convert To", _typeSelector.ToString());
|
||||
if (!combo)
|
||||
return;
|
||||
|
||||
foreach (var value in Enum.GetValues<TextureType>())
|
||||
{
|
||||
if (ImGui.Selectable(value.ToString(), _typeSelector == value))
|
||||
_typeSelector = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Temporary
|
||||
{
|
||||
private readonly DalamudPluginInterface _pi;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue