예제 #1
0
 private void OkButtonClick(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(NameBox.Text) || string.IsNullOrEmpty(DescriptionBox.Text))
     {
         MessageBox.Show("Name and/or Description cannot be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     RolePlayingGame = new RolePlayingGame(NameBox.Text, DescriptionBox.Text);
     Close();
 }
예제 #2
0
        private void OpenGame(string path)
        {
            _gamePath = path;
            _rpg = Serializer.Deserialize<RolePlayingGame>(GameFilePath);

            SetTitle(_rpg.Name);
            StatusLabel.Text = _gamePath;

            if (!Directory.Exists(ClassPath))
                Directory.CreateDirectory(ClassPath);

            if (!Directory.Exists(ArmorPath))
                Directory.CreateDirectory(ArmorPath);

            if (!Directory.Exists(ShieldPath))
                Directory.CreateDirectory(ShieldPath);

            if (!Directory.Exists(WeaponPath))
                Directory.CreateDirectory(WeaponPath);

            if (!Directory.Exists(KeyPath))
                Directory.CreateDirectory(KeyPath);

            if (!Directory.Exists(ContainerPath))
                Directory.CreateDirectory(ContainerPath);

            if (!Directory.Exists(SkillPath))
                Directory.CreateDirectory(SkillPath);

            FormDetails.ReadEntityData();
            FormDetails.ReadItemData();
            FormDetails.ReadKeyData();
            FormDetails.ReadContainerData();
            FormDetails.ReadSkillData();
            PrepareForms();
        }
예제 #3
0
        private void NewGameMenuItemClick(object sender, EventArgs e)
        {
            using (var newGameForm = new FormNewGame())
            {
                DialogResult result = newGameForm.ShowDialog();
                if (result != DialogResult.OK || newGameForm.RolePlayingGame == null)
                    return;

                var folderBrowser = new FolderBrowserDialog
                {
                    Description = "Select folder to create game in.",
                    SelectedPath = Application.StartupPath
                };

                result = folderBrowser.ShowDialog();

                if (result != DialogResult.OK)
                    return;

                try
                {
                    _rpg = newGameForm.RolePlayingGame;

                    _gamePath = Path.Combine(folderBrowser.SelectedPath, GameFolder);

                    if (Directory.Exists(_gamePath))
                    {
                        MessageBox.Show("Target directory already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    Directory.CreateDirectory(_gamePath);
                    Directory.CreateDirectory(ClassPath);
                    Directory.CreateDirectory(ArmorPath);
                    Directory.CreateDirectory(ShieldPath);
                    Directory.CreateDirectory(WeaponPath);
                    Directory.CreateDirectory(KeyPath);
                    Directory.CreateDirectory(ContainerPath);
                    Directory.CreateDirectory(SkillPath);

                    Serializer.Serialize(_rpg, GameFilePath);

                    ExportMenuItem.Enabled = true;
                    ClassesMenuItem.Enabled = true;
                    ItemsMenuItem.Enabled = true;
                    KeysMenuItem.Enabled = true;
                    ContainersMenuItem.Enabled = true;

                    SetTitle(_rpg.Name);
                    StatusBar.Text = _gamePath;
                }
                catch (IOException ex)
                {
                    MessageBox.Show(
                        "IO operation failed when creating game files. IOException thrown with message: " + ex.Message +
                        "\n\nStack Trace:\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }