daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user