Esempio n. 1
0
        public void HookProcessSwitch(On.ProcessManager.orig_SwitchMainProcess orig, ProcessManager instance, ProcessManager.ProcessID id)
        {
            if (instance.currentMainLoop != null)
            {
                if (instance.currentMainLoop.ID == ProcessManager.ProcessID.Game)
                {
                    Debug.Log("Switching off of game");

                    if (playerObject != null)
                    {
                        playerObject.Destroy();
                    }
                }
            }

            orig(instance, id);

            if (id == ProcessManager.ProcessID.SlugcatSelect)
            {
                currentMenu = (instance.currentMainLoop as SlugcatSelectMenu);
                newCharacterMenuContainer = new MenuContainer(currentMenu, currentMenu.pages[0], Vector2.zero);
                CreateMenu();
                currentMenu.pages[0].subObjects.Add(newCharacterMenuContainer);
                newCharacterMenuContainer.menu = currentMenu;
                UpdateMenu();
            }
            else if (isMenuInitialized)
            {
                DestroyMenu();
            }
        }
Esempio n. 2
0
 public void HookSingal(On.Menu.SlugcatSelectMenu.orig_Singal original, SlugcatSelectMenu instance, MenuObject sender, string message)
 {
     if (message != null)
     {
         if (message == "CHARACTERDOWN")
         {
             currentScrollIndex--;
         }
         else if (message == "CHARACTERUP")
         {
             currentScrollIndex++;
         }
         else if (message[0] == 'C')
         {
             SelectedPlayer(int.Parse(message[1].ToString()));
         }
         else if (message == "START")
         {
             original(instance, sender, message);
             customArtSprite.isVisible = false;
         }
         else
         {
             original(instance, sender, message);
         }
     }
     else
     {
         original(instance, sender, message);
     }
 }
Esempio n. 3
0
        internal static void SlugcatSelectMenu_StartGame(On.Menu.SlugcatSelectMenu.orig_StartGame orig, SlugcatSelectMenu self, int storyGameCharacter)
        {
            orig(self, storyGameCharacter);
            // Bugfix to prevent crazy inconsistency that could happen if played restarted a save they just starved on
            // (vanilla would call 'Wipe' and still load the starve which is clearly a bug)

            if (self.manager.menuSetup.startGameCondition == ProcessManager.MenuSetup.StoryGameInitCondition.New)
            {
                self.manager.rainWorld.progression.starvedSaveState = null;
            }
        }
