This commit is contained in:
h z
2024-07-12 14:32:16 +01:00
parent 5548a7243b
commit 1df3c08a9e
20 changed files with 119 additions and 148 deletions

View File

@@ -7,7 +7,7 @@ using Nocturnis.GlobalManagement.Providers;
namespace Enigmos.Manual;
public abstract partial class ModuleManual : Panel, ISceneConcept
public abstract partial class ModuleManual : Panel, ISceneConcept, IModuleManual
{
private bool InitFlag { get; set; }
@@ -17,14 +17,14 @@ public abstract partial class ModuleManual : Panel, ISceneConcept
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 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; }
private LineEdit LabelString { get; set; }
public override void _Ready()
{
if(!InitFlag)
@@ -38,58 +38,47 @@ public abstract partial class ModuleManual : Panel, ISceneConcept
LabelString = GetNode<LineEdit>("LabelString");
LabelString.Text = Module.LabelString;
Tabs = new List<IModuleManualTab>();
PortMaintenanceTab mainTab = GlobalProvider
.AssetMapper<PortMaintenanceTab>.Scene
.Instantiate<PortMaintenanceTab>();
mainTab.Init(Module);
PortMaintenanceTab mainTab =
GlobalProvider.ProcessProvider.BuildPortMaintenanceTab(Module) as PortMaintenanceTab;
Tabs.Add(mainTab);
ConfigurationTabs.AddChild(mainTab);
if (Module is IPolymorphismModule polyModule)
{
ModulePolymorphismTab polyTab = GlobalProvider
.AssetMapper<ModulePolymorphismTab>.Scene
.Instantiate<ModulePolymorphismTab>();
polyTab.Init(polyModule);
ModulePolymorphismTab polyTab =
GlobalProvider.ProcessProvider.BuildModulePolymorphismTab(polyModule) as ModulePolymorphismTab;
Tabs.Add(polyTab);
ConfigurationTabs.AddChild(polyTab);
}
if (Module is IParameterizedModule paraModule)
{
ModuleParameterTab paraTab = GlobalProvider
.AssetMapper<ModuleParameterTab>.Scene
.Instantiate<ModuleParameterTab>();
paraTab.Init(paraModule);
ModuleParameterTab paraTab =
GlobalProvider.ProcessProvider.BuildModuleParameterTab(paraModule) as ModuleParameterTab;
Tabs.Add(paraTab);
ConfigurationTabs.AddChild(paraTab);
}
if (Module is ICommunicateModule comModule)
{
CommunicatorPairTab pairTab = GlobalProvider
.AssetMapper<CommunicatorPairTab>.Scene
.Instantiate<CommunicatorPairTab>();
pairTab.Init(comModule);
CommunicatorPairTab pairTab =
GlobalProvider.ProcessProvider.BuildCommunicatorPairTab(comModule) as CommunicatorPairTab;
Tabs.Add(pairTab);
ConfigurationTabs.AddChild(pairTab);
}
if (Module is ProgrammableModule programmableModule)
if (Module is IProgrammableModule progModule)
{
ProgrammableModuleSettingTab progTab =GlobalProvider
.AssetMapper<ProgrammableModuleSettingTab>.Scene
.Instantiate<ProgrammableModuleSettingTab>();
progTab.Init(programmableModule);
ProgrammableModuleSettingTab progTab =
GlobalProvider.ProcessProvider.BuildProgrammableModuleSettingTab(progModule) as ProgrammableModuleSettingTab;
Tabs.Add(progTab);
ConfigurationTabs.AddChild(progTab);
}
if (Module is IErrorHandlerModule errorHandlerModule)
if (Module is IErrorHandlerModule errModule)
{
ErrorHandlerTab errTab = GlobalProvider
.AssetMapper<ErrorHandlerTab>.Scene
.Instantiate<ErrorHandlerTab>();
errTab.Init(errorHandlerModule);
ErrorHandlerTab errTab = GlobalProvider.ProcessProvider.BuildErrorHandlerTab(errModule) as ErrorHandlerTab;
Tabs.Add(errTab);
ConfigurationTabs.AddChild(errTab);
}

View File

@@ -3,7 +3,7 @@ using Nocturnis.DataStructures.ConfigurableParameters;
namespace Enigmos.Manual;
public abstract partial class ModuleParameterSetter : Control
public abstract partial class ModuleParameterSetter : Control, IModuleParameterSetter
{
protected bool InitFlag { get; set; }
public IConfigurableParameter UnderlyingParameter { get; set; }

View File

@@ -30,37 +30,27 @@ public partial class ModuleParameterTab : Panel, IModuleManualTab, ISceneConcept
{
if(parameter is IDoubleParameter doubleParameter)
{
ModuleRealValueParameterSetter setter = GlobalProvider
.AssetMapper<ModuleRealValueParameterSetter>.Scene
.Instantiate<ModuleRealValueParameterSetter>();
setter.Init(doubleParameter);
ModuleRealValueParameterSetter setter = GlobalProvider.ProcessProvider
.BuildModuleRealValueParameterSetter(doubleParameter) as ModuleRealValueParameterSetter;
Parameters.AddChild(setter);
}
else if (parameter is IBoolParameter boolParameter)
{
ModuleBoolValueParameterSetter setter = GlobalProvider
.AssetMapper<ModuleBoolValueParameterSetter>.Scene
.Instantiate<ModuleBoolValueParameterSetter>();
setter.Init(boolParameter);
ModuleBoolValueParameterSetter setter = GlobalProvider.ProcessProvider
.BuildModuleBoolValueParameterSetter(boolParameter) as ModuleBoolValueParameterSetter;
Parameters.AddChild(setter);
}
else if (parameter is ICharParameter charParameter)
{
ModuleCharValueParameterSetter setter =
GlobalProvider
.AssetMapper<ModuleCharValueParameterSetter>.Scene
.Instantiate<ModuleCharValueParameterSetter>();
setter.Init(charParameter);
ModuleCharValueParameterSetter setter = GlobalProvider.ProcessProvider
.BuildModuleCharValueParameterSetter(charParameter) as ModuleCharValueParameterSetter;
Parameters.AddChild(setter);
}
else if (parameter is IKeyParameter keyParameter)
{
ModuleKeyValueParameterSetter setter =
GlobalProvider
.AssetMapper<ModuleKeyValueParameterSetter>.Scene
.Instantiate<ModuleKeyValueParameterSetter>();
setter.Init(keyParameter);
ModuleKeyValueParameterSetter setter = GlobalProvider.ProcessProvider
.BuildModuleKeyValueParameterSetter(keyParameter) as ModuleKeyValueParameterSetter;
Parameters.AddChild(setter);
}
}

View File

@@ -1,6 +1,7 @@
using Godot;
using Nocturnis;
using Nocturnis.DataStructures.DataPortGroups;
using Nocturnis.DataStructures.DataTypes;
using Nocturnis.GlobalManagement.Providers;
namespace Enigmos.Manual;
@@ -18,20 +19,20 @@ public partial class PortTypeSelector : Control, ISceneConcept
/// <summary>
/// Underlying Group must be set before _Ready
/// </summary>
public IDataPortGroup? UnderlyingGroup { get; set; }
private Label? Description { get; set; }
private OptionButton? TypeOptions { get; set; }
public IDataPortGroup UnderlyingGroup { get; set; }
private Label Description { get; set; }
private OptionButton TypeOptions { get; set; }
public override void _Ready()
{
if (!InitFlag)
throw new Exception("TODO - NEED INIT");
Description = GetNode<Label>("Description");
TypeOptions = GetNode<OptionButton>("TypeOptions");
TypeOptions.Clear();
for (int idx = 0; idx < UnderlyingGroup!.TypeOptions.Length; idx++)
TypeOptions.AddIconItem(GlobalProvider.EnigmosProvider!.DataPortTypeMap[UnderlyingGroup.TypeOptions[idx]], "", idx);
TypeOptions!.Clear();
for (int idx = 0; idx < UnderlyingGroup!.TypeOptions.Count; idx++)
TypeOptions.AddIconItem(GlobalProvider.DataTypeTexture[UnderlyingGroup.TypeOptions[idx].Type], "", idx);
Description.Text = UnderlyingGroup.Description;
TypeOptions.Select(Array.IndexOf(UnderlyingGroup.TypeOptions, UnderlyingGroup.SelectedType));
TypeOptions.Select(UnderlyingGroup.TypeOptions.IndexOf(UnderlyingGroup.SelectedType));
}
private void SetType(int index)

View File

@@ -2,17 +2,18 @@ using Enigmos.Modules.ProgrammableModules;
using Godot;
using Nocturnis;
using Nocturnis.Enigmos.ModuleManuals;
using Nocturnis.Enigmos.Modules;
using Nocturnis.GlobalManagement.Providers;
namespace Enigmos.Manual;
public abstract partial class ProgrammableModuleSettingTab : Panel, IModuleManualTab, ISceneConcept
{
private ProgrammableModule? Module { get; set; }
private IProgrammableModule Module { get; set; }
private Button? EditModule { get; set; }
private Button EditModule { get; set; }
public void Init(ProgrammableModule module)
public void Init(IProgrammableModule module)
{
Module = module;
}
@@ -28,7 +29,7 @@ public abstract partial class ProgrammableModuleSettingTab : Panel, IModuleManua
private void EnterProgrammableBoard()
{
GlobalProvider.SceneProvider!.RootScene.ChangeScene(Module!.UnderlyingBoard);
GlobalProvider.SceneProvider!.RootScene.ChangeScene(Module!.UnderlyingBoard.AsNode());
}
}