コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public override void OnClose(SegmentEntity targetEntity)
 {
     ItemSearch = false;
     QuantumIoPortItemSearch.TerminateSearchWindow();
 }
コード例 #4
0
        public override bool ButtonClicked(string name, SegmentEntity targetEntity)
        {
            var quantumIoPort = targetEntity as QuantumIoPortMachine;
            var controller    = quantumIoPort.GetController();

            if (controller == null || !controller.IsOperating())
            {
                return(false);
            }

            if (name.Contains("iconItem"))
            {
                int.TryParse(name.Replace("iconItem", string.Empty), out var itemSlot);
                if (itemSlot > -1 && itemSlot < SlotCount)
                {
                    int amount = ItemUtils.GetItemAmoutToRetrieve();

                    var itemBase = ItemManager.CloneItem(controller.GetItem(itemSlot));
                    if (amount < ItemManager.GetCurrentStackSize(itemBase))
                    {
                        ItemManager.SetItemCount(itemBase, amount);
                    }
                    else
                    {
                        amount = ItemManager.GetCurrentStackSize(itemBase);
                    }

                    if (TakeItem(WorldScript.mLocalPlayer, controller, itemBase))
                    {
                        UIManager.ForceNGUIUpdate = 0.1f;
                        AudioHUDManager.instance.OrePickup();
                        return(true);
                    }
                }
            }

            if (name == FindItemButton)
            {
                ItemSearch = true;
                QuantumIoPortItemSearch.SetupUIRules();
                Redraw(targetEntity);
                return(true);
            }

            if (ItemSearch && name.Contains("itemIcon"))
            {
                QuantumIoPortItemSearch.HandleButtonPress(this, name, out var itemBase);
                int amount = ItemUtils.GetItemAmoutToRetrieve();
                if (amount < ItemManager.GetCurrentStackSize(itemBase))
                {
                    ItemManager.SetItemCount(itemBase, amount);
                }
                else
                {
                    amount = ItemManager.GetCurrentStackSize(itemBase);
                }
                if (TakeItem(WorldScript.mLocalPlayer, controller, itemBase))
                {
                    UIManager.ForceNGUIUpdate = 0.1f;
                    AudioHUDManager.instance.OrePickup();
                }
                return(true);
            }

            if (QuantumIoPortItemSearch.HandleButtonPress(this, name, out var selectedItem))
            {
                ItemSearch = false;
                manager.RedrawWindow();
            }

            return(false);
        }