daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -45,12 +45,23 @@ namespace StgSharp.Controls
|
||||
{
|
||||
|
||||
public bool IsEntity => true;
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Vec2 Position
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
|
||||
@@ -53,38 +53,48 @@ namespace StgSharp.Controls
|
||||
buttonList = new List<TriggerButton>();
|
||||
}
|
||||
|
||||
public bool IsEntity { get => false; }
|
||||
public bool IsEntity
|
||||
{
|
||||
get => false;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public TriggerButton CurrentButton
|
||||
{
|
||||
get => current;
|
||||
}
|
||||
|
||||
public vec2d Position { get; set; }
|
||||
public Vec2 Position
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
protected List<TriggerButton> AllButton
|
||||
{
|
||||
get => buttonList;
|
||||
}
|
||||
|
||||
public void AddButton(TriggerButton button)
|
||||
public void AddButton( TriggerButton button )
|
||||
{
|
||||
buttonList.Add(button);
|
||||
buttonList.Add( button );
|
||||
}
|
||||
|
||||
public abstract void Confirm();
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
foreach (TriggerButton item in buttonList)
|
||||
{
|
||||
foreach( TriggerButton item in buttonList ) {
|
||||
yield return item.Single();
|
||||
}
|
||||
}
|
||||
@@ -92,12 +102,10 @@ namespace StgSharp.Controls
|
||||
public void MoveDown()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Down != null) && button.Down.IsDisabled)
|
||||
{
|
||||
while( ( button.Down != null ) && button.Down.IsDisabled ) {
|
||||
button = button.Right;
|
||||
}
|
||||
if (current == button)
|
||||
{
|
||||
if( current == button ) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
@@ -108,12 +116,10 @@ namespace StgSharp.Controls
|
||||
public void MoveLeft()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Left != null) && button.Left.IsDisabled)
|
||||
{
|
||||
while( ( button.Left != null ) && button.Left.IsDisabled ) {
|
||||
button = button.Left;
|
||||
}
|
||||
if (current == button)
|
||||
{
|
||||
if( current == button ) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
@@ -124,12 +130,10 @@ namespace StgSharp.Controls
|
||||
public void MoveRight()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Right != null) && button.Right.IsDisabled)
|
||||
{
|
||||
while( ( button.Right != null ) && button.Right.IsDisabled ) {
|
||||
button = button.Right;
|
||||
}
|
||||
if (current == button)
|
||||
{
|
||||
if( current == button ) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
@@ -140,12 +144,10 @@ namespace StgSharp.Controls
|
||||
public void MoveUp()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Up != null) && button.Up.IsDisabled)
|
||||
{
|
||||
while( ( button.Up != null ) && button.Up.IsDisabled ) {
|
||||
button = button.Right;
|
||||
}
|
||||
if (current == button)
|
||||
{
|
||||
if( current == button ) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
|
||||
@@ -47,18 +47,21 @@ namespace StgSharp.Controls
|
||||
private char[] displayIndex;
|
||||
private char defaultChar;
|
||||
|
||||
Dictionary<char, PlainGeometryMesh> texIndex;
|
||||
private Dictionary<char, PlainGeometryMesh> texIndex;
|
||||
private int length;
|
||||
PlainGeometryMesh _tittleMesh;
|
||||
private PlainGeometryMesh _tittleMesh;
|
||||
|
||||
public CharacterLineIndexImage(
|
||||
int length, char defaultChar, PlainGeometryMesh tittleMesh,
|
||||
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration)
|
||||
int length,
|
||||
char defaultChar,
|
||||
PlainGeometryMesh tittleMesh,
|
||||
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration )
|
||||
{
|
||||
this.length = length;
|
||||
displayIndex = new char[length];
|
||||
_tittleMesh = tittleMesh;
|
||||
texIndex = indexEnumeration.ToDictionary(item => item.Item1, item => item.Item2);
|
||||
texIndex = indexEnumeration.ToDictionary(
|
||||
item => item.Item1, item => item.Item2 );
|
||||
}
|
||||
|
||||
public bool IsEntity
|
||||
@@ -66,23 +69,32 @@ namespace StgSharp.Controls
|
||||
get => true;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
}
|
||||
public Rectangle BoundingBox { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public vec2d Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public void Display(string message)
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Vec2 Position
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Display( string message )
|
||||
{
|
||||
if( string.IsNullOrEmpty( message ) ) {
|
||||
message = string.Empty;
|
||||
}
|
||||
|
||||
string result = (message.Length >= length) ?
|
||||
message.Substring(message.Length - displayIndex.Length) :
|
||||
message.PadLeft(length, defaultChar);
|
||||
string result = ( message.Length >= length ) ?
|
||||
message.Substring( message.Length - displayIndex.Length ) : message.PadLeft(
|
||||
length, defaultChar );
|
||||
|
||||
displayIndex = result.ToCharArray();
|
||||
}
|
||||
@@ -90,9 +102,8 @@ namespace StgSharp.Controls
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return _tittleMesh;
|
||||
foreach (char item in displayIndex)
|
||||
{
|
||||
yield return texIndex[item];
|
||||
foreach( char item in displayIndex ) {
|
||||
yield return texIndex[ item ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,27 @@ namespace StgSharp.Controls
|
||||
public interface ControllingItem : IEnumerable<PlainGeometryMesh>
|
||||
{
|
||||
|
||||
public abstract bool IsEntity { get; }
|
||||
public abstract bool IsEntity
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public abstract ReadOnlySpan<vec4d> TextureBox { get; }
|
||||
public abstract Rectangle BoundingBox { get; set; }
|
||||
public abstract vec2d Position { get; set; }
|
||||
public abstract ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public abstract Rectangle BoundingBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public abstract Vec2 Position
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
|
||||
@@ -44,20 +44,30 @@ namespace StgSharp.Controls
|
||||
|
||||
private PlainGeometryMesh renderMesh;
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
|
||||
public DecorationBox( Rectangle bound, Image texture, Vec2[] texCoord )
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(BoundingBox, new TextureProvider(texture, texCoord));
|
||||
renderMesh = new PlainGeometryMesh(
|
||||
BoundingBox, new TextureProvider( texture, texCoord ) );
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => renderMesh.TextureCoord;
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public vec2d Position { get; set; }
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Vec2 Position
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
|
||||
@@ -48,40 +48,49 @@ namespace StgSharp.Controls
|
||||
|
||||
private TimeFunction _movement;
|
||||
|
||||
private vec2d _currentPosition, _movementVec;
|
||||
private Vec2 _currentPosition, _movementVec;
|
||||
|
||||
public MarkingLabel(PlainGeometryMesh marker, TimeFunction movement)
|
||||
public MarkingLabel( PlainGeometryMesh marker, TimeFunction movement )
|
||||
{
|
||||
this.marker = marker;
|
||||
_movement = movement;
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => marker.TextureCoord;
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Vec2 Position
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return marker;
|
||||
}
|
||||
|
||||
public void Move(vec2d movement)
|
||||
public void Move( Vec2 movement )
|
||||
{
|
||||
if (!_movement.IsComplete)
|
||||
{
|
||||
Position = _currentPosition + (_movement.Calculate() * _movementVec);
|
||||
if( !_movement.IsComplete ) {
|
||||
Position = _currentPosition + ( _movement.Calculate() * _movementVec );
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveTo(vec2d target)
|
||||
public void MoveTo( Vec2 target )
|
||||
{
|
||||
Move(target - Position);
|
||||
Move( target - Position );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,11 +40,14 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
|
||||
public delegate void RenderButtonTextureCallback(ButtonStatus status, float beginTime, in TextureProvider texture);
|
||||
public delegate void RenderButtonTextureCallback(
|
||||
ButtonStatus status,
|
||||
float beginTime,
|
||||
in TextureProvider texture );
|
||||
|
||||
public enum ButtonStatus
|
||||
{
|
||||
|
||||
Error = 0b0,
|
||||
Disable = 0b1,
|
||||
Enable = 0b10,
|
||||
@@ -52,12 +55,13 @@ namespace StgSharp.Controls
|
||||
Confirm = 0b1000,
|
||||
|
||||
DisableToEnable = Disable | Enable,
|
||||
EnableToDisable = -(Enable | DisableToEnable),
|
||||
EnableToDisable = -( Enable | DisableToEnable ),
|
||||
|
||||
EnableToHighlight = Enable | Highlight,
|
||||
HighlightToEnable = -(Enable | Highlight),
|
||||
HighlightToEnable = -( Enable | Highlight ),
|
||||
|
||||
HighlightToDisable = -( Highlight | Disable ),
|
||||
|
||||
HighlightToDisable = -(Highlight | Disable),
|
||||
}
|
||||
|
||||
public class TriggerButton : ControllingItem
|
||||
@@ -66,14 +70,14 @@ namespace StgSharp.Controls
|
||||
private Action? confirmCallback;
|
||||
private Action? disableCallback;
|
||||
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
private Action? enableCallback;
|
||||
private float _statusBeginTime;
|
||||
|
||||
private RenderButtonTextureCallback _renderButton;
|
||||
private TextureProvider _texture;
|
||||
|
||||
#nullable restore
|
||||
#nullable restore
|
||||
|
||||
public TriggerButton()
|
||||
{
|
||||
@@ -102,41 +106,74 @@ namespace StgSharp.Controls
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_renderButton == null)
|
||||
{
|
||||
if( _renderButton == null ) {
|
||||
_renderButton = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_renderButton += value;
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
if (_renderButton != null)
|
||||
{
|
||||
if( _renderButton != null ) {
|
||||
_renderButton -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHighLighted { get; internal set; }
|
||||
public bool IsHighLighted
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public bool IsDisabled { get; internal set; }
|
||||
public bool IsDisabled
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => MemoryMarshal.Cast<vec2d, vec4d>(_texture.TextureCoordinate);
|
||||
get => MemoryMarshal.Cast<Vec2, Vec4>( _texture.TextureCoordinate );
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public TriggerButton Left { get; internal set; }
|
||||
public TriggerButton Right { get; internal set; }
|
||||
public TriggerButton Up { get; internal set; }
|
||||
public TriggerButton Down { get; internal set; }
|
||||
public vec2d Position { get; set; }
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public TriggerButton Left
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public TriggerButton Right
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public TriggerButton Up
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public TriggerButton Down
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public Vec2 Position
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal TextureProvider Texture
|
||||
{
|
||||
@@ -144,12 +181,15 @@ namespace StgSharp.Controls
|
||||
set => _texture = value;
|
||||
}
|
||||
|
||||
protected ButtonStatus CurrentStatus { get; set; }
|
||||
protected ButtonStatus CurrentStatus
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public void DeHighlight()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Highlight)
|
||||
{
|
||||
if( CurrentStatus == ButtonStatus.Highlight ) {
|
||||
CurrentStatus = ButtonStatus.HighlightToEnable;
|
||||
}
|
||||
}
|
||||
@@ -162,54 +202,44 @@ namespace StgSharp.Controls
|
||||
ButtonStatus.Highlight => ButtonStatus.HighlightToDisable,
|
||||
_ => CurrentStatus,
|
||||
};
|
||||
if (disableCallback != null)
|
||||
{
|
||||
if( disableCallback != null ) {
|
||||
disableCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Disable)
|
||||
{
|
||||
if( CurrentStatus == ButtonStatus.Disable ) {
|
||||
CurrentStatus = ButtonStatus.DisableToEnable;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (enableCallback != null)
|
||||
{
|
||||
if( enableCallback != null ) {
|
||||
enableCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
_renderButton(CurrentStatus, _statusBeginTime, in _texture);
|
||||
yield return new PlainGeometryMesh(this.BoundingBox, _texture);
|
||||
_renderButton( CurrentStatus, _statusBeginTime, in _texture );
|
||||
yield return new PlainGeometryMesh( this.BoundingBox, _texture );
|
||||
}
|
||||
|
||||
public void Highlight()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Enable)
|
||||
{
|
||||
if( CurrentStatus == ButtonStatus.Enable ) {
|
||||
CurrentStatus |= ButtonStatus.EnableToHighlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (confirmCallback != null)
|
||||
{
|
||||
if( confirmCallback != null ) {
|
||||
confirmCallback();
|
||||
}
|
||||
}
|
||||
|
||||
internal void Init(ButtonStatus status)
|
||||
internal void Init( ButtonStatus status )
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Error)
|
||||
{
|
||||
if( CurrentStatus == ButtonStatus.Error ) {
|
||||
CurrentStatus = status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,31 +40,55 @@ namespace StgSharp
|
||||
{
|
||||
internal static partial class InternalIO
|
||||
{
|
||||
|
||||
#region ssgc api define
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "initGL",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void InternalInitGL(int majorVersion, int minorVersion);
|
||||
[DllImport(
|
||||
SSC_libName,
|
||||
EntryPoint = "initGL",
|
||||
CallingConvention = CallingConvention.Cdecl )]
|
||||
internal static extern void InternalInitGL(
|
||||
int majorVersion,
|
||||
int minorVersion );
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "loadGlfuncDefault",
|
||||
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern IntPtr InternalLoadGlfuncDefault(string name);
|
||||
[DllImport(
|
||||
SSC_libName,
|
||||
EntryPoint = "loadGlfuncDefault",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
CharSet = CharSet.Ansi )]
|
||||
internal static extern IntPtr InternalLoadGlfuncDefault( string name );
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "linkShaderProgram",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe uint InternalLinkShaderProgram(OpenglContext* context, uint shaderProgram);
|
||||
[DllImport(
|
||||
SSC_libName,
|
||||
EntryPoint = "linkShaderProgram",
|
||||
CallingConvention = CallingConvention.Cdecl )]
|
||||
internal static extern unsafe uint InternalLinkShaderProgram(
|
||||
OpenglContext* context,
|
||||
uint shaderProgram );
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "readLog",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(
|
||||
SSC_libName,
|
||||
EntryPoint = "readLog",
|
||||
CallingConvention = CallingConvention.Cdecl )]
|
||||
internal static extern unsafe IntPtr InternalReadSSCLog();
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "loadImageData",
|
||||
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern unsafe void InternalLoadImage(string fileName, ImageInfo* output, ImageLoader loader);
|
||||
[DllImport(
|
||||
SSC_libName,
|
||||
EntryPoint = "loadImageData",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
CharSet = CharSet.Ansi )]
|
||||
internal static extern unsafe void InternalLoadImage(
|
||||
string fileName,
|
||||
ImageInfo* output,
|
||||
ImageLoader loader );
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "unloadImageData",
|
||||
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern unsafe void InternalUnloadImage(ImageInfo* output);
|
||||
[DllImport(
|
||||
SSC_libName,
|
||||
EntryPoint = "unloadImageData",
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
CharSet = CharSet.Ansi )]
|
||||
internal static extern unsafe void InternalUnloadImage(
|
||||
ImageInfo* output );
|
||||
|
||||
#endregion ssgc api define
|
||||
}
|
||||
@@ -72,34 +96,42 @@ namespace StgSharp
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
public delegate IntPtr ImageLoader(string name, ref int width, ref int height, ref int definedChannel, int desiredChannel);
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl, CharSet = CharSet.Ansi )]
|
||||
public delegate IntPtr ImageLoader(
|
||||
string name,
|
||||
ref int width,
|
||||
ref int height,
|
||||
ref int definedChannel,
|
||||
int desiredChannel );
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[StructLayout( LayoutKind.Sequential )]
|
||||
public struct OpenglContext
|
||||
{
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals( object obj )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override unsafe int GetHashCode()
|
||||
{
|
||||
fixed (OpenglContext* sptr = &this)
|
||||
{
|
||||
fixed( OpenglContext* sptr = &this ) {
|
||||
return sptr->GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator !=(OpenglContext left, OpenglContext right)
|
||||
public static bool operator !=(
|
||||
OpenglContext left,
|
||||
OpenglContext right )
|
||||
{
|
||||
return !(left == right);
|
||||
return !( left == right );
|
||||
}
|
||||
|
||||
public static bool operator ==(OpenglContext left, OpenglContext right)
|
||||
public static bool operator ==(
|
||||
OpenglContext left,
|
||||
OpenglContext right )
|
||||
{
|
||||
return left.Equals(right);
|
||||
return left.Equals( right );
|
||||
}
|
||||
|
||||
#region glapi
|
||||
@@ -244,7 +276,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, ulong, bool, void> glBufferPageCommitmentMemNV;
|
||||
internal unsafe delegate*<uint, uint, int, void> glBufferParameteriAPPLE;
|
||||
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glBufferStorage;
|
||||
[Obsolete("Param type uncertain", true)] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glBufferStorageExternalEXT;
|
||||
[Obsolete( "Param type uncertain", true )] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glBufferStorageExternalEXT;
|
||||
internal unsafe delegate*<uint, UIntPtr, uint, ulong, void> glBufferStorageMemEXT;
|
||||
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glBufferSubData;
|
||||
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glBufferSubDataARB;
|
||||
@@ -1425,7 +1457,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, ulong, bool, void> glNamedBufferPageCommitmentMemNV;
|
||||
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glNamedBufferStorage;
|
||||
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glNamedBufferStorageEXT;
|
||||
[Obsolete("Param type uncertain", true)] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glNamedBufferStorageExternalEXT;
|
||||
[Obsolete( "Param type uncertain", true )] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glNamedBufferStorageExternalEXT;
|
||||
internal unsafe delegate*<uint, UIntPtr, uint, ulong, void> glNamedBufferStorageMemEXT;
|
||||
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glNamedBufferSubData;
|
||||
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glNamedBufferSubDataEXT;
|
||||
@@ -2103,7 +2135,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<int, uint, double*, void> glUniform1dv;
|
||||
internal unsafe delegate*<int, float, void> glUniform1f;
|
||||
internal unsafe delegate*<int, float, void> glUniform1fARB;
|
||||
internal unsafe delegate*<int, uint, vec4d*, void> glUniform1fv;
|
||||
internal unsafe delegate*<int, uint, Vec4*, void> glUniform1fv;
|
||||
internal unsafe delegate*<int, uint, float*, void> glUniform1fvARB;
|
||||
internal unsafe delegate*<int, int, void> glUniform1i;
|
||||
internal unsafe delegate*<int, long, void> glUniform1i64ARB;
|
||||
@@ -2637,8 +2669,6 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<uint, uint, int*, void> glWindowRectanglesEXT;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, void> glWriteMaskEXT;
|
||||
|
||||
#endregion glapi
|
||||
|
||||
|
||||
#endregion glapi
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,14 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Data.Intrinsic;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -47,11 +49,13 @@ namespace StgSharp
|
||||
{
|
||||
public enum LogType
|
||||
{
|
||||
|
||||
Error,
|
||||
Warning,
|
||||
Info,
|
||||
InfoError,
|
||||
InfoWarning,
|
||||
|
||||
}
|
||||
|
||||
internal static unsafe partial class InternalIO
|
||||
@@ -67,42 +71,45 @@ namespace StgSharp
|
||||
new Dictionary<TypeCode, uint>();
|
||||
|
||||
internal static readonly GCHandle ssc_logHandle =
|
||||
GCHandle.Alloc(new byte[512], GCHandleType.Pinned);
|
||||
GCHandle.Alloc( new byte[512], GCHandleType.Pinned );
|
||||
|
||||
internal static IntPtr SSClibPtr = IntPtr.Zero;
|
||||
|
||||
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
|
||||
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(
|
||||
1, 1 );
|
||||
|
||||
static InternalIO()
|
||||
{
|
||||
GLtype.Add(TypeCode.Single, GLconst.FLOAT);
|
||||
GLtype.Add(TypeCode.Int32, GLconst.INT);
|
||||
GLtype.Add(TypeCode.UInt32, GLconst.UNSIGNED_INT);
|
||||
GLtype.Add(TypeCode.Int16, GLconst.SHORT);
|
||||
GLtype.Add(TypeCode.UInt16, GLconst.UNSIGNED_SHORT);
|
||||
GLtype.Add(TypeCode.SByte, GLconst.BYTE);
|
||||
GLtype.Add(TypeCode.Byte, GLconst.UNSIGNED_BYTE);
|
||||
GLtype.Add( TypeCode.Single, GLconst.FLOAT );
|
||||
GLtype.Add( TypeCode.Int32, GLconst.INT );
|
||||
GLtype.Add( TypeCode.UInt32, GLconst.UNSIGNED_INT );
|
||||
GLtype.Add( TypeCode.Int16, GLconst.SHORT );
|
||||
GLtype.Add( TypeCode.UInt16, GLconst.UNSIGNED_SHORT );
|
||||
GLtype.Add( TypeCode.SByte, GLconst.BYTE );
|
||||
GLtype.Add( TypeCode.Byte, GLconst.UNSIGNED_BYTE );
|
||||
|
||||
fixed( IntrinsicContext* cptr = &_intrinsicContext ) {
|
||||
LoadIntrinsicFunction( cptr );
|
||||
}
|
||||
}
|
||||
|
||||
internal static void InternalAppendLog(string log)
|
||||
internal static void InternalAppendLog( string log )
|
||||
{
|
||||
if (!File.Exists(SS_errorLog))
|
||||
{
|
||||
FileStream stream = File.Create(SS_errorLog);
|
||||
if( !File.Exists( SS_errorLog ) ) {
|
||||
FileStream stream = File.Create( SS_errorLog );
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
using (StreamWriter logStream = File.AppendText(SS_errorLog))
|
||||
{
|
||||
logStream.WriteLine(log);
|
||||
using( StreamWriter logStream = File.AppendText( SS_errorLog ) ) {
|
||||
logStream.WriteLine( log );
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Not completed", true)]
|
||||
internal static IntPtr InternalLoadProc<T>(IntPtr lib, string name) where T : Delegate
|
||||
[Obsolete( "Not completed", true )]
|
||||
internal static IntPtr InternalLoadProc<T>( IntPtr lib, string name )
|
||||
where T: Delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
IntPtr procPtr =
|
||||
#if WINDOWS
|
||||
IntPtr.Zero;
|
||||
@@ -110,48 +117,48 @@ namespace StgSharp
|
||||
|
||||
#else
|
||||
IntPtr.Zero;
|
||||
#endif
|
||||
#endif
|
||||
return procPtr;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
catch( Exception ) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void InternalWriteLog(string logLine, LogType logType)
|
||||
internal static void InternalWriteLog( string logLine, LogType logType )
|
||||
{
|
||||
logSyncSemaphore.Wait();
|
||||
if (!File.Exists(SS_errorLog))
|
||||
{
|
||||
FileStream stream = File.Create(SS_errorLog);
|
||||
if( !File.Exists( SS_errorLog ) ) {
|
||||
FileStream stream = File.Create( SS_errorLog );
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
using (StreamWriter logStream = File.AppendText(SS_errorLog))
|
||||
{
|
||||
logStream.WriteLine($"{logType}\t{DateTime.Now.ToString("o")}");
|
||||
logStream.WriteLine(logLine);
|
||||
using( StreamWriter logStream = File.AppendText( SS_errorLog ) ) {
|
||||
logStream.WriteLine(
|
||||
$"{logType}\t{DateTime.Now.ToString("o")}" );
|
||||
logStream.WriteLine( logLine );
|
||||
}
|
||||
logSyncSemaphore.Release();
|
||||
}
|
||||
|
||||
internal static void InternalWriteLog(string beforeTime, string logLine, LogType logType)
|
||||
internal static void InternalWriteLog(
|
||||
string beforeTime,
|
||||
string logLine,
|
||||
LogType logType )
|
||||
{
|
||||
logSyncSemaphore.Wait();
|
||||
if (!File.Exists(InternalIO.SS_errorLog))
|
||||
{
|
||||
FileStream stream = File.Create(InternalIO.SS_errorLog);
|
||||
if( !File.Exists( InternalIO.SS_errorLog ) ) {
|
||||
FileStream stream = File.Create( InternalIO.SS_errorLog );
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
using (StreamWriter logStream = File.AppendText(SS_errorLog))
|
||||
{
|
||||
logStream.WriteLine(beforeTime);
|
||||
logStream.WriteLine($"{logType}\t@\t{DateTime.Now.ToString("o")}");
|
||||
logStream.WriteLine(logLine);
|
||||
using( StreamWriter logStream = File.AppendText( SS_errorLog ) ) {
|
||||
logStream.WriteLine( beforeTime );
|
||||
logStream.WriteLine(
|
||||
$"{logType}\t@\t{DateTime.Now.ToString("o")}" );
|
||||
logStream.WriteLine( logLine );
|
||||
}
|
||||
logSyncSemaphore.Release(1);
|
||||
logSyncSemaphore.Release( 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="KeyEnum.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using System;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public enum KeyboardKey : int
|
||||
{
|
||||
|
||||
UNKNOWN = -1,
|
||||
None = 0,
|
||||
Space = 32,
|
||||
Apostrophe = 39/*'*/,
|
||||
Comma = 44/*,*/,
|
||||
Minus = 45/*-*/,
|
||||
Period = 46/*.*/,
|
||||
Slash = 47/*/*/,
|
||||
Zero = 48,
|
||||
One = 49,
|
||||
Two = 50,
|
||||
Three = 51,
|
||||
Four = 52,
|
||||
Five = 53,
|
||||
Six = 54,
|
||||
Seven = 55,
|
||||
Eight = 56,
|
||||
Nine = 57,
|
||||
Semicolon = 59/*,*/,
|
||||
Equal = 61/*=*/,
|
||||
A = 65,
|
||||
B = 66,
|
||||
C = 67,
|
||||
D = 68,
|
||||
E = 69,
|
||||
F = 70,
|
||||
G = 71,
|
||||
H = 72,
|
||||
I = 73,
|
||||
J = 74,
|
||||
K = 75,
|
||||
L = 76,
|
||||
M = 77,
|
||||
N = 78,
|
||||
O = 79,
|
||||
P = 80,
|
||||
Q = 81,
|
||||
R = 82,
|
||||
S = 83,
|
||||
T = 84,
|
||||
U = 85,
|
||||
V = 86,
|
||||
W = 87,
|
||||
X = 88,
|
||||
Y = 89,
|
||||
Z = 90,
|
||||
LeftBracket = 91/*[*/,
|
||||
BACKSLASH = 92/*\*/,
|
||||
RightBracket = 93/*]*/,
|
||||
GraveAccent = 96/*`*/,
|
||||
World1 = 161/*non-US#1*/,
|
||||
World2 = 162/*non-US#2*/,
|
||||
Esc = 256,
|
||||
Enter = 257,
|
||||
Tab = 258,
|
||||
Backspace = 259,
|
||||
Insert = 260,
|
||||
Delete = 261,
|
||||
Right = 262,
|
||||
Left = 263,
|
||||
Down = 264,
|
||||
Up = 265,
|
||||
PgUp = 266,
|
||||
PgDown = 267,
|
||||
Home = 268,
|
||||
End = 269,
|
||||
CapsLock = 280,
|
||||
ScrollLock = 281,
|
||||
NumLock = 282,
|
||||
PrintScreen = 283,
|
||||
Pause = 284,
|
||||
F1 = 290,
|
||||
F2 = 291,
|
||||
F3 = 292,
|
||||
F4 = 293,
|
||||
F5 = 294,
|
||||
F6 = 295,
|
||||
F7 = 296,
|
||||
F8 = 297,
|
||||
F9 = 298,
|
||||
F10 = 299,
|
||||
F11 = 300,
|
||||
F12 = 301,
|
||||
F13 = 302,
|
||||
F14 = 303,
|
||||
F15 = 304,
|
||||
F16 = 305,
|
||||
F17 = 306,
|
||||
F18 = 307,
|
||||
F19 = 308,
|
||||
F20 = 309,
|
||||
F21 = 310,
|
||||
F22 = 311,
|
||||
F23 = 312,
|
||||
F24 = 313,
|
||||
F25 = 314,
|
||||
NumPad0 = 320,
|
||||
NumPad1 = 321,
|
||||
NumPad2 = 322,
|
||||
NumPad3 = 323,
|
||||
NumPad4 = 324,
|
||||
NumPad5 = 325,
|
||||
NumPad6 = 326,
|
||||
NumPad7 = 327,
|
||||
NumPad8 = 328,
|
||||
NumPad9 = 329,
|
||||
NumPadDec = 330,
|
||||
NumPadDiv = 331,
|
||||
NumPadMul = 332,
|
||||
NumPadSub = 333,
|
||||
NumPadAdd = 334,
|
||||
NumPadAnter = 335,
|
||||
NumPadEqual = 336,
|
||||
LeftShift = 340,
|
||||
LeftControl = 341,
|
||||
LeftAlt = 342,
|
||||
LeftSuper = 343,
|
||||
RightShift = 344,
|
||||
RightControl = 345,
|
||||
RightAlt = 346,
|
||||
RightSuper = 347,
|
||||
Menu = 348,
|
||||
First = Space,
|
||||
Last = Menu,
|
||||
|
||||
}
|
||||
|
||||
#pragma warning disable CA1707
|
||||
#pragma warning disable CA1712
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1027
|
||||
public enum Joystick : int
|
||||
#pragma warning restore CA1027
|
||||
{
|
||||
|
||||
Joystick_1 = GLconst.GLFW_JOYSTICK_1,
|
||||
Joystick_2 = GLconst.GLFW_JOYSTICK_2,
|
||||
Joystick_3 = GLconst.GLFW_JOYSTICK_3,
|
||||
Joystick_4 = GLconst.GLFW_JOYSTICK_4,
|
||||
Joystick_5 = GLconst.GLFW_JOYSTICK_5,
|
||||
Joystick_6 = GLconst.GLFW_JOYSTICK_6,
|
||||
Joystick_7 = GLconst.GLFW_JOYSTICK_7,
|
||||
Joystick_8 = GLconst.GLFW_JOYSTICK_8,
|
||||
Joystick_9 = GLconst.GLFW_JOYSTICK_9,
|
||||
Joystick_10 = GLconst.GLFW_JOYSTICK_10,
|
||||
Joystick_11 = GLconst.GLFW_JOYSTICK_11,
|
||||
Joystick_12 = GLconst.GLFW_JOYSTICK_12,
|
||||
Joystick_13 = GLconst.GLFW_JOYSTICK_13,
|
||||
Joystick_14 = GLconst.GLFW_JOYSTICK_14,
|
||||
Joystick_15 = GLconst.GLFW_JOYSTICK_15,
|
||||
Joystick_16 = GLconst.GLFW_JOYSTICK_16,
|
||||
First = Joystick_1,
|
||||
Last = Joystick_16
|
||||
|
||||
}
|
||||
|
||||
[System.Flags]
|
||||
public enum Mouse : int
|
||||
{
|
||||
|
||||
Button1 = 0,
|
||||
Button2 = 1,
|
||||
Button3 = 2,
|
||||
Button4 = 3,
|
||||
Button5 = 4,
|
||||
Button6 = 5,
|
||||
Button7 = 6,
|
||||
Button8 = 7,
|
||||
First = Button1,
|
||||
Last = Button8,
|
||||
Left = Button1,
|
||||
Right = Button2,
|
||||
Middle = Button3
|
||||
|
||||
}
|
||||
|
||||
#pragma warning restore CA1707
|
||||
#pragma warning restore CA1712
|
||||
#pragma warning restore CA7008
|
||||
|
||||
internal enum InputEquipment
|
||||
{
|
||||
|
||||
Keyboard,
|
||||
Mouse,
|
||||
Joystick
|
||||
|
||||
}
|
||||
|
||||
public enum KeyStatus : int
|
||||
{
|
||||
|
||||
RELEASE = 0,
|
||||
PRESS = 1
|
||||
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
[AttributeUsage( AttributeTargets.Method )]
|
||||
public class KeyEventAttribute : Attribute
|
||||
{
|
||||
|
||||
@@ -44,27 +44,26 @@ namespace StgSharp
|
||||
internal int _keyStat;
|
||||
internal int _keyTarget;
|
||||
|
||||
public KeyEventAttribute(KeyboardKey key, KeyStatus status)
|
||||
public KeyEventAttribute( KeyboardKey key, KeyStatus status )
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)key;
|
||||
_keyStat = (int)status;
|
||||
_equipment = ( int )InputEquipment.Keyboard;
|
||||
_keyTarget = ( int )key;
|
||||
_keyStat = ( int )status;
|
||||
}
|
||||
|
||||
public KeyEventAttribute(Joystick joystick, KeyStatus status)
|
||||
public KeyEventAttribute( Joystick joystick, KeyStatus status )
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)joystick;
|
||||
_keyStat = (int)status;
|
||||
_equipment = ( int )InputEquipment.Keyboard;
|
||||
_keyTarget = ( int )joystick;
|
||||
_keyStat = ( int )status;
|
||||
}
|
||||
|
||||
public KeyEventAttribute(Mouse mouse, KeyStatus status)
|
||||
public KeyEventAttribute( Mouse mouse, KeyStatus status )
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)mouse;
|
||||
_keyStat = (int)status;
|
||||
_equipment = ( int )InputEquipment.Keyboard;
|
||||
_keyTarget = ( int )mouse;
|
||||
_keyStat = ( int )status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="IClickTrigger.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public interface IClickTrigger
|
||||
{
|
||||
|
||||
public int TargetKeyOrButtonID
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public KeyStatus TriggeredStatus
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,47 +34,57 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public struct JoystickTrigger : ITrigger, IEquatable<JoystickTrigger>
|
||||
public readonly struct JoystickTrigger : IClickTrigger, IEquatable<JoystickTrigger>
|
||||
{
|
||||
|
||||
private KeyStatus _triggeredStat;
|
||||
public Joystick Stick;
|
||||
private readonly Joystick _stick;
|
||||
private readonly KeyStatus _status;
|
||||
|
||||
public JoystickTrigger(Joystick targetKey)
|
||||
public JoystickTrigger( Joystick targetKey, KeyStatus status )
|
||||
{
|
||||
this.Stick = targetKey;
|
||||
this._stick = targetKey;
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public int TargetKeyOrButtonID => (int)Stick;
|
||||
public int TargetKeyOrButtonID => ( int )_stick;
|
||||
|
||||
public KeyStatus TriggeredStatus => _triggeredStat;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public Joystick Stick
|
||||
{
|
||||
return base.Equals(obj);
|
||||
get => _stick;
|
||||
}
|
||||
|
||||
public KeyStatus TriggeredStatus => _status;
|
||||
|
||||
public override bool Equals( object obj )
|
||||
{
|
||||
return base.Equals( obj );
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ((int)Stick) + (17 * ((int)_triggeredStat));
|
||||
return ( ( int )_stick ) + ( 17 * ( ( int )_status ) );
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Key {Stick} triggered when {_triggeredStat}";
|
||||
return $"Key {_stick} triggered when {_status}";
|
||||
}
|
||||
|
||||
public static bool operator !=(JoystickTrigger left, JoystickTrigger right)
|
||||
public static bool operator !=(
|
||||
JoystickTrigger left,
|
||||
JoystickTrigger right )
|
||||
{
|
||||
return !(left == right);
|
||||
return !( left == right );
|
||||
}
|
||||
|
||||
public static bool operator ==(JoystickTrigger left, JoystickTrigger right)
|
||||
public static bool operator ==(
|
||||
JoystickTrigger left,
|
||||
JoystickTrigger right )
|
||||
{
|
||||
return (left._triggeredStat == right._triggeredStat) && (left.Stick == right.Stick);
|
||||
return ( left._status == right._status ) && ( left._stick == right._stick );
|
||||
}
|
||||
|
||||
bool IEquatable<JoystickTrigger>.Equals(JoystickTrigger other)
|
||||
bool IEquatable<JoystickTrigger>.Equals( JoystickTrigger other )
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
|
||||
@@ -35,31 +35,30 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
|
||||
public struct KeyTrigger : ITrigger, IEquatable<KeyTrigger>
|
||||
public readonly struct KeyTrigger : IClickTrigger, IEquatable<KeyTrigger>
|
||||
{
|
||||
|
||||
private KeyboardKey _targetKey;
|
||||
private KeyStatus _triggerStat;
|
||||
private readonly KeyboardKey _targetKey;
|
||||
private readonly KeyStatus _triggerStat;
|
||||
|
||||
public KeyTrigger(KeyboardKey targetKey, KeyStatus targetStat)
|
||||
public KeyTrigger( KeyboardKey targetKey, KeyStatus targetStat )
|
||||
{
|
||||
this._targetKey = targetKey;
|
||||
this._triggerStat = targetStat;
|
||||
}
|
||||
|
||||
public int TargetKeyOrButtonID => (int)_targetKey;
|
||||
public int TargetKeyOrButtonID => ( int )_targetKey;
|
||||
|
||||
public KeyStatus TriggeredStatus => _triggerStat;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals( object obj )
|
||||
{
|
||||
return base.Equals(obj);
|
||||
return base.Equals( obj );
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ((int)_targetKey) + (17 * ((int)_triggerStat));
|
||||
return ( ( int )_targetKey ) + ( 17 * ( ( int )_triggerStat ) );
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -67,17 +66,17 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
return $"Key {_targetKey} triggered when {_triggerStat}";
|
||||
}
|
||||
|
||||
public static bool operator !=(KeyTrigger left, KeyTrigger right)
|
||||
public static bool operator !=( KeyTrigger left, KeyTrigger right )
|
||||
{
|
||||
return !(left == right);
|
||||
return !( left == right );
|
||||
}
|
||||
|
||||
public static bool operator ==(KeyTrigger left, KeyTrigger right)
|
||||
public static bool operator ==( KeyTrigger left, KeyTrigger right )
|
||||
{
|
||||
return (left._triggerStat == right._triggerStat) && (left._targetKey == right._targetKey);
|
||||
return ( left._triggerStat == right._triggerStat ) && ( left._targetKey == right._targetKey );
|
||||
}
|
||||
|
||||
bool IEquatable<KeyTrigger>.Equals(KeyTrigger other)
|
||||
bool IEquatable<KeyTrigger>.Equals( KeyTrigger other )
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="MouseTrigger.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.SymbolStore;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public readonly struct MouseTrigger : IClickTrigger, IEquatable<MouseTrigger>
|
||||
{
|
||||
|
||||
private readonly KeyStatus _status;
|
||||
private readonly Mouse _mouse;
|
||||
|
||||
public MouseTrigger( Mouse mouse, KeyStatus status )
|
||||
{
|
||||
_mouse = mouse;
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public int TargetKeyOrButtonID => ( int )_mouse;
|
||||
|
||||
public KeyStatus TriggeredStatus => _status;
|
||||
|
||||
public bool Equals( MouseTrigger other )
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
|
||||
public static bool operator !=( MouseTrigger left, MouseTrigger right )
|
||||
{
|
||||
return left._mouse != right._mouse || left._status != right._status;
|
||||
}
|
||||
|
||||
public static bool operator ==( MouseTrigger left, MouseTrigger right )
|
||||
{
|
||||
return left._mouse == right._mouse && left._status == right._status;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="TriggetFactory.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public static class TriggetBuilder
|
||||
{
|
||||
|
||||
private const int JoystickMax = ( int )Joystick.Last + 1;
|
||||
private const int JoystickMin = ( int )Joystick.First - 1;
|
||||
private const int KeyboardMax = ( int )KeyboardKey.Last + 1;
|
||||
private const int KeyboardMin = ( int )KeyboardKey.First - 1;
|
||||
private const int MouseMax = ( int )Mouse.Last + 1;
|
||||
private const int MouseMin = ( int )Mouse.First - 1;
|
||||
|
||||
private static KeyTrigger keyboardtemp;
|
||||
private static MouseTrigger mousetemp;
|
||||
|
||||
public static JoystickTrigger BuildJoystickClickTrigger(
|
||||
int keyCode,
|
||||
KeyStatus status )
|
||||
{
|
||||
if( keyCode > MouseMin && keyCode < MouseMax ) {
|
||||
return new JoystickTrigger( ( Joystick )keyCode, status );
|
||||
}
|
||||
throw new InvalidOperationException(
|
||||
"Known key code or key is not on joystick." );
|
||||
}
|
||||
|
||||
public static KeyTrigger BuildKeyboardClickTrigger(
|
||||
int keyCode,
|
||||
KeyStatus status )
|
||||
{
|
||||
if( keyCode > KeyboardMin && keyCode < KeyboardMax ) {
|
||||
return new KeyTrigger( ( KeyboardKey )keyCode, status );
|
||||
}
|
||||
throw new InvalidOperationException(
|
||||
"Known key code or kay is not on keyboard." );
|
||||
}
|
||||
|
||||
public static MouseTrigger BuildMouseClickTrigger(
|
||||
int keyCode,
|
||||
KeyStatus status )
|
||||
{
|
||||
if( keyCode >= MouseMin && keyCode <= MouseMax ) {
|
||||
return new MouseTrigger( ( Mouse )keyCode, status );
|
||||
}
|
||||
throw new InvalidOperationException(
|
||||
"Known key code or key is not on mouse." );
|
||||
}
|
||||
|
||||
public static IClickTrigger BuildTrigger(
|
||||
int keyCode,
|
||||
KeyStatus status )
|
||||
{
|
||||
if( keyCode > KeyboardMin && keyCode < KeyboardMax ) {
|
||||
return new KeyTrigger( ( KeyboardKey )keyCode, status );
|
||||
}
|
||||
if( keyCode > JoystickMin && keyCode < JoystickMax ) {
|
||||
return new JoystickTrigger( ( Joystick )keyCode, status );
|
||||
}
|
||||
if( keyCode >= MouseMin && keyCode <= MouseMax ) {
|
||||
return new MouseTrigger( ( Mouse )keyCode, status );
|
||||
}
|
||||
throw new InvalidOperationException( "Known key code." );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user