public override void SpawnWindow(SegmentEntity targetEntity)
        {
            if (!(targetEntity is QuantumOutputPortMachine))
            {
                UIManager.RemoveUIRules("Machine");
            }
            else
            {
                manager.SetTitle("Quantum Output Port");
                if (!_itemSearch)
                {
                    manager.AddIcon(OutputItemIcon, "empty", Color.white, 10, 0);
                    manager.AddBigLabel(OutputTitleLabel, PersistentSettings.GetString("Choose_output"), Color.white, 70, 0);
                    manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, OutputStatusLabel,
                                     string.Empty, Color.white, false, 10, TextHeight * 2);
                    manager.AddButton(ChooseItemButton, PersistentSettings.GetString("Choose_Item"), 100,
                                      ButtonsRowStart + QuantumStorageModSettings.ButtonHeight * 2);
                    manager.AddButton(ToggleStatusButton, "Toggle item output", 100,
                                      ButtonsRowStart + QuantumStorageModSettings.ButtonHeight * 3);
                }
                else
                {
                    ItemSearchWindow.SpawnWindow((BaseMachineWindow)this);
                }

                Dirty = true;
            }
        }
Пример #2
0
        public override void SpawnWindow(SegmentEntity targetEntity)
        {
            if (!(targetEntity is QuantumStorageControllerMachine controller))
            {
                GenericMachinePanelScript.instance.Hide();
                UIManager.RemoveUIRules("Machine");
                return;
            }

            if (_itemSearch)
            {
                ItemSearchWindow.SpawnWindow(this);
                Dirty = true;
                return;
            }

            var textHeight       = 30;
            var buttonHeight     = 35;
            var itemWidth        = 60;
            var itemHeight       = 80;
            var buttonWidth      = 120;
            var buttonRowStart   = textHeight * 4 + buttonHeight;
            var itemRuleRowStart = buttonRowStart + buttonHeight * 2 + itemHeight;

            manager.SetTitle(QuantumStorageControllerMachine.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.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, InputStatusLabel,
                             string.Empty, Color.white,
                             false, 10, textHeight * 3);

            manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, OutputStatusLabel,
                             string.Empty, Color.white,
                             false, 10, textHeight * 4);

            manager.AddButton(InputStatusButton, "Toggle item input", 100, buttonRowStart);
            manager.AddButton(OutputStatusButton, "Toggle item output", 100, buttonRowStart + QuantumStorageModSettings.ButtonHeight);
            manager.AddButton(InputRuleAddButton, "Add input item rule", 100, buttonRowStart + QuantumStorageModSettings.ButtonHeight * 2);

            for (int i = 0; i < controller.GetItemInputRules().Count; i++)
            {
                manager.AddIcon(InputRuleItemIcon + i, "empty", Color.white, 10, itemRuleRowStart + itemHeight * i);
                manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, InputRuleItemLabel + i, string.Empty, Color.white, false, 28, itemRuleRowStart + itemHeight * i + 17);
                manager.AddButton(InputRuleReduceButton + i, "-" + QuantumStorageControllerMachine.DefaultInputRuleStep, itemWidth + 10, itemRuleRowStart + itemHeight * i);
                manager.AddButton(InputRuleIncreaseButton + i, "+" + QuantumStorageControllerMachine.DefaultInputRuleStep, buttonWidth + itemWidth + 10, itemRuleRowStart + itemHeight * i);
                manager.AddButton(InputRuleRemoveButton + i, "X", buttonWidth / 2 + itemWidth + 10, itemRuleRowStart + itemHeight * i + buttonHeight);
            }

            Dirty = true;
        }
Пример #3
0
 public override bool ButtonRightClicked(string name, SegmentEntity targetEntity)
 {
     if (name != InputRuleAddButton)
     {
         return(base.ButtonRightClicked(name, targetEntity));
     }
     _itemSearch = true;
     ItemSearchWindow.SetupUIRules();
     Redraw(targetEntity);
     return(true);
 }
