Esempio n. 1
0
        private IEnumerator EaseOut(Oui next)
        {
            OuiChapterSelectIcon selected = null;

            if (next is OuiChapterPanel)
            {
                (selected = icons[area]).Select();
            }

            bool isVanilla = currentLevelSet == "Celeste";

            foreach (OuiChapterSelectIcon icon in icons)
            {
                AreaData area = AreaData.Areas[icon.Area];
                if (area.GetLevelSet() != currentLevelSet)
                {
                    continue;
                }

                if (selected != icon)
                {
                    icon.Hide();
                }

                if (isVanilla)
                {
                    yield return(0.01f);
                }
            }

            Visible = false;
            yield break;
        }
Esempio n. 2
0
        public override IEnumerator Enter(Oui from)
        {
            // Fix "out of bounds" level selection.
            int areaOffs = SaveData.Instance.GetLevelSetStats().AreaOffset;
            int areaMax  = Math.Max(areaOffs, SaveData.Instance.UnlockedAreas);

            area = Calc.Clamp(area, areaOffs, areaMax);

            Visible = true;
            EaseCamera();
            display = true;

            journalEnabled = Celeste.PlayMode == Celeste.PlayModes.Debug || (SaveData.Instance?.CheatMode ?? false);
            for (int i = 0; i <= SaveData.Instance.UnlockedAreas && !journalEnabled; i++)
            {
                if (SaveData.Instance.Areas[i].Modes[0].TimePlayed > 0L && !AreaData.Get(i).Interlude)
                {
                    journalEnabled = true;
                }
            }

            OuiChapterSelectIcon unselected = null;

            if (from is OuiChapterPanel)
            {
                (unselected = icons[area]).Unselect();
            }

            currentLevelSet = SaveData.Instance?.GetLevelSet() ?? "Celeste";
            foreach (OuiChapterSelectIcon icon in icons)
            {
                AreaData area = AreaData.Areas[icon.Area];
                if (area.GetLevelSet() != currentLevelSet)
                {
                    continue;
                }

                int index = area.ToKey().ID;
                if (index <= Math.Max(1, SaveData.Instance.UnlockedAreas) && icon != unselected)
                {
                    icon.Position = icon.HiddenPosition;
                    icon.Show();
                    icon.AssistModeUnlockable = false;
                }
                else if (SaveData.Instance.AssistMode && index == SaveData.Instance.UnlockedAreas + 1)
                {
                    icon.Position = icon.HiddenPosition;
                    icon.Show();
                    icon.AssistModeUnlockable = true;
                }

                // yield return 0.01f; // Originally returns 0.01f
            }

            if (from is OuiChapterPanel)
            {
                yield return(0.25f);
            }
        }
Esempio n. 3
0
        private static void OnChapterPanelReset(On.Celeste.OuiChapterPanel.orig_Reset orig, OuiChapterPanel self)
        {
            resetCrystalHeart(self);

            AreaData forceArea = self.Overworld == null ? null : new DynData <Overworld>(self.Overworld).Get <AreaData>("collabInGameForcedArea");

            if (forceArea == null)
            {
                orig(self);
                customizeCrystalHeart(self);
                return;
            }

            SaveData save    = SaveData.Instance;
            Session  session = save.CurrentSession;

            lastArea = save.LastArea;

            save.LastArea       = forceArea.ToKey();
            save.CurrentSession = null;

            DynData <OuiChapterSelect> ouiChapterSelect = new DynData <OuiChapterSelect>(self.Overworld.GetUI <OuiChapterSelect>());
            OuiChapterSelectIcon       icon             = ouiChapterSelect.Get <List <OuiChapterSelectIcon> >("icons")[save.LastArea.ID];

            icon.SnapToSelected();
            icon.Add(new Coroutine(UpdateIconRoutine(self, icon)));

            orig(self);
            customizeCrystalHeart(self);

            DynData <OuiChapterPanel> data = new DynData <OuiChapterPanel>(self);

            data["hasCollabCredits"] = true;

            if (!isPanelShowingLobby())
            {
                data["chapter"] = (new DynData <Overworld>(self.Overworld).Get <AreaData>("collabInGameForcedArea").Name + "_author").DialogCleanOrNull() ?? "";
            }

            /*
             * (data.modes as IList).Add(
             *  DynamicData.New(t_OuiChapterPanelOption)(new {
             *      Label = "",
             *      BgColor = Calc.HexToColor("223022"),
             *      Icon = GFX.Gui["areas/null"],
             *      Large = false
             *  })
             * );
             */

            // LastArea is also checked in Render.
            save.CurrentSession = session;
        }
Esempio n. 4
0
        private static IEnumerator UpdateIconRoutine(OuiChapterPanel panel, OuiChapterSelectIcon icon)
        {
            Overworld overworld = overworldWrapper?.WrappedScene;

            if (overworld == null)
            {
                yield break;
            }

            while (overworld.Current == panel || overworld.Last == panel || overworld.Next == panel)
            {
                icon.Position = panel.Position + panel.IconOffset;
                yield return(null);
            }
        }
