Skip to content

Commit

Permalink
Focus the identifier we got in the modlist
Browse files Browse the repository at this point in the history
  • Loading branch information
Postremus committed Sep 27, 2015
1 parent 1dbe741 commit 3ecfdf3
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions GUI/Main.cs
Expand Up @@ -344,18 +344,8 @@ protected override void OnLoad(EventArgs e)

int i = 0;
log.Debug("Attempting to select mod from startup parameters");
foreach (DataGridViewRow row in ModList.Rows)
{
var module = ((GUIMod) row.Tag);
if (identifier == module.Identifier)
{
ModList.FirstDisplayedScrollingRowIndex = i;
row.Selected = true;
break;
}

i++;
}
FocusMod(identifier, true, true);
ModList.Refresh();
log.Debug("Failed to select mod from startup parameters");
}

Expand Down Expand Up @@ -1020,7 +1010,7 @@ private void DependsGraphTree_NodeMouseDoubleClick(object sender, TreeNodeMouseC
FocusMod(e.Node.Name, true);
}

private void FocusMod(string key, bool exactMatch)
private void FocusMod(string key, bool exactMatch, bool showAsFirst=false)
{
DataGridViewRow current_row = ModList.CurrentRow;
int currentIndex = current_row != null ? current_row.Index : 0;
Expand All @@ -1032,12 +1022,13 @@ private void FocusMod(string key, bool exactMatch)
bool row_match = false;
if (exactMatch)
{
row_match = mod.Name == key;
row_match = mod.Name == key || mod.Identifier == key;
}
else
{
row_match = mod.Name.StartsWith(key, StringComparison.OrdinalIgnoreCase) ||
mod.Abbrevation.StartsWith(key, StringComparison.OrdinalIgnoreCase);
mod.Abbrevation.StartsWith(key, StringComparison.OrdinalIgnoreCase) ||
mod.Identifier.StartsWith(key, StringComparison.OrdinalIgnoreCase);
}
if (row_match && first_match == null)
{
Expand Down Expand Up @@ -1065,6 +1056,8 @@ private void FocusMod(string key, bool exactMatch)
// Setting this to the Name cell prevents the checkbox from being toggled
// by pressing Space while the row is not indicated as active
ModList.CurrentCell = match.Cells[2];
if (showAsFirst)
ModList.FirstDisplayedScrollingRowIndex = match.Index;
}
else
{
Expand Down

0 comments on commit 3ecfdf3

Please sign in to comment.