Skip to content

Commit f5e2820

Browse files
committed
Spore ModAPI Easy Uninstaller: keep window open after uninstallation
1 parent d40a39b commit f5e2820

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

ModAPI Installers/InstalledMods.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ public void Load(XmlDocument document, XmlNode node)
246246

247247
public bool Load(string path)
248248
{
249+
ModConfigurations.Clear();
250+
249251
if (File.Exists(path))
250252
{
251253

Spore ModAPI Easy Uninstaller/EasyUninstaller.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ static void Main()
4848

4949
Mods = new InstalledMods();
5050
Mods.Load();
51-
52-
foreach (ModConfiguration mod in Mods.ModConfigurations)
53-
{
54-
Form.AddMod(mod);
55-
}
56-
57-
Form.SortMods();
51+
ReloadMods();
5852

5953
Application.Run(Form);
6054
}
6155
}
6256

57+
public static void ReloadMods()
58+
{
59+
Mods.Load();
60+
Form.AddMods(Mods.ModConfigurations);
61+
}
62+
6363
public static void UninstallMods(Dictionary<ModConfiguration, bool> mods)
6464
{
6565
List<ModConfiguration> successfulMods = new List<ModConfiguration>();
@@ -95,6 +95,9 @@ public static void UninstallMods(Dictionary<ModConfiguration, bool> mods)
9595
{
9696
Mods.Save();
9797

98+
// reload before we show the message box
99+
EasyUninstaller.ReloadMods();
100+
98101
var sb = new StringBuilder();
99102
foreach (ModConfiguration mod in successfulMods)
100103
{
@@ -212,10 +215,7 @@ public static void ExecuteConfigurator(ModConfiguration mod, bool uninstall)
212215
string args = "\"" + mod.Name + "\"" + " true " + uninstall.ToString();
213216
//MessageBox.Show(path + "\n\n" + args, "process information");
214217
var process = Process.Start(path, args);
215-
if (uninstall)
216-
{
217-
process.WaitForExit();
218-
}
218+
process.WaitForExit();
219219
}
220220
else
221221
{

Spore ModAPI Easy Uninstaller/UninstallerForm.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,29 @@ public UninstallerForm()
3434
this.BringToFront();
3535
}
3636

37-
public void AddMod(ModConfiguration mod)
37+
public void AddMods(HashSet<ModConfiguration> mods)
3838
{
39-
int index = this.dataGridView1.Rows.Add(new object[] { false, mod, mod.DisplayName });
39+
// clear rows
40+
while (this.dataGridView1.RowCount > 1)
41+
{
42+
this.dataGridView1.Rows.RemoveAt(1);
43+
}
4044

41-
if (GetConfiguratorPath(index) != null)
42-
this.dataGridView1.Rows[index].Cells[3].ReadOnly = true;
43-
}
45+
// add mods
46+
foreach (var mod in mods)
47+
{
4448

45-
public void SortMods()
46-
{
49+
int index = this.dataGridView1.Rows.Add(new object[] { false, mod, mod.DisplayName });
50+
51+
if (GetConfiguratorPath(index) != null)
52+
this.dataGridView1.Rows[index].Cells[3].ReadOnly = true;
53+
}
54+
55+
// sort mods
4756
this.dataGridView1.Sort(new ModRowComparer());
57+
58+
// reset header state
59+
dataGridView_CellValueChanged(this, new DataGridViewCellEventArgs(0, 1));
4860
}
4961

5062
private void btnCancel_Click(object sender, EventArgs e)
@@ -134,7 +146,6 @@ private void btnUninstall_Click(object sender, EventArgs e)
134146
if (result == DialogResult.Yes)
135147
{
136148
EasyUninstaller.UninstallMods(list);
137-
this.Close();
138149
}
139150
}
140151
}
@@ -210,8 +221,10 @@ private void ExecuteConfigurator(ModConfiguration mod)
210221
{
211222
try
212223
{
224+
this.Hide();
213225
EasyUninstaller.ExecuteConfigurator(mod, false);
214-
this.Close();
226+
EasyUninstaller.ReloadMods();
227+
this.Show();
215228
}
216229
catch (Exception ex)
217230
{

0 commit comments

Comments
 (0)