Ejemplo n.º 1
0
        private void ReloadItems()
        {
            foreach (TextMenu.Item item in items)
            {
                menu.Remove(item);
            }
            items.Clear();

            string filterSet = null;

            if (type == 0)
            {
                filterSet = "Celeste";
            }
            else if (type >= 2)
            {
                filterSet = sets[type - 2];
            }

            string        lastLevelSet  = null;
            LevelSetStats levelSetStats = null;
            string        name;

            List <AreaStats> areaStatsAll = SaveData.Instance.Areas;

            for (int i = 0; i < AreaData.Areas.Count; i++)
            {
                AreaData area = AreaData.Areas[i];
                if (!area.HasMode((AreaMode)side))
                {
                    continue;
                }

                string levelSet = area.GetLevelSet();

                if ((filterSet == null && levelSet == "Celeste") || (filterSet != null && filterSet != levelSet))
                {
                    continue;
                }

                if (lastLevelSet != levelSet)
                {
                    lastLevelSet  = levelSet;
                    levelSetStats = SaveData.Instance.GetLevelSetStatsFor(levelSet);
                    if (levelSet != "Celeste")
                    {
                        name = DialogExt.CleanLevelSet(levelSet);
                        TextMenuExt.SubHeaderExt levelSetHeader = new TextMenuExt.SubHeaderExt(name);
                        levelSetHeader.Alpha = 0f;
                        menu.Add(levelSetHeader);
                        items.Add(levelSetHeader);
                    }
                }

                name = area.Name;
                name = name.DialogCleanOrNull() ?? name.SpacedPascalCase();

                TextMenuExt.ButtonExt button = new TextMenuExt.ButtonExt(name);
                button.Alpha = 0f;

                if (area.Icon != "areas/null")
                {
                    button.Icon = area.Icon;
                }
                button.IconWidth = 128f;

                if (levelSet == "Celeste" && i > levelSetStats.UnlockedAreas)
                {
                    button.Disabled = true;
                }
                if (side == 1 && !areaStatsAll[i].Cassette)
                {
                    button.Disabled = true;
                }
                if (side >= 2 && SaveData.Instance.UnlockedModes < (side + 1))
                {
                    button.Disabled = true;
                }

                menu.Add(button.Pressed(() => {
                    Inspect(area, (AreaMode)side);
                }));
                items.Add(button);
            }

            // Do this afterwards as the menu has now properly updated its size.
            for (int i = 0; i < items.Count; i++)
            {
                Add(new Coroutine(FadeIn(i, items[i])));
            }

            if (menu.Height > menu.ScrollableMinSize)
            {
                menu.Position.Y = menu.ScrollTargetY;
            }
        }
Ejemplo n.º 2
0
        private void ReloadItems()
        {
            foreach (TextMenu.Item item in items)
            {
                menu.Remove(item);
            }
            items.Clear();

            foreach (Everest.Updater.Source source in Everest.Updater.Sources)
            {
                TextMenuExt.SubHeaderExt header = new TextMenuExt.SubHeaderExt(source.NameDialog.DialogClean());
                header.Alpha = 0f;
                menu.Add(header);
                items.Add(header);

                if (source.ErrorDialog != null)
                {
                    string text = source.ErrorDialog.DialogClean();
                    TextMenuExt.SubHeaderExt error = new TextMenuExt.SubHeaderExt(text);
                    error.Alpha = 0f;
                    menu.Add(error);
                    items.Add(error);
                    continue;
                }

                if (source.Entries == null)
                {
                    TextMenuExt.SubHeaderExt info = new TextMenuExt.SubHeaderExt(Dialog.Clean("updater_versions_requesting"));
                    info.Alpha = 0f;
                    menu.Add(info);
                    items.Add(info);
                    continue;
                }

                string branch = null;
                int    count  = 0;
                foreach (Everest.Updater.Entry entry in source.Entries)
                {
                    if (entry.Branch != branch)
                    {
                        branch = entry.Branch;
                        count  = 0;

                        if (!string.IsNullOrEmpty(entry.Branch))
                        {
                            TextMenuExt.SubHeaderExt headerBranch = new TextMenuExt.SubHeaderExt("branch: " + entry.Branch);
                            headerBranch.Alpha = 0f;
                            menu.Add(headerBranch);
                            items.Add(headerBranch);
                        }
                    }
                    if (count >= buildsPerBranch)
                    {
                        continue;
                    }
                    count++;
                    TextMenuExt.ButtonExt item = new TextMenuExt.ButtonExt(entry.Name);
                    item.Alpha = 0f;
                    menu.Add(item.Pressed(() => {
                        Everest.Updater.Update(OuiModOptions.Instance.Overworld.Goto <OuiLoggedProgress>(), entry);
                    }));
                    items.Add(item);
                    continue;
                }
            }

            // Do this afterwards as the menu has now properly updated its size.
            for (int i = 0; i < items.Count; i++)
            {
                Add(new Coroutine(FadeIn(i, items[i])));
            }

            if (menu.Height > menu.ScrollableMinSize)
            {
                menu.Position.Y = menu.ScrollTargetY;
            }
        }