Split project
This commit is contained in:
72
Manual/PortMaintenanceTab.cs
Normal file
72
Manual/PortMaintenanceTab.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Ports;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class PortMaintenanceTab : Panel, IModuleManualTab
|
||||
{
|
||||
private bool InitFlag { get; set; }
|
||||
|
||||
public void Init(IBaseModule module)
|
||||
{
|
||||
Module = module;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
public string FullName() => "Maintenance";
|
||||
private static readonly PackedScene PortFixerScene = GlobalProvider.SceneProvider.AssetMapper<PortFixer>();
|
||||
/// <summary>
|
||||
/// Should Be Assigned Before This Tab Been Added As Child To Tab Container
|
||||
/// </summary>
|
||||
public IBaseModule Module { get; set; }
|
||||
private VBoxContainer Ports { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NEED INIT");
|
||||
Ports = GetNode<VBoxContainer>("ScrolledItems/Ports");
|
||||
foreach (IBasePort port in Module.Ports)
|
||||
{
|
||||
PortFixer fixer = PortFixerScene.Instantiate<PortFixer>();
|
||||
fixer.Init(port);
|
||||
Ports.AddChild(fixer);
|
||||
}
|
||||
|
||||
if (Module is ProgrammableModule programmableModule)
|
||||
{
|
||||
HashSet<string> used = new HashSet<string>();
|
||||
foreach (BasePort port in programmableModule.ExplicitPorts())
|
||||
{
|
||||
int i = 0;
|
||||
while (used.Contains("Exterior" + port.Name + $"#{i}"))
|
||||
i++;
|
||||
used.Add("Exterior" + port.Name + $"#{i}");
|
||||
port.Name = "Exterior" + port.Name + $"#{i}";
|
||||
PortFixer fixer = PortFixerScene.Instantiate<PortFixer>();
|
||||
fixer.Init(port);
|
||||
Ports.AddChild(fixer);
|
||||
}
|
||||
foreach (BasePort port in programmableModule.ImplicitPorts())
|
||||
{
|
||||
string baseName = port.Name.ToString().Replace("Empty", "Interior");
|
||||
int i = 0;
|
||||
while (used.Contains(baseName + $"#{i}"))
|
||||
i++;
|
||||
used.Add(baseName + $"#{i}");
|
||||
port.Name = baseName + $"#{i}";
|
||||
PortFixer fixer = PortFixerScene.Instantiate<PortFixer>();
|
||||
fixer.Init(port);
|
||||
Ports.AddChild(fixer);
|
||||
}
|
||||
}
|
||||
|
||||
Name = "Main";
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user