daily update on 20240528 by nitload youmu
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="BattleField.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.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
//TODO 这玩意如何加载一个渲染流程以获得各个图元还没搞清楚
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class BattleField : ControllingItem
|
||||
{
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class CharacterLineIndexImage : ControllingItem
|
||||
{
|
||||
private int length;
|
||||
private char[] displayIndex;
|
||||
private char defaultChar;
|
||||
|
||||
Dictionary<char, PlainGeometryMesh> texIndex;
|
||||
|
||||
PlainGeometryMesh _tittleMesh;
|
||||
|
||||
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);
|
||||
|
||||
displayIndex = result.ToCharArray();
|
||||
}
|
||||
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return _tittleMesh;
|
||||
foreach (char item in displayIndex)
|
||||
{
|
||||
yield return texIndex[item];
|
||||
}
|
||||
}
|
||||
|
||||
public CharacterLineIndexImage(
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public abstract partial class ControllingItem: IEnumerable<PlainGeometryMesh>
|
||||
{
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public abstract IEnumerator<PlainGeometryMesh> GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class DecorationBox : ControllingItem
|
||||
{
|
||||
private PlainGeometryMesh renderMesh;
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return renderMesh;
|
||||
}
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(BoundingBox, texture, texCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="KeyboardButton.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.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class KeyboardButton : ControllingItem
|
||||
{
|
||||
private PlainGeometryMesh current;
|
||||
private AnimationBuilder switchAnimationBuilder;
|
||||
|
||||
private Action? enableAction;
|
||||
private Action? disableAction;
|
||||
private Action? confirmAction;
|
||||
|
||||
public bool IsHighLighted { get; internal set; }
|
||||
public bool IsDisabled { get; internal set; }
|
||||
|
||||
public event Action EnableEvent
|
||||
{
|
||||
add { enableAction += value; }
|
||||
remove { enableAction -= value; }
|
||||
}
|
||||
|
||||
public event Action DisableEvent
|
||||
{
|
||||
add { disableAction += value; }
|
||||
remove { disableAction -= value; }
|
||||
}
|
||||
|
||||
public event Action ConfirmEvent
|
||||
{
|
||||
add { confirmAction += value; }
|
||||
remove { confirmAction -= value; }
|
||||
}
|
||||
|
||||
public void Enable(AnimationBuilder animation)
|
||||
{
|
||||
if (!IsDisabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (switchAnimationBuilder.IsComplete || switchAnimationBuilder == null)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if( enableAction != null)enableAction();
|
||||
}
|
||||
|
||||
public void Disable(AnimationBuilder animation)
|
||||
{
|
||||
if (switchAnimationBuilder.IsComplete || switchAnimationBuilder == null)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if (disableAction != null) disableAction();
|
||||
}
|
||||
|
||||
public void Highlight(AnimationBuilder animation)
|
||||
{
|
||||
if (switchAnimationBuilder.IsComplete || switchAnimationBuilder == null)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if (confirmAction != null) confirmAction();
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
current.Texture = switchAnimationBuilder.GetAnimationFrame();
|
||||
yield return current;
|
||||
}
|
||||
|
||||
}//----------------------------------- End of class --------------------------------------------
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.Controls
|
||||
{
|
||||
public class MarkingLabel : ControllingItem
|
||||
{
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
private vec2d _currentPosition, _movementVec;
|
||||
|
||||
private TimeFunction _movement;
|
||||
private PlainGeometryMesh marker;
|
||||
|
||||
public void MoveTo(vec2d target)
|
||||
{
|
||||
Move(target - Position);
|
||||
}
|
||||
|
||||
public void Move(vec2d movement)
|
||||
{
|
||||
if (!_movement.IsComplete)
|
||||
{
|
||||
Position = _currentPosition + _movement.Calculate() * _movementVec;
|
||||
}
|
||||
}
|
||||
|
||||
public MarkingLabel(PlainGeometryMesh marker, TimeFunction movement)
|
||||
{
|
||||
this.marker = marker;
|
||||
_movement = movement;
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public class ViewDesigner
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}//---------------------------------- End of Class -----------------------------------------
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Get.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.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public partial class ViewModel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Get the status of a certain key on the keyboard.
|
||||
/// </summary>
|
||||
/// <param name="form"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyStatus GetKeyStatus(ViewModel form, KeyboardKey key)
|
||||
{
|
||||
return InternalIO.glfwGetKey(form.id, (int)key);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,155 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="InternalIO.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.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.GL;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
#if Windows
|
||||
|
||||
#endif
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public enum LogType
|
||||
{
|
||||
Error,
|
||||
Warning,
|
||||
Info,
|
||||
InfoError,
|
||||
InfoWarning,
|
||||
}
|
||||
|
||||
internal static unsafe partial class InternalIO
|
||||
{
|
||||
internal const string SS_errorLog =
|
||||
"SS_errorlog.log";
|
||||
|
||||
internal const string SSC_libName =
|
||||
"StgSharpC";
|
||||
|
||||
internal static Dictionary<TypeCode, uint> GLtype =
|
||||
new Dictionary<TypeCode, uint>();
|
||||
|
||||
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
internal static readonly GCHandle ssc_logHandle =
|
||||
GCHandle.Alloc(new byte[512], GCHandleType.Pinned);
|
||||
|
||||
internal static IntPtr SSClibPtr = IntPtr.Zero;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
internal static void InternalAppendLog(string log)
|
||||
{
|
||||
if (!File.Exists(SS_errorLog))
|
||||
{
|
||||
FileStream stream = File.Create(SS_errorLog);
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr procPtr =
|
||||
#if Windows
|
||||
IntPtr.Zero;
|
||||
#elif Linux
|
||||
|
||||
#endif
|
||||
return procPtr;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void InternalWriteLog(string logLine, LogType logType)
|
||||
{
|
||||
logSyncSemaphore.Wait();
|
||||
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);
|
||||
}
|
||||
logSyncSemaphore.Release();
|
||||
}
|
||||
|
||||
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);
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="KeyControl.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 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*/,
|
||||
ESCAPE = 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,
|
||||
NumPadSiv = 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
|
||||
}
|
||||
|
||||
#pragma warning disable CA1707
|
||||
#pragma warning disable CA1712
|
||||
#pragma warning disable CA1008
|
||||
[System.Flags]
|
||||
public enum Joystick : int
|
||||
{
|
||||
JOYSTICK_1 = 0,
|
||||
JOYSTICK_2 = 1,
|
||||
JOYSTICK_3 = 2,
|
||||
JOYSTICK_4 = 3,
|
||||
JOYSTICK_5 = 4,
|
||||
JOYSTICK_6 = 5,
|
||||
JOYSTICK_7 = 6,
|
||||
JOYSTICK_8 = 7,
|
||||
JOYSTICK_9 = 8,
|
||||
JOYSTICK_10 = 9,
|
||||
JOYSTICK_11 = 10,
|
||||
JOYSTICK_12 = 11,
|
||||
JOYSTICK_13 = 12,
|
||||
JOYSTICK_14 = 13,
|
||||
JOYSTICK_15 = 14,
|
||||
JOYSTICK_16 = 15,
|
||||
JOYSTICK_LAST = JOYSTICK_16
|
||||
}
|
||||
|
||||
[System.Flags]
|
||||
public enum Mouse : int
|
||||
{
|
||||
BUTTON_1 = 0,
|
||||
BUTTON_2 = 1,
|
||||
BUTTON_3 = 2,
|
||||
BUTTON_4 = 3,
|
||||
BUTTON_5 = 4,
|
||||
BUTTON_6 = 5,
|
||||
BUTTON_7 = 6,
|
||||
BUTTON_8 = 7,
|
||||
BUTTON_LAST = BUTTON_8,
|
||||
BUTTON_LEFT = BUTTON_1,
|
||||
BUTTON_RIGHT = BUTTON_2,
|
||||
BUTTON_MIDDLE = BUTTON_3
|
||||
}
|
||||
#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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
[AttributeUsage( AttributeTargets.Method)]
|
||||
public class KeyEventAttribute:Attribute
|
||||
{
|
||||
internal int _keyTarget;
|
||||
internal int _equipment;
|
||||
internal int _keyStat;
|
||||
|
||||
public KeyEventAttribute(KeyboardKey key ,KeyStatus status)
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)key;
|
||||
_keyStat = (int)status;
|
||||
}
|
||||
|
||||
public KeyEventAttribute(Joystick joystick, KeyStatus status)
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)joystick;
|
||||
_keyStat = (int)status;
|
||||
}
|
||||
|
||||
public KeyEventAttribute(Mouse mouse, KeyStatus status)
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)mouse;
|
||||
_keyStat = (int)status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
|
||||
public partial class ViewModel
|
||||
{
|
||||
Dictionary<KeyboardKey, KeyBoardEvent> keyEventDictionary = new Dictionary<KeyboardKey, KeyBoardEvent>();
|
||||
|
||||
internal void InternalLoadInput(MethodInfo[] methods)
|
||||
{
|
||||
if (methods.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (MethodInfo m in methods) //find all methods decorated by RenderActivityAttribute
|
||||
{
|
||||
KeyEventAttribute attr = m.GetCustomAttribute<KeyEventAttribute>(false);
|
||||
if (attr == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!m.IsStatic && (m.GetParameters().Length != 0) && (m.ReturnType != typeof(void)))
|
||||
{
|
||||
throw new NotSupportedException("A render activity cannot have parameters, returning value or be static.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void InternalProcessInput()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public delegate void KeyBoardEvent(KeyboardKey key, KeyStatus status);
|
||||
public delegate void MouseEvent(Mouse mouse, KeyStatus status);
|
||||
public delegate void JoystickEvent(Joystick joystick, KeyStatus status);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user