fix formatting

main
cosmonaut 2022-03-03 17:42:00 -08:00
parent b2abdb4a55
commit 4e4746dd4c
4 changed files with 67 additions and 53 deletions

14
.editorconfig Normal file
View File

@ -0,0 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[*.cs]
csharp_space_after_cast = true
charset = utf-8-bom
max_line_length = 100

View File

@ -1,4 +1,4 @@
using MoonWorks.Graphics; using MoonWorks.Graphics;
using MoonWorks; using MoonWorks;
using ImGuiNET; using ImGuiNET;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -9,15 +9,15 @@ using System.Collections.Generic;
namespace MoonWorksImGuiExample namespace MoonWorksImGuiExample
{ {
class MoonWorksImGuiExampleGame : Game class MoonWorksImGuiExampleGame : Game
{ {
private string ContentPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Content"); private string ContentPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Content");
private ImFontPtr DefaultFontPtr; private ImFontPtr DefaultFontPtr;
private int TextureID; private int TextureID;
private System.IntPtr? FontTexturePtr; private System.IntPtr? FontTexturePtr;
private Dictionary<System.IntPtr, Texture> LoadedTextures = new Dictionary<System.IntPtr, Texture>(); private Dictionary<System.IntPtr, Texture> LoadedTextures = new Dictionary<System.IntPtr, Texture>();
private Dictionary<Texture, System.IntPtr> TextureHandles = new Dictionary<Texture, System.IntPtr>(); private Dictionary<Texture, System.IntPtr> TextureHandles = new Dictionary<Texture, System.IntPtr>();
private uint VertexCount = 0; private uint VertexCount = 0;
private uint IndexCount = 0; private uint IndexCount = 0;
@ -28,12 +28,12 @@ namespace MoonWorksImGuiExample
private ShaderModule ImGuiFragmentShader; private ShaderModule ImGuiFragmentShader;
private Sampler ImGuiSampler; private Sampler ImGuiSampler;
public MoonWorksImGuiExampleGame( public MoonWorksImGuiExampleGame(
WindowCreateInfo windowCreateInfo, WindowCreateInfo windowCreateInfo,
PresentMode presentMode, PresentMode presentMode,
bool debugMode bool debugMode
) : base(windowCreateInfo, presentMode, 60, debugMode) ) : base(windowCreateInfo, presentMode, 60, debugMode)
{ {
var context = ImGui.CreateContext(); var context = ImGui.CreateContext();
ImGui.SetCurrentContext(context); ImGui.SetCurrentContext(context);
@ -78,12 +78,12 @@ namespace MoonWorksImGuiExample
MultisampleState = MultisampleState.None MultisampleState = MultisampleState.None
} }
); );
} }
protected override void Update(System.TimeSpan dt) protected override void Update(System.TimeSpan dt)
{ {
// Insert your game update logic here. // Insert your game update logic here.
} }
private System.IntPtr BindTexture(Texture texture) private System.IntPtr BindTexture(Texture texture)
{ {
@ -196,23 +196,23 @@ namespace MoonWorksImGuiExample
GraphicsDevice.Submit(commandBuffer); GraphicsDevice.Submit(commandBuffer);
} }
protected override void Draw(System.TimeSpan dt, double alpha) protected override void Draw(System.TimeSpan dt, double alpha)
{ {
// Replace this with your own drawing code. // Replace this with your own drawing code.
var io = ImGui.GetIO(); var io = ImGui.GetIO();
io.KeyShift = Inputs.Keyboard.IsDown(Keycode.LeftShift) || Inputs.Keyboard.IsDown(Keycode.RightShift); io.KeyShift = Inputs.Keyboard.IsDown(Keycode.LeftShift) || Inputs.Keyboard.IsDown(Keycode.RightShift);
io.KeyCtrl = Inputs.Keyboard.IsDown(Keycode.LeftControl) || Inputs.Keyboard.IsDown(Keycode.RightControl); io.KeyCtrl = Inputs.Keyboard.IsDown(Keycode.LeftControl) || Inputs.Keyboard.IsDown(Keycode.RightControl);
io.KeyAlt = Inputs.Keyboard.IsDown(Keycode.LeftAlt) || Inputs.Keyboard.IsDown(Keycode.RightAlt); io.KeyAlt = Inputs.Keyboard.IsDown(Keycode.LeftAlt) || Inputs.Keyboard.IsDown(Keycode.RightAlt);
io.KeySuper = Inputs.Keyboard.IsDown(Keycode.LeftMeta) || Inputs.Keyboard.IsDown(Keycode.RightMeta); io.KeySuper = Inputs.Keyboard.IsDown(Keycode.LeftMeta) || Inputs.Keyboard.IsDown(Keycode.RightMeta);
io.KeyMap[(int)ImGuiKey.Backspace] = (int)Keycode.Backspace; io.KeyMap[(int) ImGuiKey.Backspace] = (int) Keycode.Backspace;
io.MousePos = new System.Numerics.Vector2(Inputs.Mouse.X, Inputs.Mouse.Y); io.MousePos = new System.Numerics.Vector2(Inputs.Mouse.X, Inputs.Mouse.Y);
io.MouseDown[0] = Inputs.Mouse.LeftButton.IsDown; io.MouseDown[0] = Inputs.Mouse.LeftButton.IsDown;
io.MouseDown[1] = Inputs.Mouse.RightButton.IsDown; io.MouseDown[1] = Inputs.Mouse.RightButton.IsDown;
io.MouseDown[2] = Inputs.Mouse.MiddleButton.IsDown; io.MouseDown[2] = Inputs.Mouse.MiddleButton.IsDown;
io.MouseWheel = Inputs.Mouse.Wheel > 0 ? 1 : Inputs.Mouse.Wheel < 0 ? -1 : 0; io.MouseWheel = Inputs.Mouse.Wheel > 0 ? 1 : Inputs.Mouse.Wheel < 0 ? -1 : 0;
ImGui.NewFrame(); ImGui.NewFrame();
@ -300,11 +300,11 @@ namespace MoonWorksImGuiExample
} }
GraphicsDevice.Submit(commandBuffer); GraphicsDevice.Submit(commandBuffer);
} }
protected override void OnDestroy() protected override void OnDestroy()
{ {
} }
} }
} }

