102 lines
3.1 KiB
C#
102 lines
3.1 KiB
C#
using Godot;
|
|
using Nocturnis;
|
|
using Nocturnis.Enigmos.ModuleManuals;
|
|
using Nocturnis.Enigmos.Modules;
|
|
using Nocturnis.GlobalManagement.Providers;
|
|
|
|
namespace Enigmos.Manual;
|
|
|
|
public abstract partial class ModuleManual : Panel, ISceneConcept, IModuleManual
|
|
{
|
|
private bool InitFlag { get; set; }
|
|
|
|
public void Init(IBaseModule module)
|
|
{
|
|
Module = module;
|
|
InitFlag = true;
|
|
}
|
|
|
|
private Label ModuleDescriptionTitle { get; set; }
|
|
private RichTextLabel ModuleDescription { get; set; }
|
|
private Label ModuleConfigurationTitle { get; set; }
|
|
private TextureButton Close { get; set; }
|
|
private TabContainer ConfigurationTabs { get; set; }
|
|
private IBaseModule Module { get; set; }
|
|
private List<IModuleManualTab> Tabs { get; set; } = new();
|
|
private LineEdit LabelString { get; set; }
|
|
public override void _Ready()
|
|
{
|
|
if(!InitFlag)
|
|
throw new Exception("TODO - NEED INIT");
|
|
ModuleDescriptionTitle = GetNode<Label>("ModuleDescriptionTitle");
|
|
ModuleDescription = GetNode<RichTextLabel>("ModuleDescription");
|
|
ModuleConfigurationTitle = GetNode<Label>("ModuleConfigurationTitle");
|
|
Close = GetNode<TextureButton>("Close");
|
|
ConfigurationTabs = GetNode<TabContainer>("ConfigurationTabs");
|
|
ModuleDescription.Text = Module.GetDescription;
|
|
LabelString = GetNode<LineEdit>("LabelString");
|
|
LabelString.Text = Module.LabelString;
|
|
Tabs = new List<IModuleManualTab>();
|
|
|
|
PortMaintenanceTab mainTab =
|
|
GlobalProvider.ProcessProvider.BuildPortMaintenanceTab(Module) as PortMaintenanceTab;
|
|
Tabs.Add(mainTab);
|
|
ConfigurationTabs.AddChild(mainTab);
|
|
if (Module is IPolymorphismModule polyModule)
|
|
{
|
|
ModulePolymorphismTab polyTab =
|
|
GlobalProvider.ProcessProvider.BuildModulePolymorphismTab(polyModule) as ModulePolymorphismTab;
|
|
Tabs.Add(polyTab);
|
|
ConfigurationTabs.AddChild(polyTab);
|
|
}
|
|
if (Module is IParameterizedModule paraModule)
|
|
{
|
|
|
|
ModuleParameterTab paraTab =
|
|
GlobalProvider.ProcessProvider.BuildModuleParameterTab(paraModule) as ModuleParameterTab;
|
|
Tabs.Add(paraTab);
|
|
ConfigurationTabs.AddChild(paraTab);
|
|
}
|
|
|
|
if (Module is ICommunicateModule comModule)
|
|
{
|
|
|
|
CommunicatorPairTab pairTab =
|
|
GlobalProvider.ProcessProvider.BuildCommunicatorPairTab(comModule) as CommunicatorPairTab;
|
|
Tabs.Add(pairTab);
|
|
ConfigurationTabs.AddChild(pairTab);
|
|
}
|
|
|
|
if (Module is IProgrammableModule progModule)
|
|
{
|
|
ProgrammableModuleSettingTab progTab =
|
|
GlobalProvider.ProcessProvider.BuildProgrammableModuleSettingTab(progModule) as ProgrammableModuleSettingTab;
|
|
Tabs.Add(progTab);
|
|
ConfigurationTabs.AddChild(progTab);
|
|
}
|
|
|
|
if (Module is IErrorHandlerModule errModule)
|
|
{
|
|
ErrorHandlerTab errTab = GlobalProvider.ProcessProvider.BuildErrorHandlerTab(errModule) as ErrorHandlerTab;
|
|
Tabs.Add(errTab);
|
|
ConfigurationTabs.AddChild(errTab);
|
|
}
|
|
|
|
base._Ready();
|
|
}
|
|
|
|
private void ShowTabTooltip(int idx) => ModuleConfigurationTitle.Text = Tabs[idx].FullName();
|
|
|
|
private void CloseManual()
|
|
{
|
|
GetParent().RemoveChild(this);
|
|
Module.Board.ManualOpened = false;
|
|
}
|
|
|
|
private void SetLabel(string label)
|
|
{
|
|
Module.Label.Text = label;
|
|
Module.LabelString = label;
|
|
}
|
|
}
|