Пример #4
0
 private void OnItemLinkCommand(string command, string arguments)
 {
     this.itemSearchCommandWindow = new ItemSearchWindow(this.Data, new UiBuilder(this.InterfaceManager, "ItemSearcher"), false, arguments);
     this.itemSearchCommandWindow.OnItemChosen += (sender, item) =>
     {
         this.Framework.Gui.Chat.PrintChat(new XivChatEntry
         {
             MessageBytes = SeStringUtils.CreateItemLink(item, false).Encode()
         });
     };
     this.isImguiDrawItemSearchWindow = true;
 }
        public override bool ButtonClicked(string name, SegmentEntity targetEntity)
        {
            utils.LogUtils.LogDebug("QuantumOutputPortWindow", "ButtonClicked name: " + name);
            QuantumOutputPortMachine outputPort = targetEntity as QuantumOutputPortMachine;

            if (name == OutputItemIcon)
            {
                utils.LogUtils.LogDebug("QuantumOutputPortWindow", "ButtonClicked outputitem");
                if (outputPort.Exemplar != null)
                {
                    utils.LogUtils.LogDebug("QuantumOutputPortWindow", "ButtonClicked outputitem - exemplar in outputPort not null");
                    SetExemplar(WorldScript.mLocalPlayer, outputPort, (ItemBase)null);
                    manager.RedrawWindow();
                }
                return(true);
            }

            if (name == ChooseItemButton)
            {
                _itemSearch = true;
                ItemSearchWindow.SetupUIRules();
                Redraw(targetEntity);
                return(true);
            }

            if (name == ToggleStatusButton)
            {
                ToggleStatus(WorldScript.mLocalPlayer, outputPort);
                manager.RedrawWindow();
            }

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

            if (selectedItem == null)
            {
                return(false);
            }

            SetExemplar(WorldScript.mLocalPlayer, outputPort, selectedItem);
            return(true);
        }
Пример #6
0
        public override void UpdateMachine(SegmentEntity targetEntity)
        {
            if (!(targetEntity is QuantumStorageControllerMachine quantumStorageController))
            {
                GenericMachinePanelScript.instance.Hide();
                UIManager.RemoveUIRules("Machine");
                return;
            }

            if (_itemSearch)
            {
                if (ItemSearchWindow.UpdateMachine(this))
                {
                    Dirty = true;
                }
            }
            else
            {
                WindowUpdate(quantumStorageController);
            }
        }
        public override void UpdateMachine(SegmentEntity targetEntity)
        {
            QuantumOutputPortMachine outputPort = targetEntity as QuantumOutputPortMachine;

            if (outputPort == null)
            {
                GenericMachinePanelScript.instance.Hide();
                UIManager.RemoveUIRules("Machine");
                return;
            }

            if (!Dirty)
            {
                return;
            }

            if (_itemSearch)
            {
                if (ItemSearchWindow.UpdateMachine((BaseMachineWindow)this))
                {
                    Dirty = true;
                    return;
                }
            }
            else
            {
                ItemBase exemplar = outputPort.Exemplar;
                if (exemplar != null)
                {
                    string itemName = ItemManager.GetItemName(exemplar);
                    manager.UpdateIcon(OutputItemIcon, ItemManager.GetItemIcon(exemplar), Color.white);
                    manager.UpdateLabel(OutputTitleLabel, itemName, Color.white);
                }

                manager.UpdateLabel(OutputStatusLabel, outputPort.Enabled ? "Output enabled" : "Output disabled", Color.white);
            }

            Dirty = false;
        }
        public override bool ButtonRightClicked(string name, SegmentEntity targetEntity)
        {
            utils.LogUtils.LogDebug("QuantumOutputPortWindow", "ButtonClicked name: " + name);
            if (name != OutputItemIcon)
            {
                return(base.ButtonRightClicked(name, targetEntity));
            }

            QuantumOutputPortMachine outputPort = targetEntity as QuantumOutputPortMachine;

            if (name == OutputItemIcon)
            {
                QuantumOutputPortWindow.SetExemplar(WorldScript.mLocalPlayer, outputPort, (ItemBase)null);
                manager.RedrawWindow();
                return(true);
            }

            _itemSearch = true;
            ItemSearchWindow.SetupUIRules();
            Redraw(targetEntity);
            return(true);
        }
Пример #9
0
        private void OnItemLinkCommand(string command, string arguments)
        {
            this.itemSearchCommandWindow = new ItemSearchWindow(this.Data, new UiBuilder(this.InterfaceManager, "ItemSearcher"), false);
            this.itemSearchCommandWindow.OnItemChosen += (sender, item) => {
                var hexData = new byte[] {
                    0x02, 0x13, 0x06, 0xFE, 0xFF, 0xF3, 0xF3, 0xF3, 0x03, 0x02, 0x27, 0x07, 0x03, 0xF2, 0x3A, 0x2F,
                    0x02, 0x01, 0x03, 0x02, 0x13, 0x06, 0xFE, 0xFF, 0xFF, 0x7B, 0x1A, 0x03, 0xEE, 0x82, 0xBB, 0x02,
                    0x13, 0x02, 0xEC, 0x03
                };

                var endTag = new byte[] {
                    0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03, 0x02, 0x13, 0x02, 0xEC, 0x03
                };

                BitConverter.GetBytes((short)item.RowId).Reverse().ToArray().CopyTo(hexData, 14);

                hexData = hexData.Concat(Encoding.UTF8.GetBytes(item.Name)).Concat(endTag).ToArray();

                this.Framework.Gui.Chat.PrintChat(new XivChatEntry {
                    MessageBytes = hexData
                });
            };
            this.isImguiDrawItemSearchWindow = true;
        }
 public ItemNameSearchFilter(ItemSearchPluginConfig config, ItemSearchWindow window, string startingValue = "") : base(config)
 {
     searchText     = startingValue;
     lastSearchText = string.Empty;
     this.window    = window;
 }
