示例#1
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string   input = File.ReadAllText(openFileDialog.FileName);
                string[] lines = input.Split(new char[] { '\n' });

                Console.WriteLine(lines[0]);

                if (lines[0] != "DSKP")
                {
                    MessageBox.Show("Wybrano nieodpowiedni plik!", "Błąd!");
                }
                else if (lines[1] == "PC")
                {
                    string name  = lines[2];
                    int    level = Convert.ToInt32(lines[3]);

                    Dictionary <string, int> tempstats      = new Dictionary <string, int>();
                    Dictionary <string, int> tempknowledege = new Dictionary <string, int>();
                    Dictionary <string, int> tempsenses     = new Dictionary <string, int>();


                    for (int i = 4; i < 10; i++)
                    {
                        string[] temp = lines[i].Split(new char[] { ' ' });
                        tempstats.Add(temp[0], Convert.ToInt32(temp[1]));
                    }

                    for (int i = 10; i < 16; i++)
                    {
                        string[] temp = lines[i].Split(new char[] { ' ' });
                        tempknowledege.Add(temp[0], Convert.ToInt32(temp[1]));
                    }

                    for (int i = 16; i < 21; i++)
                    {
                        string[] temp = lines[i].Split(new char[] { ' ' });
                        tempsenses.Add(temp[0], Convert.ToInt32(temp[1]));
                    }

                    FormPC2 formPC2 = new FormPC2(tempstats, tempknowledege, tempsenses, level, name);
                    formPC2.Show();
                    this.Hide();
                }
                else if (lines[1] == "NPC")
                {
                    string name  = lines[2];
                    int    level = Convert.ToInt32(lines[3]);

                    Dictionary <string, int> tempstats = new Dictionary <string, int>();
                }
            }
        }
示例#2
0
        private void confirmButton_Click(object sender, EventArgs e)
        {
            bool completed = true;

            foreach (var x in this.Controls.OfType <ComboBox>())
            {
                if (x.SelectedIndex == -1)
                {
                    completed = false;
                    break;
                }
            }

            if (completed == true)
            {
                foreach (var x in this.Controls.OfType <TextBox>())
                {
                    if (x.Text.Trim() == "")
                    {
                        completed = false;
                        break;
                    }
                }

                if (completed == true)
                {
                    string       message = "Program przystąpi teraz do generacji karty przy użyciu wprowadzonych danych. Ich zmiana nie będzie później możliwa. Kontynuować?";
                    string       label   = "Generacja Karty";
                    DialogResult result  = MessageBox.Show(message, label, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (result == DialogResult.Yes)
                    {
                        setOrder();
                        string nameRaceClass = nameTextBox.Text + ", " + raceTextBox.Text + " " + classTextBox.Text;

                        FormPC2 formPC2 = new FormPC2(stats1, knowledge1, senses1, nameRaceClass, false);
                        formPC2.Show();
                        this.Close();
                    }
                    if (result == DialogResult.No)
                    {
                        stats1.Clear();
                        senses1.Clear();
                        knowledge1.Clear();
                    }
                }
                else
                {
                    string message = "W Edytorze pozostały puste pola! Wypełnij je aby kontynuować.";
                    string label   = "Błąd!";

                    MessageBox.Show(message, label, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }