public DisplayPanel(List <LandingPadGroup> groups, IMyTextPanel textPanel) { Group = null; TextPanel = textPanel; PanelType = PanelType.Main; _textBuilder = new MainPanelTextBuilder(groups); }
private void Setup() { _groupList.Clear(); List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); // Find all blocks with a "[LandingPad]" section in custom data. GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(blocks, block => MyIni.HasSection(block.CustomData, MyConstants.SectionName) && block.IsSameConstructAs(Me)); // Step through each block and determine groups foreach (IMyTerminalBlock block in blocks) { // parse the custom data for the block MyIniParseResult parsedIniResult; if (_data.TryParse(block.CustomData, out parsedIniResult)) { MyConfiguration blockConfig = new MyConfiguration(_data); // Get the Group value. string groupName = blockConfig.GroupName; // If there is no group specified and if this is a text panel, use that as a main panel, // otherwise continue with next block. if (blockConfig.GroupName == MyConstants.DefaultGroupName) { IMyTextPanel lcdPanel = block as IMyTextPanel; if (lcdPanel != null) { DisplayPanel panel = new DisplayPanel(_groupList, lcdPanel); _mainPanels.Add(panel); } continue; } ; // If group does not exist, add a new group with this name. if (!_groupList.Exists(x => x.GroupName == groupName)) { LandingPadGroup landingLightGroup = new LandingPadGroup(groupName); _groupList.Add(landingLightGroup); } // Get the group for this block it should be added to. LandingPadGroup group = _groupList.Find(x => x.GroupName == groupName); AddBlockToGroup(group, block, blockConfig); } } // All block should now be assigned. // Configure the individual blocks for each group. foreach (LandingPadGroup group in _groupList) { group.ConfigureBlocks(); } }
public IndicatorPanelTextBuilder(LandingPadGroup group) { _group = group; _lineLength = MyConstants.LCDPanelLineLength; _title = SetupTitleLine(group.GroupName, _lineLength); _topLine = SetupTopLine(_lineLength); _bottomLine = SetupBottomLine(_lineLength); _currentShipName = string.Empty; }
private string BuildInformationForGroup(LandingPadGroup group) { StringBuilder builder = new StringBuilder(); builder.AppendLine($"{_topLine}"); builder.AppendLine($"{_title}"); builder.AppendLine($"{_bottomLine}"); builder.AppendLine(); builder.AppendLine($"{SetupShipLine(group.ConnectedShipName, _lineLength)}"); return(builder.ToString()); }
private string BuildInformationForGroup(LandingPadGroup group) { StringBuilder builder = new StringBuilder(); builder.AppendLine(_title); builder.AppendLine("-------------------------"); builder.AppendLine($"Connector: {group.ConnectorStatusAsText}"); builder.AppendLine($"Ship : {group.ConnectedShipName}"); builder.AppendLine($"Lights : {group.Lights.Count}"); builder.AppendLine($"Max Seq : {group.MaxSequence}"); builder.AppendLine($"Time : {group.TotalTime}"); builder.AppendLine($"Offset : {group.OffsetPerLight}"); return(builder.ToString()); }
private void AddBlockToGroup(LandingPadGroup group, IMyTerminalBlock block, MyConfiguration blockConfig) { // Is this an LCD Panel? IMyTextPanel lcdPanel = block as IMyTextPanel; if (lcdPanel != null) { PanelType panelType = PanelType.Main; switch (blockConfig.PanelType) { case MyConstants.PanelTypeDetail: panelType = PanelType.Detail; break; case MyConstants.PanelTypeIndicator: panelType = PanelType.Indicator; break; default: break; } DisplayPanel panel = new DisplayPanel(group, lcdPanel, panelType); group.Panels.Add(panel); } // Is this a lighting block? IMyLightingBlock light = block as IMyLightingBlock; if (light != null) { if (blockConfig.Sequence > 0) { LandingLight landingLight = new LandingLight(light, blockConfig.Sequence); group.Lights.Add(landingLight); } } // Is this a connector block? IMyShipConnector shipConnector = block as IMyShipConnector; if (shipConnector != null && group.Connector == null) { group.Connector = shipConnector; } }
public DisplayPanel(LandingPadGroup group, IMyTextPanel textPanel, PanelType panelType) { Group = group; TextPanel = textPanel; PanelType = panelType; // LCD Panels can be a detail panel or an indicator panel. switch (panelType) { case PanelType.Detail: _textBuilder = new DetailPanelTextBuilder(group); break; case PanelType.Indicator: _textBuilder = new IndicatorPanelTextBuilder(group); break; case PanelType.Main: break; default: break; } }
public DetailPanelTextBuilder(LandingPadGroup group) { _group = group; _lineLength = MyConstants.LCDPanelLineLength; _title = SetupTitleLine(group.GroupName, _lineLength); }