/* * AboutDialogProc: Display info about client. */ BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { int i; HBITMAP gBitmap; switch (message) { HANDLE_MSG(hDlg, WM_INITDIALOG, AboutInitDialog); HANDLE_MSG(hDlg, WM_TIMER, AboutTimer); HANDLE_MSG(hDlg, WM_LBUTTONDOWN, AboutLButtonDown); case WM_COMMAND: switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: case IDCANCEL: EndDialog(hDlg, IDOK); if (timer_id != 0) KillTimer(hDlg, TIMER_ABOUT); gBitmap = (HBITMAP) SelectObject(gDC, gOldBitmap); DeleteObject(gBitmap); DeleteDC(gDC); for (i=0; i < NUM_DUDES; i++) if (dudes[i].obj != NULL) dudes[i].obj = ObjectDestroyAndFree(dudes[i].obj); BitmapsFree(&credits_b); return TRUE; } break; case WM_DESTROY: hAboutDlg = NULL; return TRUE; } return FALSE; }
//////////////////////////////////////////////////////////// // TWallTextureontrol // ----------------- // void TWallTextureControl::BuildBitmapData (const char *texname, SHORT /*remapPlayer*/) { Bitmaps b; PDIB pdib; BYTE *bits; int size; if (DibOpenFile(texname, &b) == False) { Notify("Couldn't load texture %s", texname); return; } pdib = BitmapsGetPdib(b, 0, 0); if (pdib == NULL) { Notify("Missing bitmap 0 in texture %s", texname); return; } BitmapXSize = DibWidth(pdib); BitmapYSize = DibHeight(pdib); bits = DibPtr(pdib); size = BitmapXSize * BitmapYSize; pBitmapData = (BYTE *) GetMemory(size); memcpy(pBitmapData, bits, size); BitmapsFree(&b); // Mark used colors BYTE *ptrData = pBitmapData; for (int i = 0 ; i < size ; i++ ) { pUsedColors[*ptrData] = TRUE; ptrData++; } return; }
/* * DibOpenFile: Load the bitmaps in the file given by filename into the * given bitmap structure. Return TRUE on success. */ Bool DibOpenFile(const char *szFile, Bitmaps *b) { file_node f; DWORD dwLen, dwBits; DWORD width, height, xoffset, yoffset; BYTE num_hotspots, shrink; int i, j, size, offset, num_indices; if (!MappedFileOpenRead(szFile, &f)) return False; if (!DibReadHeader(&f, b, &shrink)) return MappedFileClose(&f); // Allocate memory for bitmap pointers and indices size = b->num_bitmaps * sizeof(PDIB) + b->num_groups * b->max_indices * sizeof(int); b->pdibs = (PDIB *) SafeMalloc(size); b->indices = (int *) ((BYTE *) b->pdibs + b->num_bitmaps * sizeof(PDIB)); memset(b->pdibs, 0, size); // Read in bitmaps for (i=0; i < b->num_bitmaps; i++) { // Switch width and height since walls are rotated 90 degrees if (MappedFileRead(&f, &height, 4) != 4) return MappedFileClose(&f); if (MappedFileRead(&f, &width, 4) != 4) return MappedFileClose(&f); if (MappedFileRead(&f, &xoffset, 4) != 4) return MappedFileClose(&f); if (MappedFileRead(&f, &yoffset, 4) != 4) return MappedFileClose(&f); if (MappedFileRead(&f, &num_hotspots, 1) != 1) return MappedFileClose(&f); /* How much memory do we need to hold the PDIB? */ dwBits = width * height; dwLen = dwBits + sizeof(DIBHEADER) + num_hotspots * (sizeof(POINT) + sizeof(BYTE)); // Arrangement of PDIB in memory: // Header // bytes of bitmap // array of hotspot numbers // array of hotspot positions b->pdibs[i] = (PDIB) SafeMalloc(dwLen); b->pdibs[i]->width = width; b->pdibs[i]->height = height; b->pdibs[i]->xoffset = xoffset; b->pdibs[i]->yoffset = yoffset; b->pdibs[i]->num_hotspots = num_hotspots; b->pdibs[i]->numbers = (char *) (DibPtr(b->pdibs[i]) + dwBits); b->pdibs[i]->hotspots = (POINT *) (b->pdibs[i]->numbers + num_hotspots * sizeof(BYTE)); b->pdibs[i]->shrink = shrink; // read in the hotspots for (j=0; j < num_hotspots; j++) { if ((MappedFileRead(&f, &b->pdibs[i]->numbers[j], 1) != 1) || (MappedFileRead(&f, &b->pdibs[i]->hotspots[j].x, 4) != 4) || (MappedFileRead(&f, &b->pdibs[i]->hotspots[j].y, 4) != 4)) { BitmapsFree(b); return MappedFileClose(&f); } } /* read in the bits */ if (!DibReadBits(&f, b->pdibs[i], version)) { BitmapsFree(b); return MappedFileClose(&f); } RotateBits(DibPtr(b->pdibs[i]), height, width); } // Read in indices for (i=0; i < b->num_groups; i++) { // offset stores where we are in indices array offset = b->max_indices * i; if (MappedFileRead(&f, &num_indices, 4) != 4) { BitmapsFree(b); return MappedFileClose(&f); } b->indices[offset] = num_indices; for (j=0; j < num_indices; j++) { offset++; if (MappedFileRead(&f, &b->indices[offset], 4) != 4) { BitmapsFree(b); return MappedFileClose(&f); } } } MappedFileClose(&f); return True; }
/* * IntroShowSplash: Display splash screen. */ void IntroShowSplash(void) { RECT rect; BYTE *gTitleBits; int i; Bitmaps b; PDIB pdib; if (cinfo->config->quickstart) { OfflineConnect(); return; } if (showing_splash) return; showing_splash = True; IntroFreeLogo(); hwndDialButton = CreateWindow("button", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, cinfo->hMain, (HMENU) IDC_DIALBUTTON, hInst, NULL); SetWindowText(hwndDialButton, GetString(hInst, IDS_INTRO)); /* Subclass button */ lpfnDefButtonProc = SubclassWindow(hwndDialButton, MainButtonProc); /* Get bits of bitmap from bgf file */ if (DibOpenFile(splash_filename, &b)) { pdib = BitmapsGetPdibByIndex(b, 0); /* Get bitmap's size */ bm_width = DibWidth(pdib); bm_height = DibHeight(pdib); /* Create bitmap */ hTitleDC = CreateMemBitmap(bm_width, bm_height, &hOldTitleBitmap, &gTitleBits); if (hTitleDC == NULL) { debug(("IntroShowSplash couldn't create bitmap!\n")); BitmapsFree(&b); return; } /* Copy bits into bitmap */ for (i=0; i < bm_height; i++) memcpy(gTitleBits + i * DIBWIDTH(bm_width), DibPtr(pdib) + i * bm_width, bm_width); BitmapsFree(&b); } else { hTitleDC = NULL; bm_width = BUTTON_XSIZE; } button_width = bm_width; button_height = BUTTON_YSIZE; /* Simulate resize to get positions right */ GetClientRect(cinfo->hMain, &rect); EventResize(rect.right, rect.bottom, NULL); SetFocus(hwndDialButton); timer_id = SetTimer(NULL, 0, MUSIC_DELAY, PlayMusicProc); }