Exemple #1
0
        // 270 : 16 40 ?? 16

        public RecipeBrowserWindow(Mod mod)
        {
            categories.Clear();
            recipeView          = new RecipeView();
            this.mod            = mod;
            this.CanMove        = true;
            base.Width          = recipeView.Width + this.spacing * 2f;
            base.Height         = 420f;
            recipeView.Position = new Vector2(this.spacing, this.spacing + 40);
            this.AddChild(recipeView);
            this.InitializeRecipeCategories();
            Texture2D texture = mod.GetTexture("UI/closeButton");
            UIImage   uIImage = new UIImage(texture);

            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.Anchor      = AnchorPosition.TopRight;
            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);

            //lookupItemSlot = new Slot(0);
            lookupItemSlot          = new RecipeQuerySlot();
            lookupItemSlot.Position = new Vector2(spacing, halfspacing);
            lookupItemSlot.Scale    = .85f;
            //lookupItemSlot.functionalSlot = true;
            this.AddChild(lookupItemSlot);

            for (int j = 0; j < RecipeBrowserWindow.categoryIcons.Length; j++)
            {
                UIImage uIImage2 = new UIImage(RecipeBrowserWindow.categoryIcons[j]);
                Vector2 position = new Vector2(this.spacing + 48, this.spacing);
                uIImage2.Scale = 32f / Math.Max(categoryIcons[j].Width, categoryIcons[j].Height);

                position.X += (float)(j % 6 * 40);
                position.Y += (float)(j / 6 * 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 = RecipeBrowserWindow.buttonColor;
                if (j == 0)
                {
                    uIImage2.ForegroundColor = RecipeBrowserWindow.buttonSelectedColor;
                }
                uIImage2.Tooltip = RecipeBrowserWindow.categNames[j];
                RecipeBrowserWindow.bCategories[j] = uIImage2;
                this.AddChild(uIImage2);
            }

            for (int j = 0; j < Recipe.maxRequirements; j++)
            {
                GenericItemSlot genericItemSlot = new GenericItemSlot();
                Vector2         position        = new Vector2(this.spacing, this.spacing);

                //position.X += j * 60 + 120;
                //position.Y += 250;

                position.X += 166 + (j % cols * 51);
                position.Y += 244 + (j / cols * 51);

                genericItemSlot.Position           = position;
                genericItemSlot.Tag                = j;
                RecipeBrowserWindow.ingredients[j] = genericItemSlot;
                this.AddChild(genericItemSlot, false);
            }

            recipeView.selectedCategory = RecipeBrowserWindow.categories[0].ToArray();
            recipeView.activeSlots      = recipeView.selectedCategory;
            recipeView.ReorderSlots();
        }
Exemple #2
0
        // 270 : 16 40 ?? 16

        public RecipeBrowserWindow(CheatSheet mod)
        {
            Main.instance.LoadItem(ItemID.AlphabetStatueA);
            Main.instance.LoadItem(ItemID.AlphabetStatueM);

            Texture2D[] categoryIcons =
            {
                TextureAssets.Item[ItemID.AlphabetStatueA].Value,
                TextureAssets.Item[ItemID.AlphabetStatueM].Value,
            };

            categories.Clear();
            bCategories         = new UIImage[categoryIcons.Length];
            recipeView          = new RecipeView();
            this.mod            = mod;
            CanMove             = true;
            Width               = recipeView.Width + spacing * 2f;
            Height              = 420f;
            recipeView.Position = new Vector2(spacing, spacing + 40);
            AddChild(recipeView);
            InitializeRecipeCategories();
            Texture2D texture = mod.GetTexture("UI/closeButton").Value;
            UIImage   uIImage = new UIImage(texture);

            uIImage.Anchor       = AnchorPosition.TopRight;
            uIImage.Position     = new Vector2(Width - spacing, spacing);
            uIImage.onLeftClick += bClose_onLeftClick;
            AddChild(uIImage);
            textbox             = new UITextbox();
            textbox.Anchor      = AnchorPosition.TopRight;
            textbox.Position    = new Vector2(Width - spacing * 2f - uIImage.Width, spacing /** 2f + uIImage.Height*/);
            textbox.KeyPressed += textbox_KeyPressed;
            AddChild(textbox);

            //lookupItemSlot = new Slot(0);
            lookupItemSlot          = new RecipeQuerySlot();
            lookupItemSlot.Position = new Vector2(spacing, halfspacing);
            lookupItemSlot.Scale    = .85f;
            //lookupItemSlot.functionalSlot = true;
            AddChild(lookupItemSlot);

            for (int j = 0; j < categoryIcons.Length; j++)
            {
                UIImage uIImage2 = new UIImage(categoryIcons[j]);
                Vector2 position = new Vector2(spacing + 48, spacing);
                uIImage2.Scale = 32f / Math.Max(categoryIcons[j].Width, categoryIcons[j].Height);

                position.X += j % 6 * 40;
                position.Y += j / 6 * 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);
            }

            ingredients = new GenericItemSlot[Recipe.maxRequirements];
            for (int j = 0; j < Recipe.maxRequirements; j++)
            {
                GenericItemSlot genericItemSlot = new GenericItemSlot();
                Vector2         position        = new Vector2(spacing, spacing);

                //position.X += j * 60 + 120;
                //position.Y += 250;

                position.X += 166 + j % cols * 51;
                position.Y += 244 + j / cols * 51;

                genericItemSlot.Position = position;
                genericItemSlot.Tag      = j;
                ingredients[j]           = genericItemSlot;
                AddChild(genericItemSlot, false);
            }

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