c-o
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="BattleField.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.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
//TODO 这玩意如何加载一个渲染流程以获得各个图元还没搞清楚
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class BattleField : ControllingItem
|
||||
{
|
||||
public override vec4d[] TextureBox
|
||||
{
|
||||
get ;
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class KeyboardButtonGroup : ControllingItem
|
||||
{
|
||||
private List<TriggerButton> buttonList;
|
||||
|
||||
private TriggerButton current;
|
||||
|
||||
public KeyboardButtonGroup()
|
||||
{
|
||||
buttonList = new List<TriggerButton>();
|
||||
}
|
||||
|
||||
public void AddButton(TriggerButton button)
|
||||
{
|
||||
buttonList.Add(button);
|
||||
}
|
||||
|
||||
public TriggerButton CurrentButton
|
||||
{
|
||||
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)
|
||||
{
|
||||
yield return item.Single();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
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 int length;
|
||||
private char[] displayIndex;
|
||||
private char defaultChar;
|
||||
|
||||
Dictionary<char, PlainGeometryMesh> texIndex;
|
||||
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)
|
||||
{
|
||||
this.length = length;
|
||||
displayIndex = new char[length];
|
||||
_tittleMesh = tittleMesh;
|
||||
texIndex = indexEnumeration.ToDictionary(item => item.Item1, item => item.Item2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public abstract partial class ControllingItem: IEnumerable<PlainGeometryMesh>
|
||||
{
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
public Rectangle BoundingBox { get; set; }
|
||||
public abstract vec4d[] TextureBox { get; }
|
||||
|
||||
|
||||
public abstract IEnumerator<PlainGeometryMesh> GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class DecorationBox : ControllingItem
|
||||
{
|
||||
private PlainGeometryMesh renderMesh;
|
||||
|
||||
public override vec4d[] TextureBox
|
||||
{
|
||||
get => renderMesh.TextureCoord;
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return renderMesh;
|
||||
}
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, vec4d[] texCoord)
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(BoundingBox, texture, texCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void Move(vec2d movement)
|
||||
{
|
||||
if (!_movement.IsComplete)
|
||||
{
|
||||
Position = _currentPosition + _movement.Calculate() * _movementVec;
|
||||
}
|
||||
}
|
||||
|
||||
public MarkingLabel(PlainGeometryMesh marker, TimeFunction movement)
|
||||
{
|
||||
this.marker = marker;
|
||||
_movement = movement;
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return marker;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="TriggerButton.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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controls
|
||||
{
|
||||
public class TriggerButton : ControllingItem
|
||||
{
|
||||
private AnimationBuilder switchAnimationBuilder;
|
||||
|
||||
#nullable enable
|
||||
private Action? enableAction;
|
||||
private Action? disableAction;
|
||||
private Action? confirmAction;
|
||||
#nullable restore
|
||||
|
||||
public override vec4d[] TextureBox
|
||||
{
|
||||
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; }
|
||||
}
|
||||
|
||||
public event Action ConfirmEvent
|
||||
{
|
||||
add { confirmAction += value; }
|
||||
remove { confirmAction -= value; }
|
||||
}
|
||||
|
||||
public void Enable(AnimationBuilder animation)
|
||||
{
|
||||
if (!IsDisabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (switchAnimationBuilder == null || switchAnimationBuilder.IsComplete)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if( enableAction != null)enableAction();
|
||||
}
|
||||
|
||||
public void Disable(AnimationBuilder animation)
|
||||
{
|
||||
if (switchAnimationBuilder == null || switchAnimationBuilder.IsComplete)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if (disableAction != null) disableAction();
|
||||
}
|
||||
|
||||
public void Highlight(AnimationBuilder animation)
|
||||
{
|
||||
if (switchAnimationBuilder == null || switchAnimationBuilder.IsComplete)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if (confirmAction != null) confirmAction();
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return new PlainGeometryMesh(this.BoundingBox, switchAnimationBuilder.GetAnimationFrame(),
|
||||
this.TextureBox);
|
||||
}
|
||||
|
||||
}//----------------------------------- End of class --------------------------------------------
|
||||
}
|
||||
Reference in New Issue
Block a user