21 #define ID_SPLASHSCREEN 25 23 static const char *gConception[] = {
29 static const char *gLeadDevelopers[] = {
36 static const char *gRootDevelopers[] = {
53 static const char *gRootDocumentation[] = {
59 static char **gContributors = 0;
61 typedef struct tagImgInfo {
68 static IMG_INFO gImageInfo;
72 static HINSTANCE gInst;
73 static HWND gSplashWnd = 0;
74 static BOOL gShow =
FALSE;
75 static DWORD gDelayVal = 0;
76 static HDC gDCScreen = 0, gDCCredits = 0;
77 static HBITMAP gBmpScreen = 0, gBmpOldScreen = 0;
78 static HBITMAP gBmpCredits = 0, gBmpOldCredits = 0;
79 static HRGN gRgnScreen = 0;
80 static int gCreditsBmpWidth;
81 static int gCreditsBmpHeight;
83 static bool gStayUp =
true;
84 static bool gAbout =
false;
85 static RECT gCreditsRect = { 15, 155, 305, 285 };
86 static unsigned int gCreditsWidth = gCreditsRect.right - gCreditsRect.left;
87 static unsigned int gCreditsHeight = gCreditsRect.bottom - gCreditsRect.top;
89 static void ReadContributors()
96 sprintf(buf,
"%s/CREDITS", ROOTDOCDIR);
98 sprintf(buf,
"%s/README/CREDITS", getenv(
"ROOTSYS"));
103 FILE *
f = fopen(buf,
"r");
107 while (fgets(buf,
sizeof(buf), f)) {
108 if (!strncmp(buf,
"N: ", 3)) {
112 gContributors =
new char*[cnt+1];
116 while (fgets(buf,
sizeof(buf), f)) {
117 if (!strncmp(buf,
"N: ", 3)) {
118 int len = strlen(buf);
121 gContributors[
cnt] =
new char[len];
122 strlcpy(gContributors[cnt], buf+3, len);
126 gContributors[
cnt] = 0;
131 static void DrawVersion(HDC hDC)
140 Height = gImageInfo.sizeInPix.cy;
142 GetTextExtentPoint32(hDC, version, strlen(version), &lpSize);
145 drawRect.top = Height - 25;
146 drawRect.right = 15 + lpSize.cx;
147 drawRect.bottom = drawRect.top + lpSize.cy;
148 DrawTextEx(hDC, version, strlen(version), &drawRect, DT_LEFT, 0);
151 static int DrawCreditItem(HDC hDC,
const char *creditItem,
const char **members,
157 SIZE lpSize1, lpSize2;
163 GetTextMetrics(hDC, &lptm);
165 lineSpacing = lptm.tmAscent + lptm.tmDescent;
167 strcpy(credit, creditItem);
168 for (i = 0; members && members[i]; i++) {
169 if (i) strcat(credit,
", ");
170 GetTextExtentPoint32(hDC, credit, strlen(credit), &lpSize1);
171 GetTextExtentPoint32(hDC, members[i], strlen(members[i]), &lpSize2);
172 if((lpSize1.cx + lpSize2.cx) > (
int) gCreditsWidth) {
175 drawRect.right = gCreditsRect.right;
176 drawRect.bottom = y + lineSpacing;
178 DrawTextEx(hDC, credit, strlen(credit), &drawRect, DT_LEFT, 0);
182 strcat(credit, members[i]);
186 drawRect.right = gCreditsRect.right;
187 drawRect.bottom = y + lineSpacing;
189 DrawTextEx(hDC, credit, strlen(credit), &drawRect, DT_LEFT, 0);
194 static int DrawCredits(HDC hDC,
bool draw,
bool extended)
203 DWORD length =
sizeof (user_name);
206 GetTextMetrics(hDC, &lptm);
208 lineSpacing = lptm.tmAscent + lptm.tmDescent;
210 y = DrawCreditItem(hDC,
"Conception: ", gConception, y, draw);
211 y += 2 * lineSpacing - 3;
212 y = DrawCreditItem(hDC,
"Lead Developers: ", gLeadDevelopers, y, draw);
213 y += 2 * lineSpacing - 3;
214 y = DrawCreditItem(hDC,
"Core Engineering: ", gRootDevelopers, y, draw);
217 y += 2 * lineSpacing - 3;
218 y = DrawCreditItem(hDC,
"Documentation: ", gRootDocumentation, y, draw);
220 if (extended && gContributors) {
221 y += 2 * lineSpacing;
222 y = DrawCreditItem(hDC,
"Contributors: ", (
const char **)gContributors, y, draw);
224 y += 2 * lineSpacing;
225 y = DrawCreditItem(hDC,
"Our sincere thanks and apologies to anyone who deserves", 0, y, draw);
227 y = DrawCreditItem(hDC,
"credit but fails to appear in this list.", 0, y, draw);
229 if (GetUserName (user_name, &length)) {
230 char *
name =
new char [strlen(user_name)+1];
231 strcpy(name, user_name);
232 char *s = strchr(name,
',');
235 sprintf(line,
"Extra special thanks go to %s,", name);
237 y += 2 * lineSpacing;
238 y = DrawCreditItem(hDC, line, 0, y, draw);
240 y = DrawCreditItem(hDC,
"one of our favorite users.", 0, y, draw);
246 void CreateCredits(HDC hDC,
bool extended)
248 HFONT hFont, hOldFont;
253 gRgnScreen = CreateRectRgnIndirect(&gCreditsRect);
254 SelectClipRgn(hDC, gRgnScreen);
256 gDCScreen = CreateCompatibleDC(hDC);
257 gBmpScreen = CreateCompatibleBitmap(hDC, (gCreditsRect.right - gCreditsRect.left),
258 (gCreditsRect.bottom - gCreditsRect.top) );
259 gBmpOldScreen = (HBITMAP)SelectObject(gDCScreen, gBmpScreen);
261 gDCCredits = CreateCompatibleDC(hDC);
263 gCreditsBmpWidth = (gCreditsRect.right - gCreditsRect.left);
264 gCreditsBmpHeight = DrawCredits(gDCCredits,
false, extended);
266 gBmpCredits = CreateCompatibleBitmap(gDCCredits, gCreditsBmpWidth, gCreditsBmpHeight);
267 gBmpOldCredits = (HBITMAP)SelectObject(gDCCredits, gBmpCredits);
269 hBr = CreateSolidBrush(RGB(255,255,255));
270 fillRect.top = fillRect.left = 0;
271 fillRect.bottom = gCreditsBmpHeight;
272 fillRect.right = gCreditsBmpWidth;
273 FillRect(gDCCredits, &fillRect, hBr);
275 memset((
void*)&lf, 0,
sizeof(lf));
278 lf.lfQuality = NONANTIALIASED_QUALITY;
279 strcpy(lf.lfFaceName,
"Arial");
280 hFont = CreateFontIndirect(&lf);
283 hOldFont = (HFONT)SelectObject(gDCCredits, hFont);
285 SetBkMode(gDCCredits, TRANSPARENT);
288 DrawCredits(gDCCredits,
true, extended);
290 SetBkColor(gDCCredits, 0x00FFFFFF);
291 SelectObject(gDCCredits, hOldFont);
294 void ScrollCredits(BOOL extended)
298 static int nScrollY = 0;
302 if (!IsWindow(gSplashWnd))
304 HDC hDC = GetDC(gSplashWnd);
306 if(gDCCredits == 0) {
307 CreateCredits(hDC, extended);
311 BitBlt(gDCScreen, 0, 0, gCreditsBmpWidth, gCreditsBmpHeight, gDCCredits,
312 0, nScrollY, SRCCOPY);
313 BitBlt(hDC, gCreditsRect.left, gCreditsRect.top,
314 (gCreditsRect.right - gCreditsRect.left),
315 (gCreditsRect.bottom - gCreditsRect.top),
316 gDCScreen, 0, 0, SRCCOPY);
329 if (nScrollY > (
int) (gCreditsBmpHeight - 2*gCreditsHeight))
330 nScrollY = -int(gCreditsHeight);
336 ATOM MyRegisterClass(HINSTANCE hInstance);
337 LRESULT
CALLBACK SplashWndProc(HWND, UINT, WPARAM, LPARAM);
340 void *OpenGraphic(
char *
name)
343 SIZE sizeInHiMetric,sizeInPix;
344 const int HIMETRIC_PER_INCH = 2540;
345 HDC hDCScreen = GetDC(0);
347 int nPixelsPerInchX = GetDeviceCaps(hDCScreen, LOGPIXELSX);
348 int nPixelsPerInchY = GetDeviceCaps(hDCScreen, LOGPIXELSY);
349 wchar_t OlePathName[512];
351 ReleaseDC(0, hDCScreen);
352 mbstowcs(OlePathName,name,strlen(name)+1);
353 hr = OleLoadPicturePath(OlePathName, 0, 0, 0, IID_IPicture,
359 hr = Ipic->get_Width(&sizeInHiMetric.cx);
362 Ipic->get_Height(&sizeInHiMetric.cy);
367 sizeInPix.cx = (nPixelsPerInchX * sizeInHiMetric.cx +
368 HIMETRIC_PER_INCH / 2) / HIMETRIC_PER_INCH;
369 sizeInPix.cy = (nPixelsPerInchY * sizeInHiMetric.cy +
370 HIMETRIC_PER_INCH / 2) / HIMETRIC_PER_INCH;
371 gImageInfo.sizeInPix = sizeInPix;
372 gImageInfo.sizeInHiMetric = sizeInHiMetric;
373 gImageInfo.Ipic = Ipic;
374 gImageInfo.Path =
name;
380 void DisplayGraphic(HWND hwnd,HDC pDC)
382 IPicture *Ipic = gImageInfo.Ipic;
392 HPALETTE hPalOld=0, hPalMemOld=0;
393 hr = Ipic->get_hPal(&hPal);
398 hPalOld = SelectPalette(pDC,(HPALETTE)hPal,
FALSE);
404 GetClientRect(hwnd,&rc);
406 if (SUCCEEDED(Ipic->get_Attributes(&dwAttr)) ||
407 (dwAttr & PICTURE_TRANSPARENT)) {
409 HDC MemDC = CreateCompatibleDC(pDC);
410 Bmp = CreateCompatibleBitmap(pDC,gImageInfo.sizeInPix.cx,gImageInfo.sizeInPix.cy);
412 BmpOld = (HBITMAP)SelectObject(MemDC,Bmp);
415 hPalMemOld = SelectPalette(MemDC,(HPALETTE)hPal,
FALSE);
416 RealizePalette(MemDC);
420 hr = Ipic->Render(MemDC, 0, 0, rc.right, rc.bottom, 0,
421 gImageInfo.sizeInHiMetric.cy,
422 gImageInfo.sizeInHiMetric.cx,
423 -gImageInfo.sizeInHiMetric.cy, &rc);
425 BitBlt(pDC,0, 0, gImageInfo.sizeInPix.cx, gImageInfo.sizeInPix.cy,
426 MemDC, 0, 0, SRCCOPY);
428 SelectObject(MemDC,BmpOld);
431 SelectPalette(MemDC,pPalMemOld,
FALSE);
438 Ipic->Render(pDC, 0, 0, rc.right, rc.bottom, 0,
439 gImageInfo.sizeInHiMetric.cy,
440 gImageInfo.sizeInHiMetric.cx,
441 -gImageInfo.sizeInHiMetric.cy, &rc);
445 SelectPalette(pDC,hPalOld,
FALSE);
447 DeleteObject((HPALETTE)hPal);
451 void CloseImage(
void *Ipict)
453 IPicture *ip = (IPicture *)Ipict;
456 ip = gImageInfo.Ipic;
460 memset(&gImageInfo,0,
sizeof(gImageInfo));
471 if (IsWindow(gSplashWnd)) {
472 DestroyWindow(gSplashWnd);
474 UnregisterClass(
"RootSplashScreen", gInst);
476 if(gDCScreen != 0 && gBmpOldScreen != 0) {
477 SelectObject(gDCScreen, gBmpOldScreen);
478 DeleteObject(gBmpScreen);
480 if(gDCCredits != 0 && gBmpOldCredits != 0) {
481 SelectObject(gDCCredits, gBmpOldCredits);
482 DeleteObject(gBmpCredits);
484 DeleteDC(gDCCredits);
488 CloseImage(gImageInfo.Ipic);
494 BOOL CreateSplashScreen(HWND hParent)
499 xScreen = GetSystemMetrics(SM_CXFULLSCREEN);
500 yScreen = GetSystemMetrics(SM_CYFULLSCREEN);
504 gSplashWnd = CreateWindowEx(
508 WS_POPUP | WS_VISIBLE,
517 return (gSplashWnd != 0);
524 BOOL PreTranslateMessage(MSG* pMsg)
526 if (!IsWindow(gSplashWnd))
530 if (pMsg->message == WM_KEYDOWN ||
531 pMsg->message == WM_SYSKEYDOWN ||
532 pMsg->message == WM_LBUTTONDOWN ||
533 pMsg->message == WM_RBUTTONDOWN ||
534 pMsg->message == WM_MBUTTONDOWN ||
535 pMsg->message == WM_NCLBUTTONDOWN ||
536 pMsg->message == WM_NCRBUTTONDOWN ||
537 pMsg->message == WM_NCMBUTTONDOWN) {
547 MyRegisterClass(gInst);
552 gDelayVal = time * 1000;
560 CreateSplashScreen(0);
564 if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
565 PreTranslateMessage(&msg);
566 TranslateMessage(&msg);
567 DispatchMessage(&msg);
571 ScrollCredits(extended);
574 ScrollCredits(extended);
597 ATOM MyRegisterClass(HINSTANCE hInstance)
601 wcex.cbSize =
sizeof(WNDCLASSEX);
603 wcex.style = CS_HREDRAW | CS_VREDRAW;
604 wcex.lpfnWndProc = (WNDPROC)SplashWndProc;
607 wcex.hInstance = hInstance;
609 wcex.hCursor = LoadCursor(0, IDC_ARROW);
610 wcex.hbrBackground = 0;
611 wcex.lpszMenuName = 0;
612 wcex.lpszClassName =
"RootSplashScreen";
614 return RegisterClassEx(&wcex);
622 LRESULT
CALLBACK SplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
628 const char bmpDir[] =
"\\icons\\Splash.gif";
630 char pszNewWindowTitle[1024];
631 char pszOldWindowTitle[1024];
632 char FullBmpDir[256];
640 SetTimer(hWnd, ID_SPLASHSCREEN, gDelayVal, 0);
641 RootSysDir = getenv(
"ROOTSYS");
642 sprintf(FullBmpDir,
"%s%s",RootSysDir,bmpDir);
644 OpenGraphic(FullBmpDir);
646 DisplayGraphic(hWnd, hDC);
647 SetBkMode(hDC, TRANSPARENT);
648 memset((
void*)&lf, 0,
sizeof(lf));
651 lf.lfQuality = NONANTIALIASED_QUALITY;
652 strcpy(lf.lfFaceName,
"Arial");
653 hFont = CreateFontIndirect(&lf);
654 xScreen = GetSystemMetrics(SM_CXFULLSCREEN);
655 yScreen = GetSystemMetrics(SM_CYFULLSCREEN);
656 SetWindowPos(hWnd, HWND_TOPMOST, (xScreen - gImageInfo.sizeInPix.cx)/2,
657 (yScreen - gImageInfo.sizeInPix.cy)/2, gImageInfo.sizeInPix.cx,
658 gImageInfo.sizeInPix.cy, 0 );
662 if (wParam == ID_SPLASHSCREEN) {
663 KillTimer (hWnd, ID_SPLASHSCREEN);
673 hDC = BeginPaint(hWnd, &ps);
675 GetClientRect(hWnd, &rt);
676 RootSysDir = getenv(
"ROOTSYS");
677 sprintf(FullBmpDir,
"%s%s",RootSysDir,bmpDir);
678 OpenGraphic(FullBmpDir);
680 DisplayGraphic(hWnd, hDC);
681 SetBkMode(hDC, TRANSPARENT);
683 SelectObject(hDC, hFont);
688 GetConsoleTitle(pszOldWindowTitle, 1024);
690 wsprintf(pszNewWindowTitle,
"%d/%d", GetTickCount(), GetCurrentProcessId());
692 SetConsoleTitle(pszNewWindowTitle);
696 hwndFound=FindWindow(
NULL, pszNewWindowTitle);
698 ShowWindow(hwndFound, SW_RESTORE);
699 SetForegroundWindow(hwndFound);
700 SetConsoleTitle(
"ROOT session");
704 return DefWindowProc(hWnd, message, wParam, lParam);
void CreateSplash(DWORD time, BOOL extended)
void DestroySplashScreen()