示例#1
0
文件: MainForm.cs 项目: dbridle/PoM
        private void NewGame(object sender, EventArgs e)
        {
            using(NewGameForm frm = new NewGameForm())
            {

                if (frm.ShowDialog() == DialogResult.OK)
                {

                    // Check if there is a games folder, if not create it
                    if (!Directory.Exists(Application.StartupPath + @"\Games\" + frm.GameName))
                        Directory.CreateDirectory(Application.StartupPath + @"\Games\" + frm.GameName);

                    // Check if there is a stats folder, if not create it
                    if (!Directory.Exists(Application.StartupPath + @"\Games\" + frm.GameName + @"\stats"))
                        Directory.CreateDirectory(Application.StartupPath + @"\Games\" + frm.GameName + @"\stats");

                    // Check if there is a races folder, if not create it
                    if (!Directory.Exists(Application.StartupPath + @"\Games\" + frm.GameName + @"\races"))
                        Directory.CreateDirectory(Application.StartupPath + @"\Games\" + frm.GameName + @"\races");

                    // Check if there is a classes folder, if not create it
                    if (!Directory.Exists(Application.StartupPath + @"\Games\" + frm.GameName + @"\classes"))
                        Directory.CreateDirectory(Application.StartupPath + @"\Games\" + frm.GameName + @"\classes");

                    // Check if there is a entities folder, if not create it
                    if (!Directory.Exists(Application.StartupPath + @"\Games\" + frm.GameName + @"\entities"))
                         Directory.CreateDirectory(Application.StartupPath + @"\Games\" + frm.GameName + @"\entities");

                    // Check if there is a skills folder, if not create it
                    if (!Directory.Exists(Application.StartupPath + @"\Games\" + frm.GameName + @"\skills"))
                        Directory.CreateDirectory(Application.StartupPath + @"\Games\" + frm.GameName + @"\skills");

                    _game = new RPGGame(frm.GameName, frm.GameDescription);

                    XmlSerializer serializer = new XmlSerializer(typeof(RPGGame));
                    FileStream stream = new FileStream(Application.StartupPath + @"\Games\" + _game.GameName + @"\" + _game.GameName + ".gdf", FileMode.Create);

                    serializer.Serialize(stream, _game);

                    stream.Close();

                    //enable stats menu and button for now since
                    //it's the only one that doesn't have a pre-requisite
                    tbStats.Enabled = true;
                    mnuStats.Enabled = true;

                    mnuClasses.Enabled = false;
                    tbClasses.Enabled = false;

                    mnuRaces.Enabled = false;
                    tbRaces.Enabled = false;

                    mnuEntities.Enabled = false;
                    tbEntities.Enabled = false;

                    mnuSkills.Enabled = false;
                    tbSkills.Enabled = false;
                }
            }
        }
示例#2
0
文件: MainForm.cs 项目: dbridle/PoM
        private void OpenGame(object sender, EventArgs e)
        {
            using (OpenGameForm frm = new OpenGameForm())
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {

                    if (_game == null)
                        _game = new RPGGame();

                    _game.GameName = frm.GameName;
                    _game.Description = frm.GameDescription;

                    this.Text = this.Tag + (" - " + frm.GameName);

                    mnuStats.Enabled = true;
                    tbStats.Enabled = true;

                    bool classesLoaded = false;
                    bool racesLoaded = false;
                    bool statsLoaded = false;

                    // Check the game folder to see what exists and enable buttons

                    if (Directory.GetFiles(Application.StartupPath + @"\Games\" + _game.GameName + @"\stats").Length > 0)
                    {

                        // If stats are there, enable races and classes
                        mnuClasses.Enabled = true;
                        tbClasses.Enabled = true;

                        mnuRaces.Enabled = true;
                        tbRaces.Enabled = true;

                        statsLoaded = true;
                    }
                    else
                    {
                        mnuClasses.Enabled = false;
                        tbClasses.Enabled = false;

                        mnuRaces.Enabled = false;
                        tbRaces.Enabled = false;

                        statsLoaded = false;
                    }

                    if (Directory.GetFiles(Application.StartupPath + @"\Games\" + _game.GameName + @"\races").Length > 0)
                    {
                        mnuRaces.Enabled = true;
                        tbRaces.Enabled = true;

                        racesLoaded = true;
                    }
                    else
                    {

                        racesLoaded = false;
                    }

                    if (Directory.GetFiles(Application.StartupPath + @"\Games\" + _game.GameName + @"\classes").Length > 0)
                    {
                        mnuClasses.Enabled = true;
                        tbClasses.Enabled = true;

                        classesLoaded = true;
                    }
                    else
                    {

                        classesLoaded = false;
                    }

                    if (Directory.GetFiles(Application.StartupPath + @"\Games\" + _game.GameName + @"\entities").Length > 0 ||
                        (classesLoaded && racesLoaded && statsLoaded))
                    {
                        mnuEntities.Enabled = true;
                        tbEntities.Enabled = true;
                    }
                    else
                    {
                    }

                    if (Directory.GetFiles(Application.StartupPath + @"\Games\" + _game.GameName + @"\skills").Length > 0 ||
                        (classesLoaded && racesLoaded && statsLoaded))
                    {
                        mnuSkills.Enabled = true;
                        tbSkills.Enabled = true;
                    }
                    else
                    {
                    }

                }
            }
        }