Example #1
0
        private void RegisterContinueButton()
        {
            On.RoR2.UI.MainMenu.MainMenuController.Start += (orig, self) => {
                var singlePlayerButton = GameObject.Find("GenericMenuButton (Singleplayer)");
                var continueButton     = Instantiate(singlePlayerButton, singlePlayerButton.transform.parent);
                ProperSave.continueButton = new WeakReference <GameObject>(continueButton);
                continueButton.name       = "[PS] Continue";
                continueButton.transform.SetSiblingIndex(1);

                var buttonComponent = continueButton.GetComponent <HGButton>();
                buttonComponent.hoverToken = LanguageConsts.PS_TITLE_CONTINUE_DESC;

                var languageComponent = continueButton.GetComponent <LanguageTextMeshController>();
                languageComponent.token = LanguageConsts.PS_TITLE_CONTINUE;

                buttonComponent.onClick = new UnityEngine.UI.Button.ButtonClickedEvent();
                buttonComponent.onClick.AddListener(() =>
                {
                    RoR2.Console.instance.SubmitCmd(null, "ps_load");
                });
                buttonComponent.interactable = File.Exists(GetSavePath());

                orig(self);
            };

            On.RoR2.UI.MainMenu.ProfileMainMenuScreen.SetMainProfile += (orig, self, profile) =>
            {
                orig(self, profile);
                if (continueButton.TryGetTarget(out var button))
                {
                    button.GetComponent <HGButton>().interactable = File.Exists(GetSavePath());
                }
            };
        }