public override void UpdateMachine(SegmentEntity targetEntity) { QuantumIoPortMachine ioPort = targetEntity as QuantumIoPortMachine; if (ioPort == null) { GenericMachinePanelScript.instance.Hide(); UIManager.RemoveUIRules("Machine"); return; } if (ItemSearch) { if (QuantumIoPortItemSearch.UpdateMachine((BaseMachineWindow)this)) { Dirty = true; return; } } else { if (ioPort.GetController().GetItems().Count != SlotCount) { Redraw(targetEntity); Dirty = true; return; } else { WindowUpdate(ioPort.GetController()); } } Dirty = false; }
public override void SpawnWindow(SegmentEntity targetEntity) { if (!(targetEntity is QuantumIoPortMachine quantumIoPort)) { GenericMachinePanelScript.instance.Hide(); UIManager.RemoveUIRules("Machine"); return; } QuantumIoPort = (QuantumIoPortMachine)targetEntity; if (!ItemSearch) { var itemWidth = 60; var itemHeight = 60; var textHeight = 30; var itemRowStart = textHeight * 5; var items = quantumIoPort.GetController().GetItems(); manager.SetTitle(QuantumIoPortMachine.MachineName); manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, StorageSizeLabel, string.Empty, Color.white, false, 10, textHeight); manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, StatusLabel, string.Empty, Color.white, false, 10, textHeight * 2); manager.AddButton(FindItemButton, "Search", 100, QuantumStorageModSettings.ButtonHeight * 3); SlotCount = 0; for (var index = 0; index < items.Count(); index++) { var line = index / 5; var column = index % 5; manager.AddIcon("iconItem" + index, "empty", Color.white, column * itemWidth + 10, line * itemHeight + itemRowStart + 10); manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "labelItem" + index, string.Empty, Color.white, false, column * itemWidth + 28, line * itemHeight + itemRowStart + 17); SlotCount++; } { var line = items.Count() / 5; var column = items.Count() % 5; manager.AddIcon("iconItem" + items.Count, "empty", Color.white, column * itemWidth + 10, line * itemHeight + itemRowStart + 10); manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "labelItem" + items.Count, string.Empty, Color.white, false, column * itemWidth + 28, line * itemHeight + itemRowStart + 17); } } else { QuantumIoPortItemSearch.SpawnWindow(this); } Dirty = true; }