Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new hotkey to close the interface #126

Open
wants to merge 1 commit into
base: 1.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RecipeBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal class RecipeBrowser : Mod
//internal static Dictionary<string, LocalizedText> translations; // reference to private field.
internal static Mod itemChecklistInstance;
internal ModKeybind ToggleRecipeBrowserHotKey;
internal ModKeybind CloseRecipeBrowserHotKey;
internal ModKeybind QueryHoveredItemHotKey;
internal ModKeybind ToggleFavoritedPanelHotKey;

Expand Down Expand Up @@ -80,6 +81,7 @@ public override void Load()
{
*/
ToggleRecipeBrowserHotKey = KeybindLoader.RegisterKeybind(this, "ToggleRecipeBrowser", "OemCloseBrackets");
CloseRecipeBrowserHotKey = KeybindLoader.RegisterKeybind(this, "CloseRecipeBrowser", "Esc");
QueryHoveredItemHotKey = KeybindLoader.RegisterKeybind(this, "QueryHoveredItem", "Mouse3");
ToggleFavoritedPanelHotKey = KeybindLoader.RegisterKeybind(this, "ToggleFavoritedRecipesWindow", "F3");
/*
Expand Down Expand Up @@ -118,6 +120,7 @@ public override void Unload()
itemChecklistInstance = null;
LootCache.instance = null;
ToggleRecipeBrowserHotKey = null;
CloseRecipeBrowserHotKey = null;
QueryHoveredItemHotKey = null;
RecipeBrowserUI.instance = null;
RecipeCatalogueUI.instance = null;
Expand Down
12 changes: 12 additions & 0 deletions RecipeBrowserPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ public override void ProcessTriggers(TriggersSet triggersSet)
{
//if (!RecipeBrowser.instance.CheatSheetLoaded)
{
if (RecipeBrowser.instance.CloseRecipeBrowserHotKey.JustPressed)
{
RecipeBrowserUI.instance.ShowRecipeBrowser = false;
// Debug assistance, allows for reinitializing RecipeBrowserUI
//if (!RecipeBrowserUI.instance.ShowRecipeBrowser)
//{
// RecipeBrowserUI.instance.RemoveAllChildren();
// var isInitializedFieldInfo = typeof(Terraria.UI.UIElement).GetField("_isInitialized", BindingFlags.Instance | BindingFlags.NonPublic);
// isInitializedFieldInfo.SetValue(RecipeBrowserUI.instance, false);
// RecipeBrowserUI.instance.Activate();
//}
}
if (RecipeBrowser.instance.ToggleRecipeBrowserHotKey.JustPressed)
{
RecipeBrowserUI.instance.ShowRecipeBrowser = !RecipeBrowserUI.instance.ShowRecipeBrowser;
Expand Down