X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=38c7c3f76fc26a95f1cdd0051325dd42f8acc03d;hb=d9236358bbc4eea6a967503078ac6fc6a881d1da;hp=67e950a75a0527e911f229bd98a9db3e6b0b0b41;hpb=be12082df5c3ef2c7ef9fe133d1ff397acec7a33;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 67e950a..38c7c3f 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -889,16 +889,19 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, void SetUserLogo() { // update user logo if necessary - static char oldUserName[MSG_SIZ], *curName; + static char oldUserName[MSG_SIZ], dir[MSG_SIZ], *curName; if(appData.autoLogo) { curName = UserName(); if(strcmp(curName, oldUserName)) { - snprintf(oldUserName, MSG_SIZ, "logos\\%s.bmp", curName); + GetCurrentDirectory(MSG_SIZ, dir); + SetCurrentDirectory(installDir); + snprintf(oldUserName, MSG_SIZ, "logos\\%s.bmp", curName); userLogo = LoadImage( 0, oldUserName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); safeStrCpy(oldUserName, curName, sizeof(oldUserName)/sizeof(oldUserName[0]) ); if(userLogo == NULL) userLogo = LoadImage( 0, "logos\\dummy.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + SetCurrentDirectory(dir); /* return to prev directory */ } } } @@ -956,8 +959,11 @@ EnsureOnScreen(int *x, int *y, int minX, int minY) } VOID -LoadLogo(ChessProgramState *cps, int n) +LoadLogo(ChessProgramState *cps, int n, Boolean ics) { + char buf[MSG_SIZ], dir[MSG_SIZ]; + GetCurrentDirectory(MSG_SIZ, dir); + SetCurrentDirectory(installDir); if( appData.logo[n] && appData.logo[n][0] != NULLCHAR) { cps->programLogo = LoadImage( 0, appData.logo[n], IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); @@ -965,12 +971,16 @@ LoadLogo(ChessProgramState *cps, int n) fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.logo[n] ); } } else if(appData.autoLogo) { - if(appData.firstDirectory && appData.directory[n][0]) { - char buf[MSG_SIZ]; - snprintf(buf, MSG_SIZ, "%s/logo.bmp", appData.directory[n]); - cps->programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + if(ics) { // [HGM] logo: in ICS mode second can be used for ICS + sprintf(buf, "logos\\%s.bmp", appData.icsHost); + cps->programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } else + if(appData.directory[n] && appData.directory[n][0]) { + SetCurrentDirectory(appData.directory[n]); + cps->programLogo = LoadImage( 0, "logo.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); } } + SetCurrentDirectory(dir); /* return to prev directory */ } BOOL @@ -1028,25 +1038,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) } /* [HGM] logo: Load logos if specified (must be done before InitDrawingSizes) */ - LoadLogo(&first, 0); - - if( appData.secondLogo && appData.secondLogo[0] != NULLCHAR) { - second.programLogo = LoadImage( 0, appData.secondLogo, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - - if (second.programLogo == NULL && appData.debugMode) { - fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.secondLogo ); - } - } else if(appData.autoLogo) { - char buf[MSG_SIZ]; - if(appData.icsActive) { // [HGM] logo: in ICS mode second can be used for ICS - snprintf(buf, MSG_SIZ, "logos\\%s.bmp", appData.icsHost); - second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - } else - if(appData.secondDirectory && appData.secondDirectory[0]) { - snprintf(buf, MSG_SIZ, "%s\\logo.bmp", appData.secondDirectory); - second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - } - } + LoadLogo(&first, 0, FALSE); + LoadLogo(&second, 1, appData.icsActive); SetUserLogo(); @@ -1238,7 +1231,7 @@ ParseFontName(char *name, MyFontParams *mfp) q = strchr(p, ':'); if (q) { if (q - p >= sizeof(mfp->faceName)) - ExitArgError(_("Font name too long:"), name); + ExitArgError(_("Font name too long:"), name, TRUE); memcpy(mfp->faceName, p, q - p); mfp->faceName[q - p] = NULLCHAR; p = q + 1; @@ -1247,12 +1240,12 @@ ParseFontName(char *name, MyFontParams *mfp) while (*p && !isdigit(*p)) { *q++ = *p++; if (q - mfp->faceName >= sizeof(mfp->faceName)) - ExitArgError(_("Font name too long:"), name); + ExitArgError(_("Font name too long:"), name, TRUE); } while (q > mfp->faceName && q[-1] == ' ') q--; *q = NULLCHAR; } - if (!*p) ExitArgError(_("Font point size missing:"), name); + if (!*p) ExitArgError(_("Font point size missing:"), name, TRUE); mfp->pointSize = (float) atof(p); mfp->bold = (strchr(p, 'b') != NULL); mfp->italic = (strchr(p, 'i') != NULL); @@ -1358,7 +1351,7 @@ ParseBoardSize(void *addr, char *name) } bs++; } - ExitArgError(_("Unrecognized board size value"), name); + ExitArgError(_("Unrecognized board size value"), name, TRUE); } void @@ -3386,7 +3379,10 @@ DrawLogoOnDC(HDC hdc, RECT logoRect, HBITMAP logo) HBITMAP hbm; int w = 100, h = 50; - if(logo == NULL) return; + if(logo == NULL) { + if(!logoHeight) return; + FillRect( hdc, &logoRect, whitePieceBrush ); + } // GetClientRect(hwndMain, &Rect); // bufferBitmap = CreateCompatibleBitmap(hdc, Rect.right-Rect.left+1, // Rect.bottom-Rect.top+1); @@ -3444,6 +3440,15 @@ DisplayLogos() } } +void +UpdateLogos(int display) +{ // called after loading new engine(s), in tourney or from menu + LoadLogo(&first, 0, FALSE); + LoadLogo(&second, 1, appData.icsActive); + InitDrawingSizes(-2, 0); // adapt layout of board window to presence/absence of logos + if(display) DisplayLogos(); +} + static HDC hdcSeek; // [HGM] seekgraph @@ -4956,6 +4961,10 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) EditTagsProc(); break; + case IDM_EditBook: + EditBookEvent(); + break; + case IDM_EditComment: case IDM_Comment: if (commentUp && editComment) { @@ -5612,7 +5621,7 @@ MyLoadSound(MySound *ms) struct stat st; FILE *f; - if (ms->data) free(ms->data); + if (ms->data && ms->flag) free(ms->data); ms->data = NULL; switch (ms->name[0]) { @@ -5633,6 +5642,7 @@ MyLoadSound(MySound *ms) HANDLE h = FindResource(hInst, ms->name + 1, "WAVE"); if (h == NULL) break; ms->data = (void *)LoadResource(hInst, h); + ms->flag = 0; // not maloced, so cannot be freed! if (h == NULL) break; ok = TRUE; } @@ -5643,6 +5653,7 @@ MyLoadSound(MySound *ms) if (f == NULL) break; if (fstat(fileno(f), &st) < 0) break; ms->data = malloc(st.st_size); + ms->flag = 1; if (fread(ms->data, st.st_size, 1, f) < 1) break; fclose(f); ok = TRUE; @@ -8593,6 +8604,12 @@ PlayAlarmSound() MyPlaySound(&sounds[(int)SoundAlarm]); } +VOID +PlayTellSound() +{ + MyPlaySound(&textAttribs[ColorTell].sound); +} + VOID EchoOn() @@ -8908,9 +8925,6 @@ StartChildProcess(char *cmdLine, char *dir, ProcRef *pr) * dir relative to the directory WinBoard loaded from. */ GetCurrentDirectory(MSG_SIZ, buf); SetCurrentDirectory(installDir); - // kludgey way to update logos in tourney, as long as back-end can't do it - if(!strcmp(cmdLine, first.program)) LoadLogo(&first, 0); else - if(!strcmp(cmdLine, second.program)) LoadLogo(&second, 1); SetCurrentDirectory(dir); /* Now create the child process. */