Skip to content

Commit c0dfc3b

Browse files
committed
v1.6.1 finish implementation of saved status
1 parent 7086e79 commit c0dfc3b

9 files changed

+758
-543
lines changed

OPRPCharBuild/OPRPCharBuild/Add_Achievement.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,28 @@ private void button1_Click(object sender, EventArgs e) {
3535
}
3636
}
3737

38-
public void NewDialog(ref ListBox Main_Form) {
38+
// Adds a new item. Returns true if added, otherwise false
39+
public bool NewDialog(ref ListBox Main_Form) {
3940
this.ShowDialog();
4041
if (button_clicked) {
4142
Main_Form.Items.Add(richTextBox1.Text);
43+
return true;
4244
}
45+
return false;
4346
}
4447

45-
public void EditDialogue(ref ListBox Main_Form, int index) {
48+
// Edits a new item. Returns true if edited, otherwise false
49+
public bool EditDialogue(ref ListBox Main_Form, int index) {
4650
this.Text = "Edit Achievement";
4751
button1.Text = "Edit";
4852
string oldAch = Main_Form.Items[index].ToString();
4953
richTextBox1.Text = oldAch;
5054
this.ShowDialog();
5155
if (button_clicked) {
5256
Main_Form.Items[index] = richTextBox1.Text;
57+
return true;
5358
}
59+
return false;
5460
}
5561

5662
private void richTextBox1_TextChanged(object sender, EventArgs e) {

OPRPCharBuild/OPRPCharBuild/Add_Equipment.cs

+16-10
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,21 @@ private void button1_Click(object sender, EventArgs e) {
4949
}
5050
}
5151

52-
private void Add_ListItem(ref ListView Main_Form) {
52+
// Returns true if item is added
53+
private bool Add_ListItem(ref ListView Main_Form) {
5354
this.ShowDialog();
5455
if (button_clicked) {
5556
ListViewItem item = new ListViewItem();
5657
item.SubItems[0].Text = textBox1.Text; // First column: Name of Weapon/Item
5758
item.SubItems.Add(richTextBox1.Text); // Second column: Description
5859
Main_Form.Items.Add(item);
60+
return true;
5961
}
62+
return false;
6063
}
6164

62-
private void Edit_ListItem(ref ListView Main_Form) {
65+
// Returns true if item is edited
66+
private bool Edit_ListItem(ref ListView Main_Form) {
6367
button1.Text = "Edit";
6468
// Put what we're editing into the Dialog
6569
textBox1.Text = Main_Form.SelectedItems[0].SubItems[0].Text;
@@ -69,27 +73,29 @@ private void Edit_ListItem(ref ListView Main_Form) {
6973
if (button_clicked) {
7074
Main_Form.SelectedItems[0].SubItems[0].Text = textBox1.Text;
7175
Main_Form.SelectedItems[0].SubItems[1].Text = richTextBox1.Text;
76+
return true;
7277
}
78+
return false;
7379
}
7480

75-
public void Add_Weapon(ref ListView Main_Form) {
81+
public bool Add_Weapon(ref ListView Main_Form) {
7682
this.Text = "Add Weapon";
77-
Add_ListItem(ref Main_Form);
83+
return Add_ListItem(ref Main_Form);
7884
}
7985

80-
public void Add_Item(ref ListView Main_Form) {
86+
public bool Add_Item(ref ListView Main_Form) {
8187
this.Text = "Add Item";
82-
Add_ListItem(ref Main_Form);
88+
return Add_ListItem(ref Main_Form);
8389
}
8490

85-
public void Edit_Weapon(ref ListView Main_Form) {
91+
public bool Edit_Weapon(ref ListView Main_Form) {
8692
this.Text = "Edit Weapon";
87-
Edit_ListItem(ref Main_Form);
93+
return Edit_ListItem(ref Main_Form);
8894
}
8995

90-
public void Edit_Item(ref ListView Main_Form) {
96+
public bool Edit_Item(ref ListView Main_Form) {
9197
this.Text = "Edit Item";
92-
Edit_ListItem(ref Main_Form);
98+
return Edit_ListItem(ref Main_Form);
9399
}
94100

95101
private void textBox1_TextChanged(object sender, EventArgs e) {

OPRPCharBuild/OPRPCharBuild/Add_Profession.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ private void button1_Click(object sender, EventArgs e) {
5858
}
5959
}
6060

61-
public void NewDialog(ref DataGridView dgv, ref Dictionary<string, Profession> profDict) {
61+
// Returns true if a new Profession is added
62+
public bool NewDialog(ref DataGridView dgv, ref Dictionary<string, Profession> profDict) {
6263
this.ShowDialog();
6364
if (button_clicked) {
6465
try {
@@ -71,14 +72,17 @@ public void NewDialog(ref DataGridView dgv, ref Dictionary<string, Profession> p
7172
string bool_str = (primary) ? "Primary" : "Secondary";
7273
dgv.Rows.Insert(0, name, textBox_Custom.Text, bool_str,
7374
richTextBox1_Desc.Text, richTextBox2_Primary.Text);
75+
return true;
7476
}
7577
catch (Exception e) {
7678
MessageBox.Show("Can't add the same profession twice.\nReason: " + e.Message, "Exception Thrown");
7779
}
7880
}
81+
return false;
7982
}
8083

81-
public void EditDialog(ref DataGridView dgv, ref Dictionary<string, Profession> profDict) {
84+
// Returns true if a new Profession is edited
85+
public bool EditDialog(ref DataGridView dgv, ref Dictionary<string, Profession> profDict) {
8286
this.Text = "Edit Profession";
8387
button_Add.Text = "Edit";
8488
// Put what's Edited into the Dialog Box first.
@@ -107,6 +111,7 @@ public void EditDialog(ref DataGridView dgv, ref Dictionary<string, Profession>
107111
Profession editProf = new Profession(name, primary, textBox_Custom.Text,
108112
richTextBox1_Desc.Text, richTextBox2_Primary.Text);
109113
profDict.Add(name, editProf);
114+
return true;
110115
}
111116
catch (Exception e) {
112117
profDict.Add(prof_name, sel_prof); // Re-Add
@@ -116,9 +121,9 @@ public void EditDialog(ref DataGridView dgv, ref Dictionary<string, Profession>
116121
dgv.SelectedRows[0].Cells[3].Value = sel_prof.desc;
117122
dgv.SelectedRows[0].Cells[4].Value = sel_prof.bonus;
118123
MessageBox.Show("Can't add the same profession twice.\nReason: " + e.Message, "Exception Thrown");
119-
return;
120124
}
121125
}
126+
return false;
122127
}
123128

124129
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {

OPRPCharBuild/OPRPCharBuild/Add_Technique.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -1147,17 +1147,29 @@ private void button_AddEffect_Click(object sender, EventArgs e) {
11471147
}
11481148
}
11491149

1150-
// Remember this requirement: Secondary Elite Effect is ALWAYS below a General Effect
1151-
// Also remember: EffectList.Remove(key) ONLY
1152-
private void button_EffectRemove_Click(object sender, EventArgs e) {
1150+
// Helper function to delete a ListViewItem
1151+
public string Delete_ListViewItem(ref ListView list) {
1152+
if (list.SelectedItems.Count == 1) {
1153+
string key = list.SelectedItems[0].SubItems[0].Text; // Typically the key value is always the name
1154+
foreach (ListViewItem eachItem in list.SelectedItems) {
1155+
list.Items.Remove(eachItem);
1156+
}
1157+
return key;
1158+
}
1159+
return null;
1160+
}
1161+
1162+
// Remember this requirement: Secondary Elite Effect is ALWAYS below a General Effect
1163+
// Also remember: EffectList.Remove(key) ONLY
1164+
private void button_EffectRemove_Click(object sender, EventArgs e) {
11531165
// "Remove" an Effect
11541166
if (listView_Effects.SelectedIndices.Count > 0) {
11551167
if (listView_Effects.SelectedItems[0].SubItems[0].Text == Database.EFF_SECON) {
11561168
MessageBox.Show("Can't remove a Secondary General Effect cost!\nRemove a General Effect instead.", "Error",
11571169
MessageBoxButtons.OK, MessageBoxIcon.Error);
11581170
return;
11591171
}
1160-
string effect = MainForm.Delete_ListViewItem(ref listView_Effects);
1172+
string effect = Delete_ListViewItem(ref listView_Effects);
11611173
if (!string.IsNullOrWhiteSpace(effect)) {
11621174
// That means we deleted an Effect from the ListView.
11631175
// Now we must 1) Check for General and 2) Remove Effect from Dict.

0 commit comments

Comments
 (0)