Esempio n. 5
0
        public override void Added(Scene scene)
        {
            orig_Added(scene);

            SaveData save = SaveData.Instance;

            for (int i = icons.Count - 1; i > -1; --i)
            {
                OuiChapterSelectIcon icon = icons[i];
                AreaData             area = AreaData.Get(icon.Area);

                if (!string.IsNullOrEmpty(area?.GetMeta()?.Parent))
                {
                    icons[i].Area = -1;
                    icons[i].Hide();
                    continue;
                }
            }
        }
Esempio n. 6
0
        private IEnumerator EaseOut(Oui next)
        {
            OuiChapterSelectIcon selected = null;

            if (next is OuiChapterPanel)
            {
                (selected = icons[area]).Select();
            }

            foreach (OuiChapterSelectIcon icon in icons)
            {
                if (selected != icon)
                {
                    icon.Hide();
                }
                // yield return 0.01f; // Originally returns 0.01f
            }

            Visible = false;
            yield break;
        }
 public static bool GetIsSelected(this OuiChapterSelectIcon self)
 => ((patch_OuiChapterSelectIcon)self).IsSelected;
Esempio n. 8
0
        // Mods can't access patch_ classes directly.
        // We thus expose any new members through extensions.

        public static bool IsHidden(this OuiChapterSelectIcon self)
        => ((patch_OuiChapterSelectIcon)self).IsHidden;
Esempio n. 9
0
        public override IEnumerator Enter(Oui from)
        {
            // Fix "out of bounds" level selection.
            GetMinMaxArea(out int areaOffs, out int areaMax);
            int areaUnclamp = area;

            area = Calc.Clamp(area, areaOffs, areaMax);

            Visible = true;
            EaseCamera();
            display = true;

            currentLevelSet = SaveData.Instance?.GetLevelSet() ?? "Celeste";

            journalEnabled = string.IsNullOrEmpty(currentLevelSet) || Celeste.PlayMode == Celeste.PlayModes.Debug || (SaveData.Instance?.CheatMode ?? false);
            for (int i = 0; i <= SaveData.Instance.UnlockedAreas && !journalEnabled; i++)
            {
                if (SaveData.Instance.Areas[i].Modes[0].TimePlayed > 0L && !AreaData.Get(i).Interlude)
                {
                    journalEnabled = true;
                }
            }

            OuiChapterSelectIcon unselected = null;

            if (from is OuiChapterPanel)
            {
                (unselected = icons[areaUnclamp]).Unselect();
                if (areaUnclamp != area)
                {
                    unselected.Hide();
                }
            }

            bool isVanilla = currentLevelSet == "Celeste";

            foreach (OuiChapterSelectIcon icon in icons)
            {
                AreaData area = AreaData.Get(icon.Area);
                if (area == null || area.GetLevelSet() != currentLevelSet)
                {
                    continue;
                }

                int index = area.ToKey().ID;
                if ((string.IsNullOrEmpty(currentLevelSet) || index <= Math.Max(1, SaveData.Instance.UnlockedAreas)) &&
                    icon != unselected)
                {
                    icon.Position = icon.HiddenPosition;
                    icon.Show();
                    icon.AssistModeUnlockable = false;
                }
                else if (SaveData.Instance.AssistMode && index == SaveData.Instance.UnlockedAreas + 1)
                {
                    icon.Position = icon.HiddenPosition;
                    icon.Show();
                    icon.AssistModeUnlockable = true;
                }

                if (isVanilla)
                {
                    yield return(0.01f);
                }
            }

            if (from is OuiChapterPanel)
            {
                yield return(0.25f);
            }
        }
        private static IEnumerator onAssistUnlockRoutine(On.Celeste.OuiChapterSelectIcon.orig_AssistModeUnlockRoutine orig, OuiChapterSelectIcon self, Action onComplete)
        {
            IEnumerator origRoutine = orig(self, onComplete);

            while (origRoutine.MoveNext())
            {
                yield return(origRoutine.Current);
            }

            string collab = collabNames.FirstOrDefault(collabName => AreaData.Get(self.Area).GetLevelSet() == $"{collabName}/0-Lobbies");

            if (collab != null)
            {
                // we just assist unlocked the lobbies!
                LevelSetStats stats = SaveData.Instance.GetLevelSetStatsFor($"{collab}/0-Lobbies");
                stats.UnlockedAreas = stats.Areas.Count - 1;
                List <OuiChapterSelectIcon> icons = new DynData <OuiChapterSelect>((self.Scene as Overworld).GetUI <OuiChapterSelect>()).Get <List <OuiChapterSelectIcon> >("icons");
                icons[self.Area + 1].AssistModeUnlockable = false;
                for (int i = self.Area + 2; i <= SaveData.Instance.MaxArea; i++)
                {
                    icons[i].Show();
                }
            }
        }