diff options
Diffstat (limited to 'Valheim_v202102/Valheim/assembly_valheim/Menu.cs')
-rw-r--r-- | Valheim_v202102/Valheim/assembly_valheim/Menu.cs | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/Valheim_v202102/Valheim/assembly_valheim/Menu.cs b/Valheim_v202102/Valheim/assembly_valheim/Menu.cs new file mode 100644 index 0000000..0ab76a7 --- /dev/null +++ b/Valheim_v202102/Valheim/assembly_valheim/Menu.cs @@ -0,0 +1,131 @@ +using UnityEngine; + +public class Menu : MonoBehaviour +{ + private GameObject m_settingsInstance; + + private static Menu m_instance; + + public Transform m_root; + + public Transform m_menuDialog; + + public Transform m_quitDialog; + + public Transform m_logoutDialog; + + public GameObject m_settingsPrefab; + + public GameObject m_feedbackPrefab; + + private int m_hiddenFrames; + + public static Menu instance => m_instance; + + private void Start() + { + m_instance = this; + m_root.gameObject.SetActive(value: false); + } + + public static bool IsVisible() + { + if (m_instance == null) + { + return false; + } + return m_instance.m_hiddenFrames <= 2; + } + + private void Update() + { + if (Game.instance.IsLoggingOut()) + { + m_root.gameObject.SetActive(value: false); + return; + } + if (m_root.gameObject.activeSelf) + { + m_hiddenFrames = 0; + if ((Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")) && !m_settingsInstance && !Feedback.IsVisible()) + { + if (m_quitDialog.gameObject.activeSelf) + { + OnQuitNo(); + } + else if (m_logoutDialog.gameObject.activeSelf) + { + OnLogoutNo(); + } + else + { + m_root.gameObject.SetActive(value: false); + } + } + return; + } + m_hiddenFrames++; + bool flag = !InventoryGui.IsVisible() && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible(); + if ((Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")) && flag) + { + GoogleAnalyticsV4.instance.LogEvent("Screen", "Enter", "Menu", 0L); + m_root.gameObject.SetActive(value: true); + m_menuDialog.gameObject.SetActive(value: true); + m_logoutDialog.gameObject.SetActive(value: false); + m_quitDialog.gameObject.SetActive(value: false); + } + } + + public void OnSettings() + { + GoogleAnalyticsV4.instance.LogEvent("Screen", "Enter", "Settings", 0L); + m_settingsInstance = Object.Instantiate(m_settingsPrefab, base.transform); + } + + public void OnQuit() + { + m_quitDialog.gameObject.SetActive(value: true); + m_menuDialog.gameObject.SetActive(value: false); + } + + public void OnQuitYes() + { + GoogleAnalyticsV4.instance.LogEvent("Game", "Quit", "", 0L); + Application.Quit(); + } + + public void OnQuitNo() + { + m_quitDialog.gameObject.SetActive(value: false); + m_menuDialog.gameObject.SetActive(value: true); + } + + public void OnLogout() + { + m_menuDialog.gameObject.SetActive(value: false); + m_logoutDialog.gameObject.SetActive(value: true); + } + + public void OnLogoutYes() + { + GoogleAnalyticsV4.instance.LogEvent("Game", "LogOut", "", 0L); + Game.instance.Logout(); + } + + public void OnLogoutNo() + { + m_logoutDialog.gameObject.SetActive(value: false); + m_menuDialog.gameObject.SetActive(value: true); + } + + public void OnClose() + { + GoogleAnalyticsV4.instance.LogEvent("Screen", "Exit", "Menu", 0L); + m_root.gameObject.SetActive(value: false); + } + + public void OnButtonFeedback() + { + Object.Instantiate(m_feedbackPrefab, base.transform); + } +} |