Example #1
0
        public ItemBrowser(CheatSheet mod)
        {
            categories.Clear();
            bCategories            = new UIImage[categoryIcons.Length];
            this.itemView          = new ItemView();
            this.mod               = mod;
            this.CanMove           = true;
            base.Width             = this.itemView.Width + this.spacing * 2f;
            base.Height            = 420f;
            this.itemView.Position = new Vector2(this.spacing, base.Height - this.spacing - this.itemView.Height);
            this.AddChild(this.itemView);
            this.ParseList2();
            Texture2D texture = mod.GetTexture("UI/closeButton");
            UIImage   uIImage = new UIImage(texture /*UIView.GetEmbeddedTexture("Images.closeButton.png")*/);

            uIImage.Anchor       = AnchorPosition.TopRight;
            uIImage.Position     = new Vector2(base.Width - this.spacing, this.spacing);
            uIImage.onLeftClick += new EventHandler(this.bClose_onLeftClick);
            this.AddChild(uIImage);
            this.textbox          = new UITextbox();
            this.textbox.Width    = 100;
            this.textbox.Anchor   = AnchorPosition.TopRight;
            this.textbox.Position = new Vector2(base.Width - this.spacing * 2f - uIImage.Width, this.spacing + 40);
            //	this.textbox.Position = new Vector2(base.Width - this.spacing * 2f - uIImage.Width, this.spacing * 2f + uIImage.Height);
            this.textbox.KeyPressed += new UITextbox.KeyPressedHandler(this.textbox_KeyPressed);
            this.AddChild(this.textbox);
            for (int j = 0; j < ItemBrowser.categoryIcons.Length; j++)
            {
                UIImage uIImage2 = new UIImage(ItemBrowser.categoryIcons[j]);
                Vector2 position = new Vector2(this.spacing, this.spacing);
                uIImage2.Scale = 32f / Math.Max(categoryIcons[j].Width, categoryIcons[j].Height);

                position.X += (float)(j % 12 * 40);
                position.Y += (float)(j / 12 * 40);

                if (categoryIcons[j].Height > categoryIcons[j].Width)
                {
                    position.X += (32 - categoryIcons[j].Width) / 2;
                }
                else if (categoryIcons[j].Height < categoryIcons[j].Width)
                {
                    position.Y += (32 - categoryIcons[j].Height) / 2;
                }

                uIImage2.Position        = position;
                uIImage2.Tag             = j;
                uIImage2.onLeftClick    += (s, e) => buttonClick(s, e, true);
                uIImage2.onRightClick   += (s, e) => buttonClick(s, e, false);
                uIImage2.ForegroundColor = ItemBrowser.buttonColor;
                if (j == 0)
                {
                    uIImage2.ForegroundColor = ItemBrowser.buttonSelectedColor;
                }
                uIImage2.Tooltip           = ItemBrowser.categNames[j];
                ItemBrowser.bCategories[j] = uIImage2;
                this.AddChild(uIImage2);
            }
            itemView.selectedCategory = ItemBrowser.categories[0].ToArray();
            itemView.activeSlots      = itemView.selectedCategory;
            itemView.ReorderSlots();
            return;
        }