daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange

This commit is contained in:
Nitload
2024-10-03 04:03:06 +08:00
parent 0979123ac0
commit 6e2f93b053
265 changed files with 26732 additions and 19058 deletions
@@ -45,12 +45,23 @@ namespace StgSharp.Controls
{
public bool IsEntity => true;
public ReadOnlySpan<vec4d> TextureBox
public ReadOnlySpan<Vec4> TextureBox
{
get => throw new NotImplementedException();
}
public Rectangle BoundingBox { get; set; }
public vec2d Position { get; set; }
public Rectangle BoundingBox
{
get;
set;
}
public Vec2 Position
{
get;
set;
}
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
@@ -53,38 +53,48 @@ namespace StgSharp.Controls
buttonList = new List<TriggerButton>();
}
public bool IsEntity { get => false; }
public bool IsEntity
{
get => false;
}
public ReadOnlySpan<vec4d> TextureBox
public ReadOnlySpan<Vec4> TextureBox
{
get => throw new NotSupportedException();
}
public Rectangle BoundingBox { get; set; }
public Rectangle BoundingBox
{
get;
set;
}
public TriggerButton CurrentButton
{
get => current;
}
public vec2d Position { get; set; }
public Vec2 Position
{
get;
set;
}
protected List<TriggerButton> AllButton
{
get => buttonList;
}
public void AddButton(TriggerButton button)
public void AddButton( TriggerButton button )
{
buttonList.Add(button);
buttonList.Add( button );
}
public abstract void Confirm();
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
foreach (TriggerButton item in buttonList)
{
foreach( TriggerButton item in buttonList ) {
yield return item.Single();
}
}
@@ -92,12 +102,10 @@ namespace StgSharp.Controls
public void MoveDown()
{
TriggerButton button = current;
while ((button.Down != null) && button.Down.IsDisabled)
{
while( ( button.Down != null ) && button.Down.IsDisabled ) {
button = button.Right;
}
if (current == button)
{
if( current == button ) {
return;
}
current.DeHighlight();
@@ -108,12 +116,10 @@ namespace StgSharp.Controls
public void MoveLeft()
{
TriggerButton button = current;
while ((button.Left != null) && button.Left.IsDisabled)
{
while( ( button.Left != null ) && button.Left.IsDisabled ) {
button = button.Left;
}
if (current == button)
{
if( current == button ) {
return;
}
current.DeHighlight();
@@ -124,12 +130,10 @@ namespace StgSharp.Controls
public void MoveRight()
{
TriggerButton button = current;
while ((button.Right != null) && button.Right.IsDisabled)
{
while( ( button.Right != null ) && button.Right.IsDisabled ) {
button = button.Right;
}
if (current == button)
{
if( current == button ) {
return;
}
current.DeHighlight();
@@ -140,12 +144,10 @@ namespace StgSharp.Controls
public void MoveUp()
{
TriggerButton button = current;
while ((button.Up != null) && button.Up.IsDisabled)
{
while( ( button.Up != null ) && button.Up.IsDisabled ) {
button = button.Right;
}
if (current == button)
{
if( current == button ) {
return;
}
current.DeHighlight();
@@ -47,18 +47,21 @@ namespace StgSharp.Controls
private char[] displayIndex;
private char defaultChar;
Dictionary<char, PlainGeometryMesh> texIndex;
private Dictionary<char, PlainGeometryMesh> texIndex;
private int length;
PlainGeometryMesh _tittleMesh;
private PlainGeometryMesh _tittleMesh;
public CharacterLineIndexImage(
int length, char defaultChar, PlainGeometryMesh tittleMesh,
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration)
int length,
char defaultChar,
PlainGeometryMesh tittleMesh,
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration )
{
this.length = length;
displayIndex = new char[length];
_tittleMesh = tittleMesh;
texIndex = indexEnumeration.ToDictionary(item => item.Item1, item => item.Item2);
texIndex = indexEnumeration.ToDictionary(
item => item.Item1, item => item.Item2 );
}
public bool IsEntity
@@ -66,23 +69,32 @@ namespace StgSharp.Controls
get => true;
}
public ReadOnlySpan<vec4d> TextureBox
public ReadOnlySpan<Vec4> TextureBox
{
get => throw new NotSupportedException();
}
public Rectangle BoundingBox { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public vec2d Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public void Display(string message)
public Rectangle BoundingBox
{
if (string.IsNullOrEmpty(message))
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public Vec2 Position
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public void Display( string message )
{
if( string.IsNullOrEmpty( message ) ) {
message = string.Empty;
}
string result = (message.Length >= length) ?
message.Substring(message.Length - displayIndex.Length) :
message.PadLeft(length, defaultChar);
string result = ( message.Length >= length ) ?
message.Substring( message.Length - displayIndex.Length ) : message.PadLeft(
length, defaultChar );
displayIndex = result.ToCharArray();
}
@@ -90,9 +102,8 @@ namespace StgSharp.Controls
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
yield return _tittleMesh;
foreach (char item in displayIndex)
{
yield return texIndex[item];
foreach( char item in displayIndex ) {
yield return texIndex[ item ];
}
}
@@ -42,12 +42,27 @@ namespace StgSharp.Controls
public interface ControllingItem : IEnumerable<PlainGeometryMesh>
{
public abstract bool IsEntity { get; }
public abstract bool IsEntity
{
get;
}
public abstract ReadOnlySpan<vec4d> TextureBox { get; }
public abstract Rectangle BoundingBox { get; set; }
public abstract vec2d Position { get; set; }
public abstract ReadOnlySpan<Vec4> TextureBox
{
get;
}
public abstract Rectangle BoundingBox
{
get;
set;
}
public abstract Vec2 Position
{
get;
set;
}
IEnumerator IEnumerable.GetEnumerator()
{
@@ -44,20 +44,30 @@ namespace StgSharp.Controls
private PlainGeometryMesh renderMesh;
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
public DecorationBox( Rectangle bound, Image texture, Vec2[] texCoord )
{
renderMesh = new PlainGeometryMesh(BoundingBox, new TextureProvider(texture, texCoord));
renderMesh = new PlainGeometryMesh(
BoundingBox, new TextureProvider( texture, texCoord ) );
}
public bool IsEntity => true;
public ReadOnlySpan<vec4d> TextureBox
public ReadOnlySpan<Vec4> TextureBox
{
get => renderMesh.TextureCoord;
}
public Rectangle BoundingBox { get; set; }
public vec2d Position { get; set; }
public Rectangle BoundingBox
{
get;
set;
}
public Vec2 Position
{
get;
set;
}
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
@@ -48,40 +48,49 @@ namespace StgSharp.Controls
private TimeFunction _movement;
private vec2d _currentPosition, _movementVec;
private Vec2 _currentPosition, _movementVec;
public MarkingLabel(PlainGeometryMesh marker, TimeFunction movement)
public MarkingLabel( PlainGeometryMesh marker, TimeFunction movement )
{
this.marker = marker;
_movement = movement;
}
public bool IsEntity => true;
public ReadOnlySpan<vec4d> TextureBox
public ReadOnlySpan<Vec4> TextureBox
{
get => marker.TextureCoord;
}
public Rectangle BoundingBox { get; set; }
public vec2d Position { get; set; }
public Rectangle BoundingBox
{
get;
set;
}
public Vec2 Position
{
get;
set;
}
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
yield return marker;
}
public void Move(vec2d movement)
public void Move( Vec2 movement )
{
if (!_movement.IsComplete)
{
Position = _currentPosition + (_movement.Calculate() * _movementVec);
if( !_movement.IsComplete ) {
Position = _currentPosition + ( _movement.Calculate() * _movementVec );
}
}
public void MoveTo(vec2d target)
public void MoveTo( Vec2 target )
{
Move(target - Position);
Move( target - Position );
}
}
}
@@ -40,11 +40,14 @@ using System.Text;
namespace StgSharp.Controls
{
public delegate void RenderButtonTextureCallback(ButtonStatus status, float beginTime, in TextureProvider texture);
public delegate void RenderButtonTextureCallback(
ButtonStatus status,
float beginTime,
in TextureProvider texture );
public enum ButtonStatus
{
Error = 0b0,
Disable = 0b1,
Enable = 0b10,
@@ -52,12 +55,13 @@ namespace StgSharp.Controls
Confirm = 0b1000,
DisableToEnable = Disable | Enable,
EnableToDisable = -(Enable | DisableToEnable),
EnableToDisable = -( Enable | DisableToEnable ),
EnableToHighlight = Enable | Highlight,
HighlightToEnable = -(Enable | Highlight),
HighlightToEnable = -( Enable | Highlight ),
HighlightToDisable = -( Highlight | Disable ),
HighlightToDisable = -(Highlight | Disable),
}
public class TriggerButton : ControllingItem
@@ -66,14 +70,14 @@ namespace StgSharp.Controls
private Action? confirmCallback;
private Action? disableCallback;
#nullable enable
#nullable enable
private Action? enableCallback;
private float _statusBeginTime;
private RenderButtonTextureCallback _renderButton;
private TextureProvider _texture;
#nullable restore
#nullable restore
public TriggerButton()
{
@@ -102,41 +106,74 @@ namespace StgSharp.Controls
{
add
{
if (_renderButton == null)
{
if( _renderButton == null ) {
_renderButton = value;
}
else
{
} else {
_renderButton += value;
}
}
remove
{
if (_renderButton != null)
{
if( _renderButton != null ) {
_renderButton -= value;
}
}
}
public bool IsHighLighted { get; internal set; }
public bool IsHighLighted
{
get;
internal set;
}
public bool IsDisabled { get; internal set; }
public bool IsDisabled
{
get;
internal set;
}
public bool IsEntity => true;
public ReadOnlySpan<vec4d> TextureBox
public ReadOnlySpan<Vec4> TextureBox
{
get => MemoryMarshal.Cast<vec2d, vec4d>(_texture.TextureCoordinate);
get => MemoryMarshal.Cast<Vec2, Vec4>( _texture.TextureCoordinate );
}
public Rectangle BoundingBox { get; set; }
public TriggerButton Left { get; internal set; }
public TriggerButton Right { get; internal set; }
public TriggerButton Up { get; internal set; }
public TriggerButton Down { get; internal set; }
public vec2d Position { get; set; }
public Rectangle BoundingBox
{
get;
set;
}
public TriggerButton Left
{
get;
internal set;
}
public TriggerButton Right
{
get;
internal set;
}
public TriggerButton Up
{
get;
internal set;
}
public TriggerButton Down
{
get;
internal set;
}
public Vec2 Position
{
get;
set;
}
internal TextureProvider Texture
{
@@ -144,12 +181,15 @@ namespace StgSharp.Controls
set => _texture = value;
}
protected ButtonStatus CurrentStatus { get; set; }
protected ButtonStatus CurrentStatus
{
get;
set;
}
public void DeHighlight()
{
if (CurrentStatus == ButtonStatus.Highlight)
{
if( CurrentStatus == ButtonStatus.Highlight ) {
CurrentStatus = ButtonStatus.HighlightToEnable;
}
}
@@ -162,54 +202,44 @@ namespace StgSharp.Controls
ButtonStatus.Highlight => ButtonStatus.HighlightToDisable,
_ => CurrentStatus,
};
if (disableCallback != null)
{
if( disableCallback != null ) {
disableCallback();
}
}
public void Enable()
{
if (CurrentStatus == ButtonStatus.Disable)
{
if( CurrentStatus == ButtonStatus.Disable ) {
CurrentStatus = ButtonStatus.DisableToEnable;
}
else
{
} else {
return;
}
if (enableCallback != null)
{
if( enableCallback != null ) {
enableCallback();
}
}
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
_renderButton(CurrentStatus, _statusBeginTime, in _texture);
yield return new PlainGeometryMesh(this.BoundingBox, _texture);
_renderButton( CurrentStatus, _statusBeginTime, in _texture );
yield return new PlainGeometryMesh( this.BoundingBox, _texture );
}
public void Highlight()
{
if (CurrentStatus == ButtonStatus.Enable)
{
if( CurrentStatus == ButtonStatus.Enable ) {
CurrentStatus |= ButtonStatus.EnableToHighlight;
}
else
{
} else {
return;
}
if (confirmCallback != null)
{
if( confirmCallback != null ) {
confirmCallback();
}
}
internal void Init(ButtonStatus status)
internal void Init( ButtonStatus status )
{
if (CurrentStatus == ButtonStatus.Error)
{
if( CurrentStatus == ButtonStatus.Error ) {
CurrentStatus = status;
}
}