void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbName.Text) || string.IsNullOrEmpty(tbDescription.Text)) { MessageBox.Show("You must enter a name and a description.", "Error"); return; } rpg = new RolePlayingGame(tbName.Text, tbDescription.Text); this.Close(); }
private void OpenGame(string path) { gamePath = Path.Combine(path, "Game"); classPath = Path.Combine(gamePath, "Classes"); itemPath = Path.Combine(gamePath, "Items"); keyPath = Path.Combine(gamePath, "Keys"); chestPath = Path.Combine(gamePath, "Chests"); skillPath = Path.Combine(gamePath, "Skills"); if (!Directory.Exists(keyPath)) { Directory.CreateDirectory(keyPath); } if (!Directory.Exists(chestPath)) { Directory.CreateDirectory(chestPath); } if (!Directory.Exists(skillPath)) { Directory.CreateDirectory(skillPath); } rolePlayingGame = XnaSerializer.Deserialize<RolePlayingGame>( gamePath + @"\Game.xml"); FormDetails.ReadEntityData(); FormDetails.ReadItemData(); FormDetails.ReadKeyData(); FormDetails.ReadChestData(); FormDetails.ReadSkillData(); PrepareForms(); }
private void OpenGame(string path) { gamePath = Path.Combine(path + "\\Game"); classPath = Path.Combine(path + "\\Game\\Classes"); itemPath = Path.Combine(path + "\\Game\\Items"); rpg = XnaSerializer.Deserialize<RolePlayingGame>(gamePath + @"\Game.xml"); FormDetails.ReadEntityData(); FormDetails.ReadItemData(); PrepareForms(); }
void newGameToolStripMenuItem_Click(object sender, EventArgs e) { using (FormNewGame frmNewGame = new FormNewGame()) { DialogResult result = frmNewGame.ShowDialog(); if (result == DialogResult.OK && frmNewGame.RolePlayingGame != null) { FolderBrowserDialog folderDialog = new FolderBrowserDialog(); folderDialog.Description = "Select folder to create game in."; folderDialog.SelectedPath = Application.StartupPath; DialogResult folderResult = folderDialog.ShowDialog(); if (folderResult == DialogResult.OK) { try { gamePath = Path.Combine(folderDialog.SelectedPath, "Game"); classPath = Path.Combine(gamePath, "Classes"); itemPath = Path.Combine(gamePath, "Items"); keyPath = Path.Combine(gamePath, "Keys"); chestPath = Path.Combine(gamePath, "Chests"); skillPath = Path.Combine(gamePath, "Skills"); if (Directory.Exists(gamePath)) throw new Exception("Selected directory already exists."); Directory.CreateDirectory(gamePath); Directory.CreateDirectory(classPath); Directory.CreateDirectory(itemPath + @"\Armor"); Directory.CreateDirectory(itemPath + @"\Shield"); Directory.CreateDirectory(itemPath + @"\Weapon"); Directory.CreateDirectory(keyPath); Directory.CreateDirectory(chestPath); Directory.CreateDirectory(skillPath); rolePlayingGame = frmNewGame.RolePlayingGame; XnaSerializer.Serialize<RolePlayingGame>(gamePath + @"\Game.xml", rolePlayingGame); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } classesToolStripMenuItem.Enabled = true; itemsToolStripMenuItem.Enabled = true; keysToolStripMenuItem.Enabled = true; chestsToolStripMenuItem.Enabled = true; skillsToolStripMenuItem.Enabled = true; } } } }
public void newGameMenu_Click(object sender, EventArgs e) { using (NewGame newGame = new NewGame()) { DialogResult result = newGame.ShowDialog(); if (result == DialogResult.OK && newGame.RolePlayingGame != null) { FolderBrowserDialog folderdDialog = new FolderBrowserDialog(); folderdDialog.Description = "Select folder for your new game"; folderdDialog.SelectedPath = Application.StartupPath; DialogResult folderResult = folderdDialog.ShowDialog(); if (folderResult == DialogResult.OK) { try { gamePath = Path.Combine(folderdDialog.SelectedPath, "Game"); classPath = Path.Combine(gamePath, "Classes"); itemPath = Path.Combine(gamePath, "Items"); if (Directory.Exists(gamePath)) { throw new Exception("Selected directory already exists"); } Directory.CreateDirectory(gamePath); Directory.CreateDirectory(classPath); Directory.CreateDirectory(itemPath + @"\Armor"); Directory.CreateDirectory(itemPath + @"\Weapon"); Directory.CreateDirectory(itemPath + @"\Shield"); rpg = newGame.RolePlayingGame; XnaSerializer.Serialize<RolePlayingGame>(gamePath + @"\Game.xml", rpg); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } classToolMenu.Enabled = true; itemMenu.Enabled = true; } } } }