Ui-Info-Suite/SDVModTest/UIElements/SkipIntro.cs

64 lines
2.2 KiB
C#
Raw Permalink Normal View History

2018-12-25 12:36:39 +08:00
using StardewModdingAPI;
2017-07-20 11:51:05 +08:00
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Menus;
using System;
namespace UIInfoSuite.UIElements
{
class SkipIntro
{
2018-12-25 12:36:39 +08:00
private readonly IModEvents _events;
2017-07-20 11:51:05 +08:00
//private bool _skipIntro = false;
2018-12-25 12:36:39 +08:00
public SkipIntro(IModEvents events)
2017-07-20 11:51:05 +08:00
{
2018-12-25 12:36:39 +08:00
_events = events;
2017-07-20 11:51:05 +08:00
//GameEvents.QuarterSecondTick += CheckForSkip;
2018-12-25 12:36:39 +08:00
events.Input.ButtonPressed += OnButtonPressed;
events.GameLoop.SaveLoaded += OnSaveLoaded;
2017-07-20 11:51:05 +08:00
//MenuEvents.MenuChanged += SkipToTitleButtons;
}
2018-12-25 12:36:39 +08:00
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, EventArgs e)
2017-07-20 11:51:05 +08:00
{
2018-12-25 12:36:39 +08:00
// stop checking for skip key
_events.Input.ButtonPressed -= OnButtonPressed;
_events.GameLoop.SaveLoaded -= OnSaveLoaded;
2017-07-20 11:51:05 +08:00
}
2018-12-25 12:36:39 +08:00
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
2017-07-20 11:51:05 +08:00
{
2018-12-25 12:36:39 +08:00
if (Game1.activeClickableMenu is TitleMenu menu && e.Button == SButton.Escape)
2017-07-20 11:51:05 +08:00
{
2018-12-25 12:36:39 +08:00
menu.skipToTitleButtons();
_events.Input.ButtonPressed -= OnButtonPressed;
2017-07-20 11:51:05 +08:00
}
}
//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;
//}
}
}