Skip to content

Commit fc39bad

Browse files
committed
Spore ModAPI Easy Uninstaller: sort mods by name
1 parent edd521f commit fc39bad

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

Spore ModAPI Easy Uninstaller/EasyUninstaller.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ static void Main()
5454
Form.AddMod(mod);
5555
}
5656

57+
Form.SortMods();
58+
5759
Application.Run(Form);
5860
}
5961
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows.Forms;
7+
8+
namespace Spore_ModAPI_Easy_Uninstaller
9+
{
10+
public class ModRowComparer : System.Collections.IComparer
11+
{
12+
public int Compare(object x, object y)
13+
{
14+
string modName1 = ((DataGridViewRow)x).Cells[2].Value.ToString();
15+
string modName2 = ((DataGridViewRow)y).Cells[2].Value.ToString();
16+
17+
if (modName1 == Strings.InstalledMods)
18+
{
19+
return -1;
20+
}
21+
else if (modName2 == Strings.InstalledMods)
22+
{
23+
return 1;
24+
}
25+
26+
return String.Compare(modName1, modName2);
27+
}
28+
}
29+
}

Spore ModAPI Easy Uninstaller/Spore ModAPI Easy Uninstaller.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
</ItemGroup>
5050
<ItemGroup>
5151
<Compile Include="..\VersionInfo\AssemblyVersionInfo.cs" />
52+
<Compile Include="ModRowComparer.cs" />
5253
<Compile Include="Strings.es.Designer.cs">
5354
<DependentUpon>Strings.es.resx</DependentUpon>
5455
<AutoGen>True</AutoGen>

Spore ModAPI Easy Uninstaller/UninstallerForm.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Data;
53
using System.Drawing;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
94
using System.Windows.Forms;
105

116
using ModAPI_Installers;
@@ -21,13 +16,11 @@ public UninstallerForm()
2116
InitializeComponent();
2217

2318
// create header row
24-
2519
this.dataGridView1.Rows.Add(new object[] { false, "Installed Mods" });
2620
this.dataGridView1.Rows[0].DefaultCellStyle.ApplyStyle(dataGridView1.ColumnHeadersDefaultCellStyle);
2721
this.dataGridView1.Rows[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
2822
this.dataGridView1.Rows[0].Cells[2].Value = Strings.InstalledMods;
2923
this.dataGridView1.Columns[1].Visible = false;
30-
3124

3225
this.dataGridView1.CellDoubleClick += dataGridView_CellDoubleClick;
3326
this.dataGridView1.CellContentClick += dataGridView_CellContentClick;
@@ -37,7 +30,6 @@ public UninstallerForm()
3730
this.btnCancel.Text = Strings.Cancel;
3831
this.btnUninstall.Text = Strings.UninstallSelected + " (0)";
3932
this.btnUninstall.Enabled = false;
40-
//this.btnUninstall.Text = "asd";
4133
this.label2.Text = "Spore ModAPI Launcher Kit Version " + ModApi.UpdateManager.UpdateManager.CurrentVersion.ToString() + "\nDLLs Build " + ModApi.UpdateManager.UpdateManager.CurrentDllsBuild;
4234
this.BringToFront();
4335
}
@@ -50,6 +42,11 @@ public void AddMod(ModConfiguration mod)
5042
this.dataGridView1.Rows[index].Cells[3].ReadOnly = true;
5143
}
5244

45+
public void SortMods()
46+
{
47+
this.dataGridView1.Sort(new ModRowComparer());
48+
}
49+
5350
private void btnCancel_Click(object sender, EventArgs e)
5451
{
5552
this.Close();

0 commit comments

Comments
 (0)