Exemple #1
0
        // Create new map
        private void createButton_Click(object sender, EventArgs e)
        {
            // Width and height of map
            width  = int.Parse(widthBox.Text);
            height = 6;
            // List of errors
            List <string> errorList = new List <string>();

            // Check which errors exist before opening a new map
            if (width < 10)
            {
                errorList.Add("Width too small. Minimum is 10");
            }
            // Print the errors in a message box
            if (width < 10)
            {
                for (int i = 0; i < errorList.Count; i++)
                {
                    MessageBox.Show(errorList[i]);
                }
            }
            // Open the editor form
            else
            {
                editorForm = new EditorForm(width, height);
                editorForm.ShowDialog();
            }
        }
Exemple #2
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            // Width and height of map
            width  = int.Parse(widthBox.Text);
            height = 6;

            // Variable for file explorer
            openFile        = new OpenFileDialog();
            openFile.Title  = "Open a level file.";
            openFile.Filter = "Level Files|*.txt";
            // Result of file explorer
            DialogResult dialogResult = openFile.ShowDialog();

            // Open new editor form and open map from desired file if user presses OK
            if (dialogResult == DialogResult.OK)
            {
                editorForm = new EditorForm(width, height, openFile.FileName);
                editorForm.ShowDialog();
            }
            // If they press anything else, don't do anything
            else
            {
            }
        }