Skip to content

Commit

Permalink
Added a toggle for the menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
lilSander committed Nov 9, 2023
1 parent 37c93fc commit b5719eb
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 57 deletions.
7 changes: 3 additions & 4 deletions Assets/SEE/Controls/KeyBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public static string ShowBindings()
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (var binding in bindings)
{
sb.Append($"Key {binding.Key}:\n {binding.Value}\n");
sb.Append("\n");
sb.Append($"Key {binding.Key}:\n {binding.Value}\n\n");
}
return sb.ToString();
}
Expand Down Expand Up @@ -117,9 +116,9 @@ public static string ShowBindings()
internal static readonly KeyCode ToggleMenu = Register(KeyCode.Space, Scope.Always, "Turns on/off the player-action menu.");

/// <summary>
/// Turns on the settings menu.
/// Turns on/off the settings menu.
/// </summary>
internal static readonly KeyCode ActivateSettings = Register(KeyCode.Escape, Scope.Always, "Turns on the settings menu.");
internal static readonly KeyCode ToggleSettings = Register(KeyCode.Escape, Scope.Always, "Turns on/off the settings menu.");

/// <summary>
/// Turns on/off the browser.
Expand Down
6 changes: 3 additions & 3 deletions Assets/SEE/Controls/SEEInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public static bool ToggleMenu()
}

/// <summary>
/// Turns on the settings menu.
/// Turns on/off the settings menu.
/// </summary>
/// <returns>true if the user requests this action and <see cref="KeyboardShortcutsEnabled"/></returns>
public static bool ActivateSettings()
public static bool ToggleSettings()
{
return KeyboardShortcutsEnabled && Input.GetKeyDown(KeyBindings.ActivateSettings);
return KeyboardShortcutsEnabled && Input.GetKeyDown(KeyBindings.ToggleSettings);
}

/// <summary>
Expand Down
66 changes: 66 additions & 0 deletions Assets/SEE/Controls/SettingsMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

namespace SEE.Controls
{
/// <summary>
/// Handles the actions in the
/// settings canvas.
/// </summary>
public class SettingsMenue : MonoBehaviour
{
/// <summary>
/// The text box, which will display the text.
/// </summary>
public TMP_Text keybindingsText;

/// <summary>
/// The settings panel which will be toggled.
/// </summary>
public GameObject settingsPanel;

/// <summary>
/// The keybindings panel which will be toggled.
/// </summary>
public GameObject keybindingsPanel;

/// <summary>
/// Start is called before the first frame update.
/// Sets the text of the textbox.
/// </summary>
void Start()
{
keybindingsText.text = KeyBindings.ShowBindings();
}

/// <summary>
/// Update is called once per frame.
/// Activates the settings panel with the esc button.
/// </summary>
void Update()
{
if (keybindingsPanel.activeSelf == true && settingsPanel.activeSelf == false && SEEInput.ToggleSettings())
{
keybindingsPanel.SetActive(false);
}
else if (SEEInput.ToggleSettings())
{
settingsPanel.SetActive(!settingsPanel.activeSelf);
}
}

/// <summary>
/// When this method is called, the application will be terminated.
/// </summary>
public void ExitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
}
File renamed without changes.
47 changes: 0 additions & 47 deletions Assets/SEE/Controls/SettingsMenue.cs

This file was deleted.

8 changes: 5 additions & 3 deletions Assets/Scenes/SEEWorld.unity
Original file line number Diff line number Diff line change
Expand Up @@ -21344,7 +21344,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
keybindingsText: {fileID: 1474148082}
settings: {fileID: 1806861827}
settingsPanel: {fileID: 1806861827}
keybindingsPanel: {fileID: 1896622442}
--- !u!114 &1429832262
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -25778,7 +25779,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
keybindingsText: {fileID: 0}
settings: {fileID: 0}
settingsPanel: {fileID: 0}
keybindingsPanel: {fileID: 0}
--- !u!1001 &1767985078
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -36407,7 +36409,7 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1896622442}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
Expand Down

0 comments on commit b5719eb

Please sign in to comment.