Пример #11
0
        public override bool ButtonClicked(string name, SegmentEntity targetEntity)
        {
            var controller = targetEntity as QuantumStorageControllerMachine;

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

            if (name.Equals(InputStatusButton))
            {
                controller.ToggleInput();

                if (!WorldScript.mbIsServer)
                {
                    NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumStorageControllerWindowKey,
                                                                 "ToggleInput",
                                                                 null, null, controller, 0.0f);
                }
                Dirty = true;
                return(true);
            }

            if (name.Equals(OutputStatusButton))
            {
                controller.ToggleOutput();

                if (!WorldScript.mbIsServer)
                {
                    NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumStorageControllerWindowKey,
                                                                 "ToggleOutput",
                                                                 null, null, controller, 0.0f);
                }
                Dirty = true;
                return(true);
            }

            if (name.Contains(InputRuleIncreaseButton))
            {
                int.TryParse(name.Replace(InputRuleIncreaseButton, string.Empty), out var itemSlot);

                if (itemSlot == -1)
                {
                    return(false);
                }

                controller.IncreaseItemInputRuleLimit(controller.GetItemInputRules()[itemSlot]);
                if (!WorldScript.mbIsServer)
                {
                    NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumStorageControllerWindowKey,
                                                                 "IncreaseItemRule",
                                                                 null, controller.GetItemInputRules()[itemSlot].Item, controller, 0.0f);
                }
                Dirty = true;
                return(true);
            }

            if (name.Contains(InputRuleReduceButton))
            {
                int.TryParse(name.Replace(InputRuleReduceButton, string.Empty), out var itemSlot);

                if (itemSlot == -1)
                {
                    return(false);
                }

                controller.ReduceItemInputRuleLimit(controller.GetItemInputRules()[itemSlot]);
                if (!WorldScript.mbIsServer)
                {
                    NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumStorageControllerWindowKey,
                                                                 "ReduceItemRule",
                                                                 null, controller.GetItemInputRules()[itemSlot].Item, controller, 0.0f);
                }
                Dirty = true;
                return(true);
            }

            if (name.Contains(InputRuleRemoveButton))
            {
                int.TryParse(name.Replace(InputRuleRemoveButton, string.Empty), out var itemSlot);

                if (itemSlot == -1)
                {
                    return(false);
                }

                controller.RemoveItemInputRule(controller.GetItemInputRules()[itemSlot]);

                if (!WorldScript.mbIsServer)
                {
                    NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumStorageControllerWindowKey,
                                                                 "RemoveItemRule",
                                                                 controller.GetItemInputRules()[itemSlot].MaxInput.ToString(), controller.GetItemInputRules()[itemSlot].Item, controller, 0.0f);
                }
                Redraw(targetEntity);
            }

            if (name.Equals(InputRuleAddButton))
            {
                _itemSearch = true;
                ItemSearchWindow.SetupUIRules();
                Redraw(targetEntity);
                return(true);
            }

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

            if (selectedItem == null)
            {
                return(false);
            }
            else
            {
                var itemInputRule = new ItemInputRule();
                itemInputRule.MaxInput = QuantumStorageControllerMachine.DefaultInputRuleStep;
                itemInputRule.Item     = selectedItem;
                controller.AddItemInputRule(itemInputRule);
                if (!WorldScript.mbIsServer)
                {
                    NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumStorageControllerWindowKey,
                                                                 "AddItemRule",
                                                                 itemInputRule.MaxInput.ToString(), selectedItem, controller, 0.0f);
                }
                Redraw(targetEntity);
            }

            return(false);
        }
 public override void OnClose(SegmentEntity targetEntity)
 {
     _itemSearch = false;
     ItemSearchWindow.TerminateSearchWindow();
 }
Пример #13
0
        private void OpenWindow()
        {
            var window = new ItemSearchWindow();

            window.Show();
        }