MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnLoadBitmap

Method OnLoadBitmap

editor/WorldTexturesDialog.cpp:1295–1346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1293}
1294
1295void CWorldTexturesDialog::OnLoadBitmap() {
1296 char filename[255];
1297 int bm_handle;
1298 int anim = 0;
1299 int n = D3EditState.texdlg_texture;
1300 int tex_size = NORMAL_TEXTURE;
1301
1302 CString filter =
1303 "Descent III files (*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl||";
1304
1305 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
1306 return;
1307
1308 // Okay, we selected a file. Lets do what needs to be done here.
1309 if (GameTextures[n].flags & TF_TEXTURE_64)
1310 tex_size = SMALL_TEXTURE;
1311 else if (GameTextures[n].flags & TF_TEXTURE_32)
1312 tex_size = TINY_TEXTURE;
1313 else if (GameTextures[n].flags & TF_TEXTURE_256)
1314 tex_size = HUGE_TEXTURE;
1315
1316 int format = GameBitmaps[GetTextureBitmap(n, 0)].format;
1317
1318 bm_handle = LoadTextureImage(filename, &anim, tex_size, 0, 0, format);
1319
1320 if (bm_handle < 0) {
1321 OutrageMessageBox("Could not load that bitmap...restoring previous bitmap.");
1322 return;
1323 }
1324
1325 GameTextures[n].bm_handle = bm_handle;
1326
1327 if (anim)
1328 GameTextures[n].flags |= TF_ANIMATED;
1329 else
1330 GameTextures[n].flags &= ~TF_ANIMATED;
1331
1332 mprintf(0, "Making a copy of this bitmap locally...\n");
1333
1334 if (anim) {
1335 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1336 GameVClips[GameTextures[n].bm_handle].name);
1337 SaveVClip(filename, GameTextures[n].bm_handle);
1338 } else {
1339 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1340 GameBitmaps[GameTextures[n].bm_handle].name);
1341 bm_SaveFileBitmap(filename, GameTextures[n].bm_handle);
1342 }
1343
1344 CheckIfTextureIsTmap2(n);
1345 UpdateDialog();
1346}
1347
1348void CWorldTexturesDialog::OnCheckDestroy() {
1349 int n = D3EditState.texdlg_texture;

Callers

nothing calls this directly

Calls 7

OpenFileDialogFunction · 0.85
GetTextureBitmapFunction · 0.85
LoadTextureImageFunction · 0.85
OutrageMessageBoxFunction · 0.85
SaveVClipFunction · 0.85
bm_SaveFileBitmapFunction · 0.85
CheckIfTextureIsTmap2Function · 0.85

Tested by

no test coverage detected