Skip to content

Commit

Permalink
Fix name
Browse files Browse the repository at this point in the history
  • Loading branch information
slikts committed Jun 2, 2015
1 parent 1fba3ab commit 5701a6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions GUI/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class Configuration
public bool CheckForUpdatesOnLaunchNoNag = false;

// Sort by the mod name (index = 2) column by default
public int sortByColumnIndex = 2;
public bool sortDescending = false;
public int SortByColumnIndex = 2;
public bool SortDescending = false;

private string m_Path = "";
private Point m_window_loc = new Point(0,0);
Expand Down
7 changes: 3 additions & 4 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,12 @@ private void OnFilterUpdateTimer(Object source, EventArgs e)
private void ModList_HeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
var new_sort_column = this.ModList.Columns[e.ColumnIndex];
var current_sort_column = this.ModList.Columns[this.m_Configuration.sortByColumnIndex];
var current_sort_column = this.ModList.Columns[this.m_Configuration.SortByColumnIndex];
// Reverse the sort order if the current sorting column is clicked again
this.m_Configuration.sortDescending = new_sort_column == current_sort_column ? !this.m_Configuration.sortDescending : false;
this.m_Configuration.SortDescending = new_sort_column == current_sort_column ? !this.m_Configuration.SortDescending : false;
// Reset the glyph
current_sort_column.HeaderCell.SortGlyphDirection = SortOrder.None;
this.m_Configuration.sortByColumnIndex = new_sort_column.Index;
this.m_Configuration.Save();
this.m_Configuration.SortByColumnIndex = new_sort_column.Index;
this.UpdateFilters(this);
}

Expand Down
10 changes: 5 additions & 5 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ private IEnumerable<DataGridViewRow> _SortRowsByColumn(IEnumerable<DataGridViewR
Func<DataGridViewRow, string> sort_fn;

// XXX: There should be a better way to identify checkbox columns than hardcoding their indices here
if (this.m_Configuration.sortByColumnIndex < 2)
if (this.m_Configuration.SortByColumnIndex < 2)
{
sort_fn = new Func<DataGridViewRow, string>(row => {
var cell = row.Cells[this.m_Configuration.sortByColumnIndex];
var cell = row.Cells[this.m_Configuration.SortByColumnIndex];
if (cell.ValueType == typeof(bool)) {
return (bool)cell.Value ? "a" : "b";
}
Expand All @@ -33,12 +33,12 @@ private IEnumerable<DataGridViewRow> _SortRowsByColumn(IEnumerable<DataGridViewR
}
else
{
sort_fn = new Func<DataGridViewRow, string>(row => row.Cells[this.m_Configuration.sortByColumnIndex].Value.ToString());
sort_fn = new Func<DataGridViewRow, string>(row => row.Cells[this.m_Configuration.SortByColumnIndex].Value.ToString());
}
// Update the column sort glyph
this.ModList.Columns[this.m_Configuration.sortByColumnIndex].HeaderCell.SortGlyphDirection = this.m_Configuration.sortDescending ? SortOrder.Descending : SortOrder.Ascending;
this.ModList.Columns[this.m_Configuration.SortByColumnIndex].HeaderCell.SortGlyphDirection = this.m_Configuration.SortDescending ? SortOrder.Descending : SortOrder.Ascending;
// The columns will be sorted by mod name in addition to whatever the current sorting column is
if (this.m_Configuration.sortDescending)
if (this.m_Configuration.SortDescending)
{
return rows.OrderByDescending(sort_fn).ThenBy(get_row_mod_name);
}
Expand Down

0 comments on commit 5701a6c

Please sign in to comment.