protected void InitEditorBar() { EditorBar = new InfoBar(UI.GetInterface(Name)); EditorBar.Size = new Vector2(6000, EditorBar.Size.Y); EditorBar.AddElement("File", SupportedInfoBarElement.Button); EditorBar[0].HoverButtonList.Add("New Map"); EditorBar[0].HoverButtonList.Add("Load Map"); EditorBar[0].HoverButtonList.Add("Save Map"); EditorBar.AddElement("Edit", SupportedInfoBarElement.Button); EditorBar[1].HoverButtonList.Add("Undo"); EditorBar[1].HoverButtonList.Add("Redo"); EditorBar.AddElement("Window", SupportedInfoBarElement.Button); EditorBar[2].HoverButtonList.Add("Tile Selector"); EditorBar[2].HoverButtonList.Add("Toolbar"); EditorBar.AddElement("Start Game", SupportedInfoBarElement.Button); //EditorBar function EditorBar[0].HoverButtonList[0].Clicked += (sender) => { GameStateManager.TransitionState(GameStateManager.NewMapPrefs); }; EditorBar[0].HoverButtonList[1].Clicked += (sender) => { Map.Clear(); Map.Load(); }; EditorBar[0].HoverButtonList[2].Clicked += (sender) => { MultiThreading.StartThread("Thread_Saver"); }; EditorBar[1].HoverButtonList[0].Clicked += (sender) => { EventHandler.Undo(); }; EditorBar[1].HoverButtonList[1].Clicked += (sender) => { EventHandler.Redo(); }; EditorBar[2].HoverButtonList[0].Clicked += (sender) => { CurrentTileBar.Open(new Vector2(200, Game1.ScreenHeight - 125)); TileSelect.Open(new Vector2(0, 21)); }; EditorBar[2].HoverButtonList[1].Clicked += (sender) => { ToolBar.Open(new Vector2(Game1.ScreenWidth - ToolBar.Size.X, 21)); }; EditorBar[3].Clicked += (sender) => { Map.SaveAndReLoad(); Map.CurrentBrush.SetBrush(new BrushTool(Map.Settings.AccessibleTiles.PlaceholderTile, 1)); Game1.Cam.Zoom = 1; GameStateManager.TransitionState(GameStateManager.Playing); }; }
public InfoPanel(InfoBar info_bar) { this.info_bar = info_bar; }
//Prepare player to run\\ void Start() { //If debugMode is on at start, tell us (incase we're looking at performance, and forgot about debugMode if(debugMode == true) UnityEngine.Debug.Log ("Debug Mode is on"); //Check if the first part of the OS name is "Unix" (Mac OS is a Unix-based system) if(Environment.OSVersion.ToString().Substring (0, 4) == "Unix") { //Set path to the predefined location for UMP music files on Macintosh-based OS path = mac; onMac = true; //If debugMode is on, tell us that the user is running a Macintosh-based Operating System if(debugMode == true) UnityEngine.Debug.Log ("Player Running on Macintosh OS"); } else { //Set path to the predefined location for UMP music files on a Windows-based OS path = windows; onMac = false; //If debugMode is on, tell us that the user is running a Windows-based Operating System if(debugMode == true) UnityEngine.Debug.Log ("Player Running on Windows OS"); } publicPath = path; //Find & assign infoBar and audioVisualizer infoBar = GameObject.FindGameObjectWithTag("InfoBar").GetComponent<InfoBar>(); //Assign mediaPath to the correct directory mediaPath = path + Path.DirectorySeparatorChar + "Media"; //Assign prefsLocation to the correct directory prefsLocation = path + Path.DirectorySeparatorChar + "Preferences.ump"; //Get the current directory (so we know where to save the new version if an update is avaliable) appLocation = Environment.CurrentDirectory; //Check if the directories exist //NOTE: We only need to check mediaPath because if mediaPath exists, so does path if(!Directory.Exists (mediaPath)) { //If debugMode is on, tell us that the directories do not exist if(debugMode == true) UnityEngine.Debug.Log ("Directories Do Not Exist"); //Show the X image to alert the user that something is wrong filesExistImage.texture = x; //Tell the user that they need to create the directories for UMP to work filesExistText.text = "The requried directories do not exist!\nTo create them, click 'Create Directories'"; //Set the boolean filesExist to false and the array clipList to null filesExist = false; clipList = null; } else { //Set the boolean filesExist to true filesExist = true; //Get the all the files ending in .WAV in path & assign them to the array clipList clipList = Directory.GetFiles(mediaPath, "*.wav"); //Get the number of songs currently playiable and send that to infoBar infoBar.songCount = clipList.Length; //If debugMode is on, display how many songs are playable if(debugMode == true) UnityEngine.Debug.Log (clipList.Length + " songs are playable"); } //If the Preferences file exists set the preferences accordingly if(File.Exists (prefsLocation)) { //Bring all the text from our file into memory string[] prefs = File.ReadAllLines(prefsLocation); //Set loop, shuffle, and the volume to what it was last loop = Convert.ToBoolean(prefs[0]); shuffle = Convert.ToBoolean(prefs[1]); continuous = Convert.ToBoolean(prefs[2]); volumeBarValue = Convert.ToSingle(prefs[3]); previousSongs[0] = Convert.ToInt32(prefs[4]); if(previousSongs[0] > clipList.Length) previousSongs[0] = clipList.Length; previousSongs[1] = Convert.ToInt32(prefs[5]); if(previousSongs[1] > clipList.Length) previousSongs[1] = clipList.Length; previousSongs[2] = Convert.ToInt32(prefs[6]); if(previousSongs[2] > clipList.Length) previousSongs[2] = clipList.Length; previousSongs[3] = Convert.ToInt32(prefs[7]); if(previousSongs[3] > clipList.Length) previousSongs[3] = clipList.Length; previousSongs[4] = Convert.ToInt32(prefs[8]); if(previousSongs[4] > clipList.Length) previousSongs[4] = clipList.Length; previousSongs[5] = Convert.ToInt32(prefs[9]); if(previousSongs[5] > clipList.Length) previousSongs[5] = clipList.Length; previousSongs[6] = Convert.ToInt32(prefs[10]); if(previousSongs[6] > clipList.Length) previousSongs[6] = clipList.Length; TextWriter savePrefs = new StreamWriter(prefsLocation); savePrefs.WriteLine(loop + "\n" + shuffle + "\n" + continuous + "\n" + volumeBarValue + "\n" + previousSongs[0] + "\n" + previousSongs[1] + "\n" + previousSongs[2] + "\n" + previousSongs[3] + "\n" + previousSongs[4] + "\n" + previousSongs[5] + "\n" + previousSongs[6]); savePrefs.Close(); //If the Preferences file does not exist, create it } else if(filesExist == true){ //Create the file using (FileStream createPrefs = File.Create(prefsLocation)) { //Make a byte array and fill it with the values for loop, shuffle, volume, and empty values for the previous sogns. Byte[] preferences = new UTF8Encoding(true).GetBytes(loop + "\n" + shuffle + "\n" + continuous + "\n" + volumeBarValue + "\n 0 \n 0 \n 0 \n 0 \n 0 \n 0 \n 0"); //Write to our new file createPrefs.Write(preferences, 0, preferences.Length); createPrefs.Close(); } } InvokeRepeating("CheckMediaPath", 0, 2); }