diff --git a/.editorconfig b/.editorconfig
index a1ebbcd..d13dcab 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -36,3 +36,14 @@ dotnet_diagnostic.CA1001.severity = none
dotnet_diagnostic.CA1725.severity = none
dotnet_diagnostic.CA1707.severity = none
dotnet_diagnostic.CA1711.severity = none
+
+# Roslynator
+dotnet_diagnostic.rcs0056.severity = warning
+roslynator_max_line_length = 100
+
+dotnet_diagnostic.rcs1194.severity = none
+dotnet_diagnostic.rcs1129.severity = none
+dotnet_diagnostic.rcs1061.severity = none
+dotnet_diagnostic.rcs1006.severity = none
+dotnet_diagnostic.rcs1141.severity = none
+dotnet_diagnostic.rcs1161.severity = none
diff --git a/Dear ImGui for Godot Demo.csproj b/Dear ImGui for Godot Demo.csproj
index 942085b..c199bbb 100644
--- a/Dear ImGui for Godot Demo.csproj
+++ b/Dear ImGui for Godot Demo.csproj
@@ -12,5 +12,21 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
\ No newline at end of file
diff --git a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs
index 00641da..c737009 100644
--- a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs
+++ b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs
@@ -89,10 +89,8 @@ public static bool ToolInit()
nbe.ToolInit();
return true;
}
- else
- {
- return false;
- }
+
+ return false;
}
internal static bool SubViewportWidget(SubViewport svp)
diff --git a/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs b/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs
index c35b953..50f1710 100644
--- a/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs
+++ b/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs
@@ -65,8 +65,10 @@ public override void _EnterTree()
_ci = RenderingServer.CanvasItemCreate();
RenderingServer.CanvasItemSetParent(_ci, GetCanvas());
- Node cfgScene = ResourceLoader.Load("res://addons/imgui-godot/Config.tscn").Instantiate();
- Resource cfg = (Resource)cfgScene.Get("Config") ?? (Resource)((GDScript)GD.Load("res://addons/imgui-godot/scripts/ImGuiConfig.gd")).New();
+ Node cfgScene = ResourceLoader.Load("res://addons/imgui-godot/Config.tscn")
+ .Instantiate();
+ Resource cfg = (Resource)cfgScene.Get("Config") ?? (Resource)((GDScript)GD.Load(
+ "res://addons/imgui-godot/scripts/ImGuiConfig.gd")).New();
cfgScene.Free();
Layer = (int)cfg.Get("Layer");
@@ -127,11 +129,17 @@ public override void _Process(double delta)
// this is more or less how SubViewportContainer works
_subViewportSize = winSize;
_finalTransform = ft;
- RenderingServer.ViewportSetSize(_subViewportRid, _subViewportSize.X, _subViewportSize.Y);
+ RenderingServer.ViewportSetSize(
+ _subViewportRid,
+ _subViewportSize.X,
+ _subViewportSize.Y);
Rid vptex = RenderingServer.ViewportGetTexture(_subViewportRid);
RenderingServer.CanvasItemClear(_ci);
RenderingServer.CanvasItemSetTransform(_ci, ft.AffineInverse());
- RenderingServer.CanvasItemAddTextureRect(_ci, new(0, 0, _subViewportSize.X, _subViewportSize.Y), vptex);
+ RenderingServer.CanvasItemAddTextureRect(
+ _ci,
+ new(0, 0, _subViewportSize.X, _subViewportSize.Y),
+ vptex);
}
Signaler.EmitSignal("imgui_layout");
@@ -143,9 +151,9 @@ public override void _Notification(int what)
Internal.Input.ProcessNotification(what);
}
- public override void _Input(InputEvent e)
+ public override void _Input(InputEvent @event)
{
- if (Internal.State.Instance.ProcessInput(e, _window))
+ if (Internal.State.Instance.ProcessInput(@event, _window))
{
_window.SetInputAsHandled();
}
@@ -166,8 +174,9 @@ private void CheckContentScale()
private void PrintErrContentScale()
{
- GD.PrintErr($"imgui-godot only supports content scale modes {Window.ContentScaleModeEnum.Disabled}" +
- $" or {Window.ContentScaleModeEnum.CanvasItems}");
+ GD.PrintErr(
+ $"imgui-godot only supports content scale modes {Window.ContentScaleModeEnum.Disabled}"
+ + $" or {Window.ContentScaleModeEnum.CanvasItems}");
GD.PrintErr($" current mode is {_window.ContentScaleMode}/{_window.ContentScaleAspect}");
}
}
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/BackendNative.cs b/addons/imgui-godot/ImGuiGodot/Internal/BackendNative.cs
index d87424f..f35443d 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/BackendNative.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/BackendNative.cs
@@ -25,9 +25,17 @@ private sealed class PropertyName
public static readonly StringName Visible = "Visible";
}
- public float JoyAxisDeadZone { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
+ public float JoyAxisDeadZone
+ {
+ get => throw new System.NotImplementedException();
+ set => throw new System.NotImplementedException();
+ }
public float Scale { get; set; } = 1.0f; // TODO: make property
- public bool Visible { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
+ public bool Visible
+ {
+ get => throw new System.NotImplementedException();
+ set => throw new System.NotImplementedException();
+ }
public void AddFont(FontFile fontData, int fontSize, bool merge)
{
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs b/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs
index cb1ee90..35ce28c 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs
@@ -49,20 +49,20 @@ public void ResetFonts()
State.Instance.Fonts.ResetFonts();
}
- public bool SubViewportWidget(SubViewport vp)
+ public bool SubViewportWidget(SubViewport svp)
{
- Vector2 vpSize = new(vp.Size.X, vp.Size.Y);
+ Vector2 vpSize = new(svp.Size.X, svp.Size.Y);
var pos = ImGui.GetCursorScreenPos();
var pos_max = new Vector2(pos.X + vpSize.X, pos.Y + vpSize.Y);
- ImGui.GetWindowDrawList().AddImage((IntPtr)vp.GetTexture().GetRid().Id, pos, pos_max);
+ ImGui.GetWindowDrawList().AddImage((IntPtr)svp.GetTexture().GetRid().Id, pos, pos_max);
- ImGui.PushID(vp.NativeInstance);
+ ImGui.PushID(svp.NativeInstance);
ImGui.InvisibleButton("godot_subviewport", vpSize);
ImGui.PopID();
if (ImGui.IsItemHovered())
{
- State.Instance.Input.CurrentSubViewport = vp;
+ State.Instance.Input.CurrentSubViewport = svp;
State.Instance.Input.CurrentSubViewportPos = pos;
return true;
}
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/CanvasRenderer.cs b/addons/imgui-godot/ImGuiGodot/Internal/CanvasRenderer.cs
index 5c8eaae..7cc02b6 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/CanvasRenderer.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/CanvasRenderer.cs
@@ -51,7 +51,8 @@ private void RenderOne(Rid vprid, ImDrawDataPtr drawData)
ViewportData vd = _vpData[vprid];
Rid parent = vd.RootCanvasItem;
- var window = (GodotImGuiWindow)GCHandle.FromIntPtr(drawData.OwnerViewport.PlatformHandle).Target!;
+ var window = (GodotImGuiWindow)GCHandle.FromIntPtr(drawData.OwnerViewport.PlatformHandle)
+ .Target!;
if (!_canvasItemPools.ContainsKey(parent))
_canvasItemPools[parent] = [];
@@ -168,7 +169,16 @@ private void RenderOne(Rid vprid, ImDrawDataPtr drawData)
drawCmd.ClipRect.W - drawCmd.ClipRect.Y)
);
- RenderingServer.CanvasItemAddTriangleArray(child, indices, cmdvertices, cmdcolors, cmduvs, null, null, texrid, -1);
+ RenderingServer.CanvasItemAddTriangleArray(
+ child,
+ indices,
+ cmdvertices,
+ cmdcolors,
+ cmduvs,
+ null,
+ null,
+ texrid,
+ -1);
}
}
}
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/Fonts.cs b/addons/imgui-godot/ImGuiGodot/Internal/Fonts.cs
index 929c981..a361541 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/Fonts.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/Fonts.cs
@@ -34,7 +34,8 @@ public void ResetFonts()
public void AddFont(FontFile? fontData, int fontSize, bool merge)
{
- _fontConfiguration.Add(new FontParams { Font = fontData, FontSize = fontSize, Merge = merge });
+ _fontConfiguration.Add(
+ new FontParams { Font = fontData, FontSize = fontSize, Merge = merge });
}
private static unsafe void AddFontToAtlas(FontFile? fontData, int fontSize, bool merge)
@@ -82,7 +83,8 @@ private static unsafe void AddFontToAtlas(FontFile? fontData, int fontSize, bool
private static unsafe ImVector GetRanges(Font font)
{
- var builder = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
+ var builder = new ImFontGlyphRangesBuilderPtr(
+ ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
builder.AddText(font.GetSupportedChars());
builder.BuildRanges(out ImVector vec);
builder.Destroy();
@@ -146,15 +148,18 @@ public unsafe void RebuildFontAtlas(float scale)
AddFontToAtlas(fontParams.Font, (int)(fontParams.FontSize * scale), fontParams.Merge);
}
- io.Fonts.GetTexDataAsRGBA32(out byte* pixelData, out int width, out int height, out int bytesPerPixel);
+ io.Fonts.GetTexDataAsRGBA32(
+ out byte* pixelData,
+ out int width,
+ out int height,
+ out int bytesPerPixel);
byte[] pixels = new byte[width * height * bytesPerPixel];
Marshal.Copy((IntPtr)pixelData, pixels, 0, pixels.Length);
var img = Image.CreateFromData(width, height, false, Image.Format.Rgba8, pixels);
- var imgtex = ImageTexture.CreateFromImage(img);
- _fontTexture = imgtex;
+ _fontTexture = ImageTexture.CreateFromImage(img);
io.Fonts.SetTexID((IntPtr)_fontTexture.GetRid().Id);
io.Fonts.ClearTexData();
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/Input.cs b/addons/imgui-godot/ImGuiGodot/Internal/Input.cs
index 0f66688..cb8ae39 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/Input.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/Input.cs
@@ -24,13 +24,13 @@ private void UpdateMouse(ImGuiIOPtr io)
if (io.WantSetMousePos)
{
// WarpMouse is relative to the current focused window
- int[] windows = DisplayServer.GetWindowList();
- foreach (int w in windows)
+ foreach (int w in DisplayServer.GetWindowList())
{
if (DisplayServer.WindowIsFocused(w))
{
var winPos = DisplayServer.WindowGetPosition(w);
- Godot.Input.WarpMouse(new(io.MousePos.X - winPos.X, io.MousePos.Y - winPos.Y));
+ Godot.Input
+ .WarpMouse(new(io.MousePos.X - winPos.X, io.MousePos.Y - winPos.Y));
break;
}
}
@@ -97,7 +97,8 @@ public bool ProcessInput(InputEvent evt, Window window)
var vpEvent = evt.Duplicate() as InputEvent;
if (vpEvent is InputEventMouse mouseEvent)
{
- mouseEvent.Position = new Vector2(windowPos.X + mouseEvent.GlobalPosition.X - CurrentSubViewportPos.X,
+ mouseEvent.Position = new Vector2(
+ windowPos.X + mouseEvent.GlobalPosition.X - CurrentSubViewportPos.X,
windowPos.Y + mouseEvent.GlobalPosition.Y - CurrentSubViewportPos.Y)
.Clamp(Vector2.Zero, CurrentSubViewport.Size);
}
@@ -142,7 +143,7 @@ public bool ProcessInput(InputEvent evt, Window window)
case MouseButton.WheelRight:
_mouseWheel.X = mb.Factor;
break;
- };
+ }
consumed = io.WantCaptureMouse;
mb.Dispose();
}
@@ -209,7 +210,7 @@ public bool ProcessInput(InputEvent evt, Window window)
case JoyAxis.TriggerRight:
io.AddKeyAnalogEvent(ImGuiKey.GamepadR2, pressed, v);
break;
- };
+ }
consumed = true;
jm.Dispose();
}
@@ -228,7 +229,7 @@ public static void ProcessNotification(long what)
case MainLoop.NotificationApplicationFocusOut:
ImGui.GetIO().AddFocusEvent(false);
break;
- };
+ }
}
private static void UpdateKeyMods(ImGuiIOPtr io)
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/RdRenderer.cs b/addons/imgui-godot/ImGuiGodot/Internal/RdRenderer.cs
index db4408b..53b82c8 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/RdRenderer.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/RdRenderer.cs
@@ -27,9 +27,15 @@ internal class RdRenderer : IRenderer
private readonly ArrayPool _bufPool = ArrayPool.Create();
private Rid _idxBuffer;
- private int _idxBufferSize = 0; // size in indices
+ ///
+ /// size in indices
+ ///
+ private int _idxBufferSize = 0;
private Rid _vtxBuffer;
- private int _vtxBufferSize = 0; // size in vertices
+ ///
+ /// size in vertices
+ ///
+ private int _vtxBufferSize = 0;
private readonly Dictionary _uniformSets = new(8);
private readonly HashSet _usedTextures = new(8);
@@ -50,7 +56,8 @@ public RdRenderer()
// set up everything to match the official Vulkan backend as closely as possible
- using var shaderFile = ResourceLoader.Load("res://addons/imgui-godot/data/ImGuiShader.glsl");
+ using var shaderFile = ResourceLoader.Load(
+ "res://addons/imgui-godot/data/ImGuiShader.glsl");
_shader = RD.ShaderCreateFromSpirV(shaderFile.GetSpirV());
if (!_shader.IsValid)
throw new RdRendererException("failed to create shader");
@@ -82,7 +89,10 @@ public RdRenderer()
Offset = sizeof(float) * 4
};
- var vattrs = new Godot.Collections.Array() { attrPoints, attrUvs, attrColors };
+ var vattrs = new Godot.Collections.Array() {
+ attrPoints,
+ attrUvs,
+ attrColors };
_vtxFormat = RD.VertexFormatCreate(vattrs);
// blend state
@@ -198,8 +208,7 @@ private void SetupBuffers(ImDrawDataPtr drawData)
uniform.AddId(_sampler);
uniform.AddId(texrid);
_uniformArray[0] = uniform;
- Rid uniformSet = RD.UniformSetCreate(_uniformArray, _shader, 0);
- _uniformSets[texid] = uniformSet;
+ _uniformSets[texid] = RD.UniformSetCreate(_uniformArray, _shader, 0);
}
}
}
@@ -217,7 +226,8 @@ protected static void ReplaceTextureRids(ImDrawDataPtr drawData)
for (int cmdi = 0; cmdi < cmdList.CmdBuffer.Size; ++cmdi)
{
ImDrawCmdPtr drawCmd = cmdList.CmdBuffer[cmdi];
- drawCmd.TextureId = (IntPtr)RenderingServer.TextureGetRdTexture(Util.ConstructRid((ulong)drawCmd.TextureId)).Id;
+ drawCmd.TextureId = (IntPtr)RenderingServer.TextureGetRdTexture(
+ Util.ConstructRid((ulong)drawCmd.TextureId)).Id;
}
}
}
@@ -277,7 +287,9 @@ protected void RenderOne(Rid fb, ImDrawDataPtr drawData)
{
if (_idxBuffer.Id != 0)
RD.FreeRid(_idxBuffer);
- _idxBuffer = RD.IndexBufferCreate((uint)drawData.TotalIdxCount, RenderingDevice.IndexBufferFormat.Uint16);
+ _idxBuffer = RD.IndexBufferCreate(
+ (uint)drawData.TotalIdxCount,
+ RenderingDevice.IndexBufferFormat.Uint16);
_idxBufferSize = drawData.TotalIdxCount;
}
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/RdRendererThreadSafe.cs b/addons/imgui-godot/ImGuiGodot/Internal/RdRendererThreadSafe.cs
index f9290fc..1f6e065 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/RdRendererThreadSafe.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/RdRendererThreadSafe.cs
@@ -5,7 +5,8 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
-using SharedList = ImGuiGodot.Internal.DisposableList;
+using SharedList = ImGuiGodot.Internal.DisposableList;
namespace ImGuiGodot.Internal;
@@ -50,7 +51,7 @@ public unsafe void Dispose()
internal sealed class DisposableList : List>, IDisposable where U : IDisposable
{
- public DisposableList() : base() { }
+ public DisposableList() { }
public DisposableList(int capacity) : base(capacity) { }
public void Dispose()
@@ -70,7 +71,7 @@ internal sealed class RdRendererThreadSafe : RdRenderer, IRenderer
private readonly object _sharedDataLock = new();
private SharedList? _dataToDraw;
- public RdRendererThreadSafe() : base()
+ public RdRendererThreadSafe()
{
// draw on the renderer thread to avoid conflicts
RenderingServer.FramePreDraw += OnFramePreDraw;
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/State.cs b/addons/imgui-godot/ImGuiGodot/Internal/State.cs
index 61c33a9..ca021e6 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/State.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/State.cs
@@ -19,10 +19,10 @@ private enum RendererType
private static IntPtr _rendererName = IntPtr.Zero;
private IntPtr _iniFilenameBuffer = IntPtr.Zero;
- internal Viewports Viewports { get; private set; }
- internal Fonts Fonts { get; private set; }
- internal Input Input { get; private set; }
- internal IRenderer Renderer { get; private set; }
+ internal Viewports Viewports { get; }
+ internal Fonts Fonts { get; }
+ internal Input Input { get; }
+ internal IRenderer Renderer { get; }
internal float Scale { get; set; } = 1.0f;
internal static State Instance { get; set; } = null!;
@@ -84,7 +84,8 @@ public static void Init(Window mainWindow, Rid mainSubViewport, Resource cfg)
}
// fall back to Canvas in OpenGL compatibility mode
- if (renderer == RendererType.RenderingDevice && RenderingServer.GetRenderingDevice() == null)
+ if (renderer == RendererType.RenderingDevice
+ && RenderingServer.GetRenderingDevice() == null)
{
renderer = RendererType.Canvas;
}
@@ -99,7 +100,9 @@ public static void Init(Window mainWindow, Rid mainSubViewport, Resource cfg)
{
RendererType.Dummy => new DummyRenderer(),
RendererType.Canvas => new CanvasRenderer(),
- RendererType.RenderingDevice => threadModel == 2 ? new RdRendererThreadSafe() : new RdRenderer(),
+ RendererType.RenderingDevice => threadModel == 2
+ ? new RdRendererThreadSafe()
+ : new RdRenderer(),
_ => throw new ArgumentException("Invalid renderer", nameof(cfg))
};
}
@@ -184,6 +187,9 @@ public void Render()
//_inProcessFrame = false;
}
+ ///
+ /// Send input event to ImGui
+ ///
///
/// True if the InputEvent was consumed
///
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/Util.cs b/addons/imgui-godot/ImGuiGodot/Internal/Util.cs
index 9769a27..4b65f45 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/Util.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/Util.cs
@@ -12,7 +12,9 @@ internal static class Util
static Util()
{
- ConstructorInfo cinfo = typeof(Rid).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, [typeof(ulong)]) ??
+ ConstructorInfo cinfo = typeof(Rid).GetConstructor(
+ BindingFlags.NonPublic | BindingFlags.Instance,
+ [typeof(ulong)]) ??
throw new PlatformNotSupportedException("failed to get Rid constructor");
DynamicMethod dm = new("ConstructRid", typeof(Rid), [typeof(ulong)]);
ILGenerator il = dm.GetILGenerator();
diff --git a/addons/imgui-godot/ImGuiGodot/Internal/Viewports.cs b/addons/imgui-godot/ImGuiGodot/Internal/Viewports.cs
index a2a36c1..7a5a342 100644
--- a/addons/imgui-godot/ImGuiGodot/Internal/Viewports.cs
+++ b/addons/imgui-godot/ImGuiGodot/Internal/Viewports.cs
@@ -14,7 +14,9 @@ internal sealed class GodotImGuiWindow : IDisposable
public Window GodotWindow { get; init; }
- // sub window
+ ///
+ /// sub window
+ ///
public GodotImGuiWindow(ImGuiViewportPtr vp)
{
_gcHandle = GCHandle.Alloc(this);
@@ -26,7 +28,8 @@ public GodotImGuiWindow(ImGuiViewportPtr vp)
Window mainWindow = ImGuiLayer.Instance.GetWindow();
if (mainWindow.GuiEmbedSubwindows)
{
- GD.PushWarning("ImGui Viewports: 'display/window/subwindows/embed_subwindows' needs to be disabled");
+ GD.PushWarning(
+ "ImGui Viewports: 'display/window/subwindows/embed_subwindows' needs to be disabled");
mainWindow.GuiEmbedSubwindows = false;
}
@@ -56,7 +59,9 @@ public GodotImGuiWindow(ImGuiViewportPtr vp)
RenderingServer.ViewportSetTransparentBackground(GodotWindow.GetViewportRid(), true);
}
- // main window
+ ///
+ /// main window
+ ///
public GodotImGuiWindow(ImGuiViewportPtr vp, Window gw, Rid mainSubViewport)
{
_gcHandle = GCHandle.Alloc(this);
@@ -144,10 +149,14 @@ internal sealed partial class Viewports
{
[LibraryImport("cimgui")]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
- private static unsafe partial void ImGuiPlatformIO_Set_Platform_GetWindowPos(ImGuiPlatformIO* platform_io, IntPtr funcPtr);
+ private static unsafe partial void ImGuiPlatformIO_Set_Platform_GetWindowPos(
+ ImGuiPlatformIO* platform_io,
+ IntPtr funcPtr);
[LibraryImport("cimgui")]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
- private static unsafe partial void ImGuiPlatformIO_Set_Platform_GetWindowSize(ImGuiPlatformIO* platform_io, IntPtr funcPtr);
+ private static unsafe partial void ImGuiPlatformIO_Set_Platform_GetWindowSize(
+ ImGuiPlatformIO* platform_io,
+ IntPtr funcPtr);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void Platform_CreateWindow(ImGuiViewportPtr vp);
@@ -187,13 +196,13 @@ internal sealed partial class Viewports
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool Platform_GetWindowMinimized(ImGuiViewportPtr vp);
- private static readonly Platform_GetWindowMinimized _getWindowMinimized = Godot_GetWindowMinimized;
+ private static readonly Platform_GetWindowMinimized _getWindowMinimized
+ = Godot_GetWindowMinimized;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void Platform_SetWindowTitle(ImGuiViewportPtr vp, string title);
private static readonly Platform_SetWindowTitle _setWindowTitle = Godot_SetWindowTitle;
- //private static bool _wantUpdateMonitors = true;
private readonly GodotImGuiWindow _mainWindow;
private static void UpdateMonitors()
@@ -238,11 +247,16 @@ private static unsafe void InitPlatformInterface()
//pio->Platform_GetWindowSize = Marshal.GetFunctionPointerForDelegate(_getWindowSize);
pio->Platform_SetWindowFocus = Marshal.GetFunctionPointerForDelegate(_setWindowFocus);
pio->Platform_GetWindowFocus = Marshal.GetFunctionPointerForDelegate(_getWindowFocus);
- pio->Platform_GetWindowMinimized = Marshal.GetFunctionPointerForDelegate(_getWindowMinimized);
+ pio->Platform_GetWindowMinimized = Marshal.GetFunctionPointerForDelegate(
+ _getWindowMinimized);
pio->Platform_SetWindowTitle = Marshal.GetFunctionPointerForDelegate(_setWindowTitle);
- ImGuiPlatformIO_Set_Platform_GetWindowPos(pio, Marshal.GetFunctionPointerForDelegate(_getWindowPos));
- ImGuiPlatformIO_Set_Platform_GetWindowSize(pio, Marshal.GetFunctionPointerForDelegate(_getWindowSize));
+ ImGuiPlatformIO_Set_Platform_GetWindowPos(
+ pio,
+ Marshal.GetFunctionPointerForDelegate(_getWindowPos));
+ ImGuiPlatformIO_Set_Platform_GetWindowSize(
+ pio,
+ Marshal.GetFunctionPointerForDelegate(_getWindowSize));
}
public Viewports(Window mainWindow, Rid mainSubViewport)
diff --git a/addons/imgui-godot/ImGuiGodot/Widgets.cs b/addons/imgui-godot/ImGuiGodot/Widgets.cs
index ca7b1bc..f06bbdd 100644
--- a/addons/imgui-godot/ImGuiGodot/Widgets.cs
+++ b/addons/imgui-godot/ImGuiGodot/Widgets.cs
@@ -38,12 +38,23 @@ public static void Image(Texture2D tex, Vector2 size, Vector2 uv0, Vector2 uv1)
Image(tex, size, uv0, uv1, Vector4.One, Vector4.Zero);
}
- public static void Image(Texture2D tex, Vector2 size, Vector2 uv0, Vector2 uv1, Vector4 tint_col)
+ public static void Image(
+ Texture2D tex,
+ Vector2 size,
+ Vector2 uv0,
+ Vector2 uv1,
+ Vector4 tint_col)
{
Image(tex, size, uv0, uv1, tint_col, Vector4.Zero);
}
- public static void Image(Texture2D tex, Vector2 size, Vector2 uv0, Vector2 uv1, Vector4 tint_col, Vector4 border_col)
+ public static void Image(
+ Texture2D tex,
+ Vector2 size,
+ Vector2 uv0,
+ Vector2 uv1,
+ Vector4 tint_col,
+ Vector4 border_col)
{
ImGuiNative.igImage((IntPtr)tex.GetRid().Id, size, uv0, uv1, tint_col, border_col);
}
@@ -74,17 +85,35 @@ public static bool ImageButton(string str_id, Texture2D tex, Vector2 size, Vecto
return ImageButton(str_id, tex, size, uv0, Vector2.One, Vector4.Zero, Vector4.One);
}
- public static bool ImageButton(string str_id, Texture2D tex, Vector2 size, Vector2 uv0, Vector2 uv1)
+ public static bool ImageButton(
+ string str_id,
+ Texture2D tex,
+ Vector2 size,
+ Vector2 uv0,
+ Vector2 uv1)
{
return ImageButton(str_id, tex, size, uv0, uv1, Vector4.Zero, Vector4.One);
}
- public static bool ImageButton(string str_id, Texture2D tex, Vector2 size, Vector2 uv0, Vector2 uv1, Vector4 bg_col)
+ public static bool ImageButton(
+ string str_id,
+ Texture2D tex,
+ Vector2 size,
+ Vector2 uv0,
+ Vector2 uv1,
+ Vector4 bg_col)
{
return ImageButton(str_id, tex, size, uv0, uv1, bg_col, Vector4.One);
}
- public static bool ImageButton(string str_id, Texture2D tex, Vector2 size, Vector2 uv0, Vector2 uv1, Vector4 bg_col, Vector4 tint_col)
+ public static bool ImageButton(
+ string str_id,
+ Texture2D tex,
+ Vector2 size,
+ Vector2 uv0,
+ Vector2 uv1,
+ Vector4 bg_col,
+ Vector4 tint_col)
{
return ImGui.ImageButton(str_id, (IntPtr)tex.GetRid().Id, size, uv0, uv1, bg_col, tint_col);
}
@@ -99,7 +128,12 @@ public static bool ImageButton(string str_id, AtlasTexture tex, Vector2 size, Ve
return ImageButton(str_id, tex, size, bg_col, Vector4.One);
}
- public static bool ImageButton(string str_id, AtlasTexture tex, Vector2 size, Vector4 bg_col, Vector4 tint_col)
+ public static bool ImageButton(
+ string str_id,
+ AtlasTexture tex,
+ Vector2 size,
+ Vector4 bg_col,
+ Vector4 tint_col)
{
(Vector2 uv0, Vector2 uv1) = GetAtlasUVs(tex);
return ImGui.ImageButton(str_id, (IntPtr)tex.GetRid().Id, size, uv0, uv1, bg_col, tint_col);
diff --git a/src/MySecondNode.cs b/src/MySecondNode.cs
index 1015799..fb84b4d 100644
--- a/src/MySecondNode.cs
+++ b/src/MySecondNode.cs
@@ -19,7 +19,7 @@ public partial class MySecondNode : Node
private static bool _fontLoaded = false;
private static readonly System.Numerics.Vector4 MyTextColor = Colors.Aquamarine.ToVector4();
- private static readonly ImGuiWindowFlags CsWinFlags =
+ private const ImGuiWindowFlags CsWinFlags =
ImGuiWindowFlags.NoDecoration |
ImGuiWindowFlags.AlwaysAutoResize |
ImGuiWindowFlags.NoSavedSettings |
diff --git a/src/ViewportArea.cs b/src/ViewportArea.cs
index b53f1e2..c90e668 100644
--- a/src/ViewportArea.cs
+++ b/src/ViewportArea.cs
@@ -15,14 +15,14 @@ public override void _Ready()
_decalTexture = GD.Load("res://data/icon.svg");
}
- public override void _InputEvent(Camera3D cam, InputEvent evt, Vector3 pos,
+ public override void _InputEvent(Camera3D camera, InputEvent @event, Vector3 position,
Vector3 normal, int shapeIdx)
{
- if (evt is InputEventMouseMotion)
+ if (@event is InputEventMouseMotion)
{
- _piece.Position = pos;
+ _piece.Position = position;
}
- else if (evt is InputEventMouseButton mb && mb.Pressed)
+ else if (@event is InputEventMouseButton mb && mb.Pressed)
{
if (mb.ButtonIndex == MouseButton.Left)
{
@@ -30,7 +30,7 @@ public override void _InputEvent(Camera3D cam, InputEvent evt, Vector3 pos,
{
TextureAlbedo = _decalTexture,
Scale = new(10, 10, 10),
- Position = pos,
+ Position = position,
CullMask = 1,
});
}
@@ -45,9 +45,9 @@ public override void _InputEvent(Camera3D cam, InputEvent evt, Vector3 pos,
}
}
- public override void _UnhandledKeyInput(InputEvent evt)
+ public override void _UnhandledKeyInput(InputEvent @event)
{
- if (evt is InputEventKey k && k.Pressed)
+ if (@event is InputEventKey k && k.Pressed)
{
if (k.Keycode == Key.R)
{