mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Removed redundant Point struct and SceneViewport improvements
- Keyboard shortcuts for Gizmo control - Improved mousepick-blocking
This commit is contained in:
@@ -27,22 +27,22 @@ namespace GlitchyEngine
|
||||
|
||||
public static extern bool IsMouseButtonPressed(MouseButton button);
|
||||
public static extern bool IsMouseButtonReleased(MouseButton button);
|
||||
public static extern Point GetMousePosition();
|
||||
public static extern Int2 GetMousePosition();
|
||||
public static extern int32 GetMouseX();
|
||||
public static extern int32 GetMouseY();
|
||||
|
||||
// TODO: Should Input be able to set mousepos?
|
||||
public static extern void SetMousePosition(Point pos);
|
||||
public static extern void SetMousePosition(Int2 pos);
|
||||
|
||||
public static extern bool WasMouseButtonPressed(MouseButton button);
|
||||
public static extern bool WasMouseButtonReleased(MouseButton button);
|
||||
public static extern Point GetLastMousePosition();
|
||||
public static extern Int2 GetLastMousePosition();
|
||||
public static extern int32 GetLastMouseX();
|
||||
public static extern int32 GetLastMouseY();
|
||||
|
||||
public static extern bool IsMouseButtonPressing(MouseButton button);
|
||||
public static extern bool IsMouseButtonReleasing(MouseButton button);
|
||||
public static extern Point GetMouseMovement();
|
||||
public static extern Int2 GetMouseMovement();
|
||||
|
||||
public static extern void NewFrame();
|
||||
}
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace GlitchyEngine.Math
|
||||
{
|
||||
|
||||
/**
|
||||
* A 2D point represented by two 32bit integers.
|
||||
*/
|
||||
public struct Point
|
||||
{
|
||||
public int32 X, Y;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a @Point with both components set to zero.
|
||||
*/
|
||||
public this() => this = default;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a @Point with both components set to the specified value.
|
||||
* @param value The value for both components.
|
||||
*/
|
||||
public this(int32 value)
|
||||
{
|
||||
X = value;
|
||||
Y = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of a @Point.
|
||||
* @param x The value for the x-component.
|
||||
* @param y The value for the y-component.
|
||||
*/
|
||||
public this(int32 x, int32 y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
//
|
||||
// Unary Operators
|
||||
//
|
||||
|
||||
public static Point operator +(Point value) => value;
|
||||
|
||||
public static Point operator -(Point value) => .(-value.X, -value.Y);
|
||||
|
||||
//
|
||||
// Binary Operators
|
||||
//
|
||||
|
||||
public static Point operator +(Point left, Point right) => .(left.X + right.X, left.Y + right.Y);
|
||||
public static Point operator +(int32 left, Point right) => .(left + right.X, left + right.Y);
|
||||
public static Point operator +(Point left, int32 right) => .(left.X + right, left.Y + right);
|
||||
|
||||
public static Point operator -(Point left, Point right) => .(left.X - right.X, left.Y - right.Y);
|
||||
public static Point operator -(int32 left, Point right) => .(left - right.X, left - right.Y);
|
||||
public static Point operator -(Point left, int32 right) => .(left.X - right, left.Y - right);
|
||||
|
||||
public static Point operator *(Point left, Point right) => .(left.X * right.X, left.Y * right.Y);
|
||||
public static Point operator *(int32 left, Point right) => .(left * right.X, left * right.Y);
|
||||
public static Point operator *(Point left, int32 right) => .(left.X * right, left.Y * right);
|
||||
|
||||
public static Point operator /(Point left, Point right) => .(left.X / right.X, left.Y / right.Y);
|
||||
public static Point operator /(int32 left, Point right) => .(left / right.X, left / right.Y);
|
||||
public static Point operator /(Point left, int32 right) => .(left.X / right, left.Y / right);
|
||||
|
||||
//
|
||||
// Assignment Operators
|
||||
//
|
||||
|
||||
public void operator +=(Point value) mut
|
||||
{
|
||||
X += value.X;
|
||||
Y += value.Y;
|
||||
}
|
||||
|
||||
public void operator +=(int32 value) mut
|
||||
{
|
||||
X += value;
|
||||
Y += value;
|
||||
}
|
||||
|
||||
public void operator -=(Point value) mut
|
||||
{
|
||||
X -= value.X;
|
||||
Y -= value.Y;
|
||||
}
|
||||
|
||||
public void operator -=(int32 value) mut
|
||||
{
|
||||
X -= value;
|
||||
Y -= value;
|
||||
}
|
||||
|
||||
public void operator *=(Point value) mut
|
||||
{
|
||||
X *= value.X;
|
||||
Y *= value.Y;
|
||||
}
|
||||
|
||||
public void operator *=(int32 value) mut
|
||||
{
|
||||
X *= value;
|
||||
Y *= value;
|
||||
}
|
||||
|
||||
public void operator /=(Point value) mut
|
||||
{
|
||||
X /= value.X;
|
||||
Y /= value.Y;
|
||||
}
|
||||
|
||||
public void operator /=(int32 value) mut
|
||||
{
|
||||
X /= value;
|
||||
Y /= value;
|
||||
}
|
||||
|
||||
//
|
||||
// Equality
|
||||
//
|
||||
public static bool operator ==(Point left, Point right) => left.X == right.X && left.Y == right.Y;
|
||||
public static bool operator !=(Point left, Point right) => left.X != right.X || left.Y != right.Y;
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
public override void ToString(String strBuffer) => strBuffer.AppendF("X={0} Y={1}", X, Y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,8 +17,8 @@ namespace GlitchyEngine
|
||||
struct WindowsInputState
|
||||
{
|
||||
public int8[256] KeyStates;
|
||||
public Point CursorPosition;
|
||||
public Point CursorPositionDifference;
|
||||
public Int2 CursorPosition;
|
||||
public Int2 CursorPositionDifference;
|
||||
}
|
||||
|
||||
static WindowsInputState[2] IputStates;
|
||||
@@ -119,7 +119,7 @@ namespace GlitchyEngine
|
||||
return state >= 0;
|
||||
}
|
||||
|
||||
public override static Point GetMousePosition() => CurrentState.CursorPosition;
|
||||
public override static Int2 GetMousePosition() => CurrentState.CursorPosition;
|
||||
|
||||
public override static int32 GetMouseX() => CurrentState.CursorPosition.X;
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace GlitchyEngine
|
||||
return state >= 0;
|
||||
}
|
||||
|
||||
public override static Point GetLastMousePosition() => LastState.CursorPosition;
|
||||
public override static Int2 GetLastMousePosition() => LastState.CursorPosition;
|
||||
|
||||
public override static int32 GetLastMouseX() => LastState.CursorPosition.X;
|
||||
|
||||
@@ -153,18 +153,18 @@ namespace GlitchyEngine
|
||||
|
||||
public override static bool IsMouseButtonReleasing(MouseButton button) => IsMouseButtonReleased(button) && WasMouseButtonPressed(button);
|
||||
|
||||
public override static Point GetMouseMovement() => CurrentState.CursorPositionDifference;
|
||||
public override static Int2 GetMouseMovement() => CurrentState.CursorPositionDifference;
|
||||
|
||||
public override static void SetMousePosition(Point pos) => SetCursorPos(pos.X, pos.Y);
|
||||
public override static void SetMousePosition(Int2 pos) => SetCursorPos(pos.X, pos.Y);
|
||||
|
||||
//[CLink, CallingConvention(.Stdcall)]
|
||||
//static extern int16 GetKeyState(int32 keycode);
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern IntBool GetCursorPos(out Point p);
|
||||
static extern IntBool GetCursorPos(out Int2 p);
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern IntBool SetCursorPos(c_int x, c_int y);
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern IntBool ScreenToClient(HWnd hWnd, ref Point p);
|
||||
static extern IntBool ScreenToClient(HWnd hWnd, ref Int2 p);
|
||||
|
||||
public override static void NewFrame()
|
||||
{
|
||||
|
||||
@@ -66,13 +66,13 @@ namespace GlitchyEngine
|
||||
//
|
||||
// Size
|
||||
//
|
||||
public override Point Size
|
||||
public override Int2 Size
|
||||
{
|
||||
get => *(Point*)&_clientRect.Width;
|
||||
get => *(Int2*)&_clientRect.Width;
|
||||
|
||||
set
|
||||
{
|
||||
*(Point*)&_clientRect.Width = value;
|
||||
*(Int2*)&_clientRect.Width = value;
|
||||
ApplyRectangle();
|
||||
}
|
||||
}
|
||||
@@ -102,13 +102,13 @@ namespace GlitchyEngine
|
||||
//
|
||||
// Position
|
||||
//
|
||||
public override Point Position
|
||||
public override Int2 Position
|
||||
{
|
||||
get => *(Point*)&_clientRect;
|
||||
get => *(Int2*)&_clientRect;
|
||||
|
||||
set
|
||||
{
|
||||
*(Point*)&_clientRect = value;
|
||||
*(Int2*)&_clientRect = value;
|
||||
ApplyRectangle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace GlitchyEngine
|
||||
/**
|
||||
* Gets or Sets the width and height of the window.
|
||||
*/
|
||||
public extern Point Size {get; set;}
|
||||
public extern Int2 Size {get; set;}
|
||||
/**
|
||||
* Gets or Sets the width of the window.
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ namespace GlitchyEngine
|
||||
/**
|
||||
* Gets or Sets the position of the upper-left corner of the client area of the window.
|
||||
*/
|
||||
public extern Point Position {get; set;}
|
||||
public extern Int2 Position {get; set;}
|
||||
|
||||
/**
|
||||
* Gets or Sets the x-coordinate of the upper-left corner of the client area of the window.
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace GlitchyEngine.World
|
||||
|
||||
public Matrix View => _view;
|
||||
|
||||
// Gets whether or not the camera is currently being moved.
|
||||
public bool InUse => BindMouse;
|
||||
|
||||
public RenderTargetGroup RenderTarget
|
||||
{
|
||||
get => _renderTarget;
|
||||
|
||||
Reference in New Issue
Block a user