Esempio n. 4
0
        // Automatically override intro cutscenes
        private static void SlugcatSelectMenu_StartGame(On.Menu.SlugcatSelectMenu.orig_StartGame orig, SlugcatSelectMenu self, int storyGameCharacter)
        {
            orig(self, storyGameCharacter);

            if (!self.restartChecked && self.manager.rainWorld.progression.IsThereASavedGame(storyGameCharacter))
            {
                return;
            }

            // Only continue to the slideshow if this character has an intro slideshow
            SlugBaseCharacter ply = PlayerManager.GetCustomPlayer(storyGameCharacter);

            if (ply == null)
            {
                return;
            }
            if (ply.HasSlideshow("Intro") && !Input.GetKey("s"))
            {
                OverrideNextSlideshow(ply, "Intro");
                self.manager.upcomingProcess = null;
                self.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.SlideShow);
            }
            else
            {
                self.manager.upcomingProcess = null;
                self.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.Game);
            }
        }
        private static void SlugcatSelectMenu_ctor(On.Menu.SlugcatSelectMenu.orig_ctor orig, SlugcatSelectMenu self, ProcessManager manager)
        {
            orig(self, manager);

            int saveSlot = self.manager.rainWorld.options.saveSlot;

            if (CustomWorldMod.saveProblems[saveSlot].AnyProblems)
            {
                bool   allNewGame = true;
                string errorText  = CustomWorldMod.Translate("Problems found in your save, " +
                                                             "please check the tab SaveAnalyzer in the config screen for more information.");
                for (int m = 0; m < self.slugcatPages.Length; m++)
                {
                    if (self.saveGameData[m] != null)
                    {
                        allNewGame = false;
                        break;
                    }
                }
                if (allNewGame)
                {
                    errorText = CustomWorldMod.Translate("Problems found in your save, please use the Reset Progress button in the RW options menu");
                }

                MenuLabel menuLabel = new MenuLabel(self, self.pages[0],
                                                    errorText,
                                                    new Vector2(self.manager.rainWorld.options.ScreenSize.x * 0.5f, self.manager.rainWorld.options.ScreenSize.y * 0.85f),
                                                    new Vector2(0, 0), false);

                menuLabel.label.color     = new Color((108f / 255f), 0.001f, 0.001f);
                menuLabel.label.alignment = FLabelAlignment.Center;

                self.pages[0].subObjects.Add(menuLabel);
            }
            if (CustomWorldMod.missingDependencies.Count > 0)
            {
                string errorText = CustomWorldMod.Translate($"You have missing dependencies, please reinstall the following packs: " +
                                                            $"[{string.Join(", ", CustomWorldMod.missingDependencies.Keys.ToArray())}]");

                MenuLabel menuLabel = new MenuLabel(self, self.pages[0],
                                                    errorText,
                                                    new Vector2(self.manager.rainWorld.options.ScreenSize.x * 0.5f, self.manager.rainWorld.options.ScreenSize.y * 0.95f),
                                                    new Vector2(0, 0), true);

                menuLabel.label.color     = new Color((108f / 255f), 0.001f, 0.001f);
                menuLabel.label.alignment = FLabelAlignment.Center;

                self.pages[0].subObjects.Add(menuLabel);

                // Second line

                MenuLabel menuLabel2 = new MenuLabel(self, self.pages[0],
                                                     $"Missing dependencies: [{string.Join(", ", CustomWorldMod.missingDependencies.Values.SelectMany(i => i).Distinct().ToArray())}]",
                                                     new Vector2(self.manager.rainWorld.options.ScreenSize.x * 0.5f, self.manager.rainWorld.options.ScreenSize.y * 0.91f),
                                                     new Vector2(0, 0), false);

                menuLabel2.label.color     = new Color((108f / 255f), 0.001f, 0.001f);
                menuLabel2.label.alignment = FLabelAlignment.Center;

                self.pages[0].subObjects.Add(menuLabel2);
            }
        }
        private static void SlugcatSelectMenu_ctor(On.Menu.SlugcatSelectMenu.orig_ctor orig, SlugcatSelectMenu self, ProcessManager manager)
        {
            orig(self, manager);

            int saveSlot = self.manager.rainWorld.options.saveSlot;

            if (CustomWorldMod.saveProblems[saveSlot].AnyProblems)
            {
                bool   allNewGame = true;
                string errorText  = CustomWorldMod.Translate("Problems found in your save, please check the tab SaveAnalyzer in the config screen for more information.");
                for (int m = 0; m < self.slugcatPages.Length; m++)
                {
                    if (self.saveGameData[m] != null)
                    {
                        allNewGame = false;
                        break;
                    }
                }
                if (allNewGame)
                {
                    errorText = CustomWorldMod.Translate("Problems found in your save, please use the Reset Progress button in the RW options menu");
                }

                MenuLabel menuLabel = new MenuLabel(self, self.pages[0],
                                                    errorText,
                                                    new Vector2(self.manager.rainWorld.options.ScreenSize.x * 0.5f, self.manager.rainWorld.options.ScreenSize.y * 0.85f),
                                                    new Vector2(0, 0), false);

                menuLabel.label.color     = new Color((108f / 255f), 0.001f, 0.001f);
                menuLabel.label.alignment = FLabelAlignment.Center;

                self.pages[0].subObjects.Add(menuLabel);
            }
        }
Esempio n. 7
0
        // The original took a slugcat index as an input, indexed into slugcatColorOrder, and returned the save game at that slot
        // slugcatColorOrder is a list of slugcat indices, indexed by page number
        // Indexing into this list is not guaranteed to return the correct output, but it works for the vanilla slugcats
        private static SlugcatSelectMenu.SaveGameData SlugcatSelectMenu_GetSaveGameData(On.Menu.SlugcatSelectMenu.orig_GetSaveGameData orig, SlugcatSelectMenu self, int slugcatColor)
        {
            int i = Array.IndexOf(self.slugcatColorOrder, slugcatColor);

            if (i < 0 || i >= self.saveGameData.Length)
            {
                return(null);
            }
            return(self.saveGameData[i]);
        }
