コード例 #1
0
        private void OpenCodex(UIMouseEvent evt, UIElement listeningElement)
        {
            if (Main.LocalPlayer.GetModPlayer <CodexHandler>().CodexState != 0)
            {
                Open     = true;
                NewEntry = false;
                Main.PlaySound(SoundID.MenuOpen);
            }

            if (!Elements.Any(element => element is EntryButton))
            {
                foreach (CodexEntry entry in Main.LocalPlayer.GetModPlayer <CodexHandler>().Entries)
                {
                    EntryButton button = new EntryButton(entry);
                    button.Visible = false;
                    Buttons.Add(button);
                    Append(button);
                }
            }

            if (!Elements.Any(element => element is RecipeButton))
            {
                foreach (RiftRecipe recipe in ModContent.GetInstance <StarlightRiver>().RiftRecipes)
                {
                    RecipeButton button = new RecipeButton(recipe);
                    button.Visible = false;
                    Recipes.Add(button);
                    Append(button);
                }
            }
        }
コード例 #2
0
        public void Refresh()
        {
            foreach (UIElement element in Elements.Where(element => element is EntryButton))
            {
                (element as EntryButton).Visible = false;
                element.Width.Set(0, 0);
            }

            for (int k = 0; k < ShownButtons.Count; k++)
            {
                EntryButton button = ShownButtons.ElementAt(k);
                button.Left.Set(140, 0.5f);
                button.Top.Set(k * 30 - 150, 0.5f);
                button.Width.Set(120, 0);
                button.Height.Set(24, 0);
                button.Visible = true;
            }
        }
コード例 #3
0
        internal void ChangeCategory(CodexEntry.Categories category) //swaps out all of the entry buttons based on the category
        {
            if (!(Parent is Codex))
            {
                return;
            }
            Codex parent = Parent as Codex;

            ActiveCategory = category;
            CodexHandler player = Main.LocalPlayer.GetModPlayer <CodexHandler>();

            parent.ClickableEntries.Clear();

            int offY = 0;

            foreach (CodexEntry entry in player.Entries.Where(n => n.Category == category && (!n.RequiresUpgradedBook || player.CodexState == 2)))
            {
                EntryButton button = new EntryButton(entry);
                parent.AddEntryButton(button, offY);
            }
        }