diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-01 21:39:06 +0200 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-01 21:39:06 +0200 |
commit | 87b7d9516b8c035790f5292b5be6debc8d1ed701 (patch) | |
tree | e43de7cba9309e7ffe0c52968b18d9dd2acc8cca /td/Assets/Scripts/mainGUI.cs | |
parent | c7d2d5cdb20d42a2014ff99d2fdffae68657e02e (diff) | |
download | TD-87b7d9516b8c035790f5292b5be6debc8d1ed701.tar.gz TD-87b7d9516b8c035790f5292b5be6debc8d1ed701.zip |
Added dev mode, just a console dump
Diffstat (limited to 'td/Assets/Scripts/mainGUI.cs')
-rw-r--r-- | td/Assets/Scripts/mainGUI.cs | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/td/Assets/Scripts/mainGUI.cs b/td/Assets/Scripts/mainGUI.cs index d9f7ee0..d9fb955 100644 --- a/td/Assets/Scripts/mainGUI.cs +++ b/td/Assets/Scripts/mainGUI.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine; @@ -14,6 +15,8 @@ public class mainGUI : MonoBehaviour { Button btnResumeGame; Button btnExitGame; Button btnSettings; + Button btnSettingsDiscard; + Button btnSettingsSave; bool sidebarExpanded; float[] sidebarStates = new float[2] {0f, -202.4f}; // The x position of the sidebar expanded or collapsed @@ -33,12 +36,15 @@ public class mainGUI : MonoBehaviour { btnResumeGame = pnlMenu.transform.Find ("resumeGame").gameObject.GetComponent <Button> (); btnExitGame = pnlMenu.transform.Find ("exitGame").gameObject.GetComponent <Button> (); btnSettings = pnlMenu.transform.Find ("settings").gameObject.GetComponent <Button> (); + btnSettingsDiscard = pnlSettings.transform.Find ("discardChanges").gameObject.GetComponent <Button> (); + btnSettingsSave = pnlSettings.transform.Find ("saveChanges").gameObject.GetComponent <Button> (); if (btnToggleSidebar != null) { btnToggleSidebar.onClick.AddListener (toggleSidebarHandler); } if (btnPauseGame != null) { btnPauseGame.onClick.AddListener (pauseGameHandler); } if (btnResumeGame != null) { btnResumeGame.onClick.AddListener (btnResumeGameHandler); } if (btnExitGame != null) { btnExitGame.onClick.AddListener (btnExitGameHandler); } if (btnSettings != null) { btnSettings.onClick.AddListener (btnSettingsHandler); } - + if (btnSettingsDiscard != null) { btnSettingsDiscard.onClick.AddListener (btnSettingsDiscardHandler); } + if (btnSettingsSave != null) { btnSettingsSave.onClick.AddListener (btnSettingsSaveHandler); } /* Set up initial states */ updateSidebarPosandBtn (); @@ -79,6 +85,24 @@ public class mainGUI : MonoBehaviour { /* handler for btnSettings */ pnlMenu.SetActive (false); pnlSettings.SetActive (true); + + if (PlayerPrefs.HasKey ("developerMode")) { + pnlSettings.transform.Find ("developerEnabled").gameObject.GetComponent <Toggle> ().isOn = intToBool(PlayerPrefs.GetInt ("developerMode")); + } + } + + void btnSettingsSaveHandler() { + /* handler for btnSaveSettings */ + pnlMenu.SetActive (true); + pnlSettings.SetActive (false); + + PlayerPrefs.SetInt ("developerMode", Convert.ToInt32(pnlSettings.transform.Find ("developerEnabled").gameObject.GetComponent <Toggle>().isOn)); + } + + void btnSettingsDiscardHandler() { + /* handler for btnSettingsDiscard */ + pnlMenu.SetActive (true); + pnlSettings.SetActive (false); } void updateSidebarPosandBtn() { @@ -92,4 +116,13 @@ public class mainGUI : MonoBehaviour { } } + bool intToBool(int input) { + /* Converts int to boolean */ + if (input >= 1) { + return true; + } else { + return false; + } + } + } |