示例#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 >= 3)
            {
                filterSet = sets[type - 3];
            }

            string        lastLevelSet          = null;
            LevelSetStats levelSetStats         = null;
            int           levelSetAreaOffset    = 0;
            int           levelSetUnlockedAreas = int.MaxValue;
            int           levelSetUnlockedModes = int.MaxValue;
            string        name;

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

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

                // TODO: Make subchapters hidden by default in the map list, even in debug mode.
                if (!save.DebugMode && !string.IsNullOrEmpty(area.GetMeta()?.Parent))
                {
                    continue;
                }

                string levelSet = area.GetLevelSet();

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

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

                if (lastLevelSet != levelSet)
                {
                    lastLevelSet          = levelSet;
                    levelSetStats         = SaveData.Instance.GetLevelSetStatsFor(levelSet);
                    levelSetAreaOffset    = levelSetStats.AreaOffset;
                    levelSetUnlockedAreas = levelSetStats.UnlockedAreas;
                    levelSetUnlockedModes = levelSetStats.UnlockedModes;
                    string setname = DialogExt.CleanLevelSet(levelSet);
                    TextMenuExt.SubHeaderExt levelSetHeader = new TextMenuExt.SubHeaderExt(setname);
                    levelSetHeader.Alpha = 0f;
                    menu.Add(levelSetHeader);
                    items.Add(levelSetHeader);
                }

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

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

                if (levelSet == "Celeste" && i > levelSetAreaOffset + levelSetUnlockedAreas)
                {
                    button.Disabled = true;
                }
                if (side == 1 && !areaStatsAll[i].Cassette)
                {
                    button.Disabled = true;
                }
                if (side >= 2 && levelSetUnlockedModes < (side + 1))
                {
                    button.Disabled = true;
                }

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

            // compute a delay so that options don't take more than a second to show up if many mods are installed.
            float delayBetweenOptions = 0.03f;

            if (items.Count > 0)
            {
                delayBetweenOptions = Math.Min(0.03f, 1f / items.Count);
            }

            // 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, delayBetweenOptions, items[i])));
            }

            if (menu.Height > menu.ScrollableMinSize)
            {
                menu.Position.Y = menu.ScrollTargetY;
            }
        }
示例#2
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;
            int           levelSetAreaOffset    = 0;
            int           levelSetUnlockedAreas = int.MaxValue;
            int           levelSetUnlockedModes = int.MaxValue;
            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);
                    levelSetAreaOffset    = levelSetStats.AreaOffset;
                    levelSetUnlockedAreas = levelSetStats.UnlockedAreas;
                    levelSetUnlockedModes = levelSetStats.UnlockedModes;
                    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 = 64f;

                if (levelSet == "Celeste" && i > levelSetAreaOffset + levelSetUnlockedAreas)
                {
                    button.Disabled = true;
                }
                if (side == 1 && !areaStatsAll[i].Cassette)
                {
                    button.Disabled = true;
                }
                if (side >= 2 && levelSetUnlockedModes < (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;
            }
        }
示例#3
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;
            }
        }