void BackgroundSelected(object sender, PlayerIndexEventArgs e)
 {
     ObjectSelected = tileSelected;
     LayerSelected = layerSelected;
     backgrounds[tileSelected].isSelected = false;
     color = Color.Red;
     LevelCreate.backgroundChosen = true;
 }
        void TileTypeSelected(object sender, PlayerIndexEventArgs e)
        {
            tileTypes[fileSelected].isSelected = false;
            type = (TileType)fileSelected;
            MenuEntries.Clear();
            switch (type)
            {
                case TileType.Block:
                    for (int i = 0; i < tileReferenceBlocks.Length; i++)
                    {
                        //columns are more easily used when they have 4 tiles in each hence i > 3 to i = 7 below in the first new column...
                        //      that means tiles 4, 5, 6, and 7 will be in that column
                        if (i <= 3)
                        {
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 3 && i <= 7)   //first new column
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 1;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 7 && i <= 11)  //second new column
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 2;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 11 && i<= 15)  //third new column
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 3;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 15 && i <= 19)            //fourth new column
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 4;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 19)                      //fifth new column
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 5;
                            MenuEntries.Add(tiles[i]);
                        }

                    }
                    break;
                case TileType.Scenery:
                    for (int i = 0; i < tileReferenceSceneries.Length; i++)
                    {
                        if (i <= 3)
                        {
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 3 && i <= 7)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 1;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 7 && i <= 11)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 2;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 11 && i <= 15)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 3;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 15 && i <= 19)            //fourth new column
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 4;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 19)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 5;
                            MenuEntries.Add(tiles[i]);
                        }
                    }
                    break;
                case TileType.Slope:
                    for (int i = 0; i < tileReferenceSlopes.Length; i++)
                    {
                        if (i <= 3)
                        {
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 3 && i <= 7)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 1;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 7 && i <= 11)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 2;
                            MenuEntries.Add(tiles[i]);
                        }
                        else if (i > 11)
                        {
                            tiles[i].CreateNewColumn = true;
                            tiles[i].whichNewColumn = 3;
                            MenuEntries.Add(tiles[i]);
                        }

                    }
                    break;
                }

            tileSelection = true;
            isAssigned = false;
        }
        void SaveGameToTextMenuEntrySelected_Unnamed(object sender, PlayerIndexEventArgs e)
        {
            if (KeyboardResult == null && !Guide.IsVisible)
            {
                string title = "Level Name";
                string description = "Name This Level (No Repeat Names)";
                string defaultText = "'Level Name'";

                KeyboardResult = Guide.BeginShowKeyboardInput(PlayerIndex.One, title,
                                                          description, defaultText,
                                                          null, null);

            }
        }
        void LevelCreateMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            GamePlayScreen.storageDevice = storageDevice;
            GamePlayScreen.LevelCreateSession = true;

            LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new LevelCreate(false, String.Empty));
        }
        void LoadTextLevelMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            //for debug
            string listPath = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\LevelLayouts.txt";
            //string listPath = "Content\\LevelLayouts.txt";
            List<string> theList = new List<string>();

            if (File.Exists(listPath))
            {
                using (StreamReader sr = new StreamReader(listPath))
                {
                    while (sr.Peek() > 0)
                    {
                        theList.Add(sr.ReadLine());
                    }

                    sr.Close();
                }
            }

            //add more
            //theList[1] = "'LevelName'";
            ScreenManager.AddScreen(new LoadTextLevelSelection(theList), PlayerIndex.One);

            //LoadingScreen.Load(ScreenManager, false, PlayerIndex.One, new LoadTextLevelSelection(theList));
            //ScreenManager.AddScreen(new LoadTextLevelSelection(theList), PlayerIndex.One);
        }
 void ConfirmQuitMessageBoxAccepted_Invert(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new MainMenuScreen());
 }
 void HelpMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.AddScreen(new HowToCreateScreen(), PlayerIndex.One);
 }
 void OptionsGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
 }
        void PlayTestGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            //for debug
            string path = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\PlayTestInfo.txt";
            //string path = "Content\\PlayTestInfo.txt";
            using (StreamWriter sw = new StreamWriter(path))
            {
                for (int i = 0; i < Tiles.Count; i++)
                {
                    sw.WriteLine(Tiles[i].position.X.ToString() + "," + Tiles[i].position.Y.ToString() + "," + Tiles[i].type.ToString() + "," + Tiles[i].objectNumber.ToString() + "," + Tiles[i].layerNumber.ToString() + ",Tile");
                }
                for (int i = 0; i < Backgrounds.Count; i++)
                {
                    sw.WriteLine(Backgrounds[i].position.X.ToString() + "," + Backgrounds[i].position.Y.ToString() + "," + Backgrounds[i].type.ToString() + "," + Backgrounds[i].objectNumber.ToString() + "," + Backgrounds[i].layerNumber.ToString() + ",Background");
                }
                sw.Close();
            }

            LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new PlayTestScreen(path));
        }
        void ConfirmNameChangeMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            if (KeyboardResult == null && !Guide.IsVisible)
            {
                string title = "Level Name";
                string description = "Name This Level (No Repeat Names)";
                string defaultText = "'Level Name'";

                KeyboardResult = Guide.BeginShowKeyboardInput(PlayerIndex.One, title,
                                                          description, defaultText,
                                                          null, null);

            }
        }
 void ControlsGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.AddScreen(new ControlScreen(), e.PlayerIndex);
 }
 void FileNameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     //nothing
 }
 void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     MenuEntries.RemoveAt(MenuScreen.SelectedEntry);
     LbKStorageLevelCreation.FileNames.RemoveAt(MenuScreen.SelectedEntry);
 }
        void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            MenuEntries.RemoveAt(MenuScreen.SelectedEntry);
            //for debug
            string path = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\" + fileNames[MenuScreen.SelectedEntry] + ".txt";
            string listPath = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\LevelLayouts.txt";
            //string path = "Content\\" + fileNames[MenuScreen.SelectedEntry] + ".txt";
            //string listPath = "Content\\LevelLayouts.txt";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            List<string> levelList = new List<string>();

            if (File.Exists(listPath))
            {
                using (StreamReader sr = new StreamReader(listPath))
                {

                    while (sr.Peek() > 0)
                    {
                        string line = sr.ReadLine();
                        if (line != fileNames[MenuScreen.SelectedEntry])
                        {
                            levelList.Add(line);
                        }

                    }
                    sr.Close();
                }

                File.Delete(listPath);
            }

            using (StreamWriter sw = new StreamWriter(listPath))
            {
                for (int i = 0; i < levelList.Count; i++)
                {
                    sw.WriteLine(levelList[i]);
                }

            }
        }
        void BackgroundTypeSelected(object sender, PlayerIndexEventArgs e)
        {
            backgroundTypes[fileSelected].isSelected = false;
            type = (BackgroundType)fileSelected;
            MenuEntries.Clear();
            switch (type)
            {
                case BackgroundType.Normal:
                    for (int j = 0; j < normalBackgroundReferences.Length; j++)
                    {
                        if (j <= 3)
                        {
                            MenuEntries.Add(backgrounds[j]);
                        }
                        else if (j > 3 && j <= 7)
                        {
                            backgrounds[j].CreateNewColumn = true;
                            backgrounds[j].whichNewColumn = 1;
                            MenuEntries.Add(backgrounds[j]);
                        }
                        else if (j > 7 && j <= 11)
                        {
                            backgrounds[j].CreateNewColumn = true;
                            backgrounds[j].whichNewColumn = 2;
                            MenuEntries.Add(backgrounds[j]);
                        }
                        else if (j > 11)
                        {
                            backgrounds[j].CreateNewColumn = true;
                            backgrounds[j].whichNewColumn = 3;
                            MenuEntries.Add(backgrounds[j]);
                        }

                    }
                    break;
                case BackgroundType.Other:
                    for (int j = 0; j < otherBackgroundReferences.Length; j++)
                    {
                        if (j <= 3)
                        {
                            MenuEntries.Add(backgrounds[j]);
                        }
                        else if (j > 3 && j <= 7)
                        {
                            backgrounds[j].CreateNewColumn = true;
                            backgrounds[j].whichNewColumn = 1;
                            MenuEntries.Add(backgrounds[j]);
                        }
                        else if (j > 7 && j <= 11)
                        {
                            backgrounds[j].CreateNewColumn = true;
                            backgrounds[j].whichNewColumn = 2;
                            MenuEntries.Add(backgrounds[j]);
                        }
                        else if (j > 11)
                        {
                            backgrounds[j].CreateNewColumn = true;
                            backgrounds[j].whichNewColumn = 3;
                            MenuEntries.Add(backgrounds[j]);
                        }

                    }
                    break;
            }

            tileSelection = true;
            isAssigned = false;
        }
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Don't forget to save before exiting session";

            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
 protected void OnCancel(object sender, PlayerIndexEventArgs e)
 {
     OnCancel(e.PlayerIndex);
 }
 void ResumeGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     this.ExitScreen();
 }
 void ExitMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.Game.Exit();
 }
 void ReturnGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LevelCreateSession = true;
     //for debug
     string path = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\PlayTestInfo.txt";
     //string path = "Content\\PlayTestInfo.txt";
     LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new LevelCreate(true, path));
 }
        void InvertTestMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            if (KeyboardResult == null && !Guide.IsVisible)
            {
                string title = "PASSWORD";
                string description = "Enter Password to Enter Debug Session";
                string defaultText = "";

                AsyncCallback callback = new AsyncCallback(ConfirmQuitMessageBoxAccepted_Invert);

                KeyboardResult = Guide.BeginShowKeyboardInput(PlayerIndex.One, title,
                                                          description, defaultText,
                                                          callback, null, true);

            }
        }
        void ReturnToMainMenuSelected(object sender, PlayerIndexEventArgs e)
        {
            LevelCreateSession = false;

            LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new MainMenuScreen());
        }
        void LevelLoadMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            resultCheck = StorageDevice.BeginShowSelector(
                            PlayerIndex.One, null, null);

            gameLoadRequested = true;
        }
        void SaveGameToTextMenuEntrySelected_Named(object sender, PlayerIndexEventArgs e)
        {
            //for debug
            string path = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\" + SavedName + ".txt";
            //string path = "Content\\" + SavedName + ".txt";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            using (StreamWriter sw = new StreamWriter(path))
            {
                for (int i = 0; i < Tiles.Count; i++)
                {                            //0                               //1                                     //2                                          //3               //4
                    sw.WriteLine(Tiles[i].position.X.ToString() + "," + Tiles[i].position.Y.ToString() + "," + Tiles[i].type.ToString() + "," + Tiles[i].objectNumber.ToString() + "," + Tiles[i].layerNumber.ToString() + ",Tile");
                }
                for (int i = 0; i < Backgrounds.Count; i++)
                {
                    sw.WriteLine(Backgrounds[i].position.X.ToString() + "," + Backgrounds[i].position.Y.ToString() + "," + Backgrounds[i].type.ToString() + "," + Backgrounds[i].objectNumber.ToString() + "," + Backgrounds[i].layerNumber.ToString() + ",Background");
                }

                sw.Close();
            }
        }
 void VoidTestMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new VoidTest());
 }
 void TileSelected(object sender, PlayerIndexEventArgs e)
 {
     ObjectSelected = tileSelected;
     LayerSelected = layerSelected;
     tiles[tileSelected].isSelected = false;
     color = Color.Red;
     LevelCreate.tileChosen = true;
 }