project update

This commit is contained in:
h z
2024-06-30 01:52:44 +08:00
parent 117835b503
commit 59d257c06a
67 changed files with 2268 additions and 92 deletions

View File

@@ -15,16 +15,15 @@ namespace Enigmos.Modules;
public abstract partial class BaseModule : TextureRect, IBaseModule
{
private static readonly Font GnuUni = ResourceLoader.Load<Font>("res://Resources/Fonts/GnuUnifontFull-Pm9P.ttf");
[Export] private int PresetPortQuality { get; set; }
[Export] private int PresetPortCondition { get; set; }
[Export] protected bool UsingPreset { get; set; }
[Export] public IPresetModuleConnection[] PresetConnections { get; set; }
[Export] public string LabelString { get; set; } = "";
public virtual Vector2 PositionToBoard => Position;
protected virtual bool Draggable() => true;
protected virtual bool HasManual() => true;
public bool HasLabel() => HasManual();
protected virtual bool Draggable => true;
protected virtual bool HasManual => true;
public bool HasLabel => HasManual;
public virtual IEnumerable<IBasePort> Ports => Array.Empty<BasePort>();
public IBaseBoard? Board { get; set; }
@@ -42,9 +41,9 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
public virtual void Init()
{
if (HasLabel())
if (HasLabel)
{
Label = GlobalProvider.SceneProvider
Label = GlobalProvider.SceneProvider!
.AssetMapper<ISimpleLabel>()
.Instantiate<ISimpleLabel>();
Label.Position = new Vector2(0, -25);
@@ -84,9 +83,9 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
PresetValueInit();
}
protected virtual void TimeoutCheck(RootModule root)
protected virtual void TimeoutCheck(IRootModule root)
{
if (root.Timer.ElapsedMilliseconds < 25) return;
if (root.Timer!.ElapsedMilliseconds < 25) return;
root.Timer.Stop();
throw ModuleExecutionTimeout.Exception;
}
@@ -95,11 +94,11 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
public override Variant _GetDragData(Vector2 atPosition)
{
if (!Draggable())
if (!Draggable)
return default;
Board!.ModuleMovingLayer.DraggingModule = this;
Board!.ModuleMovingLayer.MouseOffset = GetLocalMousePosition();
return GlobalProvider.DataStructureProvider.NewVariantWithType("Module", this);
return GlobalProvider.DataStructureProvider!.NewVariantWithType("Module", this);
}
@@ -119,13 +118,13 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
{
if (eventMouseButton.ButtonIndex == MouseButton.Right && eventMouseButton.Pressed)
{
if (!HasManual())
if (!HasManual)
return;
if (Board.ManualOpened)
return;
if (Manual == null)
{
Manual = GlobalProvider.SceneProvider
Manual = GlobalProvider.SceneProvider!
.AssetMapper<ModuleManual>()
.Instantiate<ModuleManual>();
Manual.Init(this);