daily update on 20240528 by nitload youmu
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// 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 IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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 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,25 @@
|
||||
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 IEnumerator<PlainGeometryMesh> GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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 IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
yield return renderMesh;
|
||||
}
|
||||
|
||||
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
|
||||
{
|
||||
renderMesh = new PlainGeometryMesh(BoundingBox, texture, texCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="KeyboardButton.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 KeyboardButton : ControllingItem
|
||||
{
|
||||
private PlainGeometryMesh current;
|
||||
private AnimationBuilder switchAnimationBuilder;
|
||||
|
||||
private Action? enableAction;
|
||||
private Action? disableAction;
|
||||
private Action? confirmAction;
|
||||
|
||||
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.IsComplete || switchAnimationBuilder == null)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if( enableAction != null)enableAction();
|
||||
}
|
||||
|
||||
public void Disable(AnimationBuilder animation)
|
||||
{
|
||||
if (switchAnimationBuilder.IsComplete || switchAnimationBuilder == null)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if (disableAction != null) disableAction();
|
||||
}
|
||||
|
||||
public void Highlight(AnimationBuilder animation)
|
||||
{
|
||||
if (switchAnimationBuilder.IsComplete || switchAnimationBuilder == null)
|
||||
{
|
||||
switchAnimationBuilder = animation;
|
||||
}
|
||||
if (confirmAction != null) confirmAction();
|
||||
}
|
||||
|
||||
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
|
||||
{
|
||||
current.Texture = switchAnimationBuilder.GetAnimationFrame();
|
||||
yield return current;
|
||||
}
|
||||
|
||||
}//----------------------------------- End of class --------------------------------------------
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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.Controlling.Controls
|
||||
{
|
||||
public class MarkingLabel : ControllingItem
|
||||
{
|
||||
public vec2d Position { get; set; }
|
||||
|
||||
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()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user