예제 #1
0
        internal void UpdateFavoritedPanel()
        {
            ShowFavoritePanel = favoritedRecipes.Count > 0;
            favoritePanel.RemoveAllChildren();

            UIGrid list = new UIGrid();

            list.Width.Set(0, 1f);
            list.Height.Set(0, 1f);
            list.ListPadding = 5f;
            favoritePanel.Append(list);
            favoritePanel.AddDragTarget(list);
            favoritePanel.AddDragTarget(list._innerList);
            int width  = 1;
            int height = 0;
            int order  = 1;

            foreach (var item in favoritedRecipes)
            {
                Recipe           r = Main.recipe[item.index];
                UIRecipeProgress s = new UIRecipeProgress(item.index, r, order);
                order++;
                s.Recalculate();
                var a = s.GetInnerDimensions();
                s.Width.Precent = 1;
                list.Add(s);
                height += (int)(a.Height + list.ListPadding);
                width   = Math.Max(width, (int)a.Width);
                favoritePanel.AddDragTarget(s);
            }
            favoritePanel.Height.Pixels = height + favoritePanel.PaddingBottom + favoritePanel.PaddingTop - list.ListPadding;
            favoritePanel.Width.Pixels  = width;
            favoritePanel.Recalculate();

            var scrollbar = new InvisibleFixedUIScrollbar(userInterface);

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0, 1f);
            scrollbar.Left.Set(-20, 1f);
            favoritePanel.Append(scrollbar);
            list.SetScrollbar(scrollbar);

            Recipe.FindRecipes();
        }
예제 #2
0
        internal void UpdateFavoritedPanel()
        {
            if (!favoritePanelUpdateNeeded)
            {
                return;
            }
            favoritePanelUpdateNeeded = false;

            // Reset All
            foreach (var recipeSlot in RecipeCatalogueUI.instance.recipeSlots)
            {
                recipeSlot.favorited = false;
            }
            foreach (var recipeIndex in localPlayerFavoritedRecipes)
            {
                RecipeCatalogueUI.instance.recipeSlots[recipeIndex].favorited = true;
            }

            ShowFavoritePanel = localPlayerFavoritedRecipes.Count > 0;
            favoritePanel.RemoveAllChildren();

            UIGrid list = new UIGrid();

            list.Width.Set(0, 1f);
            list.Height.Set(0, 1f);
            list.ListPadding    = 5f;
            list.OnScrollWheel += RecipeBrowserUI.OnScrollWheel_FixHotbarScroll;
            favoritePanel.Append(list);
            favoritePanel.AddDragTarget(list);
            favoritePanel.AddDragTarget(list._innerList);
            int width  = 1;
            int height = 0;
            int order  = 1;

            for (int i = 0; i < Main.maxPlayers; i++)
            {
                if (i != Main.myPlayer && Main.player[i].active)
                {
                    foreach (var recipeIndex in Main.player[i].GetModPlayer <RecipeBrowserPlayer>().favoritedRecipes)
                    {
                        Recipe           r = Main.recipe[recipeIndex];
                        UIRecipeProgress s = new UIRecipeProgress(recipeIndex, r, order, i);
                        order++;
                        s.Recalculate();
                        var a = s.GetInnerDimensions();
                        s.Width.Precent = 1;
                        list.Add(s);
                        height += (int)(a.Height + list.ListPadding);
                        width   = Math.Max(width, (int)a.Width);
                        favoritePanel.AddDragTarget(s);
                    }
                }
            }

            foreach (var recipeIndex in localPlayerFavoritedRecipes)
            {
                Recipe           r = Main.recipe[recipeIndex];
                UIRecipeProgress s = new UIRecipeProgress(recipeIndex, r, order, Main.myPlayer);
                order++;
                s.Recalculate();
                var a = s.GetInnerDimensions();
                s.Width.Precent = 1;
                list.Add(s);
                height += (int)(a.Height + list.ListPadding);
                width   = Math.Max(width, (int)a.Width);
                favoritePanel.AddDragTarget(s);
            }
            favoritePanel.Height.Pixels = height + favoritePanel.PaddingBottom + favoritePanel.PaddingTop - list.ListPadding;
            favoritePanel.Width.Pixels  = width;
            favoritePanel.Recalculate();

            var scrollbar = new InvisibleFixedUIScrollbar(userInterface);

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0, 1f);
            scrollbar.Left.Set(-20, 1f);
            favoritePanel.Append(scrollbar);
            list.SetScrollbar(scrollbar);

            Recipe.FindRecipes();
        }