mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
Manual overloads for ImGui functions accepting text (#2319)
* wip2 * Implement AutoUtf8Buffer * reformat * Work on manual bindings * restructure * Name scripts properly * Update utility functions to use ImU8String * add overloads * Add more overloads * Use ImGuiWindow from gen, support AddCallback * Use LibraryImport for custom ImGuiNative functinos * Make manual overloads for string-returning functinos * Make all overloads with self as its first parameter extension methods * Fix overload resolution by removing unnecessary * in => scoped in * Fix compilation errors
This commit is contained in:
parent
0c63541864
commit
c69329f592
293 changed files with 61312 additions and 754 deletions
|
|
@ -1,3 +1,3 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=interface_005Cfontawesome/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Int64 x:Key="/Default/PerformanceThreshold/AnalysisFileSizeThreshold/=CSHARP/@EntryIndexedValue">300000</s:Int64>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=interface_005Cfontawesome/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=interface_005Ctextures_005Ctexturewraps_005Cinternal_005Cdrawlisttexturewrap/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
|
|||
case WM.WM_CHAR:
|
||||
if (io.WantTextInput)
|
||||
{
|
||||
io.AddInputCharacter((uint)wParam);
|
||||
io.AddInputCharacter(new Rune((uint)wParam));
|
||||
return nint.Zero;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -343,31 +343,50 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
|
|||
var vertexOffset = 0;
|
||||
var indexOffset = 0;
|
||||
var clipOff = new Vector4(drawData.DisplayPos, drawData.DisplayPos.X, drawData.DisplayPos.Y);
|
||||
this.context.Get()->PSSetShader(this.pixelShader, null, 0);
|
||||
this.context.Get()->PSSetSamplers(0, 1, this.sampler.GetAddressOf());
|
||||
foreach (ref var cmdList in cmdLists)
|
||||
{
|
||||
var cmds = new ImVectorWrapper<ImDrawCmd>(cmdList.Handle->CmdBuffer.ToUntyped());
|
||||
foreach (ref var cmd in cmds.DataSpan)
|
||||
{
|
||||
var clipV4 = cmd.ClipRect - clipOff;
|
||||
var clipRect = new RECT((int)clipV4.X, (int)clipV4.Y, (int)clipV4.Z, (int)clipV4.W);
|
||||
|
||||
// Skip the draw if nothing would be visible
|
||||
if (clipRect.left >= clipRect.right || clipRect.top >= clipRect.bottom)
|
||||
continue;
|
||||
|
||||
this.context.Get()->RSSetScissorRects(1, &clipRect);
|
||||
|
||||
if (cmd.UserCallback == null)
|
||||
switch ((ImDrawCallbackEnum)(nint)cmd.UserCallback)
|
||||
{
|
||||
// Bind texture and draw
|
||||
var srv = (ID3D11ShaderResourceView*)cmd.TextureId.Handle;
|
||||
this.context.Get()->PSSetShader(this.pixelShader, null, 0);
|
||||
this.context.Get()->PSSetSamplers(0, 1, this.sampler.GetAddressOf());
|
||||
this.context.Get()->PSSetShaderResources(0, 1, &srv);
|
||||
this.context.Get()->DrawIndexed(
|
||||
cmd.ElemCount,
|
||||
(uint)(cmd.IdxOffset + indexOffset),
|
||||
(int)(cmd.VtxOffset + vertexOffset));
|
||||
case ImDrawCallbackEnum.Empty:
|
||||
{
|
||||
var clipV4 = cmd.ClipRect - clipOff;
|
||||
var clipRect = new RECT((int)clipV4.X, (int)clipV4.Y, (int)clipV4.Z, (int)clipV4.W);
|
||||
|
||||
// Skip the draw if nothing would be visible
|
||||
if (clipRect.left >= clipRect.right || clipRect.top >= clipRect.bottom)
|
||||
continue;
|
||||
|
||||
this.context.Get()->RSSetScissorRects(1, &clipRect);
|
||||
|
||||
// Bind texture and draw
|
||||
var srv = (ID3D11ShaderResourceView*)cmd.TextureId.Handle;
|
||||
this.context.Get()->PSSetShaderResources(0, 1, &srv);
|
||||
this.context.Get()->DrawIndexed(
|
||||
cmd.ElemCount,
|
||||
(uint)(cmd.IdxOffset + indexOffset),
|
||||
(int)(cmd.VtxOffset + vertexOffset));
|
||||
break;
|
||||
}
|
||||
|
||||
case ImDrawCallbackEnum.ResetRenderState:
|
||||
{
|
||||
// Special callback value used by the user to request the renderer to reset render state.
|
||||
this.SetupRenderState(drawData);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
var cb = (delegate*<ImDrawListPtr, ref ImDrawCmd, void>)cmd.UserCallback;
|
||||
cb(cmdList, ref cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,8 +205,8 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
|
||||
/// <summary>Gets or sets a value indicating whether this popup should be modal, blocking everything behind from
|
||||
/// being interacted.</summary>
|
||||
/// <remarks>If <c>true</c>, then <see cref="ImGui.BeginPopupModal(string, ref bool, ImGuiWindowFlags)"/> will be
|
||||
/// used. Otherwise, <see cref="ImGui.Begin(string, ref bool, ImGuiWindowFlags)"/> will be used.</remarks>
|
||||
/// <remarks>If <c>true</c>, then <see cref="ImGui.BeginPopupModal(ImU8String, ref bool, ImGuiWindowFlags)"/> will be
|
||||
/// used. Otherwise, <see cref="ImGui.Begin(ImU8String, ref bool, ImGuiWindowFlags)"/> will be used.</remarks>
|
||||
public bool IsModal { get; set; } = true;
|
||||
|
||||
/// <summary>Gets or sets the window flags.</summary>
|
||||
|
|
@ -558,21 +558,10 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
||||
using (this.fontHandle?.Push())
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* buf = this.fontPreviewText)
|
||||
fixed (byte* label = "##fontPreviewText"u8)
|
||||
{
|
||||
ImGui.InputTextMultiline(
|
||||
label,
|
||||
buf,
|
||||
(uint)this.fontPreviewText.Length,
|
||||
ImGui.GetContentRegionAvail(),
|
||||
ImGuiInputTextFlags.None,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
}
|
||||
ImGui.InputTextMultiline(
|
||||
"##fontPreviewText"u8,
|
||||
this.fontPreviewText,
|
||||
ImGui.GetContentRegionAvail());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -608,15 +597,15 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
ref this.familySearch,
|
||||
255,
|
||||
ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.CallbackHistory,
|
||||
data =>
|
||||
(ref ImGuiInputTextCallbackData data) =>
|
||||
{
|
||||
if (families.Count == 0)
|
||||
return 0;
|
||||
|
||||
var baseIndex = this.selectedFamilyIndex;
|
||||
if (data->SelectionStart == 0 && data->SelectionEnd == data->BufTextLen)
|
||||
if (data.SelectionStart == 0 && data.SelectionEnd == data.BufTextLen)
|
||||
{
|
||||
switch (data->EventKey)
|
||||
switch (data.EventKey)
|
||||
{
|
||||
case ImGuiKey.DownArrow:
|
||||
this.selectedFamilyIndex = (this.selectedFamilyIndex + 1) % families.Count;
|
||||
|
|
@ -632,13 +621,13 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
if (changed)
|
||||
{
|
||||
ImGuiHelpers.SetTextFromCallback(
|
||||
data,
|
||||
ref data,
|
||||
this.ExtractName(families[this.selectedFamilyIndex]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (data->EventKey)
|
||||
switch (data.EventKey)
|
||||
{
|
||||
case ImGuiKey.DownArrow:
|
||||
this.selectedFamilyIndex = families.FindIndex(
|
||||
|
|
@ -776,15 +765,15 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
ref this.fontSearch,
|
||||
255,
|
||||
ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.CallbackHistory,
|
||||
data =>
|
||||
(ref ImGuiInputTextCallbackData data) =>
|
||||
{
|
||||
if (fonts.Count == 0)
|
||||
return 0;
|
||||
|
||||
var baseIndex = this.selectedFontIndex;
|
||||
if (data->SelectionStart == 0 && data->SelectionEnd == data->BufTextLen)
|
||||
if (data.SelectionStart == 0 && data.SelectionEnd == data.BufTextLen)
|
||||
{
|
||||
switch (data->EventKey)
|
||||
switch (data.EventKey)
|
||||
{
|
||||
case ImGuiKey.DownArrow:
|
||||
this.selectedFontIndex = (this.selectedFontIndex + 1) % fonts.Count;
|
||||
|
|
@ -799,13 +788,13 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
if (changed)
|
||||
{
|
||||
ImGuiHelpers.SetTextFromCallback(
|
||||
data,
|
||||
ref data,
|
||||
this.ExtractName(fonts[this.selectedFontIndex]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (data->EventKey)
|
||||
switch (data.EventKey)
|
||||
{
|
||||
case ImGuiKey.DownArrow:
|
||||
this.selectedFontIndex = fonts.FindIndex(
|
||||
|
|
@ -925,9 +914,9 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
255,
|
||||
ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.CallbackHistory |
|
||||
ImGuiInputTextFlags.CharsDecimal,
|
||||
data =>
|
||||
(ref ImGuiInputTextCallbackData data) =>
|
||||
{
|
||||
switch (data->EventKey)
|
||||
switch (data.EventKey)
|
||||
{
|
||||
case ImGuiKey.DownArrow:
|
||||
this.selectedFont = this.selectedFont with
|
||||
|
|
@ -946,7 +935,7 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
}
|
||||
|
||||
if (changed)
|
||||
ImGuiHelpers.SetTextFromCallback(data, $"{this.selectedFont.SizePt:0.##}");
|
||||
ImGuiHelpers.SetTextFromCallback(ref data, $"{this.selectedFont.SizePt:0.##}");
|
||||
|
||||
return 0;
|
||||
}))
|
||||
|
|
@ -1129,19 +1118,19 @@ public sealed class SingleFontChooserDialog : IDisposable
|
|||
255,
|
||||
ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.CallbackHistory |
|
||||
ImGuiInputTextFlags.CharsDecimal,
|
||||
data =>
|
||||
(ref ImGuiInputTextCallbackData data) =>
|
||||
{
|
||||
switch (data->EventKey)
|
||||
switch (data.EventKey)
|
||||
{
|
||||
case ImGuiKey.DownArrow:
|
||||
changed2 = true;
|
||||
value = Math.Min(max, (MathF.Round(value / step) * step) + step);
|
||||
ImGuiHelpers.SetTextFromCallback(data, $"{value:0.##}");
|
||||
ImGuiHelpers.SetTextFromCallback(ref data, $"{value:0.##}");
|
||||
break;
|
||||
case ImGuiKey.UpArrow:
|
||||
changed2 = true;
|
||||
value = Math.Max(min, (MathF.Round(value / step) * step) - step);
|
||||
ImGuiHelpers.SetTextFromCallback(data, $"{value:0.##}");
|
||||
ImGuiHelpers.SetTextFromCallback(ref data, $"{value:0.##}");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ internal sealed partial class ActiveNotification
|
|||
/// <summary>Calculates the effective expiry, taking ImGui window state into account.</summary>
|
||||
/// <param name="warrantsExtension">Notification will not dismiss while this paramter is <c>true</c>.</param>
|
||||
/// <returns>The calculated effective expiry.</returns>
|
||||
/// <remarks>Expected to be called BETWEEN <see cref="ImGui.Begin(string)"/> and <see cref="ImGui.End()"/>.</remarks>
|
||||
/// <remarks>Expected to be called BETWEEN <see cref="ImGui.Begin(ImU8String, ImGuiWindowFlags)"/> and <see cref="ImGui.End()"/>.</remarks>
|
||||
private DateTime CalculateEffectiveExpiry(ref bool warrantsExtension)
|
||||
{
|
||||
DateTime expiry;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ internal unsafe class UiDebug
|
|||
var addonName = atkUnitBase->NameString;
|
||||
var agent = Service<GameGui>.Get().FindAgentInterface(atkUnitBase);
|
||||
|
||||
ImGui.Text($"{addonName}");
|
||||
ImGui.Text(addonName);
|
||||
ImGui.SameLine();
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, isVisible ? 0xFF00FF00 : 0xFF0000FF);
|
||||
ImGui.Text(isVisible ? "Visible" : "Not Visible");
|
||||
|
|
@ -211,7 +211,7 @@ internal unsafe class UiDebug
|
|||
ImGui.SameLine();
|
||||
Service<SeStringRenderer>.Get().Draw(textNode->NodeText);
|
||||
|
||||
ImGui.InputText($"Replace Text##{(ulong)textNode:X}", textNode->NodeText.StringPtr, (uint)textNode->NodeText.BufSize);
|
||||
ImGui.InputText($"Replace Text##{(ulong)textNode:X}", new(textNode->NodeText.StringPtr, (int)textNode->NodeText.BufSize));
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button($"Encode##{(ulong)textNode:X}"))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System.Numerics;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Internal.UiDebug2.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
|
@ -110,7 +112,7 @@ public unsafe partial class AddonTree
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ImGui.TextColored(new(1, 0, 0, 1), $"{ex}");
|
||||
ImGui.TextColored(new Vector4(1, 0, 0, 1), $"{ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public unsafe partial class AddonTree : IDisposable
|
|||
ImGui.SameLine();
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(isVisible ? new(0.1f, 1f, 0.1f, 1f) : new(0.6f, 0.6f, 0.6f, 1), isVisible ? "Visible" : "Not Visible");
|
||||
ImGui.TextColored(isVisible ? new Vector4(0.1f, 1f, 0.1f, 1f) : new(0.6f, 0.6f, 0.6f, 1), isVisible ? "Visible" : "Not Visible");
|
||||
|
||||
ImGui.SameLine(ImGui.GetWindowWidth() - 100);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ public static class Events
|
|||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted($"{evt->State.StateFlags}");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted($"{evt->State.UnkFlags1}");
|
||||
ImGui.TextUnformatted($"{evt->State.ReturnFlags}");
|
||||
ImGui.TableNextColumn();
|
||||
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Target:X}", null, new Vector4(0.6f, 0.6f, 0.6f, 1));
|
||||
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Target:X}", default, new Vector4(0.6f, 0.6f, 0.6f, 1));
|
||||
ImGui.TableNextColumn();
|
||||
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Listener:X}", null, new Vector4(0.6f, 0.6f, 0.6f, 1));
|
||||
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Listener:X}", default, new Vector4(0.6f, 0.6f, 0.6f, 1));
|
||||
evt = evt->NextEvent;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ internal unsafe partial class TextNodeTree
|
|||
ImGui.Text("Font:");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.Combo($"##{(nint)this.Node:X}fontType", ref fontIndex, FontNames, FontList.Count))
|
||||
if (ImGui.Combo($"##{(nint)this.Node:X}fontType", ref fontIndex, FontNames))
|
||||
{
|
||||
this.TxtNode->FontType = FontList[fontIndex];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,13 +226,13 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
ImGui.TextColored(!hiRes ? new(1) : new(0.6f, 0.6f, 0.6f, 1), "Standard:\t");
|
||||
ImGui.TextColored(!hiRes ? new Vector4(1) : new(0.6f, 0.6f, 0.6f, 1), "Standard:\t");
|
||||
ImGui.SameLine();
|
||||
var cursX = ImGui.GetCursorPosX();
|
||||
|
||||
PrintPartCoords(u / 2f, v / 2f, width / 2f, height / 2f);
|
||||
|
||||
ImGui.TextColored(hiRes ? new(1) : new(0.6f, 0.6f, 0.6f, 1), "Hi-Res:\t");
|
||||
ImGui.TextColored(hiRes ? new Vector4(1) : new(0.6f, 0.6f, 0.6f, 1), "Hi-Res:\t");
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosX(cursX);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
|
@ -46,7 +47,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
|||
return;
|
||||
}
|
||||
|
||||
ImGui.TextColored(new(1), "Text:");
|
||||
ImGui.TextColored(new Vector4(1), "Text:");
|
||||
ImGui.SameLine();
|
||||
|
||||
try
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public readonly unsafe partial struct TimelineTree
|
|||
("Frame Time", $"{this.NodeTimeline->FrameTime:F2} ({this.NodeTimeline->FrameTime * 30:F0})"));
|
||||
|
||||
PrintFieldValuePairs(("Active Label Id", $"{this.NodeTimeline->ActiveLabelId}"), ("Duration", $"{this.NodeTimeline->LabelFrameIdxDuration}"), ("End Frame", $"{this.NodeTimeline->LabelEndFrameIdx}"));
|
||||
ImGui.TextColored(new(0.6f, 0.6f, 0.6f, 1), "Animation List");
|
||||
ImGui.TextColored(new Vector4(0.6f, 0.6f, 0.6f, 1), "Animation List");
|
||||
|
||||
for (var a = 0; a < animationCount; a++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ internal static class Gui
|
|||
var grey60 = new Vector4(0.6f, 0.6f, 0.6f, 1);
|
||||
if (copy)
|
||||
{
|
||||
ImGuiHelpers.ClickToCopyText(value, null, grey60);
|
||||
ImGuiHelpers.ClickToCopyText(value, default, grey60);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class BranchSwitcherWindow : Window
|
|||
var si = Service<Dalamud>.Get().StartInfo;
|
||||
|
||||
var itemsArray = this.branches.Select(x => x.Key).ToArray();
|
||||
ImGui.ListBox("Branch", ref this.selectedBranchIndex, itemsArray, itemsArray.Length);
|
||||
ImGui.ListBox("Branch", ref this.selectedBranchIndex, itemsArray);
|
||||
|
||||
var pickedBranch = this.branches.ElementAt(this.selectedBranchIndex);
|
||||
|
||||
|
|
|
|||
|
|
@ -835,11 +835,9 @@ internal class ConsoleWindow : Window, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private unsafe int CommandInputCallback(ImGuiInputTextCallbackData* data)
|
||||
private int CommandInputCallback(ref ImGuiInputTextCallbackData data)
|
||||
{
|
||||
var ptr = new ImGuiInputTextCallbackDataPtr(data);
|
||||
|
||||
switch (data->EventFlag)
|
||||
switch (data.EventFlag)
|
||||
{
|
||||
case ImGuiInputTextFlags.CallbackEdit:
|
||||
this.completionZipText = null;
|
||||
|
|
@ -847,9 +845,7 @@ internal class ConsoleWindow : Window, IDisposable
|
|||
break;
|
||||
|
||||
case ImGuiInputTextFlags.CallbackCompletion:
|
||||
var textBytes = new byte[data->BufTextLen];
|
||||
Marshal.Copy((IntPtr)data->Buf, textBytes, 0, data->BufTextLen);
|
||||
var text = Encoding.UTF8.GetString(textBytes);
|
||||
var text = Encoding.UTF8.GetString(data.BufTextSpan);
|
||||
|
||||
var words = text.Split();
|
||||
|
||||
|
|
@ -894,8 +890,8 @@ internal class ConsoleWindow : Window, IDisposable
|
|||
|
||||
if (toComplete != null)
|
||||
{
|
||||
ptr.DeleteChars(0, ptr.BufTextLen);
|
||||
ptr.InsertChars(0, toComplete);
|
||||
data.DeleteChars(0, data.BufTextLen);
|
||||
data.InsertChars(0, toComplete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -904,14 +900,14 @@ internal class ConsoleWindow : Window, IDisposable
|
|||
case ImGuiInputTextFlags.CallbackHistory:
|
||||
var prevPos = this.historyPos;
|
||||
|
||||
if (ptr.EventKey == ImGuiKey.UpArrow)
|
||||
if (data.EventKey == ImGuiKey.UpArrow)
|
||||
{
|
||||
if (this.historyPos == -1)
|
||||
this.historyPos = this.configuration.LogCommandHistory.Count - 1;
|
||||
else if (this.historyPos > 0)
|
||||
this.historyPos--;
|
||||
}
|
||||
else if (data->EventKey == ImGuiKey.DownArrow)
|
||||
else if (data.EventKey == ImGuiKey.DownArrow)
|
||||
{
|
||||
if (this.historyPos != -1)
|
||||
{
|
||||
|
|
@ -926,8 +922,8 @@ internal class ConsoleWindow : Window, IDisposable
|
|||
{
|
||||
var historyStr = this.historyPos >= 0 ? this.configuration.LogCommandHistory[this.historyPos] : string.Empty;
|
||||
|
||||
ptr.DeleteChars(0, ptr.BufTextLen);
|
||||
ptr.InsertChars(0, historyStr);
|
||||
data.DeleteChars(0, data.BufTextLen);
|
||||
data.InsertChars(0, historyStr);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ internal static class DataWindowWidgetExtensions
|
|||
{
|
||||
ImGui.SetClipboardText(s);
|
||||
Service<NotificationManager>.Get().AddNotification(
|
||||
$"Copied {ImGui.TableGetColumnNameS()} to clipboard.",
|
||||
$"Copied {ImGui.TableGetColumnName()} to clipboard.",
|
||||
widget.DisplayName,
|
||||
NotificationType.Success);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,23 +120,13 @@ internal class DataShareWidget : IDataWindowWidget
|
|||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Copy"))
|
||||
{
|
||||
fixed (byte* pData = data)
|
||||
ImGui.SetClipboardText(pData);
|
||||
}
|
||||
ImGui.SetClipboardText(data);
|
||||
|
||||
fixed (byte* pLabel = "text"u8)
|
||||
fixed (byte* pData = data)
|
||||
{
|
||||
ImGui.InputTextMultiline(
|
||||
pLabel,
|
||||
pData,
|
||||
(uint)data.Length,
|
||||
ImGui.GetContentRegionAvail(),
|
||||
ImGuiInputTextFlags.ReadOnly,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
ImGui.InputTextMultiline(
|
||||
"text"u8,
|
||||
data,
|
||||
ImGui.GetContentRegionAvail(),
|
||||
ImGuiInputTextFlags.ReadOnly);
|
||||
}
|
||||
|
||||
this.nextTab = -1;
|
||||
|
|
@ -243,7 +233,7 @@ internal class DataShareWidget : IDataWindowWidget
|
|||
{
|
||||
ImGui.SetClipboardText(tooltip?.Invoke() ?? s);
|
||||
Service<NotificationManager>.Get().AddNotification(
|
||||
$"Copied {ImGui.TableGetColumnNameS()} to clipboard.",
|
||||
$"Copied {ImGui.TableGetColumnName()} to clipboard.",
|
||||
this.DisplayName,
|
||||
NotificationType.Success);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
|
|||
|
||||
ImGui.SetNextItemWidth(160f);
|
||||
var categoryIndex = this.selectedIconCategory;
|
||||
if (ImGui.Combo("####FontAwesomeCategorySearch", ref categoryIndex, this.iconCategories, this.iconCategories.Length))
|
||||
if (ImGui.Combo("####FontAwesomeCategorySearch", ref categoryIndex, this.iconCategories))
|
||||
{
|
||||
this.selectedIconCategory = categoryIndex;
|
||||
this.iconSearchChanged = true;
|
||||
|
|
|
|||
|
|
@ -61,58 +61,25 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
|
|||
public unsafe void Draw()
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
if (ImGui.Combo("Global Scale per Font", ref this.fontScaleMode, FontScaleModes, FontScaleModes.Length))
|
||||
if (ImGui.Combo("Global Scale per Font"u8, ref this.fontScaleMode, FontScaleModes))
|
||||
this.ClearAtlas();
|
||||
if (ImGui.Checkbox("Global Scale for Atlas"u8, ref this.atlasScaleMode))
|
||||
this.ClearAtlas();
|
||||
fixed (byte* labelPtr = "Global Scale for Atlas"u8)
|
||||
{
|
||||
var v = this.atlasScaleMode;
|
||||
if (ImGui.Checkbox(labelPtr, ref v))
|
||||
{
|
||||
this.atlasScaleMode = v;
|
||||
this.ClearAtlas();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
fixed (byte* labelPtr = "Word Wrap"u8)
|
||||
{
|
||||
var v = this.useWordWrap;
|
||||
if (ImGui.Checkbox(labelPtr, &v))
|
||||
this.useWordWrap = v;
|
||||
}
|
||||
ImGui.Checkbox("Word Wrap"u8, ref this.useWordWrap);
|
||||
|
||||
ImGui.SameLine();
|
||||
fixed (byte* labelPtr = "Italic"u8)
|
||||
{
|
||||
var v = this.useItalic;
|
||||
if (ImGui.Checkbox(labelPtr, &v))
|
||||
{
|
||||
this.useItalic = v;
|
||||
this.ClearAtlas();
|
||||
}
|
||||
}
|
||||
if (ImGui.Checkbox("Italic"u8, ref this.useItalic))
|
||||
this.ClearAtlas();
|
||||
|
||||
ImGui.SameLine();
|
||||
fixed (byte* labelPtr = "Bold"u8)
|
||||
{
|
||||
var v = this.useBold;
|
||||
if (ImGui.Checkbox(labelPtr, &v))
|
||||
{
|
||||
this.useBold = v;
|
||||
this.ClearAtlas();
|
||||
}
|
||||
}
|
||||
if (ImGui.Checkbox("Bold"u8, ref this.useBold))
|
||||
this.ClearAtlas();
|
||||
|
||||
ImGui.SameLine();
|
||||
fixed (byte* labelPtr = "Minimum Range"u8)
|
||||
{
|
||||
var v = this.useMinimumBuild;
|
||||
if (ImGui.Checkbox(labelPtr, &v))
|
||||
{
|
||||
this.useMinimumBuild = v;
|
||||
this.ClearAtlas();
|
||||
}
|
||||
}
|
||||
if (ImGui.Checkbox("Minimum Range"u8, ref this.useMinimumBuild))
|
||||
this.ClearAtlas();
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Reset Text") || this.testStringBuffer.IsDisposed)
|
||||
|
|
@ -215,12 +182,8 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
|
|||
{
|
||||
if (ImGui.InputTextMultiline(
|
||||
labelPtr,
|
||||
this.testStringBuffer.Data,
|
||||
(uint)this.testStringBuffer.Capacity,
|
||||
new(ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight() * 3),
|
||||
0,
|
||||
null,
|
||||
null))
|
||||
this.testStringBuffer.StorageSpan,
|
||||
new(ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight() * 3)))
|
||||
{
|
||||
var len = this.testStringBuffer.StorageSpan.IndexOf((byte)0);
|
||||
if (len + 4 >= this.testStringBuffer.Capacity)
|
||||
|
|
@ -293,8 +256,7 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
|
|||
}
|
||||
else if (!handle.Value.Available)
|
||||
{
|
||||
fixed (byte* labelPtr = "Loading..."u8)
|
||||
ImGui.TextUnformatted(labelPtr, labelPtr + 8 + ((Environment.TickCount / 200) % 3));
|
||||
ImGui.TextUnformatted("Loading..."u8[..(8 + ((Environment.TickCount / 200) % 3))]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -303,16 +265,12 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
|
|||
if (counter++ % 2 == 0)
|
||||
{
|
||||
using var pushPop = handle.Value.Push();
|
||||
ImGui.TextUnformatted(
|
||||
this.testStringBuffer.Data,
|
||||
this.testStringBuffer.Data + this.testStringBuffer.Length);
|
||||
ImGui.TextUnformatted(this.testStringBuffer.DataSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle.Value.Push();
|
||||
ImGui.TextUnformatted(
|
||||
this.testStringBuffer.Data,
|
||||
this.testStringBuffer.Data + this.testStringBuffer.Length);
|
||||
ImGui.TextUnformatted(this.testStringBuffer.DataSpan);
|
||||
handle.Value.Pop();
|
||||
}
|
||||
}
|
||||
|
|
@ -379,12 +337,9 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
|
|||
|
||||
return;
|
||||
|
||||
unsafe void TestSingle(ImFontPtr fontPtr, IFontHandle handle)
|
||||
void TestSingle(ImFontPtr fontPtr, IFontHandle handle)
|
||||
{
|
||||
var dim = default(Vector2);
|
||||
var test = "Test string"u8;
|
||||
fixed (byte* pTest = test)
|
||||
ImGui.CalcTextSizeA(ref dim, fontPtr, fontPtr.FontSize, float.MaxValue, 0f, pTest, (string)null, null);
|
||||
var dim = ImGui.CalcTextSizeA(fontPtr, fontPtr.FontSize, float.MaxValue, 0f, "Test string"u8, out _);
|
||||
Log.Information($"{nameof(GamePrebakedFontsTestWidget)}: {handle} => {dim}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,17 +73,9 @@ internal class ImGuiWidget : IDataWindowWidget
|
|||
|
||||
ImGui.Checkbox("##manualType", ref this.notificationTemplate.ManualType);
|
||||
ImGui.SameLine();
|
||||
ImGui.Combo(
|
||||
"Type##type",
|
||||
ref this.notificationTemplate.TypeInt,
|
||||
NotificationTemplate.TypeTitles,
|
||||
NotificationTemplate.TypeTitles.Length);
|
||||
ImGui.Combo("Type##type", ref this.notificationTemplate.TypeInt, NotificationTemplate.TypeTitles);
|
||||
|
||||
ImGui.Combo(
|
||||
"Icon##iconCombo",
|
||||
ref this.notificationTemplate.IconInt,
|
||||
NotificationTemplate.IconTitles,
|
||||
NotificationTemplate.IconTitles.Length);
|
||||
ImGui.Combo("Icon##iconCombo", ref this.notificationTemplate.IconInt, NotificationTemplate.IconTitles);
|
||||
switch (this.notificationTemplate.IconInt)
|
||||
{
|
||||
case 1 or 2:
|
||||
|
|
@ -96,8 +88,7 @@ internal class ImGuiWidget : IDataWindowWidget
|
|||
ImGui.Combo(
|
||||
"Asset##iconAssetCombo",
|
||||
ref this.notificationTemplate.IconAssetInt,
|
||||
NotificationTemplate.AssetSources,
|
||||
NotificationTemplate.AssetSources.Length);
|
||||
NotificationTemplate.AssetSources);
|
||||
break;
|
||||
case 3 or 7:
|
||||
ImGui.InputText(
|
||||
|
|
@ -116,20 +107,17 @@ internal class ImGuiWidget : IDataWindowWidget
|
|||
ImGui.Combo(
|
||||
"Initial Duration",
|
||||
ref this.notificationTemplate.InitialDurationInt,
|
||||
NotificationTemplate.InitialDurationTitles,
|
||||
NotificationTemplate.InitialDurationTitles.Length);
|
||||
NotificationTemplate.InitialDurationTitles);
|
||||
|
||||
ImGui.Combo(
|
||||
"Extension Duration",
|
||||
ref this.notificationTemplate.HoverExtendDurationInt,
|
||||
NotificationTemplate.HoverExtendDurationTitles,
|
||||
NotificationTemplate.HoverExtendDurationTitles.Length);
|
||||
NotificationTemplate.HoverExtendDurationTitles);
|
||||
|
||||
ImGui.Combo(
|
||||
"Progress",
|
||||
ref this.notificationTemplate.ProgressMode,
|
||||
NotificationTemplate.ProgressModeTitles,
|
||||
NotificationTemplate.ProgressModeTitles.Length);
|
||||
NotificationTemplate.ProgressModeTitles);
|
||||
|
||||
ImGui.Checkbox("Respect UI Hidden", ref this.notificationTemplate.RespectUiHidden);
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ internal class NounProcessorWidget : IDataWindowWidget
|
|||
var language = this.languages[this.selectedLanguageIndex];
|
||||
|
||||
ImGui.SetNextItemWidth(300);
|
||||
if (ImGui.Combo("###SelectedSheetName", ref this.selectedSheetNameIndex, NounSheets.Select(t => t.Name).ToArray(), NounSheets.Length))
|
||||
if (ImGui.Combo("###SelectedSheetName", ref this.selectedSheetNameIndex, NounSheets.Select(t => t.Name).ToArray()))
|
||||
{
|
||||
this.rowId = 1;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ internal class NounProcessorWidget : IDataWindowWidget
|
|||
ImGui.SameLine();
|
||||
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.Combo("###SelectedLanguage", ref this.selectedLanguageIndex, this.languageNames, this.languageNames.Length))
|
||||
if (ImGui.Combo("###SelectedLanguage", ref this.selectedLanguageIndex, this.languageNames))
|
||||
{
|
||||
language = this.languages[this.selectedLanguageIndex];
|
||||
this.rowId = 1;
|
||||
|
|
@ -107,7 +107,7 @@ internal class NounProcessorWidget : IDataWindowWidget
|
|||
var sheet = dataManager.Excel.GetSheet<RawRow>(Language.English, sheetType.Name);
|
||||
var minRowId = (int)sheet.FirstOrDefault().RowId;
|
||||
var maxRowId = (int)sheet.LastOrDefault().RowId;
|
||||
if (ImGui.InputInt("RowId###RowId", ref this.rowId, 1, 10, ImGuiInputTextFlags.AutoSelectAll))
|
||||
if (ImGui.InputInt("RowId###RowId", ref this.rowId, 1, 10, flags: ImGuiInputTextFlags.AutoSelectAll))
|
||||
{
|
||||
if (this.rowId < minRowId)
|
||||
this.rowId = minRowId;
|
||||
|
|
@ -120,7 +120,7 @@ internal class NounProcessorWidget : IDataWindowWidget
|
|||
ImGui.TextUnformatted($"(Range: {minRowId} - {maxRowId})");
|
||||
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Amount###Amount", ref this.amount, 1, 10, ImGuiInputTextFlags.AutoSelectAll))
|
||||
if (ImGui.InputInt("Amount###Amount", ref this.amount, 1, 10, flags: ImGuiInputTextFlags.AutoSelectAll))
|
||||
{
|
||||
if (this.amount <= 0)
|
||||
this.amount = 1;
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ internal class SeStringCreatorWidget : IDataWindowWidget
|
|||
}
|
||||
}).OrderBy(sheetName => sheetName, StringComparer.InvariantCulture).ToArray();
|
||||
|
||||
var sheetChanged = ImGui.Combo("Sheet Name", ref this.importSelectedSheetName, this.validImportSheetNames, this.validImportSheetNames.Length);
|
||||
var sheetChanged = ImGui.Combo("Sheet Name", ref this.importSelectedSheetName, this.validImportSheetNames);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -683,7 +683,7 @@ internal class SeStringCreatorWidget : IDataWindowWidget
|
|||
ImGui.TableNextColumn(); // Type
|
||||
var type = (int)entry.Type;
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.Combo($"##Type{i}", ref type, ["String", "Macro", "Fixed"], 3))
|
||||
if (ImGui.Combo($"##Type{i}", ref type, ["String", "Macro", "Fixed"]))
|
||||
{
|
||||
entry.Type = (TextEntryType)type;
|
||||
updateString |= true;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
|||
ImGui.SameLine();
|
||||
var t4 = this.style.ThemeIndex ?? AtkStage.Instance()->AtkUIColorHolder->ActiveColorThemeType;
|
||||
ImGui.PushItemWidth(ImGui.CalcTextSize("WWWWWWWWWWWWWW").X);
|
||||
if (ImGui.Combo("##theme", ref t4, ThemeNames, ThemeNames.Length))
|
||||
if (ImGui.Combo("##theme", ref t4, ThemeNames))
|
||||
this.style.ThemeIndex = t4;
|
||||
|
||||
ImGui.SameLine();
|
||||
|
|
@ -265,12 +265,8 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
|||
{
|
||||
if (ImGui.InputTextMultiline(
|
||||
labelPtr,
|
||||
this.testStringBuffer.Data,
|
||||
(uint)this.testStringBuffer.Capacity,
|
||||
new(ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight() * 3),
|
||||
0,
|
||||
null,
|
||||
null))
|
||||
this.testStringBuffer.StorageSpan,
|
||||
new(ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight() * 3)))
|
||||
{
|
||||
var len = this.testStringBuffer.StorageSpan.IndexOf((byte)0);
|
||||
if (len + 4 >= this.testStringBuffer.Capacity)
|
||||
|
|
@ -278,7 +274,7 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
|||
if (len < this.testStringBuffer.Capacity)
|
||||
{
|
||||
this.testStringBuffer.LengthUnsafe = len;
|
||||
this.testStringBuffer.StorageSpan[len] = default;
|
||||
this.testStringBuffer.StorageSpan[len] = 0;
|
||||
}
|
||||
|
||||
this.testString = string.Empty;
|
||||
|
|
|
|||
|
|
@ -243,8 +243,8 @@ internal class TaskSchedulerWidget : IDataWindowWidget
|
|||
|
||||
if (ImGui.CollapsingHeader("Download"))
|
||||
{
|
||||
ImGui.InputText("URL", ref this.url, (uint)this.url.Length);
|
||||
ImGui.InputText("Local Path", ref this.localPath, (uint)this.localPath.Length);
|
||||
ImGui.InputText("URL", ref this.url);
|
||||
ImGui.InputText("Local Path", ref this.localPath);
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGuiComponents.IconButton("##localpathpicker", FontAwesomeIcon.File))
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ internal class TexWidget : IDataWindowWidget
|
|||
|
||||
private enum DrawBlameTableColumnUserId
|
||||
{
|
||||
NativeAddress,
|
||||
NativeAddress = 1,
|
||||
Actions,
|
||||
Name,
|
||||
Width,
|
||||
|
|
@ -231,7 +231,7 @@ internal class TexWidget : IDataWindowWidget
|
|||
ImGui.PopID();
|
||||
}
|
||||
|
||||
if (ImGui.CollapsingHeader($"CropCopy##{this.DrawExistingTextureModificationArgs}"))
|
||||
if (ImGui.CollapsingHeader($"CropCopy##{nameof(this.DrawExistingTextureModificationArgs)}"))
|
||||
{
|
||||
ImGui.PushID(nameof(this.DrawExistingTextureModificationArgs));
|
||||
this.DrawExistingTextureModificationArgs();
|
||||
|
|
@ -709,8 +709,7 @@ internal class TexWidget : IDataWindowWidget
|
|||
if (ImGui.Combo(
|
||||
"Assembly",
|
||||
ref this.inputManifestResourceAssemblyIndex,
|
||||
this.inputManifestResourceAssemblyCandidateNames,
|
||||
this.inputManifestResourceAssemblyCandidateNames.Length))
|
||||
this.inputManifestResourceAssemblyCandidateNames))
|
||||
{
|
||||
this.inputManifestResourceNameIndex = 0;
|
||||
this.inputManifestResourceNameCandidates = null;
|
||||
|
|
@ -727,8 +726,7 @@ internal class TexWidget : IDataWindowWidget
|
|||
ImGui.Combo(
|
||||
"Name",
|
||||
ref this.inputManifestResourceNameIndex,
|
||||
this.inputManifestResourceNameCandidates,
|
||||
this.inputManifestResourceNameCandidates.Length);
|
||||
this.inputManifestResourceNameCandidates);
|
||||
|
||||
var name =
|
||||
this.inputManifestResourceNameIndex >= 0
|
||||
|
|
@ -844,15 +842,14 @@ internal class TexWidget : IDataWindowWidget
|
|||
ImGui.Combo(
|
||||
nameof(this.textureModificationArgs.DxgiFormat),
|
||||
ref this.renderTargetChoiceInt,
|
||||
this.supportedRenderTargetFormatNames,
|
||||
this.supportedRenderTargetFormatNames.Length);
|
||||
this.supportedRenderTargetFormatNames);
|
||||
|
||||
Span<int> wh = stackalloc int[2];
|
||||
wh[0] = this.textureModificationArgs.NewWidth;
|
||||
wh[1] = this.textureModificationArgs.NewHeight;
|
||||
if (ImGui.InputInt2(
|
||||
if (ImGui.InputInt(
|
||||
$"{nameof(this.textureModificationArgs.NewWidth)}/{nameof(this.textureModificationArgs.NewHeight)}",
|
||||
ref wh[0]))
|
||||
wh))
|
||||
{
|
||||
this.textureModificationArgs.NewWidth = wh[0];
|
||||
this.textureModificationArgs.NewHeight = wh[1];
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ internal class ToastWidget : IDataWindowWidget
|
|||
|
||||
ImGui.InputText("Toast text", ref this.inputTextToast, 200);
|
||||
|
||||
ImGui.Combo("Toast Position", ref this.toastPosition, new[] { "Bottom", "Top", }, 2);
|
||||
ImGui.Combo("Toast Speed", ref this.toastSpeed, new[] { "Slow", "Fast", }, 2);
|
||||
ImGui.Combo("Quest Toast Position", ref this.questToastPosition, new[] { "Centre", "Right", "Left" }, 3);
|
||||
ImGui.Combo("Toast Position", ref this.toastPosition, ["Bottom", "Top"]);
|
||||
ImGui.Combo("Toast Speed", ref this.toastSpeed, ["Slow", "Fast"]);
|
||||
ImGui.Combo("Quest Toast Position", ref this.questToastPosition, ["Centre", "Right", "Left"]);
|
||||
ImGui.Checkbox("Quest Checkmark", ref this.questToastCheckmark);
|
||||
ImGui.Checkbox("Quest Play Sound", ref this.questToastSound);
|
||||
ImGui.InputInt("Quest Icon ID", ref this.questToastIconId);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ internal class UldWidget : IDataWindowWidget
|
|||
}
|
||||
|
||||
var selectedUldPrev = this.selectedUld;
|
||||
ImGui.Combo("##selectUld", ref this.selectedUld, uldNames, uldNames.Length);
|
||||
ImGui.Combo("##selectUld", ref this.selectedUld, uldNames);
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton("selectUldLeft", FontAwesomeIcon.AngleLeft))
|
||||
this.selectedUld = ((this.selectedUld + uldNames.Length) - 1) % uldNames.Length;
|
||||
|
|
@ -117,7 +117,7 @@ internal class UldWidget : IDataWindowWidget
|
|||
ClearTask(ref this.selectedUldFileTask);
|
||||
}
|
||||
|
||||
ImGui.Combo("##selectTheme", ref this.selectedTheme, ThemeDisplayNames, ThemeDisplayNames.Length);
|
||||
ImGui.Combo("##selectTheme", ref this.selectedTheme, ThemeDisplayNames);
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton("selectThemeLeft", FontAwesomeIcon.AngleLeft))
|
||||
this.selectedTheme = ((this.selectedTheme + ThemeDisplayNames.Length) - 1) % ThemeDisplayNames.Length;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ internal class ProfileManagerWidget
|
|||
{
|
||||
try
|
||||
{
|
||||
profman.ImportProfile(ImGui.GetClipboardTextS());
|
||||
profman.ImportProfile(ImGui.GetClipboardText());
|
||||
Service<NotificationManager>.Get().AddNotification(Locs.NotificationImportSuccess, type: NotificationType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -210,7 +210,8 @@ public class SettingsTabLook : SettingsTab
|
|||
var len = Encoding.UTF8.GetByteCount(buildingFonts);
|
||||
var p = stackalloc byte[len];
|
||||
Encoding.UTF8.GetBytes(buildingFonts, new(p, len));
|
||||
ImGui.TextUnformatted(p, (p + len + ((Environment.TickCount / 200) % 3)) - 2);
|
||||
ImGui.TextUnformatted(
|
||||
new ReadOnlySpan<byte>(p, len)[..((len + ((Environment.TickCount / 200) % 3)) - 2)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public sealed class LanguageChooserSettingsEntry : SettingsEntry
|
|||
public override void Draw()
|
||||
{
|
||||
ImGui.Text(this.Name);
|
||||
ImGui.Combo("##XlLangCombo", ref this.langIndex, this.locLanguages, this.locLanguages.Length);
|
||||
ImGui.Combo("##XlLangCombo", ref this.langIndex, this.locLanguages);
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsLanguageHint", "Select the language Dalamud will be displayed in."));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class StyleEditorWindow : Window
|
|||
|
||||
var styleAry = config.SavedStyles.Select(x => x.Name).ToArray();
|
||||
ImGui.Text(Loc.Localize("StyleEditorChooseStyle", "Choose Style:"));
|
||||
if (ImGui.Combo("###styleChooserCombo", ref this.currentSel, styleAry, styleAry.Length))
|
||||
if (ImGui.Combo("###styleChooserCombo", ref this.currentSel, styleAry))
|
||||
{
|
||||
var newStyle = config.SavedStyles[this.currentSel];
|
||||
newStyle.Apply();
|
||||
|
|
@ -166,7 +166,7 @@ public class StyleEditorWindow : Window
|
|||
{
|
||||
this.SaveStyle();
|
||||
|
||||
var styleJson = ImGui.GetClipboardTextS();
|
||||
var styleJson = ImGui.GetClipboardText();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -245,7 +245,7 @@ public class StyleEditorWindow : Window
|
|||
ImGui.Text("Alignment");
|
||||
ImGui.SliderFloat2("WindowTitleAlign", ref style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
|
||||
var windowMenuButtonPosition = (int)style.WindowMenuButtonPosition + 1;
|
||||
if (ImGui.Combo("WindowMenuButtonPosition", ref windowMenuButtonPosition, "None\0Left\0Right\0"))
|
||||
if (ImGui.Combo("WindowMenuButtonPosition", ref windowMenuButtonPosition, ["None", "Left", "Right"]))
|
||||
style.WindowMenuButtonPosition = (ImGuiDir)(windowMenuButtonPosition - 1);
|
||||
ImGui.SliderFloat2("ButtonTextAlign", ref style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
|
||||
ImGui.SameLine();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public interface IDrawListTextureWrap : IDalamudTextureWrap
|
|||
|
||||
/// <summary>Resizes this texture and draws an ImGui window.</summary>
|
||||
/// <param name="windowName">Name and ID of the window to draw. Use the value that goes into
|
||||
/// <see cref="ImGui.Begin(string)"/>.</param>
|
||||
/// <see cref="ImGui.Begin(ImU8String, ImGuiWindowFlags)"/>.</param>
|
||||
/// <param name="scale">Scale to apply to all draw commands in the draw list.</param>
|
||||
void ResizeAndDrawWindow(ReadOnlySpan<char> windowName, Vector2 scale);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
|
|
@ -15,13 +10,13 @@ internal sealed unsafe partial class DrawListTextureWrap
|
|||
/// <inheritdoc/>
|
||||
public void ResizeAndDrawWindow(ReadOnlySpan<char> windowName, Vector2 scale)
|
||||
{
|
||||
ref var window = ref ImGuiWindow.FindWindowByName(windowName);
|
||||
if (Unsafe.IsNullRef(ref window))
|
||||
var window = ImGuiP.FindWindowByName(windowName);
|
||||
if (window.IsNull)
|
||||
throw new ArgumentException("Window not found", nameof(windowName));
|
||||
|
||||
this.Size = window.Size;
|
||||
|
||||
var numDrawList = CountDrawList(ref window);
|
||||
var numDrawList = CountDrawList(window);
|
||||
var drawLists = stackalloc ImDrawList*[numDrawList];
|
||||
var drawData = new ImDrawData
|
||||
{
|
||||
|
|
@ -34,7 +29,7 @@ internal sealed unsafe partial class DrawListTextureWrap
|
|||
DisplaySize = window.Size,
|
||||
FramebufferScale = scale,
|
||||
};
|
||||
AddWindowToDrawData(ref window, ref drawLists);
|
||||
AddWindowToDrawData(window, ref drawLists);
|
||||
for (var i = 0; i < numDrawList; i++)
|
||||
{
|
||||
drawData.TotalVtxCount += drawData.CmdLists[i]->VtxBuffer.Size;
|
||||
|
|
@ -45,10 +40,9 @@ internal sealed unsafe partial class DrawListTextureWrap
|
|||
|
||||
return;
|
||||
|
||||
static bool IsWindowActiveAndVisible(scoped in ImGuiWindow window) =>
|
||||
window.Active != 0 && window.Hidden == 0;
|
||||
static bool IsWindowActiveAndVisible(ImGuiWindowPtr window) => window is { Active: true, Hidden: false };
|
||||
|
||||
static void AddWindowToDrawData(scoped ref ImGuiWindow window, ref ImDrawList** wptr)
|
||||
static void AddWindowToDrawData(ImGuiWindowPtr window, ref ImDrawList** wptr)
|
||||
{
|
||||
switch (window.DrawList.CmdBuffer.Size)
|
||||
{
|
||||
|
|
@ -63,13 +57,13 @@ internal sealed unsafe partial class DrawListTextureWrap
|
|||
|
||||
for (var i = 0; i < window.DC.ChildWindows.Size; i++)
|
||||
{
|
||||
ref var child = ref *(ImGuiWindow*)window.DC.ChildWindows[i];
|
||||
if (IsWindowActiveAndVisible(in child)) // Clipped children may have been marked not active
|
||||
AddWindowToDrawData(ref child, ref wptr);
|
||||
var child = window.DC.ChildWindows[i];
|
||||
if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active
|
||||
AddWindowToDrawData(child, ref wptr);
|
||||
}
|
||||
}
|
||||
|
||||
static int CountDrawList(scoped ref ImGuiWindow window)
|
||||
static int CountDrawList(ImGuiWindowPtr window)
|
||||
{
|
||||
var res = window.DrawList.CmdBuffer.Size switch
|
||||
{
|
||||
|
|
@ -79,51 +73,8 @@ internal sealed unsafe partial class DrawListTextureWrap
|
|||
_ => 1,
|
||||
};
|
||||
for (var i = 0; i < window.DC.ChildWindows.Size; i++)
|
||||
res += CountDrawList(ref *(ImGuiWindow*)window.DC.ChildWindows[i]);
|
||||
res += CountDrawList(window.DC.ChildWindows[i]);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x448)]
|
||||
private struct ImGuiWindow
|
||||
{
|
||||
[FieldOffset(0x048)]
|
||||
public Vector2 Pos;
|
||||
|
||||
[FieldOffset(0x050)]
|
||||
public Vector2 Size;
|
||||
|
||||
[FieldOffset(0x0CB)]
|
||||
public byte Active;
|
||||
|
||||
[FieldOffset(0x0D2)]
|
||||
public byte Hidden;
|
||||
|
||||
[FieldOffset(0x118)]
|
||||
public ImGuiWindowTempData DC;
|
||||
|
||||
[FieldOffset(0x2C0)]
|
||||
public ImDrawListPtr DrawList;
|
||||
|
||||
[DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)]
|
||||
#pragma warning disable SA1300
|
||||
public static extern ImGuiWindow* igCustom_FindWindowByName(byte* inherit);
|
||||
#pragma warning restore SA1300
|
||||
|
||||
public static ref ImGuiWindow FindWindowByName(ReadOnlySpan<char> name)
|
||||
{
|
||||
var nb = Encoding.UTF8.GetByteCount(name);
|
||||
var buf = stackalloc byte[nb + 1];
|
||||
buf[Encoding.UTF8.GetBytes(name, new(buf, nb))] = 0;
|
||||
|
||||
return ref *igCustom_FindWindowByName(buf);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0xF0)]
|
||||
public struct ImGuiWindowTempData
|
||||
{
|
||||
[FieldOffset(0x98)]
|
||||
public ImVector<nint> ChildWindows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ internal sealed unsafe class UnknownTextureWrap : IDalamudTextureWrap, IDeferred
|
|||
|
||||
/// <summary>Initializes a new instance of the <see cref="UnknownTextureWrap"/> class.</summary>
|
||||
/// <param name="unknown">The pointer to <see cref="IUnknown"/> that is suitable for use with
|
||||
/// <see cref="IDalamudTextureWrap.ImGuiHandle"/>.</param>
|
||||
/// <see cref="IDalamudTextureWrap.Handle"/>.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="callAddRef">If <c>true</c>, call <see cref="IUnknown.AddRef"/>.</param>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,14 @@ public static class ImGuiExtensions
|
|||
if (needClipping)
|
||||
{
|
||||
var fineClipRect = new Vector4(clipMin.X, clipMin.Y, clipMax.X, clipMax.Y);
|
||||
drawListPtr.AddText(ImGui.GetFont(), ImGui.GetFontSize(), pos, ImGui.GetColorU32(ImGuiCol.Text), text, ref fineClipRect);
|
||||
drawListPtr.AddText(
|
||||
ImGui.GetFont(),
|
||||
ImGui.GetFontSize(),
|
||||
pos,
|
||||
ImGui.GetColorU32(ImGuiCol.Text),
|
||||
text,
|
||||
0,
|
||||
fineClipRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -136,11 +136,7 @@ public static partial class ImGuiHelpers
|
|||
/// <param name="name">The name/ID of the window.</param>
|
||||
/// <param name="position">The position of the window.</param>
|
||||
/// <param name="condition">When to set the position.</param>
|
||||
public static void SetWindowPosRelativeMainViewport(string name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
|
||||
=> ImGui.SetWindowPos(name, position + MainViewport.Pos, condition);
|
||||
|
||||
/// <inheritdoc cref="SetWindowPosRelativeMainViewport(string, Vector2, ImGuiCond)"/>
|
||||
public static void SetWindowPosRelativeMainViewport(ReadOnlySpan<byte> name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
|
||||
public static void SetWindowPosRelativeMainViewport(ImU8String name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
|
||||
=> ImGui.SetWindowPos(name, position + MainViewport.Pos, condition);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -166,11 +162,7 @@ public static partial class ImGuiHelpers
|
|||
/// </summary>
|
||||
/// <param name="text">Text in the button.</param>
|
||||
/// <returns><see cref="Vector2"/> with the size of the button.</returns>
|
||||
public static Vector2 GetButtonSize(string text)
|
||||
=> ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
|
||||
|
||||
/// <inheritdoc cref="GetButtonSize(string)"/>
|
||||
public static Vector2 GetButtonSize(ReadOnlySpan<byte> text)
|
||||
public static Vector2 GetButtonSize(ImU8String text)
|
||||
=> ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -179,11 +171,8 @@ public static partial class ImGuiHelpers
|
|||
/// <param name="text">The text to show.</param>
|
||||
/// <param name="textCopy">The text to copy when clicked.</param>
|
||||
/// <param name="color">The color of the text.</param>
|
||||
public static void ClickToCopyText(string text, string? textCopy = null, Vector4? color = null)
|
||||
public static void ClickToCopyText(ImU8String text, ImU8String textCopy = default, Vector4? color = null)
|
||||
{
|
||||
text ??= string.Empty;
|
||||
textCopy ??= text;
|
||||
|
||||
using (var col = new ImRaii.Color())
|
||||
{
|
||||
if (color.HasValue)
|
||||
|
|
@ -191,7 +180,7 @@ public static partial class ImGuiHelpers
|
|||
col.Push(ImGuiCol.Text, color.Value);
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(text);
|
||||
ImGui.TextUnformatted(text.Span);
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
|
|
@ -206,52 +195,17 @@ public static partial class ImGuiHelpers
|
|||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(textCopy);
|
||||
ImGui.TextUnformatted(textCopy.IsNull ? text.Span : textCopy.Span);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
ImGui.SetClipboardText(textCopy);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ClickToCopyText(string, string?, Vector4?)"/>
|
||||
public static void ClickToCopyText(ReadOnlySpan<byte> text, ReadOnlySpan<byte> textCopy = default, Vector4? color = null)
|
||||
{
|
||||
if (textCopy.IsEmpty)
|
||||
textCopy = text;
|
||||
|
||||
using (var col = new ImRaii.Color())
|
||||
{
|
||||
if (color.HasValue)
|
||||
{
|
||||
col.Push(ImGuiCol.Text, color.Value);
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(text);
|
||||
ImGui.SetClipboardText(textCopy.IsNull ? text.Span : textCopy.Span);
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
|
||||
using (ImRaii.Tooltip())
|
||||
{
|
||||
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||
{
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.Copy.ToIconString());
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(textCopy);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
ImGui.SetClipboardText(textCopy);
|
||||
}
|
||||
text.Dispose();
|
||||
textCopy.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>Draws a SeString.</summary>
|
||||
|
|
@ -285,32 +239,14 @@ public static partial class ImGuiHelpers
|
|||
/// Write unformatted text wrapped.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to write.</param>
|
||||
public static void SafeTextWrapped(string text) => ImGui.TextWrapped(text.Replace("%", "%%"));
|
||||
|
||||
/// <inheritdoc cref="SafeTextWrapped(string)"/>
|
||||
public static void SafeTextWrapped(ReadOnlySpan<byte> text)
|
||||
{
|
||||
if (text.Contains((byte)'%'))
|
||||
ImGui.TextWrapped(Encoding.UTF8.GetString(text).Replace("%", "%%"));
|
||||
else
|
||||
ImGui.TextWrapped(text);
|
||||
}
|
||||
public static void SafeTextWrapped(ImU8String text) => ImGui.TextWrapped(text);
|
||||
|
||||
/// <summary>
|
||||
/// Write unformatted text wrapped.
|
||||
/// </summary>
|
||||
/// <param name="color">The color of the text.</param>
|
||||
/// <param name="text">The text to write.</param>
|
||||
public static void SafeTextColoredWrapped(Vector4 color, string text)
|
||||
{
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, color))
|
||||
{
|
||||
SafeTextWrapped(text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="SafeTextColoredWrapped(Vector4, string)"/>
|
||||
public static void SafeTextColoredWrapped(Vector4 color, ReadOnlySpan<byte> text)
|
||||
public static void SafeTextColoredWrapped(Vector4 color, ImU8String text)
|
||||
{
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, color))
|
||||
{
|
||||
|
|
@ -510,16 +446,9 @@ public static partial class ImGuiHelpers
|
|||
/// Show centered text.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to show.</param>
|
||||
public static void CenteredText(string text)
|
||||
public static void CenteredText(ImU8String text)
|
||||
{
|
||||
CenterCursorForText(text);
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="CenteredText(string)"/>
|
||||
public static void CenteredText(ReadOnlySpan<byte> text)
|
||||
{
|
||||
CenterCursorForText(text);
|
||||
CenterCursorForText(text.Span);
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
|
||||
|
|
@ -527,11 +456,7 @@ public static partial class ImGuiHelpers
|
|||
/// Center the ImGui cursor for a certain text.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to center for.</param>
|
||||
public static void CenterCursorForText(string text)
|
||||
=> CenterCursorFor(ImGui.CalcTextSize(text).X);
|
||||
|
||||
/// <inheritdoc cref="CenterCursorForText(string)"/>
|
||||
public static void CenterCursorForText(ReadOnlySpan<byte> text)
|
||||
public static void CenterCursorForText(ImU8String text)
|
||||
=> CenterCursorFor(ImGui.CalcTextSize(text).X);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -666,17 +591,13 @@ public static partial class ImGuiHelpers
|
|||
/// </summary>
|
||||
/// <param name="data">The callback data.</param>
|
||||
/// <param name="s">The new text.</param>
|
||||
internal static unsafe void SetTextFromCallback(ImGuiInputTextCallbackData* data, string s)
|
||||
internal static void SetTextFromCallback(ref ImGuiInputTextCallbackData data, ImU8String s)
|
||||
{
|
||||
if (data->BufTextLen != 0)
|
||||
data->DeleteChars(0, data->BufTextLen);
|
||||
if (data.BufTextLen != 0)
|
||||
data.DeleteChars(0, data.BufTextLen);
|
||||
|
||||
var len = Encoding.UTF8.GetByteCount(s);
|
||||
var buf = len < 1024 ? stackalloc byte[len] : new byte[len];
|
||||
Encoding.UTF8.GetBytes(s, buf);
|
||||
fixed (byte* pBuf = buf)
|
||||
data->InsertChars(0, pBuf, pBuf + len);
|
||||
data->SelectAll();
|
||||
data.InsertChars(0, s);
|
||||
data.SelectAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -161,12 +161,10 @@ public readonly ref struct ImGuiId
|
|||
ImGui.PushID((void*)this.Numeric);
|
||||
return true;
|
||||
case Type.U16:
|
||||
fixed (void* p = this.U16)
|
||||
ImGui.PushID((byte*)p, (byte*)p + (this.U16.Length * 2));
|
||||
ImGui.PushID(this.U16);
|
||||
return true;
|
||||
case Type.U8:
|
||||
fixed (void* p = this.U8)
|
||||
ImGui.PushID((byte*)p, (byte*)p + this.U8.Length);
|
||||
ImGui.PushID(this.U8);
|
||||
return true;
|
||||
case Type.None:
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public unsafe struct ImVectorWrapper<T> : IList<T>, IList, IReadOnlyList<T>, IDi
|
|||
/// Initializes a new instance of the <see cref="ImVectorWrapper{T}"/> struct.<br />
|
||||
/// If <paramref name="ownership"/> is set to true, you must call <see cref="Dispose"/> after use,
|
||||
/// and the underlying memory for <see cref="ImVector"/> must have been allocated using
|
||||
/// <see cref="ImGui.MemAlloc(ulong)"/>. Otherwise, it will crash.
|
||||
/// <see cref="ImGui.MemAlloc(nuint)"/>. Otherwise, it will crash.
|
||||
/// </summary>
|
||||
/// <param name="vector">The underlying vector.</param>
|
||||
/// <param name="destroyer">The destroyer function to call on item removal.</param>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
|
|
@ -11,28 +10,16 @@ public static partial class ImRaii
|
|||
{
|
||||
private static int disabledCount = 0;
|
||||
|
||||
public static IEndObject Child(string strId)
|
||||
public static IEndObject Child(ImU8String strId)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId));
|
||||
|
||||
public static IEndObject Child(ReadOnlySpan<byte> strId)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId));
|
||||
|
||||
public static IEndObject Child(string strId, Vector2 size)
|
||||
public static IEndObject Child(ImU8String strId, Vector2 size)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size));
|
||||
|
||||
public static IEndObject Child(ReadOnlySpan<byte> strId, Vector2 size)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size));
|
||||
|
||||
public static IEndObject Child(string strId, Vector2 size, bool border)
|
||||
public static IEndObject Child(ImU8String strId, Vector2 size, bool border)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border));
|
||||
|
||||
public static IEndObject Child(ReadOnlySpan<byte> strId, Vector2 size, bool border)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border));
|
||||
|
||||
public static IEndObject Child(string strId, Vector2 size, bool border, ImGuiWindowFlags flags)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border, flags));
|
||||
|
||||
public static IEndObject Child(ReadOnlySpan<byte> strId, Vector2 size, bool border, ImGuiWindowFlags flags)
|
||||
public static IEndObject Child(ImU8String strId, Vector2 size, bool border, ImGuiWindowFlags flags)
|
||||
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border, flags));
|
||||
|
||||
public static IEndObject DragDropTarget()
|
||||
|
|
@ -44,88 +31,40 @@ public static partial class ImRaii
|
|||
public static IEndObject DragDropSource(ImGuiDragDropFlags flags)
|
||||
=> new EndConditionally(ImGui.EndDragDropSource, ImGui.BeginDragDropSource(flags));
|
||||
|
||||
public static IEndObject Popup(string id)
|
||||
public static IEndObject Popup(ImU8String id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id));
|
||||
|
||||
public static IEndObject Popup(ReadOnlySpan<byte> id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id));
|
||||
|
||||
public static IEndObject Popup(string id, ImGuiWindowFlags flags)
|
||||
public static IEndObject Popup(ImU8String id, ImGuiWindowFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id, flags));
|
||||
|
||||
public static IEndObject Popup(ReadOnlySpan<byte> id, ImGuiWindowFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id, flags));
|
||||
|
||||
public static IEndObject PopupModal(string id)
|
||||
public static IEndObject PopupModal(ImU8String id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id));
|
||||
|
||||
public static IEndObject PopupModal(ReadOnlySpan<byte> id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id));
|
||||
|
||||
public static IEndObject PopupModal(string id, ref bool open)
|
||||
public static IEndObject PopupModal(ImU8String id, ref bool open)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open));
|
||||
|
||||
public static IEndObject PopupModal(ReadOnlySpan<byte> id, ref bool open)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open));
|
||||
|
||||
public static IEndObject PopupModal(string id, ref bool open, ImGuiWindowFlags flags)
|
||||
public static IEndObject PopupModal(ImU8String id, ref bool open, ImGuiWindowFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open, flags));
|
||||
|
||||
public static IEndObject PopupModal(ReadOnlySpan<byte> id, ref bool open, ImGuiWindowFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open, flags));
|
||||
|
||||
public static IEndObject ContextPopup(string id)
|
||||
public static IEndObject ContextPopup(ImU8String id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id));
|
||||
|
||||
public static IEndObject ContextPopup(ReadOnlySpan<byte> id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id));
|
||||
|
||||
public static IEndObject ContextPopup(string id, ImGuiPopupFlags flags)
|
||||
public static IEndObject ContextPopup(ImU8String id, ImGuiPopupFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id, flags));
|
||||
|
||||
public static IEndObject ContextPopup(ReadOnlySpan<byte> id, ImGuiPopupFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id, flags));
|
||||
|
||||
public static IEndObject ContextPopupItem(string id)
|
||||
public static IEndObject ContextPopupItem(ImU8String id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id));
|
||||
|
||||
public static IEndObject ContextPopupItem(ReadOnlySpan<byte> id)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id));
|
||||
|
||||
public static IEndObject ContextPopupItem(string id, ImGuiPopupFlags flags)
|
||||
public static IEndObject ContextPopupItem(ImU8String id, ImGuiPopupFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id, flags));
|
||||
|
||||
public static IEndObject ContextPopupItem(ReadOnlySpan<byte> id, ImGuiPopupFlags flags)
|
||||
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id, flags));
|
||||
|
||||
public static IEndObject Combo(string label, string previewValue)
|
||||
public static IEndObject Combo(ImU8String label, ImU8String previewValue)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
|
||||
|
||||
public static IEndObject Combo(ReadOnlySpan<byte> label, string previewValue)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
|
||||
|
||||
public static IEndObject Combo(string label, ReadOnlySpan<byte> previewValue)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
|
||||
|
||||
public static IEndObject Combo(ReadOnlySpan<byte> label, ReadOnlySpan<byte> previewValue)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
|
||||
|
||||
public static IEndObject Combo(string label, string previewValue, ImGuiComboFlags flags)
|
||||
public static IEndObject Combo(ImU8String label, ImU8String previewValue, ImGuiComboFlags flags)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
|
||||
|
||||
public static IEndObject Combo(ReadOnlySpan<byte> label, string previewValue, ImGuiComboFlags flags)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
|
||||
|
||||
public static IEndObject Combo(string label, ReadOnlySpan<byte> previewValue, ImGuiComboFlags flags)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
|
||||
|
||||
public static IEndObject Combo(ReadOnlySpan<byte> label, ReadOnlySpan<byte> previewValue, ImGuiComboFlags flags)
|
||||
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
|
||||
|
||||
public static IEndObject Menu(string label)
|
||||
=> new EndConditionally(ImGui.EndMenu, ImGui.BeginMenu(label));
|
||||
|
||||
public static IEndObject Menu(ReadOnlySpan<byte> label)
|
||||
public static IEndObject Menu(ImU8String label)
|
||||
=> new EndConditionally(ImGui.EndMenu, ImGui.BeginMenu(label));
|
||||
|
||||
public static IEndObject MenuBar()
|
||||
|
|
@ -170,91 +109,49 @@ public static partial class ImRaii
|
|||
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
||||
}
|
||||
|
||||
public static IEndObject ListBox(string label)
|
||||
public static IEndObject ListBox(ImU8String label)
|
||||
=> new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label));
|
||||
|
||||
public static IEndObject ListBox(ReadOnlySpan<byte> label)
|
||||
=> new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label));
|
||||
|
||||
public static IEndObject ListBox(string label, Vector2 size)
|
||||
public static IEndObject ListBox(ImU8String label, Vector2 size)
|
||||
=> new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label, size));
|
||||
|
||||
public static IEndObject ListBox(ReadOnlySpan<byte> label, Vector2 size)
|
||||
=> new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label, size));
|
||||
|
||||
public static IEndObject Table(string table, int numColumns)
|
||||
public static IEndObject Table(ImU8String table, int numColumns)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns));
|
||||
|
||||
public static IEndObject Table(ReadOnlySpan<byte> table, int numColumns)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns));
|
||||
|
||||
public static IEndObject Table(string table, int numColumns, ImGuiTableFlags flags)
|
||||
public static IEndObject Table(ImU8String table, int numColumns, ImGuiTableFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags));
|
||||
|
||||
public static IEndObject Table(ReadOnlySpan<byte> table, int numColumns, ImGuiTableFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags));
|
||||
|
||||
public static IEndObject Table(string table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize)
|
||||
public static IEndObject Table(ImU8String table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize));
|
||||
|
||||
public static IEndObject Table(ReadOnlySpan<byte> table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize));
|
||||
|
||||
public static IEndObject Table(string table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth)
|
||||
public static IEndObject Table(ImU8String table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize, innerWidth));
|
||||
|
||||
public static IEndObject Table(ReadOnlySpan<byte> table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth)
|
||||
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize, innerWidth));
|
||||
|
||||
public static IEndObject TabBar(string label)
|
||||
public static IEndObject TabBar(ImU8String label)
|
||||
=> new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label));
|
||||
|
||||
public static IEndObject TabBar(ReadOnlySpan<byte> label)
|
||||
=> new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label));
|
||||
|
||||
public static IEndObject TabBar(string label, ImGuiTabBarFlags flags)
|
||||
public static IEndObject TabBar(ImU8String label, ImGuiTabBarFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label, flags));
|
||||
|
||||
public static IEndObject TabBar(ReadOnlySpan<byte> label, ImGuiTabBarFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label, flags));
|
||||
|
||||
public static IEndObject TabItem(string label)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label));
|
||||
|
||||
public static IEndObject TabItem(ReadOnlySpan<byte> label)
|
||||
public static IEndObject TabItem(ImU8String label)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label));
|
||||
|
||||
public static unsafe IEndObject TabItem(byte* label, ImGuiTabItemFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, null, flags));
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
|
||||
|
||||
public static unsafe IEndObject TabItem(string label, ImGuiTabItemFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, null, flags));
|
||||
public static unsafe IEndObject TabItem(ImU8String label, ImGuiTabItemFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
|
||||
|
||||
public static unsafe IEndObject TabItem(ReadOnlySpan<byte> label, ImGuiTabItemFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, null, flags));
|
||||
|
||||
public static IEndObject TabItem(string label, ref bool open)
|
||||
public static IEndObject TabItem(ImU8String label, ref bool open)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open));
|
||||
|
||||
public static IEndObject TabItem(ReadOnlySpan<byte> label, ref bool open)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open));
|
||||
|
||||
public static IEndObject TabItem(string label, ref bool open, ImGuiTabItemFlags flags)
|
||||
public static IEndObject TabItem(ImU8String label, ref bool open, ImGuiTabItemFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open, flags));
|
||||
|
||||
public static IEndObject TabItem(ReadOnlySpan<byte> label, ref bool open, ImGuiTabItemFlags flags)
|
||||
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open, flags));
|
||||
|
||||
public static IEndObject TreeNode(string label)
|
||||
public static IEndObject TreeNode(ImU8String label)
|
||||
=> new EndConditionally(ImGui.TreePop, ImGui.TreeNodeEx(label));
|
||||
|
||||
public static IEndObject TreeNode(ReadOnlySpan<byte> label)
|
||||
=> new EndConditionally(ImGui.TreePop, ImGui.TreeNodeEx(label));
|
||||
|
||||
public static IEndObject TreeNode(string label, ImGuiTreeNodeFlags flags)
|
||||
=> new EndConditionally(flags.HasFlag(ImGuiTreeNodeFlags.NoTreePushOnOpen) ? Nop : ImGui.TreePop, ImGui.TreeNodeEx(label, flags));
|
||||
|
||||
public static IEndObject TreeNode(ReadOnlySpan<byte> label, ImGuiTreeNodeFlags flags)
|
||||
public static IEndObject TreeNode(ImU8String label, ImGuiTreeNodeFlags flags)
|
||||
=> new EndConditionally(flags.HasFlag(ImGuiTreeNodeFlags.NoTreePushOnOpen) ? Nop : ImGui.TreePop, ImGui.TreeNodeEx(label, flags));
|
||||
|
||||
public static IEndObject Disabled()
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ namespace Dalamud.Interface.Utility.Raii;
|
|||
// If condition is false, no id is pushed.
|
||||
public static partial class ImRaii
|
||||
{
|
||||
public static Id PushId(string id, bool enabled = true)
|
||||
=> enabled ? new Id().Push(id) : new Id();
|
||||
|
||||
public static Id PushId(ReadOnlySpan<byte> id, bool enabled = true)
|
||||
public static Id PushId(ImU8String id, bool enabled = true)
|
||||
=> enabled ? new Id().Push(id) : new Id();
|
||||
|
||||
public static Id PushId(int id, bool enabled = true)
|
||||
|
|
@ -22,18 +19,7 @@ public static partial class ImRaii
|
|||
{
|
||||
private int count;
|
||||
|
||||
public Id Push(string id, bool condition = true)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
ImGui.PushID(id);
|
||||
++this.count;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Id Push(ReadOnlySpan<byte> id, bool condition = true)
|
||||
public Id Push(ImU8String id, bool condition = true)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Dalamud.Utility;
|
|||
/// <summary>
|
||||
/// Class providing various helper methods for use in Dalamud and plugins.
|
||||
/// </summary>
|
||||
public static class Util
|
||||
public static partial class Util
|
||||
{
|
||||
private static readonly string[] PageProtectionFlagNames = [
|
||||
"PAGE_NOACCESS",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue