daily update on 20240828 by nitload youmu, autotexture added
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Logic;
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -43,18 +43,19 @@ namespace StgSharp.Controls
|
||||
{
|
||||
public class BattleField : ControllingItem
|
||||
{
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => throw new NotImplementedException() ;
|
||||
}
|
||||
public vec2d Position { get; set; }
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public bool IsEntity => true;
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,15 @@ namespace StgSharp.Controls
|
||||
buttonList = new List<TriggerButton>();
|
||||
}
|
||||
|
||||
public bool IsEntity { get => false; }
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public TriggerButton CurrentButton
|
||||
{
|
||||
get => current;
|
||||
@@ -65,10 +69,6 @@ namespace StgSharp.Controls
|
||||
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public bool IsEntity { get => false; }
|
||||
|
||||
protected List<TriggerButton> AllButton
|
||||
{
|
||||
get => buttonList;
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Geometries;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="CharacterIndexImage.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.Math;
|
||||
|
||||
@@ -13,13 +43,24 @@ namespace StgSharp.Controls
|
||||
{
|
||||
public class CharacterLineIndexImage : ControllingItem
|
||||
{
|
||||
private int length;
|
||||
|
||||
private char[] displayIndex;
|
||||
private char defaultChar;
|
||||
|
||||
Dictionary<char, PlainGeometryMesh> texIndex;
|
||||
private int length;
|
||||
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;
|
||||
@@ -29,8 +70,8 @@ namespace StgSharp.Controls
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
}
|
||||
public vec2d Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public Rectangle BoundingBox { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public vec2d Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public void Display(string message)
|
||||
{
|
||||
@@ -39,9 +80,9 @@ namespace StgSharp.Controls
|
||||
message = string.Empty;
|
||||
}
|
||||
|
||||
string result = message.Length >= length ?
|
||||
message.Substring(message.Length - displayIndex.Length) :
|
||||
message.PadLeft(length,defaultChar);
|
||||
string result = (message.Length >= length) ?
|
||||
message.Substring(message.Length - displayIndex.Length) :
|
||||
message.PadLeft(length, defaultChar);
|
||||
|
||||
displayIndex = result.ToCharArray();
|
||||
}
|
||||
@@ -55,15 +96,5 @@ namespace StgSharp.Controls
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Geometries;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ControllingIntem.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.Math;
|
||||
|
||||
@@ -9,18 +39,20 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public interface ControllingItem: IEnumerable<PlainGeometryMesh>
|
||||
public interface ControllingItem : IEnumerable<PlainGeometryMesh>
|
||||
{
|
||||
public abstract vec2d Position { get; set; }
|
||||
public abstract Rectangle BoundingBox { get; set; }
|
||||
|
||||
public abstract bool IsEntity { get; }
|
||||
|
||||
public abstract ReadOnlySpan<vec4d> TextureBox { get; }
|
||||
public abstract bool IsEntity { get; }
|
||||
public abstract Rectangle BoundingBox { get; set; }
|
||||
public abstract vec2d Position { get; set; }
|
||||
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Controls;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// 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.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
@@ -11,26 +41,28 @@ namespace StgSharp.Controls
|
||||
{
|
||||
public class DecorationBox : ControllingItem
|
||||
{
|
||||
|
||||
private PlainGeometryMesh renderMesh;
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(BoundingBox, new TextureProvider(texture, texCoord));
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => renderMesh.TextureCoord;
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public vec2d Position { get ; set ; }
|
||||
public Rectangle BoundingBox { get ; set ; }
|
||||
|
||||
public bool IsEntity => true;
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return renderMesh;
|
||||
}
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(BoundingBox, new TextureProvider(texture, texCoord));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,38 @@
|
||||
using StgSharp.Controls;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="MarkingLable.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,32 +43,12 @@ namespace StgSharp.Controls
|
||||
{
|
||||
public class MarkingLabel : ControllingItem
|
||||
{
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => marker.TextureCoord;
|
||||
}
|
||||
public vec2d Position { get; set; }
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
private vec2d _currentPosition, _movementVec;
|
||||
|
||||
private TimeFunction _movement;
|
||||
private PlainGeometryMesh marker;
|
||||
|
||||
public void MoveTo(vec2d target)
|
||||
{
|
||||
Move(target - Position);
|
||||
}
|
||||
private TimeFunction _movement;
|
||||
|
||||
public void Move(vec2d movement)
|
||||
{
|
||||
if (!_movement.IsComplete)
|
||||
{
|
||||
Position = _currentPosition + _movement.Calculate() * _movementVec;
|
||||
}
|
||||
}
|
||||
private vec2d _currentPosition, _movementVec;
|
||||
|
||||
public MarkingLabel(PlainGeometryMesh marker, TimeFunction movement)
|
||||
{
|
||||
@@ -45,10 +56,32 @@ namespace StgSharp.Controls
|
||||
_movement = movement;
|
||||
}
|
||||
|
||||
public bool IsEntity => true;
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => marker.TextureCoord;
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return marker;
|
||||
}
|
||||
|
||||
public void Move(vec2d movement)
|
||||
{
|
||||
if (!_movement.IsComplete)
|
||||
{
|
||||
Position = _currentPosition + (_movement.Calculate() * _movementVec);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveTo(vec2d target)
|
||||
{
|
||||
Move(target - Position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
|
||||
public delegate void RenderButtonTextureCallback(ButtonStatus status, float beginTime, in TextureProvider texture);
|
||||
|
||||
public enum ButtonStatus
|
||||
{
|
||||
Error = 0b0,
|
||||
@@ -57,22 +60,19 @@ namespace StgSharp.Controls
|
||||
HighlightToDisable = -(Highlight | Disable),
|
||||
}
|
||||
|
||||
public delegate void RenderButtonTextureCallback(ButtonStatus status, float beginTime, in TextureProvider texture);
|
||||
|
||||
public class TriggerButton : ControllingItem
|
||||
{
|
||||
private TextureProvider _texture;
|
||||
private float _statusBeginTime;
|
||||
|
||||
public TriggerButton Left { get; internal set; }
|
||||
public TriggerButton Right { get; internal set; }
|
||||
public TriggerButton Up { get; internal set; }
|
||||
public TriggerButton Down { get; internal set; }
|
||||
private Action? confirmCallback;
|
||||
private Action? disableCallback;
|
||||
|
||||
#nullable enable
|
||||
private Action? enableCallback;
|
||||
private Action? disableCallback;
|
||||
private Action? confirmCallback;
|
||||
private float _statusBeginTime;
|
||||
|
||||
private RenderButtonTextureCallback _renderButton;
|
||||
private TextureProvider _texture;
|
||||
|
||||
#nullable restore
|
||||
|
||||
public TriggerButton()
|
||||
@@ -80,11 +80,25 @@ namespace StgSharp.Controls
|
||||
CurrentStatus = ButtonStatus.Disable;
|
||||
}
|
||||
|
||||
protected ButtonStatus CurrentStatus { get; set; }
|
||||
public event Action ConfirmEvent
|
||||
{
|
||||
add { confirmCallback += value; }
|
||||
remove { confirmCallback -= value; }
|
||||
}
|
||||
|
||||
private RenderButtonTextureCallback _renderButton;
|
||||
public event Action DisableEvent
|
||||
{
|
||||
add { disableCallback += value; }
|
||||
remove { disableCallback -= value; }
|
||||
}
|
||||
|
||||
public event RenderButtonTextureCallback RenderButtonTexture
|
||||
public event Action EnableEvent
|
||||
{
|
||||
add { enableCallback += value; }
|
||||
remove { enableCallback -= value; }
|
||||
}
|
||||
|
||||
public event RenderButtonTextureCallback RenderButtonTexture
|
||||
{
|
||||
add
|
||||
{
|
||||
@@ -97,7 +111,7 @@ namespace StgSharp.Controls
|
||||
_renderButton += value;
|
||||
}
|
||||
}
|
||||
remove
|
||||
remove
|
||||
{
|
||||
if (_renderButton != null)
|
||||
{
|
||||
@@ -106,48 +120,51 @@ namespace StgSharp.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHighLighted { get; internal set; }
|
||||
|
||||
public bool IsDisabled { get; internal set; }
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
{
|
||||
get => MemoryMarshal.Cast<vec2d, vec4d>(_texture.TextureCoordinate);
|
||||
}
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public TriggerButton Left { get; internal set; }
|
||||
public TriggerButton Right { get; internal set; }
|
||||
public TriggerButton Up { get; internal set; }
|
||||
public TriggerButton Down { get; internal set; }
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
internal TextureProvider Texture
|
||||
{
|
||||
get => _texture;
|
||||
set => _texture = value;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<vec4d> TextureBox
|
||||
protected ButtonStatus CurrentStatus { get; set; }
|
||||
|
||||
public void DeHighlight()
|
||||
{
|
||||
get => MemoryMarshal.Cast<vec2d, vec4d>(_texture.TextureCoordinate);
|
||||
}
|
||||
|
||||
public bool IsHighLighted { get; internal set; }
|
||||
|
||||
public bool IsDisabled { get; internal set; }
|
||||
public vec2d Position { get; set; }
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
|
||||
public bool IsEntity => true;
|
||||
|
||||
public event Action EnableEvent
|
||||
{
|
||||
add { enableCallback += value; }
|
||||
remove { enableCallback -= value; }
|
||||
}
|
||||
|
||||
public event Action DisableEvent
|
||||
{
|
||||
add { disableCallback += value; }
|
||||
remove { disableCallback -= value; }
|
||||
}
|
||||
|
||||
public event Action ConfirmEvent
|
||||
{
|
||||
add { confirmCallback += value; }
|
||||
remove { confirmCallback -= value; }
|
||||
}
|
||||
|
||||
internal void Init( ButtonStatus status )
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Error)
|
||||
if (CurrentStatus == ButtonStatus.Highlight)
|
||||
{
|
||||
CurrentStatus = status;
|
||||
CurrentStatus = ButtonStatus.HighlightToEnable;
|
||||
}
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
CurrentStatus = CurrentStatus switch
|
||||
{
|
||||
ButtonStatus.Enable => ButtonStatus.EnableToDisable,
|
||||
ButtonStatus.Highlight => ButtonStatus.HighlightToDisable,
|
||||
_ => CurrentStatus,
|
||||
};
|
||||
if (disableCallback != null)
|
||||
{
|
||||
disableCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,18 +178,16 @@ namespace StgSharp.Controls
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( enableCallback != null)enableCallback();
|
||||
if (enableCallback != null)
|
||||
{
|
||||
enableCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
CurrentStatus = CurrentStatus switch
|
||||
{
|
||||
ButtonStatus.Enable => ButtonStatus.EnableToDisable,
|
||||
ButtonStatus.Highlight => ButtonStatus.HighlightToDisable,
|
||||
_ => CurrentStatus,
|
||||
};
|
||||
if (disableCallback != null) disableCallback();
|
||||
_renderButton(CurrentStatus, _statusBeginTime, in _texture);
|
||||
yield return new PlainGeometryMesh(this.BoundingBox, _texture);
|
||||
}
|
||||
|
||||
public void Highlight()
|
||||
@@ -185,21 +200,18 @@ namespace StgSharp.Controls
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (confirmCallback != null) confirmCallback();
|
||||
}
|
||||
|
||||
public void DeHighlight()
|
||||
{
|
||||
if (CurrentStatus == ButtonStatus.Highlight)
|
||||
if (confirmCallback != null)
|
||||
{
|
||||
CurrentStatus = ButtonStatus.HighlightToEnable;
|
||||
confirmCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
internal void Init(ButtonStatus status)
|
||||
{
|
||||
_renderButton(CurrentStatus,_statusBeginTime, in _texture);
|
||||
yield return new PlainGeometryMesh(this.BoundingBox, _texture);
|
||||
if (CurrentStatus == ButtonStatus.Error)
|
||||
{
|
||||
CurrentStatus = status;
|
||||
}
|
||||
}
|
||||
|
||||
}//----------------------------------- End of class --------------------------------------------
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public class ViewPortDesigner
|
||||
{
|
||||
private KeyboardButtonGroup currentButtonGroup;
|
||||
|
||||
private List<ControllingItem> _controlList;
|
||||
|
||||
public ViewPortDesigner()
|
||||
{
|
||||
_controlList = new List<ControllingItem>();
|
||||
}
|
||||
|
||||
public KeyboardButtonGroup CreateKeyboardButtonGroup(
|
||||
ITrigger leftBidning,
|
||||
ITrigger rightBinding,
|
||||
ITrigger upBinding,
|
||||
ITrigger downBinding,
|
||||
ITrigger confirmBinding
|
||||
)
|
||||
{
|
||||
var ret = new KeyboardButtonGroup();
|
||||
_controlList.Add(ret);
|
||||
currentButtonGroup = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TriggerButton CreateKeyboardButton(
|
||||
Rectangle bonding, AnimationBuilder defaultAnimation, bool isEnable
|
||||
)
|
||||
{
|
||||
var ret = new TriggerButton();
|
||||
ret.BoundingBox = bonding;
|
||||
if (isEnable)
|
||||
{
|
||||
ret.IsDisabled = false;
|
||||
ret.Enable(defaultAnimation);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.IsDisabled = true;
|
||||
ret.Disable(defaultAnimation);
|
||||
}
|
||||
currentButtonGroup.AddButton(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CharacterLineIndexImage CreateCharacterLine(
|
||||
int length, char blankFilling, PlainGeometryMesh tittle, IEnumerable<(char,PlainGeometryMesh)> charList
|
||||
)
|
||||
{
|
||||
var ret = new CharacterLineIndexImage(length, blankFilling,tittle,charList);
|
||||
_controlList.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}//---------------------------------- End of Class -----------------------------------------
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Get.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public partial class View
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Get the status of a certain key on the keyboard.
|
||||
/// </summary>
|
||||
/// <param name="form"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyStatus GetKeyStatus(ViewModelBase form, KeyboardKey key)
|
||||
{
|
||||
return InternalIO.glfwGetKey(form.WindowID, (int)key);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,30 @@ namespace StgSharp.Graphics
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OpenglContext
|
||||
{
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override unsafe int GetHashCode()
|
||||
{
|
||||
fixed (OpenglContext* sptr = &this)
|
||||
{
|
||||
return sptr->GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator !=(OpenglContext left, OpenglContext right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static bool operator ==(OpenglContext left, OpenglContext right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
#region glapi
|
||||
|
||||
internal unsafe delegate*<uint, GLfixed, void> glAccumxOES;
|
||||
@@ -2615,27 +2639,6 @@ namespace StgSharp.Graphics
|
||||
|
||||
#endregion glapi
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public unsafe override int GetHashCode()
|
||||
{
|
||||
fixed (OpenglContext* sptr = &this)
|
||||
{
|
||||
return sptr->GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(OpenglContext left, OpenglContext right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(OpenglContext left, OpenglContext right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,9 +53,10 @@ namespace StgSharp
|
||||
InfoError,
|
||||
InfoWarning,
|
||||
}
|
||||
|
||||
|
||||
internal static unsafe partial class InternalIO
|
||||
{
|
||||
|
||||
internal const string SS_errorLog =
|
||||
"SS_errorlog.log";
|
||||
|
||||
@@ -65,13 +66,13 @@ namespace StgSharp
|
||||
internal static Dictionary<TypeCode, uint> GLtype =
|
||||
new Dictionary<TypeCode, uint>();
|
||||
|
||||
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
internal static readonly GCHandle ssc_logHandle =
|
||||
GCHandle.Alloc(new byte[512], GCHandleType.Pinned);
|
||||
|
||||
internal static IntPtr SSClibPtr = IntPtr.Zero;
|
||||
|
||||
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
static InternalIO()
|
||||
{
|
||||
GLtype.Add(TypeCode.Single, GLconst.FLOAT);
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using System;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="KeyEventAttribute.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;
|
||||
@@ -6,14 +36,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
[AttributeUsage( AttributeTargets.Method)]
|
||||
public class KeyEventAttribute:Attribute
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class KeyEventAttribute : Attribute
|
||||
{
|
||||
internal int _keyTarget;
|
||||
|
||||
internal int _equipment;
|
||||
internal int _keyStat;
|
||||
internal int _keyTarget;
|
||||
|
||||
public KeyEventAttribute(KeyboardKey key ,KeyStatus status)
|
||||
public KeyEventAttribute(KeyboardKey key, KeyStatus status)
|
||||
{
|
||||
_equipment = (int)InputEquipment.Keyboard;
|
||||
_keyTarget = (int)key;
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using System;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ITrigger.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -6,7 +36,9 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public interface ITrigger
|
||||
{
|
||||
|
||||
public int TargetKeyOrButtonID { get; }
|
||||
public KeyStatus TriggeredStatus { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using System;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="JoystickTrigger.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -6,28 +36,18 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public struct JoystickTrigger : ITrigger, IEquatable<JoystickTrigger>
|
||||
{
|
||||
public Joystick Stick;
|
||||
|
||||
private KeyStatus _triggeredStat;
|
||||
|
||||
public int TargetKeyOrButtonID => (int)Stick;
|
||||
|
||||
public KeyStatus TriggeredStatus => _triggeredStat;
|
||||
public Joystick Stick;
|
||||
|
||||
public JoystickTrigger(Joystick targetKey)
|
||||
{
|
||||
this.Stick = targetKey;
|
||||
}
|
||||
|
||||
public static bool operator ==(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return left._triggeredStat == right._triggeredStat && left.Stick == right.Stick;
|
||||
}
|
||||
public int TargetKeyOrButtonID => (int)Stick;
|
||||
|
||||
public static bool operator !=(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
public KeyStatus TriggeredStatus => _triggeredStat;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
@@ -36,7 +56,7 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)Stick + 17 * (int)_triggeredStat;
|
||||
return ((int)Stick) + (17 * ((int)_triggeredStat));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -44,9 +64,20 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
return $"Key {Stick} triggered when {_triggeredStat}";
|
||||
}
|
||||
|
||||
public static bool operator !=(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static bool operator ==(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return (left._triggeredStat == right._triggeredStat) && (left.Stick == right.Stick);
|
||||
}
|
||||
|
||||
bool IEquatable<JoystickTrigger>.Equals(JoystickTrigger other)
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using System;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="KeyTrigger.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.Data.Common;
|
||||
using System.Text;
|
||||
@@ -6,30 +36,21 @@ using System.Text;
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
|
||||
public struct KeyTrigger: ITrigger,IEquatable<KeyTrigger>
|
||||
public struct KeyTrigger : ITrigger, IEquatable<KeyTrigger>
|
||||
{
|
||||
|
||||
private KeyboardKey _targetKey;
|
||||
private KeyStatus _triggerStat;
|
||||
|
||||
public int TargetKeyOrButtonID => (int)_targetKey;
|
||||
|
||||
public KeyStatus TriggeredStatus => _triggerStat;
|
||||
|
||||
public KeyTrigger(KeyboardKey targetKey, KeyStatus targetStat)
|
||||
public KeyTrigger(KeyboardKey targetKey, KeyStatus targetStat)
|
||||
{
|
||||
this._targetKey = targetKey;
|
||||
this._triggerStat = targetStat;
|
||||
}
|
||||
|
||||
public static bool operator ==(KeyTrigger left, KeyTrigger right)
|
||||
{
|
||||
return left._triggerStat == right._triggerStat && left._targetKey == right._targetKey;
|
||||
}
|
||||
public int TargetKeyOrButtonID => (int)_targetKey;
|
||||
|
||||
public static bool operator !=(KeyTrigger left, KeyTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
public KeyStatus TriggeredStatus => _triggerStat;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
@@ -38,7 +59,7 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)_targetKey + 17 * (int)_triggerStat;
|
||||
return ((int)_targetKey) + (17 * ((int)_triggerStat));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -46,9 +67,20 @@ namespace StgSharp.Controlling.UsrActivity
|
||||
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,92 +0,0 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
/// <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> where TView:View
|
||||
{
|
||||
protected TView _binding;
|
||||
|
||||
private KeyboardButtonGroup currentButtonGroup;
|
||||
|
||||
private List<ControllingItem> _controlList;
|
||||
|
||||
public ViewDesigner()
|
||||
{
|
||||
_controlList = new List<ControllingItem>();
|
||||
}
|
||||
|
||||
protected TView Binding
|
||||
{
|
||||
get => _binding;
|
||||
}
|
||||
|
||||
public TButtonGroup CreateKeyboardButtonGroup<TButtonGroup>(
|
||||
ITrigger leftBidning,
|
||||
ITrigger rightBinding,
|
||||
ITrigger upBinding,
|
||||
ITrigger downBinding,
|
||||
ITrigger confirmBinding
|
||||
)
|
||||
where TButtonGroup : KeyboardButtonGroup,new()
|
||||
{
|
||||
var 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 TriggerButton CreateKeyboardButton(
|
||||
Rectangle bonding, TextureProvider defaultAnimation, bool isEnable
|
||||
)
|
||||
{
|
||||
var ret = new TriggerButton();
|
||||
ret.BoundingBox = bonding;
|
||||
if (isEnable)
|
||||
{
|
||||
ret.IsDisabled = false;
|
||||
ret.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.IsDisabled = true;
|
||||
ret.Disable();
|
||||
}
|
||||
currentButtonGroup.AddButton(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public CharacterLineIndexImage CreateCharacterLine(
|
||||
int length, char blankFilling, PlainGeometryMesh tittle, IEnumerable<(char,PlainGeometryMesh)> charList
|
||||
)
|
||||
{
|
||||
var ret = new CharacterLineIndexImage(length, blankFilling,tittle,charList);
|
||||
_controlList.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize();
|
||||
|
||||
public abstract bool ValidateInitializing();
|
||||
|
||||
}//---------------------------------- End of Class -----------------------------------------
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public abstract class ViewResponder<TView> where TView: View
|
||||
{
|
||||
private View _viewbinding;
|
||||
private Dictionary<ITrigger, Action> keyCallbackIndex;
|
||||
private Dictionary<string, Action> nameToCallbackMap;
|
||||
private bool _isInitialized;
|
||||
|
||||
|
||||
protected ViewResponder()
|
||||
{
|
||||
keyCallbackIndex = new Dictionary<ITrigger, Action>();
|
||||
nameToCallbackMap = new Dictionary<string, Action>();
|
||||
}
|
||||
|
||||
internal void ProcessUserInput()
|
||||
{
|
||||
foreach (var pair in keyCallbackIndex)
|
||||
{
|
||||
ITrigger t = pair.Key;
|
||||
if (InternalIO.glfwGetKey(_viewbinding.ViewHandle, t.TargetKeyOrButtonID) == t.TriggeredStatus)
|
||||
{
|
||||
pair.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action this[ITrigger trigger]
|
||||
{
|
||||
get => keyCallbackIndex.TryGetValue(trigger, out Action callback) ? callback : null;
|
||||
set
|
||||
{
|
||||
if (keyCallbackIndex.TryGetValue(trigger, out Action callback))
|
||||
{
|
||||
callback += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyCallbackIndex.Add(trigger, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void Init(Func<string, Action> keyGetter)
|
||||
{
|
||||
if (_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CustomizedInitialize(
|
||||
(trigger, name) =>
|
||||
{
|
||||
if (!nameToCallbackMap.TryGetValue(name, out Action ret))
|
||||
{
|
||||
ret = keyGetter.Invoke(name)??
|
||||
throw new InvalidOperationException($"Cannot find method named {name} in binded view model");
|
||||
}
|
||||
this[trigger] = ret;
|
||||
return ret;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void ProcessInput()
|
||||
{
|
||||
foreach (var pair in keyCallbackIndex)
|
||||
{
|
||||
if (InternalIO.glfwGetKey(_viewbinding.ViewHandle,(int)pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus)
|
||||
{
|
||||
pair.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize(Func<ITrigger, string, Action> keyRegister);
|
||||
|
||||
public abstract bool ValidateInitializing();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user