mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Allow copying paths out of the resource logger.
This commit is contained in:
parent
bd59591ed8
commit
0c6d777c75
1 changed files with 28 additions and 22 deletions
|
|
@ -4,6 +4,7 @@ using OtterGui;
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
using OtterGui.Raii;
|
using OtterGui.Raii;
|
||||||
using OtterGui.Table;
|
using OtterGui.Table;
|
||||||
|
using OtterGui.Text;
|
||||||
using Penumbra.Enums;
|
using Penumbra.Enums;
|
||||||
using Penumbra.Interop.Structs;
|
using Penumbra.Interop.Structs;
|
||||||
using Penumbra.String;
|
using Penumbra.String;
|
||||||
|
|
@ -52,22 +53,26 @@ internal sealed class ResourceWatcherTable : Table<Record>
|
||||||
|
|
||||||
private static unsafe void DrawByteString(CiByteString path, float length)
|
private static unsafe void DrawByteString(CiByteString path, float length)
|
||||||
{
|
{
|
||||||
Vector2 vec;
|
if (path.IsEmpty)
|
||||||
ImGuiNative.igCalcTextSize(&vec, path.Path, path.Path + path.Length, 0, 0);
|
return;
|
||||||
if (vec.X <= length)
|
|
||||||
|
var size = ImUtf8.CalcTextSize(path.Span);
|
||||||
|
var clicked = false;
|
||||||
|
if (size.X <= length)
|
||||||
{
|
{
|
||||||
ImGuiNative.igTextUnformatted(path.Path, path.Path + path.Length);
|
clicked = ImUtf8.Selectable(path.Span);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var fileName = path.LastIndexOf((byte)'/');
|
var fileName = path.LastIndexOf((byte)'/');
|
||||||
|
using (ImRaii.Group())
|
||||||
|
{
|
||||||
CiByteString shortPath;
|
CiByteString shortPath;
|
||||||
if (fileName != -1)
|
if (fileName != -1)
|
||||||
{
|
{
|
||||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(2 * UiHelpers.Scale));
|
|
||||||
using var font = ImRaii.PushFont(UiBuilder.IconFont);
|
using var font = ImRaii.PushFont(UiBuilder.IconFont);
|
||||||
ImGui.TextUnformatted(FontAwesomeIcon.EllipsisH.ToIconString());
|
clicked = ImUtf8.Selectable(FontAwesomeIcon.EllipsisH.ToIconString());
|
||||||
ImGui.SameLine();
|
ImUtf8.SameLineInner();
|
||||||
shortPath = path.Substring(fileName, path.Length - fileName);
|
shortPath = path.Substring(fileName, path.Length - fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -75,13 +80,14 @@ internal sealed class ResourceWatcherTable : Table<Record>
|
||||||
shortPath = path;
|
shortPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiNative.igTextUnformatted(shortPath.Path, shortPath.Path + shortPath.Length);
|
clicked |= ImUtf8.Selectable(shortPath.Span, false, ImGuiSelectableFlags.AllowItemOverlap);
|
||||||
if (ImGui.IsItemClicked())
|
|
||||||
ImGuiNative.igSetClipboardText(path.Path);
|
|
||||||
|
|
||||||
if (ImGui.IsItemHovered())
|
|
||||||
ImGuiNative.igSetTooltip(path.Path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImUtf8.HoverTooltip(path.Span);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clicked)
|
||||||
|
ImUtf8.SetClipboardText(path.Span);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class RecordTypeColumn : ColumnFlags<RecordType, Record>
|
private sealed class RecordTypeColumn : ColumnFlags<RecordType, Record>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue