feat: removed the esc key menu toggle, replaced it with a pause menu option

This commit is contained in:
FreezeDriedMangoes 2022-05-14 09:55:57 -04:00
parent 695586c79d
commit 49e6e4503d
2 changed files with 22 additions and 3 deletions

View File

@ -40,9 +40,24 @@ namespace NewHorizons.Utility
_dpp = this.GetRequiredComponent<DebugPropPlacer>(); _dpp = this.GetRequiredComponent<DebugPropPlacer>();
_drc = this.GetRequiredComponent<DebugRaycaster>(); _drc = this.GetRequiredComponent<DebugRaycaster>();
Main.Instance.ModHelper.Menus.PauseMenu.OnInit += PauseMenuInitHook;
Main.Instance.ModHelper.Menus.PauseMenu.OnClosed += CloseMenu;
LoadFavoriteProps(); LoadFavoriteProps();
} }
private void PauseMenuInitHook()
{
InitMenu();
var editorButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate("Open Prop Placer Menu".ToUpper());
editorButton.OnClick += ToggleMenu;
}
private void ToggleMenu() { menuOpen = !menuOpen; }
private void CloseMenu() { menuOpen = false; }
private void LoadFavoriteProps() private void LoadFavoriteProps()
{ {
string favoritePropsPlayerPref = PlayerPrefs.GetString(favoritePropsPlayerPrefKey); string favoritePropsPlayerPref = PlayerPrefs.GetString(favoritePropsPlayerPrefKey);
@ -61,11 +76,11 @@ namespace NewHorizons.Utility
{ {
if (!Main.Debug) return; if (!Main.Debug) return;
if (Keyboard.current[Key.Escape].wasPressedThisFrame) /*if (Keyboard.current[Key.Escape].wasPressedThisFrame)
{ {
menuOpen = !menuOpen; menuOpen = !menuOpen;
if (menuOpen) InitMenu(); if (menuOpen) InitMenu();
} }*/
} }
private void OnGUI() private void OnGUI()
@ -137,6 +152,7 @@ namespace NewHorizons.Utility
if (GUILayout.Button(mod.ModHelper.Manifest.UniqueName)) if (GUILayout.Button(mod.ModHelper.Manifest.UniqueName))
{ {
loadedMod = mod; loadedMod = mod;
_dpp.active = true;
propsHaveBeenLoaded = true; propsHaveBeenLoaded = true;
var folder = loadedMod.ModHelper.Manifest.ModFolderPath; var folder = loadedMod.ModHelper.Manifest.ModFolderPath;

View File

@ -43,6 +43,8 @@ namespace NewHorizons.Utility
public HashSet<string> RecentlyPlacedProps = new HashSet<string>(); public HashSet<string> RecentlyPlacedProps = new HashSet<string>();
public bool active = false;
private void Awake() private void Awake()
{ {
_rc = this.GetRequiredComponent<DebugRaycaster>(); _rc = this.GetRequiredComponent<DebugRaycaster>();
@ -52,8 +54,9 @@ namespace NewHorizons.Utility
private void Update() private void Update()
{ {
if (!Main.Debug) return; if (!Main.Debug) return;
if (!active) return;
if (Keyboard.current[Key.Q].wasReleasedThisFrame) if (Keyboard.current[Key.X].wasReleasedThisFrame)
{ {
PlaceObject(); PlaceObject();
} }