-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from BeastLe9enD/master
Update to newest version
- Loading branch information
Showing
161 changed files
with
348 additions
and
43,897 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/ | ||
obj/ | ||
.vs/ | ||
.idea/ |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
MonoGame.ImGui/.vs/MonoGame.ImGui/xs/project-cache/MonoGame.ImGui-Debug.json
This file was deleted.
Oops, something went wrong.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
using Microsoft.Xna.Framework.Graphics; | ||
|
||
namespace MonoGame.ImGui.Data | ||
{ | ||
/// <summary> | ||
/// Contains information regarding the index buffer used by the GUIRenderer. | ||
/// </summary> | ||
public class IndexData | ||
{ | ||
public byte[] Data; | ||
public int BufferSize; | ||
public IndexBuffer Buffer; | ||
} | ||
} | ||
namespace MonoGame.ImGui.Data; | ||
|
||
/// <summary> | ||
/// Contains information regarding the index buffer used by the GUIRenderer. | ||
/// </summary> | ||
public class IndexData { | ||
public IndexBuffer Buffer; | ||
public int BufferSize; | ||
public byte[] Data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,79 @@ | ||
using System.Collections.Generic; | ||
using ImGuiNET; | ||
using ImGuiNET; | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using Microsoft.Xna.Framework.Input; | ||
using Vector2 = System.Numerics.Vector2; | ||
|
||
namespace MonoGame.ImGui.Data | ||
{ | ||
/// <summary> | ||
/// Contains the GUIRenderer's input data elements. | ||
/// </summary> | ||
public class InputData | ||
{ | ||
public int Scrollwheel; | ||
public List<int> KeyMap; | ||
namespace MonoGame.ImGui.Data; | ||
|
||
public void Update(GraphicsDevice device) | ||
{ | ||
var io = ImGuiNET.ImGui.GetIO(); | ||
var mouse = Mouse.GetState(); | ||
var keyboard = Keyboard.GetState(); | ||
/// <summary> | ||
/// Contains the GUIRenderer's input data elements. | ||
/// </summary> | ||
public class InputData { | ||
public List<int> KeyMap; | ||
public int Scrollwheel; | ||
|
||
for (int i = 0; i < KeyMap.Count; i++) | ||
io.KeysDown[KeyMap[i]] = keyboard.IsKeyDown((Keys) KeyMap[i]); | ||
public InputData() { | ||
Scrollwheel = 0; | ||
KeyMap = new List<int>(); | ||
} | ||
|
||
public void Update(GraphicsDevice device) { | ||
var io = ImGuiNET.ImGui.GetIO(); | ||
var mouse = Mouse.GetState(); | ||
var keyboard = Keyboard.GetState(); | ||
|
||
io.KeyShift = keyboard.IsKeyDown(Keys.LeftShift) || keyboard.IsKeyDown(Keys.RightShift); | ||
io.KeyCtrl = keyboard.IsKeyDown(Keys.LeftControl) || keyboard.IsKeyDown(Keys.RightControl); | ||
io.KeyAlt = keyboard.IsKeyDown(Keys.LeftAlt) || keyboard.IsKeyDown(Keys.RightAlt); | ||
io.KeySuper = keyboard.IsKeyDown(Keys.LeftWindows) || keyboard.IsKeyDown(Keys.RightWindows); | ||
for (var i = 0; i < KeyMap.Count; i++) | ||
io.KeysDown[KeyMap[i]] = keyboard.IsKeyDown((Keys) KeyMap[i]); | ||
|
||
io.DisplaySize = new System.Numerics.Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight); | ||
io.DisplayFramebufferScale = new System.Numerics.Vector2(1f, 1f); | ||
io.KeyShift = keyboard.IsKeyDown(Keys.LeftShift) || keyboard.IsKeyDown(Keys.RightShift); | ||
io.KeyCtrl = keyboard.IsKeyDown(Keys.LeftControl) || keyboard.IsKeyDown(Keys.RightControl); | ||
io.KeyAlt = keyboard.IsKeyDown(Keys.LeftAlt) || keyboard.IsKeyDown(Keys.RightAlt); | ||
io.KeySuper = keyboard.IsKeyDown(Keys.LeftWindows) || keyboard.IsKeyDown(Keys.RightWindows); | ||
|
||
io.MousePos = new System.Numerics.Vector2(mouse.X, mouse.Y); | ||
io.DisplaySize = new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight); | ||
io.DisplayFramebufferScale = new Vector2(1f, 1f); | ||
|
||
io.MouseDown[0] = mouse.LeftButton == ButtonState.Pressed; | ||
io.MouseDown[1] = mouse.RightButton == ButtonState.Pressed; | ||
io.MouseDown[2] = mouse.MiddleButton == ButtonState.Pressed; | ||
io.MousePos = new Vector2(mouse.X, mouse.Y); | ||
|
||
var scrollDelta = mouse.ScrollWheelValue - Scrollwheel; | ||
io.MouseWheel = scrollDelta > 0 ? 1 : scrollDelta < 0 ? -1 : 0; | ||
Scrollwheel = mouse.ScrollWheelValue; | ||
} | ||
io.MouseDown[0] = mouse.LeftButton == ButtonState.Pressed; | ||
io.MouseDown[1] = mouse.RightButton == ButtonState.Pressed; | ||
io.MouseDown[2] = mouse.MiddleButton == ButtonState.Pressed; | ||
|
||
public InputData Initialize(Game game) | ||
{ | ||
var io = ImGuiNET.ImGui.GetIO(); | ||
var scrollDelta = mouse.ScrollWheelValue - Scrollwheel; | ||
io.MouseWheel = scrollDelta > 0 ? 1 : scrollDelta < 0 ? -1 : 0; | ||
Scrollwheel = mouse.ScrollWheelValue; | ||
} | ||
|
||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Tab] = (int) Keys.Tab); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.LeftArrow] = (int) Keys.Left); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.RightArrow] = (int) Keys.Right); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.UpArrow] = (int) Keys.Up); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.DownArrow] = (int) Keys.Down); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.PageUp] = (int) Keys.PageUp); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.PageDown] = (int) Keys.PageDown); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Home] = (int) Keys.Home); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.End] = (int) Keys.End); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Delete] = (int) Keys.Delete); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Backspace] = (int) Keys.Back); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Enter] = (int) Keys.Enter); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Escape] = (int) Keys.Escape); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.A] = (int) Keys.A); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.C] = (int) Keys.C); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.V] = (int) Keys.V); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.X] = (int) Keys.X); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Y] = (int) Keys.Y); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Z] = (int) Keys.Z); | ||
public InputData Initialize(Game game) { | ||
var io = ImGuiNET.ImGui.GetIO(); | ||
|
||
game.Window.TextInput += (sender, args) => | ||
{ | ||
if (args.Character != '\t') | ||
io.AddInputCharacter(args.Character); | ||
}; | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Tab] = (int) Keys.Tab); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.LeftArrow] = (int) Keys.Left); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.RightArrow] = (int) Keys.Right); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.UpArrow] = (int) Keys.Up); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.DownArrow] = (int) Keys.Down); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.PageUp] = (int) Keys.PageUp); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.PageDown] = (int) Keys.PageDown); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Home] = (int) Keys.Home); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.End] = (int) Keys.End); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Delete] = (int) Keys.Delete); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Backspace] = (int) Keys.Back); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Enter] = (int) Keys.Enter); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Escape] = (int) Keys.Escape); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.A] = (int) Keys.A); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.C] = (int) Keys.C); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.V] = (int) Keys.V); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.X] = (int) Keys.X); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Y] = (int) Keys.Y); | ||
KeyMap.Add(io.KeyMap[(int) ImGuiKey.Z] = (int) Keys.Z); | ||
|
||
io.Fonts.AddFontDefault(); | ||
return this; | ||
} | ||
game.Window.TextInput += (sender, args) => { | ||
if (args.Character != '\t') | ||
io.AddInputCharacter(args.Character); | ||
}; | ||
|
||
public InputData() | ||
{ | ||
Scrollwheel = 0; | ||
KeyMap = new List<int>(); | ||
} | ||
io.Fonts.AddFontDefault(); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using Microsoft.Xna.Framework.Graphics; | ||
|
||
namespace MonoGame.ImGui.Data | ||
{ | ||
/// <summary> | ||
/// Contains the GUIRenderer's texture data element. | ||
/// </summary> | ||
public class TextureData | ||
{ | ||
public int TextureID; | ||
public IntPtr? FontTextureID; | ||
public Dictionary<IntPtr, Texture2D> Loaded; | ||
namespace MonoGame.ImGui.Data; | ||
|
||
public int GetTextureID() | ||
{ | ||
return TextureID++; | ||
} | ||
/// <summary> | ||
/// Contains the GUIRenderer's texture data element. | ||
/// </summary> | ||
public class TextureData { | ||
public IntPtr? FontTextureID; | ||
public Dictionary<IntPtr, Texture2D> Loaded; | ||
public int TextureID; | ||
|
||
public TextureData() | ||
{ | ||
Loaded = new Dictionary<IntPtr, Texture2D>(); | ||
} | ||
public TextureData() { | ||
Loaded = new Dictionary<IntPtr, Texture2D>(); | ||
} | ||
} | ||
|
||
public int GetNextTextureId() { | ||
return TextureID++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
using Microsoft.Xna.Framework.Graphics; | ||
|
||
namespace MonoGame.ImGui.Data | ||
{ | ||
/// <summary> | ||
/// Contains information regarding the vertex buffer used by the GUIRenderer. | ||
/// </summary> | ||
public class VertexData | ||
{ | ||
public byte[] Data; | ||
public int BufferSize; | ||
public VertexBuffer Buffer; | ||
} | ||
} | ||
namespace MonoGame.ImGui.Data; | ||
|
||
/// <summary> | ||
/// Contains information regarding the vertex buffer used by the GUIRenderer. | ||
/// </summary> | ||
public class VertexData { | ||
public VertexBuffer Buffer; | ||
public int BufferSize; | ||
public byte[] Data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
namespace MonoGame.ImGui | ||
{ | ||
public static class DrawText | ||
{ | ||
public static void Perform(string text) | ||
{ | ||
ImGuiNET.ImGui.Text(text); | ||
} | ||
namespace MonoGame.ImGui; | ||
|
||
public static class DrawText { | ||
public static void Perform(string text) { | ||
ImGuiNET.ImGui.Text(text); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
using ImGuiNET; | ||
using Microsoft.Xna.Framework.Graphics; | ||
|
||
namespace MonoGame.ImGui | ||
{ | ||
public static class DrawVertDeclaration | ||
{ | ||
public static readonly int Size; | ||
public static readonly VertexDeclaration Declaration; | ||
namespace MonoGame.ImGui; | ||
|
||
static DrawVertDeclaration() | ||
{ | ||
unsafe { Size = sizeof(ImDrawVert); } | ||
public static class DrawVertDeclaration { | ||
public static readonly int Size; | ||
public static readonly VertexDeclaration Declaration; | ||
|
||
var position = new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0); | ||
var uv = new VertexElement(8, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0); | ||
var color = new VertexElement(16, VertexElementFormat.Color, VertexElementUsage.Color, 0); | ||
Declaration = new VertexDeclaration(Size, position, uv, color); | ||
static DrawVertDeclaration() { | ||
unsafe { | ||
Size = sizeof(ImDrawVert); | ||
} | ||
|
||
var position = new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0); | ||
var uv = new VertexElement(8, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0); | ||
var color = new VertexElement(16, VertexElementFormat.Color, VertexElementUsage.Color, 0); | ||
Declaration = new VertexDeclaration(Size, position, uv, color); | ||
} | ||
} |
25 changes: 8 additions & 17 deletions
25
MonoGame.ImGui/Exceptions/MissingLoadedTextureKeyException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
using System; | ||
namespace MonoGame.ImGui.Exceptions; | ||
|
||
namespace MonoGame.ImGui.Exceptions | ||
{ | ||
public class MissingLoadedTextureKeyException | ||
: InvalidOperationException | ||
{ | ||
public override string Message | ||
{ | ||
get { return string.Format("Could not find a texture with id {0}, please check your bindings", _texture_id); } | ||
} | ||
public class MissingLoadedTextureKeyException : InvalidOperationException { | ||
private readonly IntPtr _textureId; | ||
|
||
public MissingLoadedTextureKeyException(IntPtr texture_id) | ||
{ | ||
_texture_id = texture_id; | ||
} | ||
|
||
private readonly IntPtr _texture_id; | ||
public MissingLoadedTextureKeyException(IntPtr textureId) { | ||
_textureId = textureId; | ||
} | ||
} | ||
|
||
public override string Message => $"Could not find a texture with id {_textureId}, please check your bindings"; | ||
} |
Oops, something went wrong.