From 2d8ded52d4a6b9172a3c39be1ceac62342b9bdbe Mon Sep 17 00:00:00 2001 From: Samson Zhang Date: Mon, 1 Sep 2025 22:46:34 +1000 Subject: [PATCH 1/2] Allow Billboard keys to close Billboard --- UIInfoSuite2/ModEntry.cs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/UIInfoSuite2/ModEntry.cs b/UIInfoSuite2/ModEntry.cs index 1061979c..04e6afa2 100644 --- a/UIInfoSuite2/ModEntry.cs +++ b/UIInfoSuite2/ModEntry.cs @@ -173,16 +173,27 @@ private static void HandleCalendarAndQuestKeyBindings(IModHelper helper) { if (_modConfig != null) { - if (Context.IsPlayerFree && _modConfig.OpenCalendarKeybind.JustPressed()) + if (_modConfig.OpenCalendarKeybind.JustPressed()) { - helper.Input.SuppressActiveKeybinds(_modConfig.OpenCalendarKeybind); - Game1.activeClickableMenu = new Billboard(); + if (Game1.activeClickableMenu is Billboard && Game1.activeClickableMenu.readyToClose()) + { + Game1.exitActiveMenu(); + } + else if (Context.IsPlayerFree) + { + Game1.activeClickableMenu = new Billboard(); + } } - else if (Context.IsPlayerFree && _modConfig.OpenQuestBoardKeybind.JustPressed()) + else if (_modConfig.OpenQuestBoardKeybind.JustPressed()) { - helper.Input.SuppressActiveKeybinds(_modConfig.OpenQuestBoardKeybind); - Game1.RefreshQuestOfTheDay(); - Game1.activeClickableMenu = new Billboard(true); + if (Game1.activeClickableMenu is Billboard && Game1.activeClickableMenu.readyToClose()) + { + Game1.exitActiveMenu(); + } + else if (Context.IsPlayerFree) + { + Game1.activeClickableMenu = new Billboard(true); + } } } } From f367d225b3529a527ddb7c601ac324ca52ae5fd8 Mon Sep 17 00:00:00 2001 From: Samson Zhang Date: Tue, 2 Sep 2025 00:09:59 +1000 Subject: [PATCH 2/2] Allow toggle between calendar & questboard --- UIInfoSuite2/ModEntry.cs | 33 ++++++++++++++++--- UIInfoSuite2/UIElements/CustomBillboards.cs | 14 ++++++++ ...howCalendarAndBillboardOnGameMenuButton.cs | 11 +++++-- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 UIInfoSuite2/UIElements/CustomBillboards.cs diff --git a/UIInfoSuite2/ModEntry.cs b/UIInfoSuite2/ModEntry.cs index 04e6afa2..4a88f27e 100644 --- a/UIInfoSuite2/ModEntry.cs +++ b/UIInfoSuite2/ModEntry.cs @@ -8,6 +8,7 @@ using UIInfoSuite2.Compatibility.CustomBush; using UIInfoSuite2.Infrastructure; using UIInfoSuite2.Options; +using UIInfoSuite2.UIElements; namespace UIInfoSuite2; @@ -173,26 +174,50 @@ private static void HandleCalendarAndQuestKeyBindings(IModHelper helper) { if (_modConfig != null) { + var currentMenu = Game1.activeClickableMenu; + if (_modConfig.OpenCalendarKeybind.JustPressed()) { - if (Game1.activeClickableMenu is Billboard && Game1.activeClickableMenu.readyToClose()) + helper.Input.SuppressActiveKeybinds(_modConfig.OpenCalendarKeybind); + + if (currentMenu is QuestBillboard) + { + Game1.exitActiveMenu(); + Game1.delayedActions.Add(new DelayedAction(1, () => // open in the next frame + { + Game1.activeClickableMenu = new CalendarBillboard(); + })); + } + else if (currentMenu is Billboard) // is CalendarBillboard or Billboard(false) { Game1.exitActiveMenu(); } else if (Context.IsPlayerFree) { - Game1.activeClickableMenu = new Billboard(); + Game1.activeClickableMenu = new CalendarBillboard(); } } else if (_modConfig.OpenQuestBoardKeybind.JustPressed()) { - if (Game1.activeClickableMenu is Billboard && Game1.activeClickableMenu.readyToClose()) + helper.Input.SuppressActiveKeybinds(_modConfig.OpenQuestBoardKeybind); + + if (currentMenu is CalendarBillboard) + { + Game1.exitActiveMenu(); + Game1.delayedActions.Add(new DelayedAction(1, () => // open in the next frame + { + Game1.RefreshQuestOfTheDay(); + Game1.activeClickableMenu = new QuestBillboard(); + })); + } + else if (currentMenu is Billboard) // is QuestBillboard or Billboard(true) { Game1.exitActiveMenu(); } else if (Context.IsPlayerFree) { - Game1.activeClickableMenu = new Billboard(true); + Game1.RefreshQuestOfTheDay(); + Game1.activeClickableMenu = new QuestBillboard(); } } } diff --git a/UIInfoSuite2/UIElements/CustomBillboards.cs b/UIInfoSuite2/UIElements/CustomBillboards.cs new file mode 100644 index 00000000..c4272f26 --- /dev/null +++ b/UIInfoSuite2/UIElements/CustomBillboards.cs @@ -0,0 +1,14 @@ +///Seperates Billboard class into two, allowing type check. + +namespace UIInfoSuite2.UIElements +{ + public class CalendarBillboard : StardewValley.Menus.Billboard + { + public CalendarBillboard() : base(false) { } + } + + public class QuestBillboard : StardewValley.Menus.Billboard + { + public QuestBillboard() : base(true) { } + } +} \ No newline at end of file diff --git a/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs b/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs index bf998deb..54838e96 100644 --- a/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs +++ b/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs @@ -144,10 +144,15 @@ private void ActivateBillboard() Game1.questOfTheDay.currentObjective = "wat?"; } - Game1.activeClickableMenu = new Billboard( - !(Utility.ModifyCoordinateForUIScale(Game1.getMouseX()) < + if (Utility.ModifyCoordinateForUIScale(Game1.getMouseX()) < _showBillboardButton.Value.bounds.X + _showBillboardButton.Value.bounds.Width / 2) - ); + { + Game1.activeClickableMenu = new CalendarBillboard(); + } + else + { + Game1.activeClickableMenu = new QuestBillboard(); + } } } #endregion