Can save and load characters and spells.
Signed-off-by: Melissa Avery-Weir <melissa.avery@wellsfargo.com>
This commit is contained in:
@@ -16,6 +16,7 @@ namespace d20_SRD_Spell_Lists {
|
|||||||
private MasterSpellSet spells;
|
private MasterSpellSet spells;
|
||||||
private Character character;
|
private Character character;
|
||||||
private string characterFile;
|
private string characterFile;
|
||||||
|
private bool loadingCharacter;
|
||||||
|
|
||||||
public FrmMain() {
|
public FrmMain() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -23,6 +24,7 @@ namespace d20_SRD_Spell_Lists {
|
|||||||
character = new Character();
|
character = new Character();
|
||||||
spells = new MasterSpellSet();
|
spells = new MasterSpellSet();
|
||||||
spellsDataGridView.AutoGenerateColumns = false;
|
spellsDataGridView.AutoGenerateColumns = false;
|
||||||
|
loadingCharacter = false;
|
||||||
|
|
||||||
setupAttributes();
|
setupAttributes();
|
||||||
setupClassList();
|
setupClassList();
|
||||||
@@ -86,7 +88,9 @@ namespace d20_SRD_Spell_Lists {
|
|||||||
updateClassInformation(classList);
|
updateClassInformation(classList);
|
||||||
updateSpellDCs();
|
updateSpellDCs();
|
||||||
updateExtraSpells();
|
updateExtraSpells();
|
||||||
offerNewSpells();
|
if (!loadingCharacter) {
|
||||||
|
offerNewSpells();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +144,7 @@ namespace d20_SRD_Spell_Lists {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveToolStripButton_Click(object sender, EventArgs e) {
|
private void saveToolStripButton_Click(object sender, EventArgs e) {
|
||||||
if (characterFile != "") {
|
if (characterFile != null && characterFile != "") {
|
||||||
try {
|
try {
|
||||||
saveCharacter();
|
saveCharacter();
|
||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
@@ -184,10 +188,13 @@ namespace d20_SRD_Spell_Lists {
|
|||||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||||
try {
|
try {
|
||||||
characterFile = ofd.FileName;
|
characterFile = ofd.FileName;
|
||||||
|
loadingCharacter = true;
|
||||||
loadCharacter();
|
loadCharacter();
|
||||||
loadValues();
|
loadValues();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
MessageBox.Show("Error: Could not read the character file. Original error: " + ex.Message);
|
MessageBox.Show("Error: Could not read the character file. Original error: " + ex.Message);
|
||||||
|
} finally {
|
||||||
|
loadingCharacter = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,6 +210,7 @@ namespace d20_SRD_Spell_Lists {
|
|||||||
txtCharacter.Text = character.Name;
|
txtCharacter.Text = character.Name;
|
||||||
txtSpellCastingAttribute.Text = character.SpellCastingAttribute.ToString();
|
txtSpellCastingAttribute.Text = character.SpellCastingAttribute.ToString();
|
||||||
charClassComboBox.SelectedItem = Character.getSpellcastingClassName(character.CharacterClass);
|
charClassComboBox.SelectedItem = Character.getSpellcastingClassName(character.CharacterClass);
|
||||||
|
refreshSpellList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnAdd_Click(object sender, EventArgs e) {
|
private void btnAdd_Click(object sender, EventArgs e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user