Exemple #1
0
        public ItemBrowser(CheatSheet mod)
        {
            categories.Clear();
            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    += new EventHandler(this.button_onLeftClick);
                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();
        }
Exemple #2
0
        private void buttonClick(object sender, EventArgs e, bool left)
        {
            UIImage uIImage = (UIImage)sender;
            int     num     = (int)uIImage.Tag;

            if (num == (int)ItemBrowserCategories.ModItems)
            {
                var mods = ModToItems.Keys.ToList();
                mods.Sort();
                if (mods.Count == 0)
                {
                    Main.NewText("No Items have been added by mods.");
                }
                else
                {
                    if (uIImage.ForegroundColor == buttonSelectedColor)
                    {
                        lastModNameNumber = left ? (lastModNameNumber + 1) % mods.Count : (mods.Count + lastModNameNumber - 1) % mods.Count;
                    }
                    string currentMod = mods[lastModNameNumber];
                    itemView.selectedCategory = categories[0].Where(x => itemView.allItemsSlots[x].item.modItem != null && itemView.allItemsSlots[x].item.modItem.Mod.Name == currentMod).ToArray();
                    itemView.activeSlots      = itemView.selectedCategory;
                    itemView.ReorderSlots();
                    bCategories[num].Tooltip = categNames[num] + ": " + currentMod;
                }
            }
            else
            {
                itemView.selectedCategory = categories[num].ToArray();
                itemView.activeSlots      = itemView.selectedCategory;
                itemView.ReorderSlots();
            }

            textbox.Text = "";
            UIImage[] array = bCategories;
            for (int j = 0; j < array.Length; j++)
            {
                UIImage uIImage2 = array[j];
                uIImage2.ForegroundColor = buttonColor;
            }

            uIImage.ForegroundColor = buttonSelectedColor;
        }
Exemple #3
0
        public ItemBrowser(CheatSheet mod)
        {
            Main.instance.LoadItem(ItemID.AlphabetStatueA);
            Main.instance.LoadItem(ItemID.SilverBroadsword);
            Main.instance.LoadItem(ItemID.SilverPickaxe);
            Main.instance.LoadItem(ItemID.SilverChainmail);
            Main.instance.LoadItem(ItemID.HermesBoots);
            Main.instance.LoadItem(ItemID.DirtBlock);
            Main.instance.LoadItem(ItemID.FlamingArrow);
            Main.instance.LoadItem(ItemID.GreaterHealingPotion);
            Main.instance.LoadItem(ItemID.WormScarf);
            Main.instance.LoadItem(ItemID.Dresser);
            Main.instance.LoadItem(ItemID.ZephyrFish);
            Main.instance.LoadItem(ItemID.SlimySaddle);
            Main.instance.LoadItem(ItemID.AlphabetStatueM);

            Texture2D[] categoryIcons =
            {
                TextureAssets.Item[ItemID.AlphabetStatueA].Value,
                TextureAssets.Item[ItemID.SilverBroadsword].Value,
                TextureAssets.Item[ItemID.SilverPickaxe].Value,
                TextureAssets.Item[ItemID.SilverChainmail].Value,
                TextureAssets.Item[ItemID.HermesBoots].Value,
                TextureAssets.Item[ItemID.DirtBlock].Value,
                TextureAssets.Item[ItemID.FlamingArrow].Value,
                TextureAssets.Item[ItemID.GreaterHealingPotion].Value,
                TextureAssets.Item[ItemID.WormScarf].Value,
                TextureAssets.Item[ItemID.Dresser].Value,
                TextureAssets.Item[ItemID.ZephyrFish].Value,
                TextureAssets.Item[ItemID.SlimySaddle].Value,
                //    TextureAssets.Item[ItemID.FallenStar].Value,
                TextureAssets.Item[ItemID.AlphabetStatueM].Value,
            };

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

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

                position.X += j % 12 * 40;
                position.Y += 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 = buttonColor;
                if (j == 0)
                {
                    uIImage2.ForegroundColor = buttonSelectedColor;
                }

                uIImage2.Tooltip = categNames[j];
                bCategories[j]   = uIImage2;
                AddChild(uIImage2);
            }

            itemView.selectedCategory = categories[0].ToArray();
            itemView.activeSlots      = itemView.selectedCategory;
            itemView.ReorderSlots();
        }