using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; using StardewValley.Menus; using System; namespace UIInfoSuite.UIElements { class SkipIntro { private readonly IModEvents _events; //private bool _skipIntro = false; public SkipIntro(IModEvents events) { _events = events; //GameEvents.QuarterSecondTick += CheckForSkip; events.Input.ButtonPressed += OnButtonPressed; events.GameLoop.SaveLoaded += OnSaveLoaded; //MenuEvents.MenuChanged += SkipToTitleButtons; } /// Raised after the player loads a save slot and the world is initialised. /// The event sender. /// The event arguments. private void OnSaveLoaded(object sender, EventArgs e) { // stop checking for skip key _events.Input.ButtonPressed -= OnButtonPressed; _events.GameLoop.SaveLoaded -= OnSaveLoaded; } /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. /// The event arguments. private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (Game1.activeClickableMenu is TitleMenu menu && e.Button == SButton.Escape) { menu.skipToTitleButtons(); _events.Input.ButtonPressed -= OnButtonPressed; } } //private void CheckForSkip(object sender, EventArgs e) //{ // if (Game1.activeClickableMenu is TitleMenu && // _skipIntro) // { // _skipIntro = false; // (Game1.activeClickableMenu as TitleMenu)?.skipToTitleButtons(); // } //} //private void SkipToTitleButtons(object sender, EventArgsClickableMenuChanged e) //{ // TitleMenu menu = e.NewMenu as TitleMenu; // menu?.skipToTitleButtons(); // //MenuEvents.MenuChanged -= SkipToTitleButtons; //} } }