daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Logic;
using StgSharp.Math;
using System;
@@ -43,14 +43,19 @@ namespace StgSharp.Controls
{
public class BattleField : ControllingItem
{
public override vec4d[] TextureBox
{
get ;
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
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();
}
}
}
@@ -1,4 +1,34 @@
using StgSharp.Geometries;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ButtonGroup.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;
@@ -6,19 +36,42 @@ 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 class KeyboardButtonGroup : ControllingItem
public abstract class KeyboardButtonGroup : ControllingItem
{
private List<TriggerButton> buttonList;
private List<TriggerButton> buttonList;
private TriggerButton current;
public KeyboardButtonGroup()
{
buttonList = new List<TriggerButton>();
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;
}
public vec2d Position { get; set; }
protected List<TriggerButton> AllButton
{
get => buttonList;
}
public void AddButton(TriggerButton button)
@@ -26,46 +79,79 @@ namespace StgSharp.Controls
buttonList.Add(button);
}
public TriggerButton CurrentButton
public abstract void Confirm();
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
get => current;
}
public override vec4d[] TextureBox
{
get => throw new NotSupportedException();
}
public void MoveLeft()
{
}
public void MoveRight()
{
}
public void MoveUp()
{
}
public void MoveDown()
{
}
public void Confirm()
{
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
{
foreach (var item in buttonList)
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,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,41 +43,14 @@ 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 override vec4d[] TextureBox
{
get => throw new NotSupportedException();
}
public void Display(string message)
{
if (string.IsNullOrEmpty(message))
{
message = string.Empty;
}
string result = message.Length >= length ?
message.Substring(message.Length - displayIndex.Length) :
message.PadLeft(length,defaultChar);
displayIndex = result.ToCharArray();
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
{
yield return _tittleMesh;
foreach (char item in displayIndex)
{
yield return texIndex[item];
}
}
public CharacterLineIndexImage(
int length, char defaultChar, PlainGeometryMesh tittleMesh,
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration)
@@ -58,5 +61,40 @@ namespace StgSharp.Controls
texIndex = indexEnumeration.ToDictionary(item => item.Item1, item => item.Item2);
}
public bool IsEntity
{
get => true;
}
public ReadOnlySpan<vec4d> 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)
{
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,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,19 +39,20 @@ using System.Text;
namespace StgSharp.Controls
{
public abstract partial class ControllingItem: IEnumerable<PlainGeometryMesh>
public interface ControllingItem : IEnumerable<PlainGeometryMesh>
{
public vec2d Position { get; set; }
public Rectangle BoundingBox { get; set; }
public abstract vec4d[] TextureBox { 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 IEnumerator<PlainGeometryMesh> GetEnumerator();
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,21 +41,28 @@ namespace StgSharp.Controls
{
public class DecorationBox : ControllingItem
{
private PlainGeometryMesh renderMesh;
public override vec4d[] TextureBox
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 override IEnumerator<PlainGeometryMesh> GetEnumerator()
public vec2d Position { get; set; }
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
yield return renderMesh;
}
public DecorationBox(Rectangle bound, Image texture, vec4d[] texCoord)
{
renderMesh = new PlainGeometryMesh(BoundingBox, 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,28 +43,12 @@ namespace StgSharp.Controls
{
public class MarkingLabel : ControllingItem
{
public override vec4d[] TextureBox
{
get => marker.TextureCoord;
}
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)
{
@@ -41,10 +56,32 @@ namespace StgSharp.Controls
_movement = movement;
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
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);
}
}
}
@@ -35,81 +35,183 @@ using StgSharp.Math;
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 AnimationBuilder switchAnimationBuilder;
private Action? confirmCallback;
private Action? disableCallback;
#nullable enable
private Action? enableAction;
private Action? disableAction;
private Action? confirmAction;
private Action? enableCallback;
private float _statusBeginTime;
private RenderButtonTextureCallback _renderButton;
private TextureProvider _texture;
#nullable restore
public override vec4d[] TextureBox
public TriggerButton()
{
get { return switchAnimationBuilder.TextureFrame.VertexStream; }
}
public bool IsHighLighted { get; internal set; }
public bool IsDisabled { get; internal set; }
public event Action EnableEvent
{
add { enableAction += value; }
remove { enableAction -= value; }
}
public event Action DisableEvent
{
add { disableAction += value; }
remove { disableAction -= value; }
CurrentStatus = ButtonStatus.Disable;
}
public event Action ConfirmEvent
{
add { confirmAction += value; }
remove { confirmAction -= value; }
add { confirmCallback += value; }
remove { confirmCallback -= value; }
}
public void Enable(AnimationBuilder animation)
public event Action DisableEvent
{
if (!IsDisabled)
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<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;
}
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 (switchAnimationBuilder == null || switchAnimationBuilder.IsComplete)
if (enableCallback != null)
{
switchAnimationBuilder = animation;
enableCallback();
}
if( enableAction != null)enableAction();
}
public void Disable(AnimationBuilder animation)
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
if (switchAnimationBuilder == null || switchAnimationBuilder.IsComplete)
{
switchAnimationBuilder = animation;
}
if (disableAction != null) disableAction();
_renderButton(CurrentStatus, _statusBeginTime, in _texture);
yield return new PlainGeometryMesh(this.BoundingBox, _texture);
}
public void Highlight(AnimationBuilder animation)
public void Highlight()
{
if (switchAnimationBuilder == null || switchAnimationBuilder.IsComplete)
if (CurrentStatus == ButtonStatus.Enable)
{
switchAnimationBuilder = animation;
CurrentStatus |= ButtonStatus.EnableToHighlight;
}
else
{
return;
}
if (confirmCallback != null)
{
confirmCallback();
}
if (confirmAction != null) confirmAction();
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
internal void Init(ButtonStatus status)
{
yield return new PlainGeometryMesh(this.BoundingBox, switchAnimationBuilder.GetAnimationFrame(),
this.TextureBox);
if (CurrentStatus == ButtonStatus.Error)
{
CurrentStatus = status;
}
}
}//----------------------------------- End of class --------------------------------------------