daily update on 20240610 by nitload youmu

This commit is contained in:
Nitload
2024-06-10 15:11:01 +08:00
parent c0093f7b5c
commit f6963b8e00
96 changed files with 2927 additions and 2290 deletions
@@ -43,6 +43,11 @@ 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();
}
}
}
}
@@ -18,9 +18,13 @@ namespace StgSharp.Controls
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))
@@ -35,7 +39,6 @@ namespace StgSharp.Controls
displayIndex = result.ToCharArray();
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
{
yield return _tittleMesh;
@@ -14,6 +14,8 @@ namespace StgSharp.Controls
public vec2d Position { get; set; }
public Rectangle BoundingBox { get; set; }
public abstract vec4d[] TextureBox { get; }
public abstract IEnumerator<PlainGeometryMesh> GetEnumerator();
@@ -13,12 +13,17 @@ namespace StgSharp.Controls
{
private PlainGeometryMesh renderMesh;
public override vec4d[] TextureBox
{
get => renderMesh.TextureCoord;
}
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
{
yield return renderMesh;
}
public DecorationBox(Rectangle bound, Image texture, vec2d[] texCoord)
public DecorationBox(Rectangle bound, Image texture, vec4d[] texCoord)
{
renderMesh = new PlainGeometryMesh(BoundingBox, texture, texCoord);
}
@@ -8,11 +8,14 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace StgSharp.Controlling.Controls
namespace StgSharp.Controls
{
public class MarkingLabel : ControllingItem
{
public vec2d Position { get; set; }
public override vec4d[] TextureBox
{
get => marker.TextureCoord;
}
private vec2d _currentPosition, _movementVec;
@@ -40,7 +43,7 @@ namespace StgSharp.Controlling.Controls
public override IEnumerator<PlainGeometryMesh> GetEnumerator()
{
throw new NotImplementedException();
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 --------------------------------------------
}
+55 -2
View File
@@ -1,4 +1,7 @@
using StgSharp.Controls;
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Controls;
using StgSharp.Controlling.UsrActivity;
using StgSharp.Math;
using System;
@@ -8,12 +11,62 @@ using System.Text;
namespace StgSharp.Graphics
{
public class ViewDesigner
public class ViewPortDesigner
{
private KeyboardButtonGroup currentButtonGroup;
private List<ControllingItem> _controlList;
public ViewPortDesigner()
{
_controlList = new List<ControllingItem>();
}
public KeyboardButtonGroup CreateKeyboardButtonGroup(
ITrigger leftBidning,
ITrigger rightBinding,
ITrigger upBinding,
ITrigger downBinding,
ITrigger confirmBinding
)
{
var ret = new KeyboardButtonGroup();
_controlList.Add(ret);
currentButtonGroup = ret;
return ret;
}
public TriggerButton CreateKeyboardButton(
Rectangle bonding, AnimationBuilder defaultAnimation, bool isEnable
)
{
var ret = new TriggerButton();
ret.BoundingBox = bonding;
if (isEnable)
{
ret.IsDisabled = false;
ret.Enable(defaultAnimation);
}
else
{
ret.IsDisabled = true;
ret.Disable(defaultAnimation);
}
currentButtonGroup.AddButton(ret);
return ret;
}
public CharacterLineIndexImage CreateCharacterLine(
int length, char blankFilling, PlainGeometryMesh tittle, IEnumerable<(char,PlainGeometryMesh)> charList
)
{
var ret = new CharacterLineIndexImage(length, blankFilling,tittle,charList);
_controlList.Add(ret);
return ret;
}
}//---------------------------------- End of Class -----------------------------------------
}
+3 -3
View File
@@ -35,7 +35,7 @@ using StgSharp.Math;
namespace StgSharp.Graphics
{
public partial class ViewModel
public partial class View
{
/// <summary>
@@ -44,9 +44,9 @@ namespace StgSharp.Graphics
/// <param name="form"></param>
/// <param name="key"></param>
/// <returns></returns>
public static KeyStatus GetKeyStatus(ViewModel form, KeyboardKey key)
public static KeyStatus GetKeyStatus(ViewModelBase form, KeyboardKey key)
{
return InternalIO.glfwGetKey(form.id, (int)key);
return InternalIO.glfwGetKey(form.WindowID, (int)key);
}
}
+1 -1
View File
@@ -143,7 +143,7 @@ namespace StgSharp
NumPad8 = 328,
NumPad9 = 329,
NumPadDec = 330,
NumPadSiv = 331,
NumPadDiv = 331,
NumPadMul = 332,
NumPadSub = 333,
NumPadAdd = 334,
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Controlling.UsrActivity
{
public interface ITrigger
{
public int TargetKeyOrButtonID { get; }
public KeyStatus TriggeredStatus { get; }
}
}
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Controlling.UsrActivity
{
public struct JoystickTrigger : ITrigger, IEquatable<JoystickTrigger>
{
public Joystick Stick;
private KeyStatus _triggeredStat;
public int TargetKeyOrButtonID => (int)Stick;
public KeyStatus TriggeredStatus => _triggeredStat;
public JoystickTrigger(Joystick targetKey)
{
this.Stick = targetKey;
}
public static bool operator ==(JoystickTrigger left, JoystickTrigger right)
{
return left._triggeredStat == right._triggeredStat && left.Stick == right.Stick;
}
public static bool operator !=(JoystickTrigger left, JoystickTrigger right)
{
return !(left == right);
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return (int)Stick + 17 * (int)_triggeredStat;
}
public override string ToString()
{
return $"Key {Stick} triggered when {_triggeredStat}";
}
bool IEquatable<JoystickTrigger>.Equals(JoystickTrigger other)
{
return other == this;
}
}
}
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
namespace StgSharp.Controlling.UsrActivity
{
public struct KeyTrigger: ITrigger,IEquatable<KeyTrigger>
{
public KeyboardKey TargetKey;
private KeyStatus _triggerStat;
int ITrigger.TargetKeyOrButtonID => (int)TargetKey;
KeyStatus ITrigger.TriggeredStatus => _triggerStat;
public KeyTrigger(KeyboardKey targetKey)
{
this.TargetKey = targetKey;
}
public static bool operator ==(KeyTrigger left, KeyTrigger right)
{
return left._triggerStat == right._triggerStat && left.TargetKey == right.TargetKey;
}
public static bool operator !=(KeyTrigger left, KeyTrigger right)
{
return !(left == right);
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return (int)TargetKey + 17 * (int)_triggerStat;
}
public override string ToString()
{
return $"Key {TargetKey} triggered when {_triggerStat}";
}
bool IEquatable<KeyTrigger>.Equals(KeyTrigger other)
{
return other == this;
}
}
}