View File

@ -1,34 +1,34 @@
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using MoonWorks; using MoonWorks;
namespace MoonWorksImGuiExample namespace MoonWorksImGuiExample
{ {
class Program class Program
{ {
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDllDirectory(string lpPathName); static extern bool SetDllDirectory(string lpPathName);
static void Main(string[] args) static void Main(string[] args)
{ {
WindowCreateInfo windowCreateInfo = new WindowCreateInfo WindowCreateInfo windowCreateInfo = new WindowCreateInfo
{ {
WindowWidth = 1280, WindowWidth = 1280,
WindowHeight = 720, WindowHeight = 720,
WindowTitle = "MoonWorksImGuiExample", WindowTitle = "MoonWorksImGuiExample",
ScreenMode = ScreenMode.Windowed ScreenMode = ScreenMode.Windowed
}; };
MoonWorksImGuiExampleGame game = new MoonWorksImGuiExampleGame( MoonWorksImGuiExampleGame game = new MoonWorksImGuiExampleGame(
windowCreateInfo, windowCreateInfo,
MoonWorks.Graphics.PresentMode.FIFORelaxed, MoonWorks.Graphics.PresentMode.FIFORelaxed,
true true
); );
game.Run(); game.Run();
} }
} }
} }

View File

@ -1,4 +1,4 @@
using MoonWorks.Graphics; using MoonWorks.Graphics;
using MoonWorks.Math; using MoonWorks.Math;
namespace MoonWorksImGuiExample namespace MoonWorksImGuiExample