Exemplo n.º 1
0
        public bool DoModal()
        {
            byte row      = 2;
            byte count    = 0;
            int  selected = 0;

            var egoItems = new List <InventoryControlItem>();

            for (int i = 0; i < this.Inventory.Items.Length; i++)
            {
                var item = this.Inventory.Items[i];

                if (item.Location == 0xff)
                {
                    var egoItem = new InventoryControlItem();
                    egoItems.Add(egoItem);

                    if (i == this.SelectedInventoryNumber)
                    {
                        selected = egoItems.Count - 1;
                    }

                    egoItem.Num  = (byte)i;
                    egoItem.Name = item.Name;
                    egoItem.Row  = row;

                    if (count % 2 == 0)
                    {
                        egoItem.Column = 1;
                    }
                    else
                    {
                        row++;
                        egoItem.Column = (byte)(39 - item.Name.Length);
                    }

                    count++;
                }
            }

            if (count == 0)
            {
                var egoItem = new InventoryControlItem
                {
                    Num    = 0,
                    Name   = UserInterface.InventoryNothing,
                    Row    = row,
                    Column = 16,
                };

                egoItems.Add(egoItem);
            }

            var array = egoItems.ToArray();

            this.Display(array, selected);

            return(this.Poll(array, selected));
        }
Exemplo n.º 2
0
        private void ChangeSelection(InventoryControlItem oldItem, InventoryControlItem newItem)
        {
            if (oldItem == null)
            {
                throw new ArgumentNullException(nameof(oldItem));
            }

            if (newItem == null)
            {
                throw new ArgumentNullException(nameof(newItem));
            }

            if (oldItem != newItem)
            {
                this.WindowManager.SetTextColor(SelectedTextForegroundColor, SelectedTextBackgroundColor);
                this.WindowManager.GotoPosition(new TextPosition(newItem.Row, newItem.Column));
                this.WindowManager.PrintFormatted(newItem.Name);

                this.WindowManager.SetTextColor(NormalTextForegroundColor, NormalTextBackgroundColor);
                this.WindowManager.GotoPosition(new TextPosition(oldItem.Row, oldItem.Column));
                this.WindowManager.PrintFormatted(oldItem.Name);
            }
        }