Change auto-select of puzzle to work when earlier level puzzles are not done. Only select it when it is going to be shown.

This commit is contained in:
Tim Young 2017-06-19 13:02:55 -05:00
parent 0eceb5e3e3
commit 64ff7a72ed

View File

@ -228,20 +228,24 @@ namespace EduNetworkBuilder
List<string> Puzzles = NB.GetPuzzleNames(); List<string> Puzzles = NB.GetPuzzleNames();
NBSettings oursettings = NB.GetSettings(); NBSettings oursettings = NB.GetSettings();
if (Puzzles == null) return; if (Puzzles == null) return;
bool wasfinished = false;
foreach (string str in Puzzles) foreach (string str in Puzzles)
{ {
wasfinished = false;
if (FilterString == "") if (FilterString == "")
{ {
pi = NB.GetPuzzleInfoFromName(str); pi = NB.GetPuzzleInfoFromName(str);
shown_name = pi.PuzzleName; shown_name = pi.PuzzleName;
if (oursettings.ScoreList.Contains(str)) if (oursettings.ScoreList.Contains(str))
{
shown_name = "* " + shown_name; shown_name = "* " + shown_name;
else if (selected == "") wasfinished = true;
selected = shown_name; //Select the first unfinished puzzle }
foreach (string tag in pi.PuzzleTags) foreach (string tag in pi.PuzzleTags)
{ {
if (isChecked(tag)) if (isChecked(tag))
{ {
if(selected == "" && !wasfinished) selected = shown_name; //Select the first unfinished puzzle
lbWindowData.Items.Add(shown_name); lbWindowData.Items.Add(shown_name);
break; break;
} }
@ -254,9 +258,10 @@ namespace EduNetworkBuilder
bool added = false; bool added = false;
string localFilter = ".*" + FilterString + ".*"; string localFilter = ".*" + FilterString + ".*";
if (oursettings.ScoreList.Contains(str)) if (oursettings.ScoreList.Contains(str))
{
shown_name = "* " + shown_name; shown_name = "* " + shown_name;
else if (selected == "") wasfinished = true;
selected = shown_name; //Select the first unfinished puzzle }
if (!added && pi.PuzzleName != null && Regex.IsMatch(pi.PuzzleName, localFilter, RegexOptions.IgnoreCase)) if (!added && pi.PuzzleName != null && Regex.IsMatch(pi.PuzzleName, localFilter, RegexOptions.IgnoreCase))
{ {
added = true; added = true;
@ -276,6 +281,7 @@ namespace EduNetworkBuilder
{ {
if (!added && pi.PuzzleTitle != null && Regex.IsMatch(tag, localFilter, RegexOptions.IgnoreCase)) if (!added && pi.PuzzleTitle != null && Regex.IsMatch(tag, localFilter, RegexOptions.IgnoreCase))
{ {
if (selected == "" && !wasfinished) selected = shown_name; //Select the first unfinished puzzle
lbWindowData.Items.Add(shown_name); lbWindowData.Items.Add(shown_name);
break; break;
} }