Add documentation links

This commit is contained in:
ackwell 2024-01-20 21:13:53 +11:00
parent 655d1722c1
commit de08862a88
2 changed files with 33 additions and 3 deletions

@ -1 +1 @@
Subproject commit 9259090121b26f097948e7bbd83b32708ea0410d Subproject commit 5d0aed2b32a61654321a6616689932635cb35dde

View file

@ -1,6 +1,7 @@
using Dalamud.Interface; using Dalamud.Interface;
using ImGuiNET; using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Custom;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Widgets; using OtterGui.Widgets;
using Penumbra.GameData; using Penumbra.GameData;
@ -13,7 +14,9 @@ namespace Penumbra.UI.AdvancedWindow;
public partial class ModEditWindow public partial class ModEditWindow
{ {
private const int MdlMaterialMaximum = 4; private const int MdlMaterialMaximum = 4;
private const string MdlImportDocumentation = @"https://github.com/xivdev/Penumbra/wiki/Model-IO#import";
private const string MdlExportDocumentation = @"https://github.com/xivdev/Penumbra/wiki/Model-IO#export";
private readonly FileEditor<MdlTab> _modelTab; private readonly FileEditor<MdlTab> _modelTab;
private readonly ModelManager _models; private readonly ModelManager _models;
@ -67,6 +70,8 @@ public partial class ModEditWindow
private void DrawImport(MdlTab tab, Vector2 size, bool _1) private void DrawImport(MdlTab tab, Vector2 size, bool _1)
{ {
using var id = ImRaii.PushId("import");
_dragDropManager.CreateImGuiSource("ModelDragDrop", _dragDropManager.CreateImGuiSource("ModelDragDrop",
m => m.Extensions.Any(e => ValidModelExtensions.Contains(e.ToLowerInvariant())), m => m => m.Extensions.Any(e => ValidModelExtensions.Contains(e.ToLowerInvariant())), m =>
{ {
@ -89,6 +94,9 @@ public partial class ModEditWindow
if (success && paths.Count > 0) if (success && paths.Count > 0)
tab.Import(paths[0]); tab.Import(paths[0]);
}, 1, _mod!.ModPath.FullName, false); }, 1, _mod!.ModPath.FullName, false);
ImGui.SameLine();
DrawDocumentationLink(MdlImportDocumentation);
} }
if (_dragDropManager.CreateImGuiTarget("ModelDragDrop", out var files, out _) && GetFirstModel(files, out var importFile)) if (_dragDropManager.CreateImGuiTarget("ModelDragDrop", out var files, out _) && GetFirstModel(files, out var importFile))
@ -97,6 +105,7 @@ public partial class ModEditWindow
private void DrawExport(MdlTab tab, Vector2 size, bool _) private void DrawExport(MdlTab tab, Vector2 size, bool _)
{ {
using var id = ImRaii.PushId("export");
using var frame = ImRaii.FramedGroup("Export", size, headerPreIcon: FontAwesomeIcon.FileExport); using var frame = ImRaii.FramedGroup("Export", size, headerPreIcon: FontAwesomeIcon.FileExport);
if (tab.GamePaths == null) if (tab.GamePaths == null)
@ -110,10 +119,10 @@ public partial class ModEditWindow
} }
DrawGamePathCombo(tab); DrawGamePathCombo(tab);
var gamePath = tab.GamePathIndex >= 0 && tab.GamePathIndex < tab.GamePaths.Count var gamePath = tab.GamePathIndex >= 0 && tab.GamePathIndex < tab.GamePaths.Count
? tab.GamePaths[tab.GamePathIndex] ? tab.GamePaths[tab.GamePathIndex]
: _customGamePath; : _customGamePath;
if (ImGuiUtil.DrawDisabledButton("Export to glTF", Vector2.Zero, "Exports this mdl file to glTF, for use in 3D authoring applications.", if (ImGuiUtil.DrawDisabledButton("Export to glTF", Vector2.Zero, "Exports this mdl file to glTF, for use in 3D authoring applications.",
tab.PendingIo || gamePath.IsEmpty)) tab.PendingIo || gamePath.IsEmpty))
_fileDialog.OpenSavePicker("Save model as glTF.", ".gltf", Path.GetFileNameWithoutExtension(gamePath.Filename().ToString()), _fileDialog.OpenSavePicker("Save model as glTF.", ".gltf", Path.GetFileNameWithoutExtension(gamePath.Filename().ToString()),
@ -127,6 +136,9 @@ public partial class ModEditWindow
_mod!.ModPath.FullName, _mod!.ModPath.FullName,
false false
); );
ImGui.SameLine();
DrawDocumentationLink(MdlExportDocumentation);
} }
private static void DrawIoExceptions(MdlTab tab) private static void DrawIoExceptions(MdlTab tab)
@ -205,6 +217,24 @@ public partial class ModEditWindow
ImGuiUtil.HoverTooltip("Right-Click to copy to clipboard.", ImGuiHoveredFlags.AllowWhenDisabled); ImGuiUtil.HoverTooltip("Right-Click to copy to clipboard.", ImGuiHoveredFlags.AllowWhenDisabled);
} }
private void DrawDocumentationLink(string address)
{
const string text = "Documentation →";
var framePadding = ImGui.GetStyle().FramePadding;
var width = ImGui.CalcTextSize(text).X + framePadding.X * 2;
// Draw the link button. We set the background colour to transparent to mimic the look of a link.
using var color = ImRaii.PushColor(ImGuiCol.Button, 0x00000000);
CustomGui.DrawLinkButton(Penumbra.Messager, text, address, width);
// Draw an underline for the text.
var lineStart = ImGui.GetItemRectMax();
lineStart -= framePadding;
var lineEnd = lineStart with { X = ImGui.GetItemRectMin().X + framePadding.X };
ImGui.GetWindowDrawList().AddLine(lineStart, lineEnd, 0xFFFFFFFF);
}
private bool DrawModelMaterialDetails(MdlTab tab, bool disabled) private bool DrawModelMaterialDetails(MdlTab tab, bool disabled)
{ {
if (!ImGui.CollapsingHeader("Materials")) if (!ImGui.CollapsingHeader("Materials"))