new mat proc std
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="BattleField"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
// TODO 这玩意如何加载一个渲染流程以获得各个图元还没搞清楚
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class BattleField : ControllingItem
|
||||
{
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public Vec2 Position { get; set; }
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ButtonGroup"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Transactions;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public abstract class KeyboardButtonGroup : ControllingItem
|
||||
{
|
||||
|
||||
private List<TriggerButton> buttonList;
|
||||
private TriggerButton current;
|
||||
|
||||
public KeyboardButtonGroup()
|
||||
{
|
||||
buttonList = new List<TriggerButton>();
|
||||
}
|
||||
|
||||
public bool IsEntity
|
||||
{
|
||||
get => false;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public TriggerButton CurrentButton
|
||||
{
|
||||
get => current;
|
||||
}
|
||||
|
||||
public Vec2 Position { get; set; }
|
||||
|
||||
protected List<TriggerButton> AllButton
|
||||
{
|
||||
get => buttonList;
|
||||
}
|
||||
|
||||
public void AddButton(TriggerButton button)
|
||||
{
|
||||
buttonList.Add(button);
|
||||
}
|
||||
|
||||
public abstract void Confirm();
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
foreach (TriggerButton item in buttonList) {
|
||||
yield return item.Single();
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveDown()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Down != null) && button.Down.IsDisabled) {
|
||||
button = button.Right;
|
||||
}
|
||||
if (current == button) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
button.Enable();
|
||||
current = button;
|
||||
}
|
||||
|
||||
public void MoveLeft()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Left != null) && button.Left.IsDisabled) {
|
||||
button = button.Left;
|
||||
}
|
||||
if (current == button) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
button.Enable();
|
||||
current = button;
|
||||
}
|
||||
|
||||
public void MoveRight()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Right != null) && button.Right.IsDisabled) {
|
||||
button = button.Right;
|
||||
}
|
||||
if (current == button) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
button.Enable();
|
||||
current = button;
|
||||
}
|
||||
|
||||
public void MoveUp()
|
||||
{
|
||||
TriggerButton button = current;
|
||||
while ((button.Up != null) && button.Up.IsDisabled) {
|
||||
button = button.Right;
|
||||
}
|
||||
if (current == button) {
|
||||
return;
|
||||
}
|
||||
current.DeHighlight();
|
||||
button.Enable();
|
||||
current = button;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="CharacterIndexImage"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
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 char[] displayIndex;
|
||||
private char defaultChar;
|
||||
|
||||
private Dictionary<char, PlainGeometryMesh> texIndex;
|
||||
private int length;
|
||||
private PlainGeometryMesh _tittleMesh;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public bool IsEntity
|
||||
{
|
||||
get => true;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox
|
||||
{
|
||||
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);
|
||||
|
||||
displayIndex = result.ToCharArray();
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return _tittleMesh;
|
||||
foreach (char item in displayIndex) {
|
||||
yield return texIndex[item];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ControllingIntem"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public interface ControllingItem : IEnumerable<PlainGeometryMesh>
|
||||
{
|
||||
|
||||
public abstract bool IsEntity { get; }
|
||||
|
||||
public abstract ReadOnlySpan<Vec4> TextureBox { get; }
|
||||
|
||||
public abstract Rectangle BoundingBox { get; set; }
|
||||
|
||||
public abstract Vec2 Position { get; set; }
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="DecorationBox.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.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class DecorationBox : ControllingItem
|
||||
{
|
||||
|
||||
private PlainGeometryMesh renderMesh;
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, Vec2[] texCoord)
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(
|
||||
BoundingBox, new TextureProvider(texture, texCoord));
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => renderMesh.TextureCoord;
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public Vec2 Position { get; set; }
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return renderMesh;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MarkingLable"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class MarkingLabel : ControllingItem
|
||||
{
|
||||
|
||||
private PlainGeometryMesh marker;
|
||||
|
||||
private Vec2 _currentPosition, _movementVec;
|
||||
|
||||
public MarkingLabel(PlainGeometryMesh marker)
|
||||
{
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => marker.TextureCoord;
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public Vec2 Position { get; set; }
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return marker;
|
||||
}
|
||||
|
||||
public void Move(Vec2 movement)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void MoveTo(Vec2 target)
|
||||
{
|
||||
Move(target - Position);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="TriggerButton"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public delegate void RenderButtonTextureCallback(ButtonStatus status, float beginTime, in TextureProvider texture);
|
||||
|
||||
public enum ButtonStatus
|
||||
{
|
||||
|
||||
Error = 0b0,
|
||||
Disable = 0b1,
|
||||
Enable = 0b10,
|
||||
Highlight = 0b100,
|
||||
Confirm = 0b1000,
|
||||
|
||||
DisableToEnable = Disable | Enable,
|
||||
EnableToDisable = -(Enable | DisableToEnable),
|
||||
|
||||
EnableToHighlight = Enable | Highlight,
|
||||
HighlightToEnable = -(Enable | Highlight),
|
||||
|
||||
HighlightToDisable = -(Highlight | Disable),
|
||||
|
||||
}
|
||||
|
||||
public class TriggerButton : ControllingItem
|
||||
{
|
||||
|
||||
private Action? confirmCallback;
|
||||
private Action? disableCallback;
|
||||
|
||||
#nullable enable
|
||||
private Action? enableCallback;
|
||||
private float _statusBeginTime;
|
||||
|
||||
private RenderButtonTextureCallback _renderButton;
|
||||
private TextureProvider _texture;
|
||||
|
||||
#nullable restore
|
||||
|
||||
public TriggerButton()
|
||||
{
|
||||
CurrentStatus = ButtonStatus.Disable;
|
||||
}
|
||||
|
||||
public event Action ConfirmEvent
|
||||
{
|
||||
add { confirmCallback += value; }
|
||||
remove { confirmCallback -= value; }
|
||||
}
|
||||
|
||||
public event Action DisableEvent
|
||||
{
|
||||
add { disableCallback += value; }
|
||||
remove { disableCallback -= value; }
|
||||
}
|
||||
|
||||
public event Action EnableEvent
|
||||
{
|
||||
add { enableCallback += value; }
|
||||
remove { enableCallback -= value; }
|
||||
}
|
||||
|
||||
public event RenderButtonTextureCallback RenderButtonTexture
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_renderButton == null)
|
||||
{
|
||||
_renderButton = value;
|
||||
} else
|
||||
{
|
||||
_renderButton += value;
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
if (_renderButton != null) {
|
||||
_renderButton -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHighLighted { get; internal set; }
|
||||
|
||||
public bool IsDisabled { get; internal set; }
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<Vec4> TextureBox
|
||||
{
|
||||
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 Vec2 Position { get; set; }
|
||||
|
||||
internal TextureProvider Texture
|
||||
{
|
||||
get => _texture;
|
||||
set => _texture = value;
|
||||
}
|
||||
|
||||
protected ButtonStatus CurrentStatus { get; set; }
|
||||
|
||||
public void DeHighlight()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Highlight) {
|
||||
CurrentStatus = ButtonStatus.HighlightToEnable;
|
||||
}
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
CurrentStatus = CurrentStatus switch
|
||||
{
|
||||
ButtonStatus.Enable => ButtonStatus.EnableToDisable,
|
||||
ButtonStatus.Highlight => ButtonStatus.HighlightToDisable,
|
||||
_ => CurrentStatus,
|
||||
};
|
||||
if (disableCallback != null) {
|
||||
disableCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Disable)
|
||||
{
|
||||
CurrentStatus = ButtonStatus.DisableToEnable;
|
||||
} else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (enableCallback != null) {
|
||||
enableCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
_renderButton(CurrentStatus, _statusBeginTime, in _texture);
|
||||
yield return new PlainGeometryMesh(this.BoundingBox, _texture);
|
||||
}
|
||||
|
||||
public void Highlight()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Enable)
|
||||
{
|
||||
CurrentStatus |= ButtonStatus.EnableToHighlight;
|
||||
} else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (confirmCallback != null) {
|
||||
confirmCallback();
|
||||
}
|
||||
}
|
||||
|
||||
internal void Init(ButtonStatus status)
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Error) {
|
||||
CurrentStatus = status;
|
||||
}
|
||||
}
|
||||
|
||||
}//----------------------------------- End of class --------------------------------------------
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="KeyEnum"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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 = FrameworkConstant. JOYSTICK_1,
|
||||
Joystick_2 = FrameworkConstant. JOYSTICK_2,
|
||||
Joystick_3 = FrameworkConstant. JOYSTICK_3,
|
||||
Joystick_4 = FrameworkConstant. JOYSTICK_4,
|
||||
Joystick_5 = FrameworkConstant. JOYSTICK_5,
|
||||
Joystick_6 = FrameworkConstant. JOYSTICK_6,
|
||||
Joystick_7 = FrameworkConstant. JOYSTICK_7,
|
||||
Joystick_8 = FrameworkConstant. JOYSTICK_8,
|
||||
Joystick_9 = FrameworkConstant. JOYSTICK_9,
|
||||
Joystick_10 = FrameworkConstant.JOYSTICK_10,
|
||||
Joystick_11 = FrameworkConstant.JOYSTICK_11,
|
||||
Joystick_12 = FrameworkConstant.JOYSTICK_12,
|
||||
Joystick_13 = FrameworkConstant.JOYSTICK_13,
|
||||
Joystick_14 = FrameworkConstant.JOYSTICK_14,
|
||||
Joystick_15 = FrameworkConstant.JOYSTICK_15,
|
||||
Joystick_16 = FrameworkConstant.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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="KeyEventAttribute"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class KeyEventAttribute : Attribute
|
||||
{
|
||||
|
||||
internal int _equipment;
|
||||
internal int _keyStat;
|
||||
internal int _keyTarget;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="IClickTrigger"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="JoystickTrigger"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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 readonly struct JoystickTrigger : IClickTrigger, IEquatable<JoystickTrigger>
|
||||
{
|
||||
|
||||
private readonly Joystick _stick;
|
||||
private readonly KeyStatus _status;
|
||||
|
||||
public JoystickTrigger(Joystick targetKey, KeyStatus status)
|
||||
{
|
||||
this._stick = targetKey;
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public int TargetKeyOrButtonID => (int)_stick;
|
||||
|
||||
public Joystick Stick
|
||||
{
|
||||
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)_status));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Key {_stick} triggered when {_status}";
|
||||
}
|
||||
|
||||
public static bool operator !=(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static bool operator ==(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return (left._status == right._status) && (left._stick == right._stick);
|
||||
}
|
||||
|
||||
bool IEquatable<JoystickTrigger>.Equals(JoystickTrigger other)
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="KeyTrigger"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Data.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public readonly struct KeyTrigger : IClickTrigger, IEquatable<KeyTrigger>
|
||||
{
|
||||
|
||||
private readonly KeyboardKey _targetKey;
|
||||
private readonly KeyStatus _triggerStat;
|
||||
|
||||
public KeyTrigger(KeyboardKey targetKey, KeyStatus targetStat)
|
||||
{
|
||||
this._targetKey = targetKey;
|
||||
this._triggerStat = targetStat;
|
||||
}
|
||||
|
||||
public int TargetKeyOrButtonID => (int)_targetKey;
|
||||
|
||||
public KeyStatus TriggeredStatus => _triggerStat;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ((int)_targetKey) + (17 * ((int)_triggerStat));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Key {_targetKey} triggered when {_triggerStat}";
|
||||
}
|
||||
|
||||
public static bool operator !=(KeyTrigger left, KeyTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static bool operator ==(KeyTrigger left, KeyTrigger right)
|
||||
{
|
||||
return (left._triggerStat == right._triggerStat) && (left._targetKey == right._targetKey);
|
||||
}
|
||||
|
||||
bool IEquatable<KeyTrigger>.Equals(KeyTrigger other)
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MouseTrigger"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="TriggetFactory"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="IStaticModule"
|
||||
// Project: StgSharp
|
||||
@@ -40,12 +40,14 @@ namespace StgSharp
|
||||
|
||||
}
|
||||
|
||||
public class ModuleToInitializeCollection : IEnumerable<IStaticModule>, IStaticModule
|
||||
public sealed class ModuleToInitializeCollection : IEnumerable<IStaticModule>, IStaticModule
|
||||
{
|
||||
|
||||
private readonly List<IStaticModule> _modules = [];
|
||||
|
||||
internal ModuleToInitializeCollection(World.Initializer i)
|
||||
internal ModuleToInitializeCollection(
|
||||
World.Initializer i
|
||||
)
|
||||
{
|
||||
_modules.Add(i);
|
||||
}
|
||||
@@ -62,7 +64,7 @@ namespace StgSharp
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleToInitializeCollection UseModule<T>() where T: IStaticModule, new()
|
||||
public ModuleToInitializeCollection UseModule<T>() where T : IStaticModule, new()
|
||||
{
|
||||
_modules.Add(new T());
|
||||
return this;
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="globalKeyStat"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static partial class World
|
||||
{
|
||||
|
||||
private static ConcurrentDictionary<int, KeyStatus> keyListener
|
||||
= new ConcurrentDictionary<int, KeyStatus>();
|
||||
|
||||
public static KeyStatus CheckKey(KeyboardKey key)
|
||||
{
|
||||
return keyListener.GetOrAdd((int)key, KeyStatus.RELEASE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewBase"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.MVVM
|
||||
{
|
||||
/// <summary>
|
||||
/// ViewBase is the base type for all view types, providing context binding and control
|
||||
/// element binding. A complete view should contain one complete <see cref="ViewDesigner{T}"
|
||||
/// />, <see cref="ViewRender{TView}" />, and <see cref="ViewResponder" />, which provide
|
||||
/// layout descriptions of control elements, user responses, and rendering implementations in
|
||||
/// the view. Data between instances of <see cref="ViewDesigner{T}" />, <see
|
||||
/// cref="ViewRender{TView}" />, and <see cref="ViewResponder{T}" /> is shared through <see
|
||||
/// cref="ViewBase" />.
|
||||
/// </summary>
|
||||
|
||||
public abstract unsafe partial class ViewBase
|
||||
{
|
||||
|
||||
private (int x, int y, int z) unitCubeSize;
|
||||
|
||||
private GetDataBindingEntryDelegate getDataBindingEntry;
|
||||
|
||||
private int usedFrame;
|
||||
private IViewDesigner<ViewBase> _design;
|
||||
private IViewRender<ViewBase> _render;
|
||||
private IViewResponder<ViewBase> _responder;
|
||||
private TimeSpanProvider time;
|
||||
|
||||
private ViewPort context;
|
||||
|
||||
private delegate bool GetDataBindingEntryDelegate(string name, out DataBindingEntry entry);
|
||||
|
||||
public DataBindingEntry this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (getDataBindingEntry(name, out DataBindingEntry entry)) {
|
||||
return entry;
|
||||
}
|
||||
if (TryGetObjectReference(name, out entry)) {
|
||||
return entry;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
public (int x, int y, int z) UnitCubeSize
|
||||
{
|
||||
get => unitCubeSize;
|
||||
}
|
||||
|
||||
public bool Activated { get; internal set; }
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => context.Height;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => context.Width;
|
||||
}
|
||||
|
||||
public IntPtr Monitor => context.Monitor;
|
||||
|
||||
public IntPtr ViewHandle => context.ViewPortHandle;
|
||||
|
||||
public IViewDesigner<ViewBase> Designer
|
||||
{
|
||||
get => _design;
|
||||
protected set => _design = value;
|
||||
}
|
||||
|
||||
public string ContextName => context.Name;
|
||||
|
||||
public string SelfName { get; set; }
|
||||
|
||||
public ViewPort Port
|
||||
{
|
||||
get => context;
|
||||
}
|
||||
|
||||
internal TimeSpanProvider TimeProvider
|
||||
{
|
||||
get => time;
|
||||
}
|
||||
|
||||
protected internal IViewRender<ViewBase> Render
|
||||
{
|
||||
get => _render;
|
||||
set => _render = value;
|
||||
}
|
||||
|
||||
protected IViewResponder<ViewBase> Responder
|
||||
{
|
||||
get => _responder;
|
||||
set => _responder = value;
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize([NotNull]ViewModelBase viewModelBinding);
|
||||
|
||||
/// <summary>
|
||||
/// Get the status of a certain key on the keyboard.
|
||||
/// </summary>
|
||||
/// <param _label="key">
|
||||
///
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <see cref="KeyStatus" /> representing if a key is pressed or released.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public KeyStatus GetKeyStatus(KeyboardKey key)
|
||||
{
|
||||
return GraphicFramework.glfwGetKey(context.ViewPortHandle, (int)key);
|
||||
}
|
||||
|
||||
public void InternalInitialize(string name, (int, int, int) cubeSize, [NotNull]ViewModelBase viewModelBinding)
|
||||
{
|
||||
SelfName = name;
|
||||
unitCubeSize = cubeSize;
|
||||
getDataBindingEntry = viewModelBinding.TryGetObjectReference;
|
||||
context = viewModelBinding.ViewPortBinding;
|
||||
time = viewModelBinding.frameTimeProvider;
|
||||
|
||||
CustomizedInitialize(viewModelBinding);
|
||||
}
|
||||
|
||||
public abstract bool TryGetObjectReference(string name, out DataBindingEntry entry);
|
||||
|
||||
public void Use()
|
||||
{
|
||||
if (usedFrame == 0)
|
||||
{
|
||||
if (!ValidateInitialization()) {
|
||||
throw new InvalidOperationException(
|
||||
"This view is not correctly initialized before rendering.");
|
||||
}
|
||||
}
|
||||
Show();
|
||||
usedFrame++;
|
||||
}
|
||||
|
||||
public bool ValidateInitialization()
|
||||
{
|
||||
return (_design != null) &&
|
||||
(_render != null) &&
|
||||
(getDataBindingEntry != null) &&
|
||||
(_responder != null) &&
|
||||
_design.ValidateInitializing() &&
|
||||
_responder.ValidateInitializing() &&
|
||||
_render.ValidateInitializing();
|
||||
}
|
||||
|
||||
protected abstract void Show();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewDesigner"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Controlling.UsrActivity;
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using StgSharp.Mathematics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.MVVM
|
||||
{
|
||||
public abstract partial class ViewBase
|
||||
{
|
||||
|
||||
public interface IViewDesigner<out TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
abstract void CustomizedInitialize();
|
||||
|
||||
abstract void Initialize();
|
||||
|
||||
abstract bool ValidateInitializing();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ViewDesigner provides descriptions of various controls in the view, binds the
|
||||
/// controls to specific user actions and behaviors, and describes the layout and
|
||||
/// interactions of each control.
|
||||
/// </summary>
|
||||
public abstract class ViewDesigner<TView> : IViewDesigner<TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
private KeyboardButtonGroup currentButtonGroup;
|
||||
|
||||
private List<ControllingItem> _controlList;
|
||||
protected TView _binding;
|
||||
|
||||
public ViewDesigner(TView binding)
|
||||
{
|
||||
_binding = binding;
|
||||
_controlList = new List<ControllingItem>();
|
||||
}
|
||||
|
||||
protected TView Binding
|
||||
{
|
||||
get => _binding;
|
||||
}
|
||||
|
||||
public CharacterLineIndexImage CreateCharacterLine(
|
||||
int length,
|
||||
char blankFilling,
|
||||
PlainGeometryMesh tittle,
|
||||
IEnumerable<(char, PlainGeometryMesh)> charList)
|
||||
{
|
||||
CharacterLineIndexImage ret = new CharacterLineIndexImage(
|
||||
length, blankFilling, tittle, charList);
|
||||
_controlList.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TriggerButton CreateKeyboardButton(
|
||||
Rectangle bonding,
|
||||
TextureProvider defaultAnimation,
|
||||
bool isEnable)
|
||||
{
|
||||
TriggerButton ret = new TriggerButton();
|
||||
ret.BoundingBox = bonding;
|
||||
ret.Texture = defaultAnimation;
|
||||
if (isEnable)
|
||||
{
|
||||
ret.IsDisabled = false;
|
||||
ret.Enable();
|
||||
} else
|
||||
{
|
||||
ret.IsDisabled = true;
|
||||
ret.Disable();
|
||||
}
|
||||
currentButtonGroup.AddButton(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TButtonGroup CreateKeyboardButtonGroup<TButtonGroup>(
|
||||
IClickTrigger leftBidning,
|
||||
IClickTrigger rightBinding,
|
||||
IClickTrigger upBinding,
|
||||
IClickTrigger downBinding,
|
||||
IClickTrigger confirmBinding)
|
||||
where TButtonGroup: KeyboardButtonGroup, new()
|
||||
{
|
||||
TButtonGroup ret = new TButtonGroup();
|
||||
_controlList.Add(ret);
|
||||
currentButtonGroup = ret;
|
||||
_binding.Responder[leftBidning] = ret.MoveLeft;
|
||||
_binding.Responder[rightBinding] = ret.MoveRight;
|
||||
_binding.Responder[upBinding] = ret.MoveUp;
|
||||
_binding.Responder[downBinding] = ret.MoveDown;
|
||||
_binding.Responder[confirmBinding] = ret.Confirm;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
CustomizedInitialize();
|
||||
}
|
||||
|
||||
public abstract bool ValidateInitializing();
|
||||
|
||||
}//---------------------------------- End of Class -----------------------------------------
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewRender"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.HighPerformance;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace StgSharp.MVVM
|
||||
{
|
||||
public abstract partial class ViewBase
|
||||
{
|
||||
|
||||
protected internal interface IViewRender<out TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
RenderStream this[DataLabel renderName] { get; }
|
||||
|
||||
void CustomizedInitialize();
|
||||
|
||||
IEnumerator<ViewPort> GetEnumerator();
|
||||
|
||||
void Initialize();
|
||||
|
||||
bool ValidateInitializing();
|
||||
|
||||
}
|
||||
|
||||
protected abstract class ViewRender<TView> : IViewRender<TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
protected ViewRender(TView binding)
|
||||
{
|
||||
_binding = binding;
|
||||
_render = new Dictionary<DataLabel, RenderStream>();
|
||||
}
|
||||
|
||||
public RenderStream this[DataLabel renderName]
|
||||
{
|
||||
get => _render.TryGetValue(renderName, out RenderStream stream) ? stream : (null!);
|
||||
protected set
|
||||
{
|
||||
if (_render.ContainsKey(renderName))
|
||||
{
|
||||
_render[renderName] = value;
|
||||
} else
|
||||
{
|
||||
_render.Add(renderName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TView Binding => _binding;
|
||||
|
||||
protected ViewPort ContextBinding => _binding.context;
|
||||
|
||||
protected ViewDesigner<TView> Design => (_binding.Designer as ViewDesigner<TView>)!;
|
||||
|
||||
protected Dictionary<DataLabel, RenderStream> Render
|
||||
{
|
||||
get => _render;
|
||||
}
|
||||
|
||||
protected ViewResponder<TView> Responder => (_binding.Responder as ViewResponder<TView>)!;
|
||||
|
||||
public T CreateRenderStream<T>() where T: RenderStream, new()
|
||||
{
|
||||
T ret = new T();
|
||||
ret.Initialize(_binding.context, Binding.TimeProvider);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public T CreateRenderStream<T>(ViewPort vp) where T: RenderStream, new()
|
||||
{
|
||||
T ret = new T();
|
||||
ret.Initialize(vp, Binding.TimeProvider);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize();
|
||||
|
||||
public IEnumerator<ViewPort> GetEnumerator()
|
||||
{
|
||||
foreach (RenderStream item in Render.Values) {
|
||||
yield return item.BindedViewPortContext;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
CustomizedInitialize();
|
||||
}
|
||||
|
||||
public abstract bool ValidateInitializing();
|
||||
|
||||
#pragma warning disable CS8618
|
||||
private Dictionary<DataLabel, RenderStream> _render;
|
||||
private TView _binding;
|
||||
#pragma warning restore CS8618
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewResponder"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Controlling.UsrActivity;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.MVVM
|
||||
{
|
||||
public partial class ViewBase
|
||||
{
|
||||
|
||||
protected interface IViewResponder<out TVIew> where TVIew: ViewBase
|
||||
{
|
||||
|
||||
Action? this[IClickTrigger trigger] { get; set; }
|
||||
|
||||
void CustomizedInitialize(Func<IClickTrigger, string, Action> keyRegister);
|
||||
|
||||
void Initialize(MethodLookUpDelegate methodGetter);
|
||||
|
||||
void ProcessUserInput();
|
||||
|
||||
bool ValidateInitializing();
|
||||
|
||||
}
|
||||
|
||||
protected abstract class ViewResponder<TView> : IViewResponder<TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
private bool _isInitialized;
|
||||
private Dictionary<IClickTrigger, Action> keyCallbackIndex;
|
||||
private Dictionary<string, Action> nameToCallbackMap;
|
||||
private TView _binding;
|
||||
|
||||
protected ViewResponder(TView binding)
|
||||
{
|
||||
keyCallbackIndex = new Dictionary<IClickTrigger, Action>();
|
||||
nameToCallbackMap = new Dictionary<string, Action>();
|
||||
_binding = binding;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1043
|
||||
public Action? this[IClickTrigger trigger]
|
||||
#pragma warning restore CA1043
|
||||
{
|
||||
get => keyCallbackIndex.TryGetValue(trigger, out Action callback) ? callback : null;
|
||||
set
|
||||
{
|
||||
if (keyCallbackIndex.TryGetValue(trigger, out Action callback))
|
||||
{
|
||||
callback += value;
|
||||
} else
|
||||
{
|
||||
keyCallbackIndex.Add(
|
||||
trigger, value ?? throw new ArgumentNullException(nameof(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected TView Binding => _binding;
|
||||
|
||||
public abstract void CustomizedInitialize(Func<IClickTrigger, string, Action> keyRegister);
|
||||
|
||||
public void Initialize(MethodLookUpDelegate methodGetter)
|
||||
{
|
||||
if (_isInitialized) {
|
||||
return;
|
||||
}
|
||||
CustomizedInitialize((trigger, name) => {
|
||||
if (!nameToCallbackMap.TryGetValue(name, out Action ret))
|
||||
{
|
||||
if (methodGetter(name, out Action lookup))
|
||||
{
|
||||
this[trigger] = lookup;
|
||||
} else
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Cannot find method named {name} in binded view model");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
public void ProcessUserInput()
|
||||
{
|
||||
foreach (KeyValuePair<IClickTrigger, Action> pair in keyCallbackIndex)
|
||||
{
|
||||
if (GraphicFramework.glfwGetKey(_binding.ViewHandle,
|
||||
pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus) {
|
||||
pair.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool ValidateInitializing();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="DataBinding"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.HighPerformance;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
#nullable enable
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate ref object BindingDataGetter();
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void BindingDataSetter(ref object value);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate bool MethodLookUpDelegate(string name, out Action callback);
|
||||
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
|
||||
public bool MethodLookup(string methodName, out Action callback)
|
||||
{
|
||||
MethodInfo method = GetType().GetMethod(methodName)!;
|
||||
if (method == null)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
callback = (Action)Delegate.CreateDelegate(typeof(Action), this, methodName);
|
||||
return true;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (MethodAccessException)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct DataBindingEntry
|
||||
{
|
||||
|
||||
[FieldOffset(0)] private IntPtr getterPtr;
|
||||
[FieldOffset(8)] private IntPtr setterPtr;
|
||||
[FieldOffset(0)] private M128 _mask;
|
||||
|
||||
public DataBindingEntry(
|
||||
[NotNull] BindingDataGetter gettingCallback,
|
||||
[NotNull] BindingDataSetter settingCallback)
|
||||
{
|
||||
getterPtr = Marshal.GetFunctionPointerForDelegate(gettingCallback);
|
||||
setterPtr = Marshal.GetFunctionPointerForDelegate(settingCallback);
|
||||
}
|
||||
|
||||
public static DataBindingEntry NullBinding
|
||||
{
|
||||
get => new DataBindingEntry();
|
||||
}
|
||||
|
||||
public bool Equals(DataBindingEntry other)
|
||||
{
|
||||
return (_mask == other._mask);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is not DataBindingEntry other) {
|
||||
return false;
|
||||
}
|
||||
return Equals(other);
|
||||
}
|
||||
|
||||
public bool ExactEqual(DataBindingEntry other)
|
||||
{
|
||||
return (getterPtr == other.getterPtr) && (setterPtr == other.setterPtr);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _mask.GetHashCode();
|
||||
}
|
||||
|
||||
public ref object GetValue()
|
||||
{
|
||||
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
|
||||
}
|
||||
|
||||
public void SetValue(ref object value)
|
||||
{
|
||||
((delegate* unmanaged[Cdecl]<ref object, void>)setterPtr)(ref value);
|
||||
}
|
||||
|
||||
public static bool operator !=(DataBindingEntry left, DataBindingEntry right)
|
||||
{
|
||||
return left._mask != right._mask;
|
||||
}
|
||||
|
||||
public static bool operator ==(DataBindingEntry left, DataBindingEntry right)
|
||||
{
|
||||
return left._mask == right._mask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#nullable restore
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ShowViewPort"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Graphics;
|
||||
using StgSharp.MVVM;
|
||||
using StgSharp.Threading;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
|
||||
private volatile bool _closed = true;
|
||||
private ViewBase _nextView, _currentView;
|
||||
|
||||
protected ViewBase CurrentView
|
||||
{
|
||||
get => _currentView;
|
||||
set => _nextView = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CustomizeInit this form and render it on screen, and respond with operation
|
||||
/// </summary>
|
||||
public unsafe void UseViewModel(
|
||||
string viewEntryName
|
||||
)
|
||||
{
|
||||
CustomizeInitialize();
|
||||
UseViewInNextFrame(viewEntryName);
|
||||
fpsCountProvider.TimeSpanRefreshed += CountFps;
|
||||
fpsCountProvider.MissTimeSpanRefreshed += CountFps;
|
||||
if (_nextView != _currentView) {
|
||||
_ = Interlocked.Exchange(ref _currentView, _nextView);
|
||||
}
|
||||
Thread renderThread = new Thread((
|
||||
token
|
||||
) => {
|
||||
try
|
||||
{
|
||||
ProcessFrameWithoutEvent();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DefaultLog.InternalWriteLog(
|
||||
$"Critical error when rendering:\n" + $"{ex}", LogType.Error);
|
||||
ShouldClose = true;
|
||||
throw;
|
||||
}
|
||||
});
|
||||
renderThread.Start();
|
||||
/**/
|
||||
while (_closed)
|
||||
{
|
||||
if (_nextView != _currentView) {
|
||||
_ = Interlocked.Exchange(ref _currentView, _nextView);
|
||||
}
|
||||
GraphicFramework.glfwPollEvents();
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
_closed = !ShouldClose;
|
||||
}
|
||||
/**/
|
||||
renderThread.Join();
|
||||
fpsCountProvider.Dispose();
|
||||
frameTimeProvider.Dispose();
|
||||
}
|
||||
|
||||
protected void UseViewInNextFrame(
|
||||
string name
|
||||
)
|
||||
{
|
||||
if (!allView.TryGetValue(name, out ViewBase v)) {
|
||||
throw new KeyNotFoundException(
|
||||
$"{$"Cannot find View named {name} "}{$"in current View Model of {GetType().FullName}"}");
|
||||
}
|
||||
CurrentView = v;
|
||||
}
|
||||
|
||||
private void CountFps(
|
||||
object sender,
|
||||
EventArgs e
|
||||
)
|
||||
{
|
||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||
Interlocked.Exchange(ref _frameCount, 0);
|
||||
}
|
||||
|
||||
private unsafe void PrivateShow()
|
||||
{
|
||||
if (0 == GraphicFramework.glfwWindowShouldClose(this.viewPortDisplay.ViewPortHandle))
|
||||
{
|
||||
CurrentView.Use();
|
||||
RenderStream.PollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessFrameWithoutEvent()
|
||||
{
|
||||
frameTimeProvider.TimeSpanRefreshed += (
|
||||
_,
|
||||
_
|
||||
) => { };
|
||||
while (_closed)
|
||||
{
|
||||
foreach (ViewPort context in CurrentView.Render) {
|
||||
context.FlushSize();
|
||||
}
|
||||
CurrentView.Use();
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewManage"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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 StgSharp.MVVM;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
public partial class ViewModelBase
|
||||
{
|
||||
|
||||
private Dictionary<string, ViewBase> allView;
|
||||
|
||||
public T CreateAndBindView<T>(string name, (int x, int y, int z) unitCubeSize) where T: ViewBase, new()
|
||||
{
|
||||
T ret = new T();
|
||||
ret.SelfName = name;
|
||||
ret.InternalInitialize(name, unitCubeSize, this);
|
||||
allView.Add(name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewModel"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Common.Timing;
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
using StgSharp.MVVM;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
using StgSharp.Threading;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
|
||||
private FrameBufferSizeHandler _resizeCallback;
|
||||
private int _frameCount;
|
||||
private int _frameSpeed;
|
||||
private ViewPort viewPortDisplay;
|
||||
|
||||
// internal IntPtr monitor;
|
||||
|
||||
internal TimeSpanProvider fpsCountProvider;
|
||||
internal TimeSpanProvider frameTimeProvider;
|
||||
internal Vector4 backgroundColor;
|
||||
|
||||
protected ViewModelBase(
|
||||
int frameSpeed
|
||||
)
|
||||
{
|
||||
viewPortDisplay = new ViewPort();
|
||||
allView = [];
|
||||
fpsCountProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, 1.0 / frameSpeed), TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
long frameLength = (FrameSpeed > 0) ? (1000L * 1000L / FrameSpeed) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, 1.0 / frameSpeed), TimeSpanProvider.DefaultProvider);
|
||||
SetFrameSizeCallback(DefaultFrameResizeCallback);
|
||||
}
|
||||
|
||||
protected ViewModelBase(
|
||||
double frameLength
|
||||
)
|
||||
{
|
||||
viewPortDisplay = new ViewPort();
|
||||
allView = [];
|
||||
fpsCountProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, frameLength), TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
long _frameLength = (FrameSpeed > 0) ? ((long)(1000 * frameLength)) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, frameLength), TimeSpanProvider.DefaultProvider);
|
||||
SetFrameSizeCallback(DefaultFrameResizeCallback);
|
||||
}
|
||||
|
||||
public ViewModelBase(
|
||||
ViewPort vBinding,
|
||||
int frameSpeed
|
||||
)
|
||||
{
|
||||
viewPortDisplay = vBinding;
|
||||
allView = [];
|
||||
fpsCountProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, 1.0), TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
long frameLength = (frameSpeed > 0) ? (1000L * 1000L / frameSpeed) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, 1.0 / frameSpeed), TimeSpanProvider.DefaultProvider);
|
||||
SetFrameSizeCallback(DefaultFrameResizeCallback);
|
||||
}
|
||||
|
||||
public ViewModelBase(
|
||||
ViewPort vBinding,
|
||||
double frameLength
|
||||
)
|
||||
{
|
||||
viewPortDisplay = vBinding;
|
||||
allView = [];
|
||||
fpsCountProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, 1.0), TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
long _frameLength = (FrameSpeed > 0) ? ((long)(1000 * frameLength)) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(TimeSequence.CreateLinear(double.PositiveInfinity, frameLength), TimeSpanProvider.DefaultProvider);
|
||||
SetFrameSizeCallback(DefaultFrameResizeCallback);
|
||||
}
|
||||
|
||||
public DataBindingEntry this[
|
||||
string name
|
||||
]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.TryGetObjectReference(name, out DataBindingEntry entry)) {
|
||||
return entry;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldClose
|
||||
{
|
||||
get => GraphicFramework.glfwWindowShouldClose(viewPortDisplay.ViewPortHandle) != 0;
|
||||
set => GraphicFramework.glfwSetWindowShouldClose(
|
||||
viewPortDisplay.ViewPortHandle, value ? 1 : 0);
|
||||
}
|
||||
|
||||
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
|
||||
|
||||
public int FrameSpeed => _frameSpeed;
|
||||
|
||||
/// <summary>
|
||||
/// Height of this form, represent in <see cref="int" />
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => viewPortDisplay.Height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width of this form, represent in <see cref="int" />
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => viewPortDisplay.Width;
|
||||
}
|
||||
|
||||
public unsafe IntPtr WindowID
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => viewPortDisplay.ViewPortHandle;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => viewPortDisplay.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width of this form, represent in <see cref="int" />
|
||||
/// </summary>
|
||||
public Vec2 Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => new Vec2(Width, Height);
|
||||
}
|
||||
|
||||
public ViewPort ViewPortBinding
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => viewPortDisplay;
|
||||
}
|
||||
|
||||
public abstract void CustomizeInitialize();
|
||||
|
||||
/// <summary>
|
||||
/// Set the Size limit of current form
|
||||
/// </summary>
|
||||
/// <param _label="minSize">
|
||||
/// Minimum Size of current form. In form of a <see cref="Vec2" /> of (width,height)
|
||||
/// </param>
|
||||
/// <param _label="maxSize">
|
||||
/// Maximum Size of current form. In form of a <see cref="Vec2" /> of (width,height)
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetSizeLimit(
|
||||
Vec2 minSize,
|
||||
Vec2 maxSize
|
||||
)
|
||||
{
|
||||
ThreadHelper.MainThreadAssert();
|
||||
GraphicFramework.glfwSetWindowSizeLimits(this.viewPortDisplay.ViewPortHandle,
|
||||
(int)minSize.X, (int)minSize.Y, (int)maxSize.X,
|
||||
(int)maxSize.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the Size limit of current form
|
||||
/// </summary>
|
||||
/// <param _label="minWidth">
|
||||
/// Minimum width of current form
|
||||
/// </param>
|
||||
/// <param _label="minHeight">
|
||||
/// Minimum height of current form
|
||||
/// </param>
|
||||
/// <param _label="maxWidth">
|
||||
/// Maximum width of current form
|
||||
/// </param>
|
||||
/// <param _label="maxHeight">
|
||||
/// Maximum height of current form
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetSizeLimit(
|
||||
int minWidth,
|
||||
int minHeight,
|
||||
int maxWidth,
|
||||
int maxHeight
|
||||
)
|
||||
{
|
||||
ThreadHelper.MainThreadAssert();
|
||||
GraphicFramework.glfwSetWindowSizeLimits(this.viewPortDisplay.ViewPortHandle, minWidth,
|
||||
minHeight, maxWidth, maxHeight);
|
||||
}
|
||||
|
||||
public abstract bool TryGetObjectReference(
|
||||
string name,
|
||||
out DataBindingEntry entry
|
||||
);
|
||||
|
||||
protected unsafe void SetFrameSizeCallback(
|
||||
FrameBufferSizeHandler callback
|
||||
)
|
||||
{
|
||||
_resizeCallback = callback;
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
||||
_ = GraphicFramework.glfwSetFrameBufferSizeCallback(
|
||||
viewPortDisplay.ViewPortHandle, (delegate* unmanaged[Cdecl]<IntPtr, int, int, void>)handlerPtr);
|
||||
}
|
||||
|
||||
private void DefaultFrameResizeCallback(
|
||||
IntPtr windowHandle,
|
||||
int width,
|
||||
int height
|
||||
)
|
||||
{
|
||||
ViewPort.GetExistedViewPort(windowHandle, out ViewPort vp);
|
||||
vp.RequestFlushSizeInNextFrame(width, height);
|
||||
|
||||
// Console.WriteLine($"{width} {height}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewPort"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.MVVM
|
||||
{
|
||||
public class ViewPort
|
||||
{
|
||||
|
||||
private static readonly ConcurrentDictionary<IntPtr, ViewPort> _handleToViewPortIndex = [];
|
||||
private int _width, _height, _newWidth, _newHeight;
|
||||
|
||||
internal ViewPort()
|
||||
{
|
||||
_newHeight = 600;
|
||||
_newWidth = 800;
|
||||
FlushSize();
|
||||
Name = new StackFrame(1, false).
|
||||
GetMethod()!.DeclaringType!.Name;
|
||||
Monitor = IntPtr.Zero;
|
||||
ViewPortHandle = GraphicFramework.glfwCreateWindow(
|
||||
_newWidth, _newHeight, Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero);
|
||||
if (ViewPortHandle == IntPtr.Zero) {
|
||||
throw new InvalidOperationException("Unable to create viewport handle.");
|
||||
}
|
||||
_ = _handleToViewPortIndex.TryAdd(ViewPortHandle, this);
|
||||
}
|
||||
|
||||
public ViewPort(int width, int height, string name, IntPtr monitor)
|
||||
{
|
||||
_newWidth = width;
|
||||
_newHeight = height;
|
||||
FlushSize();
|
||||
Name = name;
|
||||
Monitor = monitor;
|
||||
ViewPortHandle = GraphicFramework.glfwCreateWindow(
|
||||
_newWidth, _newHeight, Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero);
|
||||
if (ViewPortHandle == IntPtr.Zero) {
|
||||
throw new InvalidOperationException("Unable to create viewport handle.");
|
||||
}
|
||||
_ = _handleToViewPortIndex.TryAdd(ViewPortHandle, this);
|
||||
}
|
||||
|
||||
public unsafe int Height
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _height;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal set => Interlocked.Exchange(ref _height, value);
|
||||
}
|
||||
|
||||
public unsafe int Width
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _width;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal set => Interlocked.Exchange(ref _width, value);
|
||||
}
|
||||
|
||||
public IntPtr GraphicHandle { get; internal set; }
|
||||
|
||||
public IntPtr Monitor { get; internal set; }
|
||||
|
||||
public IntPtr ViewPortHandle { get; private set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
// [BlueprintNodeExecution]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetExistedViewPort(IntPtr handle, out ViewPort port)
|
||||
{
|
||||
return _handleToViewPortIndex.TryGetValue(handle, out port);
|
||||
}
|
||||
|
||||
internal unsafe void FlushSize()
|
||||
{
|
||||
_ = Interlocked.Exchange(ref _height, _newHeight);
|
||||
_ = Interlocked.Exchange(ref _width, _newWidth);
|
||||
}
|
||||
|
||||
internal void RequestFlushSizeInNextFrame(int width, int height)
|
||||
{
|
||||
_ = Interlocked.Exchange(ref _newHeight, height);
|
||||
_ = Interlocked .Exchange(ref _newWidth, width);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ISimpleStateMachine"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.State
|
||||
{
|
||||
public interface ISimpleStateMachine<TStateNode, TStateLabel, TStateContext>
|
||||
where TStateNode : SimpleStateMachineNode<TStateNode, TStateLabel, TStateContext>
|
||||
where TStateLabel : unmanaged, IEquatable<TStateLabel>
|
||||
where TStateContext : StateContext
|
||||
{
|
||||
|
||||
TStateNode this[
|
||||
TStateLabel label
|
||||
] { get; }
|
||||
|
||||
ref readonly TStateNode GetCurrentStateNode();
|
||||
|
||||
void Reset();
|
||||
|
||||
bool TryMoveNext(
|
||||
TStateContext ctx
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="SimpleStateMachineNode"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.State
|
||||
{
|
||||
public abstract class SimpleStateMachineNode<TSelf, TLabel, TStateContext>
|
||||
where TSelf : SimpleStateMachineNode<TSelf, TLabel, TStateContext>
|
||||
where TLabel : unmanaged, IEquatable<TLabel>
|
||||
where TStateContext : StateContext
|
||||
{
|
||||
|
||||
private readonly List<int> _jumpTable = [];
|
||||
|
||||
public ReadOnlySpan<int> AvailableNodes => CollectionsMarshal.AsSpan(_jumpTable);
|
||||
|
||||
public abstract bool IsValidateFrom(
|
||||
TSelf former,
|
||||
TStateContext context
|
||||
);
|
||||
|
||||
public abstract bool TryTransaction(
|
||||
ReadOnlySpan<TSelf> nodeSpan,
|
||||
TStateContext context,
|
||||
out TLabel label
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="StateContext.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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.State
|
||||
{
|
||||
public abstract class StateContext { }
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Bullet"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
|
||||
namespace StgSharp.Gaming
|
||||
{
|
||||
public abstract class Bullet : IInstancing, IPlainEntity
|
||||
{
|
||||
|
||||
protected Bullet(
|
||||
PlainInstancingBuffer<Bullet> buffer,
|
||||
GeometryMotion movement,
|
||||
Vec2 beginPosition,
|
||||
float angle,
|
||||
float scale)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(buffer);
|
||||
GlobalBuffer = buffer;
|
||||
BufferId = buffer.CreateInstanceID();
|
||||
((IInstancing)this).Scale = scale;
|
||||
((IInstancing)this).Coord = new Vec3(beginPosition, 0);
|
||||
((IInstancing)this).Rotation = angle;
|
||||
Motion = movement;
|
||||
}
|
||||
|
||||
public GeometryMotion Motion { get; set; }
|
||||
|
||||
public IInstancingBuffer GlobalBuffer { get; set; }
|
||||
|
||||
public int BufferId { get; set; }
|
||||
|
||||
public Vec2 CenterPosition { get; set; }
|
||||
|
||||
public bool CollideWith(IPlainEntity entity)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
Vec3 IInstancing.CenterPositionGlobal
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="CollisionTexture"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.OpenGL;
|
||||
using StgSharp.Internal;
|
||||
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
using StgSharp.MVVM;
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Stg
|
||||
{
|
||||
public interface IOneDimensionalCollisionTexture2D
|
||||
{
|
||||
|
||||
public void Init(
|
||||
Radius angleStride,
|
||||
string name
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public sealed class OneDimensionalCollisionTexture2D_GL : glRender, IOneDimensionalCollisionTexture2D
|
||||
{
|
||||
|
||||
private float[] textureOutput;
|
||||
private ElementBuffer ebo;
|
||||
private FrameBuffer fbo;
|
||||
private RenderBuffer rbo;
|
||||
|
||||
private ShaderProgram generatingShader;
|
||||
|
||||
private TextureGL t;
|
||||
|
||||
private VertexArray vao;
|
||||
private VertexBuffer vbo;
|
||||
|
||||
public OneDimensionalCollisionTexture2D_GL() { }
|
||||
|
||||
public override bool IsContextSharable => false;
|
||||
|
||||
public void GenerateCollisionTexture(
|
||||
IEnumerable<IInstancingBuffer> bufferEnumeration
|
||||
)
|
||||
{
|
||||
fbo.Bind(0);
|
||||
GL.ClearColor(0, 0, 0, 1);
|
||||
GL.Clear(MaskBufferBit.DEPTH | MaskBufferBit.COLOR);
|
||||
generatingShader.Use();
|
||||
vao.Bind(0);
|
||||
|
||||
foreach (IInstancingBuffer item in bufferEnumeration)
|
||||
{
|
||||
IGeometry g = item.TypicalShape;
|
||||
|
||||
if (g is not PlainGeometry) {
|
||||
throw new InvalidOperationException(
|
||||
"The current particle buffer contains non-planar geometry,");
|
||||
}
|
||||
|
||||
ebo.Bind(0);
|
||||
ebo.SetValue<int>(0, g.VertexIndices, BufferUsage.StreamDraw);
|
||||
|
||||
vbo.WriteVectorData<Vec4>(0, item.CoordAndRotationSpan, BufferUsage.StreamDraw);
|
||||
vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
vao.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float),
|
||||
3 * sizeof(float));
|
||||
|
||||
vbo.WriteScalerData<float>(2, item.ScalingSpan, BufferUsage.StreamDraw);
|
||||
vao.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
|
||||
|
||||
vbo.WriteVectorData(1, g.VertexStream, BufferUsage.StreamDraw);
|
||||
vao.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
|
||||
GL.DrawElementsInstanced(GeometryType.TRIANGLES, (g.VertexIndices.Length) / 3,
|
||||
TypeCode.UInt32, IntPtr.Zero, item.ScalingSpan.Length);
|
||||
}
|
||||
|
||||
t.Bind2D(0);
|
||||
GL.GetTextureImage(Texture2DTarget.Texture2D, 0, ImageChannel.SingleColor,
|
||||
PixelChannelLayout.Float, textureOutput);
|
||||
VertexArray.BindNull();
|
||||
}
|
||||
|
||||
public void Init(
|
||||
Radius angleStride,
|
||||
string name
|
||||
)
|
||||
{
|
||||
primeArgs = new ViewPort(1, (int)((new Radius(Scalar.Pi)) / angleStride), name,
|
||||
IntPtr.Zero);
|
||||
|
||||
PlatformSpecifiedInitialize();
|
||||
CustomizeInit();
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
|
||||
protected override void CustomizeDeinit()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void CustomizeInit()
|
||||
{
|
||||
generatingShader = CreateShaderProgram();
|
||||
|
||||
Shader vertexShader = CreateShaderSegment(ShaderType.Vertex, 1);
|
||||
Shader fragmentShader = CreateShaderSegment(ShaderType.Fragment, 1);
|
||||
|
||||
vertexShader.Compile(0, BuiltInShader.CollisionTextureVertexShader);
|
||||
fragmentShader.Compile(0, BuiltInShader.CollisionTextureFragmentShader);
|
||||
vertexShader.AttachTo(0, generatingShader);
|
||||
fragmentShader.AttachTo(0, generatingShader);
|
||||
|
||||
generatingShader.Link();
|
||||
generatingShader.Use();
|
||||
|
||||
vbo = CreateVertexBuffer(3);
|
||||
vao = CreateVertexArray(1);
|
||||
ebo = CreateElementBuffer(1);
|
||||
|
||||
|
||||
fbo = CreateFrameBuffer(1);
|
||||
rbo = CreateRenderBuffer(1);
|
||||
GL.SetRenderBufferStorage(RenderBufferInternalFormat.Depth24_Stencil8, this.Size);
|
||||
|
||||
|
||||
t = CreateTexture(1);
|
||||
t.Bind2D(0);
|
||||
GL.TextureImage2d<byte>(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel,
|
||||
Width, Height, ImageChannel.WithAlphaChannel,
|
||||
PixelChannelLayout.Byte, Array.Empty<byte>());
|
||||
|
||||
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
|
||||
t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest);
|
||||
|
||||
GL.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
|
||||
Texture2DTarget.Texture2D, t[0], 0);
|
||||
|
||||
GL.CombineFrameBufferRenderBuffer(FrameBufferAttachment.Color, rbo[0]);
|
||||
|
||||
textureOutput = new float[this.Width];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="TimeLine"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Stg
|
||||
{
|
||||
public class TimeLine { }
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="TouhouBuilder"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Touhou;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Stg.Touhou
|
||||
{
|
||||
public static class TouhouBuilder
|
||||
{
|
||||
/*
|
||||
public static ViewBase BuildTouhouWorld()
|
||||
{
|
||||
|
||||
TouhouForm form = new TouhouForm();
|
||||
|
||||
|
||||
return form;
|
||||
}
|
||||
/**/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="TouhouWindow"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.MVVM;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Touhou
|
||||
{
|
||||
public abstract class TouhouWindowMain : ViewModelBase
|
||||
{
|
||||
|
||||
protected TouhouWindowMain(ViewPort vp) : base(vp, 60) { }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="OpenningView"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.MVVM;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Stg.Touhou
|
||||
{
|
||||
public abstract class OpenningView : ViewBase
|
||||
{
|
||||
|
||||
public override void CustomizedInitialize(ViewModelBase viewModelBinding)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,153 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<LangVersion>Preview</LangVersion>
|
||||
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
||||
<PackageLicenseExpression> MIT</PackageLicenseExpression>
|
||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||
<AnalysisLevel>preview-all</AnalysisLevel>
|
||||
<OutputType>Library</OutputType>
|
||||
<Nullable>enable</Nullable>
|
||||
<Configurations>Debug;Release;PerformanceDebug</Configurations>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<IsNativeHost>true</IsNativeHost>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(IsWindows)'=='true'">
|
||||
<ProjectReference Include="..\StgSharp.Native\$(NativeLibName).vcxproj">
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
|
||||
<GlobalPropertiesToRemove>TargetFramework</GlobalPropertiesToRemove>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Optimize>False</Optimize>
|
||||
<DebugType>portable</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Graphics\**" />
|
||||
<EmbeddedResource Remove="Graphics\**" />
|
||||
<None Remove="Graphics\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<Optimize>False</Optimize>
|
||||
<DebugType>portable</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Benchmark|x64'">
|
||||
<Optimize>True</Optimize>
|
||||
<DebugType>embedded</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Benchmark|ARM64'">
|
||||
<Optimize>True</Optimize>
|
||||
<DebugType>embedded</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DebugType>none</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='PerformanceDebug|x64'">
|
||||
<DebugType>none</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<DebugType>none</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='PerformanceDebug|ARM64'">
|
||||
<DebugType>none</DebugType>
|
||||
<NoWarn>1701;1702;0649;1591;0169</NoWarn>
|
||||
<Deterministic>False</Deterministic>
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
|
||||
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
|
||||
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(IsWindows)'=='true'">
|
||||
<DefineConstants>WINDOWS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(IsOSX)'=='true'">
|
||||
<DefineConstants>OSX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(IsLinux)'=='true'">
|
||||
<DefineConstants>LINUX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Graphics\**" />
|
||||
<EmbeddedResource Remove="Graphics\**" />
|
||||
<None Remove="Graphics\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove=".nuspec" />
|
||||
<None Remove="StgSharp.Common.deps.json" />
|
||||
<None Remove="StgSharp.Common.dll" />
|
||||
<None Remove="StgSharp.Common.pdb" />
|
||||
<None Remove="StgSharp.Common.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="..\StgSharpGraphic">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
</Target>
|
||||
|
||||
<PropertyGroup>
|
||||
<MySymbol>$(ColiisionTextureVertexShader)</MySymbol>
|
||||
<MySymbol>$(ColiisionTextureFragmentShader)</MySymbol>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<ErrorReport>send</ErrorReport>
|
||||
<PackageProjectUrl>https://github.com/Nitload-NSI/StgSharp</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Nitload-NSI/StgSharp.git</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SolutionDir Condition="'$(SolutionDir)'=='' Or '$(SolutionDir)'=='*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NoOps|AnyCPU'">
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NoOps|x64'">
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(DisablePostBuildCopy)'!='true' And '$(SolutionDir)'!='' And '$(SolutionDir)'!='*Undefined*' And !$([System.String]::Copy('$(OutDir)').Contains('StgSharp.Benchmark'))">
|
||||
<MakeDir Directories="$(SolutionDir)build" />
|
||||
<Exec Command="xcopy /E /I /Y "$(OutDir)" "$(SolutionDir)build"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user