Split project
This commit is contained in:
45
Manual/CommunicatorPairTab.cs
Normal file
45
Manual/CommunicatorPairTab.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Enigmos.Modules.Extensions;
|
||||
using Godot;
|
||||
using Nocturnis.Communicators;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
public partial class CommunicatorPairTab : Panel, IModuleManualTab
|
||||
{
|
||||
private bool InitFlag { get; set; }
|
||||
public string FullName() => "Pair";
|
||||
|
||||
public void Init(ICommunicateModule module)
|
||||
{
|
||||
Module = module;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
public ICommunicateModule Module { get; set; }
|
||||
private OptionButton CommunicatorOptions { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NEED INIT FIRST");
|
||||
CommunicatorOptions = GetNode<OptionButton>("CommunicatorOptions");
|
||||
IBaseCommunicator[] options = Module.CompatibleCommunicators();
|
||||
for(int idx = 0; idx < options.Length; idx ++ )
|
||||
{
|
||||
CommunicatorOptions.AddIconItem
|
||||
(
|
||||
options[idx].IconTexture,
|
||||
$"{options[idx].CustomName} " + (options[idx].Paired ? "(Already Paired)" : ""),
|
||||
idx
|
||||
);
|
||||
}
|
||||
|
||||
Name = "Pair";
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void SelectHandler(int idx)
|
||||
{
|
||||
Module.Pair(Module.CompatibleCommunicators()[idx]);
|
||||
}
|
||||
}
|
||||
27
Manual/ErrorHandlerTab.cs
Normal file
27
Manual/ErrorHandlerTab.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ErrorHandlerTab : Panel, IModuleManualTab
|
||||
{
|
||||
public string FullName() => "Error Handling";
|
||||
private bool InitFlag { get; set; }
|
||||
private OptionButton Options { get; set; }
|
||||
|
||||
public void Init(IErrorHandlerModule module)
|
||||
{
|
||||
Module = module;
|
||||
Options = GetNode<OptionButton>("Options");
|
||||
Options.Clear();
|
||||
for (int i = 0; i < module.HandlingOptions().Length; i++)
|
||||
Options.AddItem(module.HandlingOptions()[i], i);
|
||||
InitFlag = true;
|
||||
|
||||
}
|
||||
|
||||
private IErrorHandlerModule Module { get; set; }
|
||||
|
||||
private void SelectHandle(int idx) => Module.SelectedOption = idx;
|
||||
}
|
||||
38
Manual/ModuleBoolValueParameterSetter.cs
Normal file
38
Manual/ModuleBoolValueParameterSetter.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModuleBoolValueParameterSetter : ModuleParameterSetter
|
||||
{
|
||||
private CheckButton ToggleSetter { get; set; }
|
||||
private Label TrueLabel { get; set; }
|
||||
private Label FalseLabel { get; set; }
|
||||
|
||||
public void Init(IBoolParameter parameter)
|
||||
{
|
||||
UnderlyingParameter = parameter;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
public new IBoolParameter UnderlyingParameter
|
||||
{
|
||||
get => (base.UnderlyingParameter as IBoolParameter)!;
|
||||
set => base.UnderlyingParameter = value;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - INIT NEED");
|
||||
ToggleSetter = GetNode<CheckButton>("ToggleSetter");
|
||||
TrueLabel = GetNode<Label>("TrueLabel");
|
||||
FalseLabel = GetNode<Label>("FalseLabel");
|
||||
ToggleSetter.ButtonPressed = UnderlyingParameter.ParameterValue;
|
||||
TrueLabel.Text = UnderlyingParameter.TrueDescription;
|
||||
FalseLabel.Text = UnderlyingParameter.FalseDescription;
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void ToggleHandler(bool val) => UnderlyingParameter.ParameterValue = val;
|
||||
}
|
||||
42
Manual/ModuleCharValueParameterSetter.cs
Normal file
42
Manual/ModuleCharValueParameterSetter.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModuleCharValueParameterSetter : ModuleParameterSetter
|
||||
{
|
||||
private LineEdit CharInput { get; set; }
|
||||
private Button Apply { get; set; }
|
||||
private Label ExtraInformation { get; set; }
|
||||
|
||||
public void Init(ICharParameter parameter)
|
||||
{
|
||||
UnderlyingParameter = parameter;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
public new ICharParameter UnderlyingParameter
|
||||
{
|
||||
get => (base.UnderlyingParameter as ICharParameter)!;
|
||||
set => base.UnderlyingParameter = value;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - INIT NEED");
|
||||
Description = GetNode<Label>("Description");
|
||||
Apply = GetNode<Button>("Apply");
|
||||
CharInput = GetNode<LineEdit>("CharInput");
|
||||
ExtraInformation = GetNode<Label>("ExtraInformation");
|
||||
Description.Text = UnderlyingParameter.ParameterName;
|
||||
CharInput.Text = UnderlyingParameter.ParameterValue.ToString();
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void ApplyChange()
|
||||
{
|
||||
UnderlyingParameter.ParameterValue = CharInput.Text[0];
|
||||
}
|
||||
|
||||
}
|
||||
46
Manual/ModuleKeyValueParameterSetter.cs
Normal file
46
Manual/ModuleKeyValueParameterSetter.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModuleKeyValueParameterSetter : ModuleParameterSetter
|
||||
{
|
||||
public new IKeyParameter UnderlyingParameter
|
||||
{
|
||||
get => (base.UnderlyingParameter as IKeyParameter)!;
|
||||
set => base.UnderlyingParameter = value;
|
||||
}
|
||||
|
||||
private Button Binding { get; set; }
|
||||
private bool ReadyToBind { get; set; }
|
||||
|
||||
public void Init(IKeyParameter parameter)
|
||||
{
|
||||
UnderlyingParameter = parameter;
|
||||
ReadyToBind = false;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Binding = GetNode<Button>("Binding");
|
||||
}
|
||||
|
||||
private void StartBind()
|
||||
{
|
||||
Binding.Text = "Press a Key";
|
||||
InputMap.ActionEraseEvents(UnderlyingParameter.ParameterValue);
|
||||
ReadyToBind = true;
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (ReadyToBind && @event is InputEventKey keyEvent)
|
||||
{
|
||||
InputMap.ActionAddEvent(UnderlyingParameter.ParameterValue, keyEvent);
|
||||
Binding.Text = keyEvent.AsTextKeyLabel();
|
||||
ReadyToBind = false;
|
||||
}
|
||||
|
||||
base._Input(@event);
|
||||
}
|
||||
}
|
||||
113
Manual/ModuleManual.cs
Normal file
113
Manual/ModuleManual.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModuleManual : Panel
|
||||
{
|
||||
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; }
|
||||
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.SceneProvider
|
||||
.AssetMapper<PortMaintenanceTab>()
|
||||
.Instantiate<PortMaintenanceTab>();
|
||||
mainTab.Init(Module);
|
||||
Tabs.Add(mainTab);
|
||||
ConfigurationTabs.AddChild(mainTab);
|
||||
if (Module is IPolymorphismModule polyModule)
|
||||
{
|
||||
ModulePolymorphismTab polyTab = GlobalProvider.SceneProvider
|
||||
.AssetMapper<ModulePolymorphismTab>()
|
||||
.Instantiate<ModulePolymorphismTab>();
|
||||
polyTab.Init(polyModule);
|
||||
Tabs.Add(polyTab);
|
||||
ConfigurationTabs.AddChild(polyTab);
|
||||
}
|
||||
|
||||
if (Module is IParameterizedModule paraModule)
|
||||
{
|
||||
ModuleParameterTab paraTab = GlobalProvider.SceneProvider
|
||||
.AssetMapper<ModuleParameterTab>()
|
||||
.Instantiate<ModuleParameterTab>();
|
||||
paraTab.Init(paraModule);
|
||||
Tabs.Add(paraTab);
|
||||
ConfigurationTabs.AddChild(paraTab);
|
||||
}
|
||||
|
||||
if (Module is ICommunicateModule comModule)
|
||||
{
|
||||
CommunicatorPairTab pairTab = GlobalProvider.SceneProvider
|
||||
.AssetMapper<CommunicatorPairTab>()
|
||||
.Instantiate<CommunicatorPairTab>();
|
||||
pairTab.Init(comModule);
|
||||
Tabs.Add(pairTab);
|
||||
ConfigurationTabs.AddChild(pairTab);
|
||||
}
|
||||
|
||||
if (Module is ProgrammableModule programmableModule)
|
||||
{
|
||||
ProgrammableModuleSettingTab progTab =GlobalProvider.SceneProvider
|
||||
.AssetMapper<ProgrammableModuleSettingTab>()
|
||||
.Instantiate<ProgrammableModuleSettingTab>();
|
||||
progTab.Init(programmableModule);
|
||||
Tabs.Add(progTab);
|
||||
ConfigurationTabs.AddChild(progTab);
|
||||
}
|
||||
|
||||
if (Module is IErrorHandlerModule errorHandlerModule)
|
||||
{
|
||||
ErrorHandlerTab errTab = GlobalProvider.SceneProvider
|
||||
.AssetMapper<ErrorHandlerTab>()
|
||||
.Instantiate<ErrorHandlerTab>();
|
||||
errTab.Init(errorHandlerModule);
|
||||
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;
|
||||
}
|
||||
}
|
||||
19
Manual/ModuleParameterSetter.cs
Normal file
19
Manual/ModuleParameterSetter.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public abstract partial class ModuleParameterSetter : Control
|
||||
{
|
||||
protected bool InitFlag { get; set; }
|
||||
public IConfigurableParameter UnderlyingParameter { get; set; }
|
||||
protected Label Description { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NEED INIT");
|
||||
Description = GetNode<Label>("Description");
|
||||
Description.Text = UnderlyingParameter.ParameterName;
|
||||
base._Ready();
|
||||
}
|
||||
}
|
||||
73
Manual/ModuleParameterTab.cs
Normal file
73
Manual/ModuleParameterTab.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModuleParameterTab : Panel, IModuleManualTab
|
||||
{
|
||||
public string FullName() => "Parameter";
|
||||
private bool InitFlag { get; set; }
|
||||
public void Init(IParameterizedModule module)
|
||||
{
|
||||
Module = module;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
public IParameterizedModule Module { get; set; }
|
||||
|
||||
private static readonly PackedScene RealParameterSetterScene =
|
||||
GlobalProvider.SceneProvider.AssetMapper<ModuleRealValueParameterSetter>();
|
||||
|
||||
private static readonly PackedScene BoolParameterSetterScene =
|
||||
GlobalProvider.SceneProvider.AssetMapper<ModuleBoolValueParameterSetter>();
|
||||
private VBoxContainer Parameters { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NEED INIT FIRST");
|
||||
Parameters = GetNode<VBoxContainer>("ScrolledItems/Parameters");
|
||||
foreach (IConfigurableParameter parameter in Module.ConfigurableParameters)
|
||||
{
|
||||
if(parameter is IDoubleParameter doubleParameter)
|
||||
{
|
||||
ModuleRealValueParameterSetter setter =
|
||||
RealParameterSetterScene.Instantiate<ModuleRealValueParameterSetter>();
|
||||
setter.Init(doubleParameter);
|
||||
Parameters.AddChild(setter);
|
||||
}
|
||||
|
||||
else if (parameter is IBoolParameter boolParameter)
|
||||
{
|
||||
ModuleBoolValueParameterSetter setter =
|
||||
BoolParameterSetterScene.Instantiate<ModuleBoolValueParameterSetter>();
|
||||
setter.Init(boolParameter);
|
||||
Parameters.AddChild(setter);
|
||||
}
|
||||
else if (parameter is ICharParameter charParameter)
|
||||
{
|
||||
ModuleCharValueParameterSetter setter =
|
||||
GlobalProvider.SceneProvider
|
||||
.AssetMapper<ModuleCharValueParameterSetter>()
|
||||
.Instantiate<ModuleCharValueParameterSetter>();
|
||||
setter.Init(charParameter);
|
||||
Parameters.AddChild(setter);
|
||||
}
|
||||
else if (parameter is IKeyParameter keyParameter)
|
||||
{
|
||||
ModuleKeyValueParameterSetter setter =
|
||||
GlobalProvider.SceneProvider
|
||||
.AssetMapper<ModuleKeyValueParameterSetter>()
|
||||
.Instantiate<ModuleKeyValueParameterSetter>();
|
||||
setter.Init(keyParameter);
|
||||
Parameters.AddChild(setter);
|
||||
}
|
||||
}
|
||||
|
||||
Name = "Para";
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
}
|
||||
40
Manual/ModulePolymorphismTab.cs
Normal file
40
Manual/ModulePolymorphismTab.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModulePolymorphismTab : Panel, IModuleManualTab
|
||||
{
|
||||
private bool InitFlag { get; set; }
|
||||
|
||||
public void Init(IPolymorphismModule module)
|
||||
{
|
||||
Module = module;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
public string FullName() => "Polymorphism";
|
||||
|
||||
private static readonly PackedScene PortTypeSelectorScene =
|
||||
GlobalProvider.SceneProvider.AssetMapper<PortTypeSelector>();
|
||||
public IPolymorphismModule Module { get; set; }
|
||||
private VBoxContainer PortGroups { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - INIT REQUIRED");
|
||||
PortGroups = GetNode<VBoxContainer>("ScrolledItems/PortGroups");
|
||||
foreach (IDataPortGroup group in Module.ConfigurablePortGroups)
|
||||
{
|
||||
PortTypeSelector selector = PortTypeSelectorScene.Instantiate<PortTypeSelector>();
|
||||
selector.Init(group);
|
||||
PortGroups.AddChild(selector);
|
||||
}
|
||||
Name = "Poly";
|
||||
base._Ready();
|
||||
}
|
||||
}
|
||||
94
Manual/ModuleRealValueParameterSetter.cs
Normal file
94
Manual/ModuleRealValueParameterSetter.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ModuleRealValueParameterSetter : ModuleParameterSetter
|
||||
{
|
||||
public void Init(IDoubleParameter parameter)
|
||||
{
|
||||
UnderlyingParameter = parameter;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Underlying Parameter must be set before ready
|
||||
/// </summary>
|
||||
public new IDoubleParameter UnderlyingParameter
|
||||
{
|
||||
get => (base.UnderlyingParameter as IDoubleParameter)!;
|
||||
set => base.UnderlyingParameter = value;
|
||||
}
|
||||
private HSlider SliderSetter { get; set; }
|
||||
private SpinBox SpinSetter { get; set; }
|
||||
private double MinValue
|
||||
{
|
||||
get => SliderSetter.MinValue;
|
||||
set
|
||||
{
|
||||
SliderSetter.MinValue = value;
|
||||
SpinSetter.MinValue = value;
|
||||
}
|
||||
}
|
||||
private double MaxValue
|
||||
{
|
||||
get => SliderSetter.MaxValue;
|
||||
set
|
||||
{
|
||||
SliderSetter.MaxValue = value;
|
||||
SpinSetter.MaxValue = value;
|
||||
}
|
||||
}
|
||||
private double Step
|
||||
{
|
||||
get => SliderSetter.Step;
|
||||
set
|
||||
{
|
||||
SliderSetter.Step = value;
|
||||
SpinSetter.Step = value;
|
||||
}
|
||||
}
|
||||
private Label MaxLabel { get; set; }
|
||||
private Label MinLabel { get; set; }
|
||||
private double Value
|
||||
{
|
||||
get => SliderSetter.Value;
|
||||
set
|
||||
{
|
||||
SliderSetter.Value = value;
|
||||
SpinSetter.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NEED INIT");
|
||||
|
||||
SliderSetter = GetNode<HSlider>("SliderSetter");
|
||||
SpinSetter = GetNode<SpinBox>("SpinSetter");
|
||||
MaxLabel = GetNode<Label>("MaxLabel");
|
||||
MinLabel = GetNode<Label>("MinLabel");
|
||||
MinValue = UnderlyingParameter.MinValue;
|
||||
MaxValue = UnderlyingParameter.MaxValue;
|
||||
Step = UnderlyingParameter.Step;
|
||||
Value = UnderlyingParameter.ParameterValue;
|
||||
MaxLabel.Text = $"{MaxValue:F3}";
|
||||
MinLabel.Text = $"{MinValue:F3}";
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void SpinValueUpdateHandler(double val)
|
||||
{
|
||||
if (!SliderSetter.Value.Equals(val))
|
||||
SliderSetter.Value = val;
|
||||
UnderlyingParameter.ParameterValue = val;
|
||||
}
|
||||
|
||||
private void SliderValueUpdateHandler(double val)
|
||||
{
|
||||
if (!SpinSetter.Value.Equals(val))
|
||||
SpinSetter.Value = val;
|
||||
UnderlyingParameter.ParameterValue = val;
|
||||
}
|
||||
}
|
||||
48
Manual/PortFixer.cs
Normal file
48
Manual/PortFixer.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Inventories.ItemSlots.ItemSlots;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class PortFixer : Control
|
||||
{
|
||||
private bool InitFlag { get; set; }
|
||||
|
||||
public void Init(IBasePort port)
|
||||
{
|
||||
RelatedPort = port;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
private IBasePort RelatedPort { get; set; }
|
||||
private IChemicalItemSlot MaterialSlot { get; set; }
|
||||
public Button FixPort { get; set; }
|
||||
private Label PortLabel { get; set; }
|
||||
private Label QualityLabel { get; set; }
|
||||
private Label ConditionLabel { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NOT INIT");
|
||||
MaterialSlot = GetNode<IChemicalItemSlot>("MaterialSlot");
|
||||
PortLabel = GetNode<Label>("PortLabel");
|
||||
FixPort = GetNode<Button>("FixPort");
|
||||
ConditionLabel = GetNode<Label>("ConditionLabel");
|
||||
QualityLabel = GetNode<Label>("QualityLabel");
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void UpdateInformation()
|
||||
{
|
||||
PortLabel.Text = $"Port : {RelatedPort?.Name}";
|
||||
QualityLabel.Text = $"Quality : {RelatedPort?.Quality}";
|
||||
ConditionLabel.Text = $"Condition : {RelatedPort?.Condition} / 100";
|
||||
}
|
||||
|
||||
private void Fix() => RelatedPort.FixWith(MaterialSlot.Item);
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
UpdateInformation();
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
41
Manual/PortTypeSelector.cs
Normal file
41
Manual/PortTypeSelector.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class PortTypeSelector : Control
|
||||
{
|
||||
private bool InitFlag { get; set; }
|
||||
|
||||
public void Init(IDataPortGroup group)
|
||||
{
|
||||
UnderlyingGroup = group;
|
||||
InitFlag = true;
|
||||
}
|
||||
|
||||
/// <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 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);
|
||||
Description.Text = UnderlyingGroup.Description;
|
||||
TypeOptions.Select(Array.IndexOf(UnderlyingGroup.TypeOptions, UnderlyingGroup.SelectedType));
|
||||
}
|
||||
|
||||
private void SetType(int index)
|
||||
{
|
||||
UnderlyingGroup.SelectedType = UnderlyingGroup.TypeOptions[index];
|
||||
UnderlyingGroup.Inference();
|
||||
}
|
||||
}
|
||||
32
Manual/ProgrammableModuleSettingTab.cs
Normal file
32
Manual/ProgrammableModuleSettingTab.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ProgrammableModuleSettingTab : Panel, IModuleManualTab
|
||||
{
|
||||
private ProgrammableModule Module { get; set; }
|
||||
|
||||
private Button EditModule { get; set; }
|
||||
|
||||
public void Init(ProgrammableModule module)
|
||||
{
|
||||
Module = module;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
EditModule = GetNode<Button>("EditModule");
|
||||
Name = "Prog";
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
public string FullName() => "Programmable";
|
||||
|
||||
private void EnterProgrammableBoard()
|
||||
{
|
||||
GlobalProvider.SceneProvider.RootScene.ChangeScene(Module.UnderlyingBoard);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user