X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwgamelist.c;h=382f06152033f89e25e5ecbd666825d565e0015a;hb=ca6061cbffe88ff5eb2332e733e0a534b89cc5e7;hp=48aa85d206966f40db4aaaf87e87c543cb1934f0;hpb=b382d988c6f886f3a49483df9e3e36de0b6b0824;p=xboard.git diff --git a/winboard/wgamelist.c b/winboard/wgamelist.c index 48aa85d..382f061 100644 --- a/winboard/wgamelist.c +++ b/winboard/wgamelist.c @@ -57,10 +57,11 @@ struct GameListStats }; /* [AS] Setup the game list according to the specified filter */ -static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats ) +static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos ) { ListGame * lg = (ListGame *) gameList.head; int nItem; + char buf[MSG_SIZ]; BOOL hasFilter = FALSE; int count = 0; struct GameListStats dummy; @@ -85,17 +86,31 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct } } + if(byPos) InitSearch(); + for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ - char * st = GameListLine(lg->number, &lg->gameInfo); + char * st = NULL; BOOL skip = FALSE; + int pos = -1; + + if(nItem % 2000 == 0) { + snprintf(buf, MSG_SIZ, _("Scanning through games (%d)"), nItem); + SetWindowText(hwndMain, buf); + } if( hasFilter ) { - if( ! SearchPattern( st, pszFilter ) ) { - skip = TRUE; - } + st = GameListLine(lg->number, &lg->gameInfo); + if( !SearchPattern( st, pszFilter) ) skip = TRUE; } + if( !skip && byPos) { + if( (pos = GameContainsPosition(gameFile, lg)) < 0) skip = TRUE; + } + + lg->position = pos; + if( ! skip ) { + if(!st) st = GameListLine(lg->number, &lg->gameInfo); SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st); count++; @@ -110,11 +125,12 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct stats->unfinished++; } - free(st); + if(st) free(st); lg = (ListGame *) lg->node.succ; } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, 0, 0); + SetWindowText(hwndMain, "WinBoard"); return count; } @@ -166,9 +182,9 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndText = GetDlgItem(hDlg, OPT_TagsText); /* Set font */ - SendDlgItemMessage( hDlg, OPT_GameListText, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 )); + SendDlgItemMessage( hDlg, OPT_GameListText, WM_SETFONT, (WPARAM)font[boardSize][GAMELIST_FONT]->hf, MAKELPARAM(TRUE, 0 )); - count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats ); + count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats, FALSE ); SendDlgItemMessage( hDlg, IDC_GameListFilter, WM_SETTEXT, 0, (LPARAM) "" ); SendDlgItemMessage( hDlg, IDC_GameListFilter, EM_SETLIMITTEXT, MAX_FILTER_LENGTH, 0 ); @@ -208,6 +224,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } GameListUpdateTitle( hDlg, _("Game List"), count, ((ListGame *) gameList.tailPred)->number, &stats ); // [HGM] always update title + GameListHighlight(lastLoadGameNumber); return FALSE; case WM_SIZE: @@ -261,8 +278,10 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* [AS] End command replacement */ switch (LOWORD(wParam)) { - case IDOK: case OPT_GameListLoad: + LoadOptionsPopup(hDlg); + return TRUE; + case IDOK: nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); if (nItem < 0) { /* is this possible? */ @@ -282,7 +301,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); break; /* load the game*/ - case OPT_GameListPrev: +// case OPT_GameListPrev: nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); nItem--; if (nItem < 0) { @@ -294,13 +313,14 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) break; /* load the game*/ /* [AS] */ + case OPT_GameListPrev: case IDC_GameListDoFilter: { char filter[MAX_FILTER_LENGTH+1]; if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) { filter[ sizeof(filter)-1 ] = '\0'; - count = GameListToListBox( hDlg, TRUE, filter, &stats ); + count = GameListToListBox( hDlg, TRUE, filter, &stats, LOWORD(wParam)!=IDC_GameListDoFilter ); GameListUpdateTitle( hDlg, _("Game List"), count, ((ListGame *) gameList.tailPred)->number, &stats ); } } @@ -406,9 +426,15 @@ VOID GameListPopDown(void) VOID GameListHighlight(int index) { + char buf[MSG_SIZ]; + int i, res = 0; if (gameListDialog == NULL) return; + for(i=0; res != LB_ERR; i++) { + res = SendDlgItemMessage( gameListDialog, OPT_GameListText, LB_GETTEXT, i, (LPARAM)buf ); + if(index <= atoi( buf )) break; + } SendDlgItemMessage(gameListDialog, OPT_GameListText, - LB_SETCURSEL, index - 1, 0); + LB_SETCURSEL, i, 0); }