Exemplo n.º 1
0
        public RecipeView()
        {
            Width         = (slotSize + slotSpace) * slotColumns + slotSpace + 20f;
            Height        = 200f;
            allRecipeSlot = new RecipeSlot[Recipe.numRecipes];
            for (int i = 0; i < allRecipeSlot.Length; i++)
            {
                allRecipeSlot[i] = new RecipeSlot(i);
            }

            //	this.allNPCSlot = (from s in this.allNPCSlot
            //					   select s).ToArray<NPCSlot>();
        }
Exemplo n.º 2
0
        private void textbox_KeyPressed(object sender, char key)
        {
            if (this.textbox.Text.Length <= 0)
            {
                recipeView.activeSlots = recipeView.selectedCategory;
                recipeView.ReorderSlots();
                return;
            }
            List <int> list = new List <int>();

            int[] category = recipeView.selectedCategory;
            for (int i = 0; i < category.Length; i++)
            {
                int        num  = category[i];
                RecipeSlot slot = recipeView.allRecipeSlot[num];
                if (slot.recipe.createItem.Name.ToLower().IndexOf(this.textbox.Text.ToLower(), StringComparison.Ordinal) != -1)
                {
                    list.Add(num);
                }
                //else
                //{
                //	for (int j = 0; j < slot.recipe.requiredItem.Length; i++)
                //	{
                //		if (slot.recipe.requiredItem[j].type > 0 && slot.recipe.requiredItem[j].name.ToLower().IndexOf(this.textbox.Text.ToLower(), StringComparison.Ordinal) != -1)
                //		{
                //			list.Add(num);
                //			break;
                //		}
                //	}
                //}
            }
            if (list.Count > 0)
            {
                recipeView.activeSlots = list.ToArray();
                recipeView.ReorderSlots();
                return;
            }
            this.textbox.Text = this.textbox.Text.Substring(0, this.textbox.Text.Length - 1);
        }
Exemplo n.º 3
0
        public void ReorderSlots()
        {
            int        type   = 0;
            List <int> groups = new List <int>();

            if (RecipeBrowserWindow.lookupItemSlot.item.stack > 0)
            {
                type = RecipeBrowserWindow.lookupItemSlot.item.type;

                foreach (var group in RecipeGroup.recipeGroups)
                {
                    if (group.Value.ValidItems.Contains(type))
                    {
                        groups.Add(group.Key);
                    }
                }
            }
            foreach (var item in groups)
            {
                Main.NewText("Group " + item);
            }

            base.ScrollPosition = 0f;
            base.ClearContent();
            int slotNum = 0;

            for (int i = 0; i < this.activeSlots.Length; i++)
            {
                if (type != 0)
                {
                    Recipe curRecipe = allRecipeSlot[activeSlots[i]].recipe;
                    //Main.NewText("Recipe " + i);
                    // if my item is in a recipe group, i should add that to required items.
                    bool inGroup = allRecipeSlot[activeSlots[i]].recipe.acceptedGroups.Intersect(groups).Any();

                    inGroup |= curRecipe.useWood(type, type) || curRecipe.useSand(type, type) || curRecipe.useFragment(type, type) || curRecipe.useIronBar(type, type) || curRecipe.usePressurePlate(type, type);

                    //if (inGroup)
                    //{
                    //	foreach (var item in allRecipeSlot[activeSlots[i]].recipe.acceptedGroups.Intersect(groups))
                    //	{
                    //		Main.NewText(i + " " + item.ToString());
                    //	}
                    //}

                    if (!inGroup)
                    {
                        // contine if neither result or ingredients contains item
                        if (!(allRecipeSlot[activeSlots[i]].recipe.createItem.type == type || allRecipeSlot[activeSlots[i]].recipe.requiredItem.Any(ing => ing.type == type)))
                        {
                            continue;
                        }
                    }
                }
                //int num = i;
                RecipeSlot slot = this.allRecipeSlot[this.activeSlots[i]];
                int        num2 = slotNum % this.slotColumns;
                int        num3 = slotNum / this.slotColumns;
                float      x    = (float)this.slotSpace + (float)num2 * (slot.Width + (float)this.slotSpace);
                float      y    = (float)this.slotSpace + (float)num3 * (slot.Height + (float)this.slotSpace);
                slot.Position = new Vector2(x, y);
                slot.Offset   = Vector2.Zero;
                this.AddChild(slot);
                slotNum++;
            }
            base.ContentHeight = base.GetLastChild().Y + base.GetLastChild().Height + this.spacing;
        }