Esempio n. 8
0
 // Stop GetSaveGameData from inlining
 private static void SlugcatSelectMenu_UpdateStartButtonText(On.Menu.SlugcatSelectMenu.orig_UpdateStartButtonText orig, SlugcatSelectMenu self)
 {
     self.startButton.fillTime = (!self.restartChecked) ? 40f : 120f;
     if (self.saveGameData[self.slugcatPageIndex] == null || self.restartChecked)
     {
         self.startButton.menuLabel.text = self.Translate("NEW GAME");
     }
     else if (self.slugcatPages[self.slugcatPageIndex].slugcatNumber == 2 && self.redIsDead)
     {
         self.startButton.menuLabel.text = self.Translate("STATISTICS");
     }
     else
     {
         self.startButton.menuLabel.text = self.Translate("CONTINUE");
     }
 }
Esempio n. 9
0
        // Add custom slugcat select screens
        private static void SlugcatSelectMenu_ctor(On.Menu.SlugcatSelectMenu.orig_ctor orig, Menu.SlugcatSelectMenu self, ProcessManager manager)
        {
            int selectedSlugcat = manager.rainWorld.progression.miscProgressionData.currentlySelectedSinglePlayerSlugcat;

            orig(self, manager);

            List <SlugBaseCharacter> plys = PlayerManager.customPlayers;
            int origLength = self.slugcatColorOrder.Length;

            // Add all SlugBase characters to the select screen
            // All other player mods should change this array, so we have a nice lower bound for indices we can take

            // Find the next available slugcat index, skipping Nightcat
            int firstCustomIndex = 4;

            // Take color order into account
            for (int i = 0; i < self.slugcatColorOrder.Length; i++)
            {
                firstCustomIndex = Math.Max(self.slugcatColorOrder[i] + 1, firstCustomIndex);
            }

            // Take slugcat names into account
            foreach (SlugcatStats.Name name in Enum.GetValues(typeof(SlugcatStats.Name)))
            {
                firstCustomIndex = Math.Max((int)name + 1, firstCustomIndex);
            }

            int nextCustomIndex = firstCustomIndex;

            // Add SlugBase characters to the page order and assign empty slots a default value
            Array.Resize(ref self.slugcatColorOrder, origLength + plys.Count);
            for (int i = origLength; i < self.slugcatColorOrder.Length; i++)
            {
                self.slugcatColorOrder[i] = -1;
            }

            for (int i = 0; i < plys.Count; i++)
            {
                // Assign each player a unique index, then save it to the page order
                // This will cause weird behavior if the user skips over the title screen using EDT, so... don't do that
                self.slugcatColorOrder[origLength + i] = nextCustomIndex;
                plys[i].slugcatIndex = nextCustomIndex++;
            }

            // Retrieve save data
            Array.Resize(ref self.saveGameData, origLength + plys.Count);

            for (int i = 0; i < plys.Count; i++)
            {
                self.saveGameData[origLength + i] = SlugcatSelectMenu.MineForSaveData(self.manager, plys[i].slugcatIndex);
            }

            // Add a new page to the menu
            Array.Resize(ref self.slugcatPages, origLength + plys.Count);

            for (int i = 0; i < plys.Count; i++)
            {
                int o = origLength + i;
                if (self.saveGameData[o] != null)
                {
                    self.slugcatPages[o] = new SlugcatSelectMenu.SlugcatPageContinue(self, null, o + 1, self.slugcatColorOrder[o]);
                }
                else
                {
                    self.slugcatPages[o] = new SlugcatSelectMenu.SlugcatPageNewGame(self, null, o + 1, self.slugcatColorOrder[o]);
                }

                // Select the correct page
                if (selectedSlugcat == self.slugcatColorOrder[o])
                {
                    self.slugcatPageIndex = o;
                }

                self.pages.Add(self.slugcatPages[o]);

                // Make sure the start button reflects the changed slugcat index
                self.UpdateStartButtonText();
                self.UpdateSelectedSlugcatInMiscProg();
            }
        }
Esempio n. 10
0
 private static void SlugMenuCtorPatch(On.Menu.SlugcatSelectMenu.orig_ctor orig, SlugcatSelectMenu self, ProcessManager manager)
 {
     orig.Invoke(self, manager);
     foreach (OptionInterface oi in OptionScript.loadedInterfaces)
     {
         oi.GenerateDataArray(self.slugcatColorOrder.Length);
     }
     LoadAndSaveOI(0, true);
 }