GreenComfyTea

Untitled

Mar 27th, 2024
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using ImGuiNET;
  8.  
  9. namespace SharpPluginLoader.Core.Rendering
  10. {
  11.     public static class ImGuiExtensions
  12.     {
  13.         public static void CreateDeviceObjectsDX11() => InternalCalls.CreateDeviceObjectsDX11();
  14.         public static void CreateDeviceObjectsDX12() => InternalCalls.CreateDeviceObjectsDX12();
  15.  
  16.         public static bool BeginTimeline(string label, float startFrame, float endFrame, ref float currentFrame, ImGuiTimelineFlags flags = 0)
  17.         {
  18.             return InternalCalls.BeginTimeline(label, startFrame, endFrame, ref currentFrame, (int)flags);
  19.         }
  20.  
  21.         public static void EndTimeline() => InternalCalls.EndTimeline();
  22.  
  23.         public static bool BeginTimelineGroup(string label, ref bool expanded)
  24.         {
  25.             return InternalCalls.BeginTimelineGroup(label, ref expanded);
  26.         }
  27.  
  28.         public static bool BeginTimelineGroup(string label)
  29.         {
  30.             var expanded = true;
  31.             return InternalCalls.BeginTimelineGroup(label, ref expanded);
  32.         }
  33.  
  34.         public static void EndTimelineGroup() => InternalCalls.EndTimelineGroup();
  35.  
  36.         public static bool TimelineTrack(string label, Span<float> keyframes, out int selectedKeyframe, int explicitCount = -1)
  37.         {
  38.             return InternalCalls.TimelineTrack(label, keyframes, out selectedKeyframe, explicitCount);
  39.         }
  40.  
  41.         public static bool TimelineTrack(string label, Span<float> keyframes, int explicitCount = -1)
  42.         {
  43.             return InternalCalls.TimelineTrack(label, keyframes, out _, explicitCount);
  44.         }
  45.  
  46.         public static bool Bitfield(string label, ref uint value, ref int hoveredBit)
  47.         {
  48.             return InternalCalls.Bitfield(label, ref value, ref hoveredBit);
  49.         }
  50.  
  51.         public static void NotificationSuccess(string message, int duration = 3000)
  52.         {
  53.             InternalCalls.NotificationSuccess(message, duration);
  54.         }
  55.  
  56.         public static void NotificationError(string message, int duration = 3000)
  57.         {
  58.             InternalCalls.NotificationError(message, duration);
  59.         }
  60.  
  61.         public static void NotificationWarning(string message, int duration = 3000)
  62.         {
  63.             InternalCalls.NotificationWarning(message, duration);
  64.         }
  65.  
  66.         public static void NotificationInfo(string message, int duration = 3000)
  67.         {
  68.             InternalCalls.NotificationInfo(message, duration);
  69.         }
  70.  
  71.         public static void Notification(ImGuiToastType type, string title, string message, int duration = 3000)
  72.         {
  73.             InternalCalls.Notification((int)type, duration, title, message);
  74.         }
  75.  
  76.         public static unsafe bool InputScalar(string label, ref sbyte value, sbyte step = 1, sbyte stepFast = 10,
  77.             string format = "%d", ImGuiInputTextFlags flags = 0)
  78.         {
  79.             return ImGui.InputScalar(
  80.                 label,
  81.                 ImGuiDataType.S8,
  82.                 (nint)Unsafe.AsPointer(ref value),
  83.                 (nint)Unsafe.AsPointer(ref step),
  84.                 (nint)Unsafe.AsPointer(ref stepFast),
  85.                 format,
  86.                 flags
  87.             );
  88.         }
  89.  
  90.         public static unsafe bool InputScalar(string label, ref byte value, byte step = 1, byte stepFast = 10,
  91.             string format = "%u", ImGuiInputTextFlags flags = 0)
  92.         {
  93.             return ImGui.InputScalar(
  94.                 label,
  95.                 ImGuiDataType.U8,
  96.                 (nint)Unsafe.AsPointer(ref value),
  97.                 (nint)Unsafe.AsPointer(ref step),
  98.                 (nint)Unsafe.AsPointer(ref stepFast),
  99.                 format,
  100.                 flags
  101.             );
  102.         }
  103.  
  104.         public static unsafe bool InputScalar(string label, ref short value, short step = 1, short stepFast = 10,
  105.             string format = "%d", ImGuiInputTextFlags flags = 0)
  106.         {
  107.             return ImGui.InputScalar(
  108.                 label,
  109.                 ImGuiDataType.S16,
  110.                 (nint)Unsafe.AsPointer(ref value),
  111.                 (nint)Unsafe.AsPointer(ref step),
  112.                 (nint)Unsafe.AsPointer(ref stepFast),
  113.                 format,
  114.                 flags
  115.             );
  116.         }
  117.  
  118.         public static unsafe bool InputScalar(string label, ref ushort value, ushort step = 1, ushort stepFast = 10,
  119.             string format = "%u", ImGuiInputTextFlags flags = 0)
  120.         {
  121.             return ImGui.InputScalar(
  122.                 label,
  123.                 ImGuiDataType.U16,
  124.                 (nint)Unsafe.AsPointer(ref value),
  125.                 (nint)Unsafe.AsPointer(ref step),
  126.                 (nint)Unsafe.AsPointer(ref stepFast),
  127.                 format,
  128.                 flags
  129.             );
  130.         }
  131.  
  132.         public static unsafe bool InputScalar(string label, ref int value, int step = 1, int stepFast = 10,
  133.             string format = "%d", ImGuiInputTextFlags flags = 0)
  134.         {
  135.             return ImGui.InputScalar(
  136.                 label,
  137.                 ImGuiDataType.S32,
  138.                 (nint)Unsafe.AsPointer(ref value),
  139.                 (nint)Unsafe.AsPointer(ref step),
  140.                 (nint)Unsafe.AsPointer(ref stepFast),
  141.                 format,
  142.                 flags
  143.             );
  144.         }
  145.  
  146.         public static unsafe bool InputScalar(string label, ref uint value, uint step = 1, uint stepFast = 10,
  147.             string format = "%u", ImGuiInputTextFlags flags = 0)
  148.         {
  149.             return ImGui.InputScalar(
  150.                 label,
  151.                 ImGuiDataType.U32,
  152.                 (nint)Unsafe.AsPointer(ref value),
  153.                 (nint)Unsafe.AsPointer(ref step),
  154.                 (nint)Unsafe.AsPointer(ref stepFast),
  155.                 format,
  156.                 flags
  157.             );
  158.         }
  159.  
  160.         public static unsafe bool InputScalar(string label, ref long value, long step = 1, long stepFast = 10,
  161.             string format = "%d", ImGuiInputTextFlags flags = 0)
  162.         {
  163.             return ImGui.InputScalar(
  164.                 label,
  165.                 ImGuiDataType.S64,
  166.                 (nint)Unsafe.AsPointer(ref value),
  167.                 (nint)Unsafe.AsPointer(ref step),
  168.                 (nint)Unsafe.AsPointer(ref stepFast),
  169.                 format,
  170.                 flags
  171.             );
  172.         }
  173.     }
  174.  
  175.     [Flags]
  176.     public enum ImGuiTimelineFlags
  177.     {
  178.         None = 0,
  179.         EnableFramePointerSnapping = 1 << 0,
  180.         EnableKeyframeSnapping = 1 << 1,
  181.         ExtendFramePointer = 1 << 2,
  182.         ExtendFrameMarkers = 1 << 3,
  183.         ShowSelectedKeyframeMarkers = 1 << 4,
  184.  
  185.         EnableSnapping = EnableFramePointerSnapping | EnableKeyframeSnapping,
  186.         ExtendMarkers = ExtendFramePointer | ExtendFrameMarkers | ShowSelectedKeyframeMarkers
  187.     }
  188.  
  189.     public enum ImGuiToastType
  190.     {
  191.         Success,
  192.         Warning,
  193.         Error,
  194.         Info
  195.     }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment