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

Function CustomCallBack

Descent3/pilot.cpp:3334–3400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3332}
3333
3334void CustomCallBack(int c) {
3335 char select_bitmap[_MAX_PATH];
3336 char *sbmp = GetStringInList(c - 1, lp_cust_bmps->files, lp_cust_bmps->needed_size);
3337 if (sbmp)
3338 strcpy(select_bitmap, sbmp);
3339 else
3340 select_bitmap[0] = '\0';
3341
3342 if (!strcmp(custom_texture, select_bitmap))
3343 return;
3344
3345 if (ship_pos.bm_handle > BAD_BITMAP_HANDLE) {
3346 if (ship_pos.texture_type)
3347 FreeVClip(ship_pos.bm_handle);
3348 else
3349 bm_FreeBitmap(ship_pos.bm_handle);
3350 ship_pos.bm_handle = -1;
3351 }
3352 ship_pos.texture_changed = true;
3353
3354 if (c == 0) {
3355 // None selected
3356 custom_texture[0] = '\0';
3357 mprintf(0, "None selected\n");
3358 bmpwindow->SetInfo(false, -1);
3359 GameTextures[ship_pos.texture_id].flags &= ~TF_ANIMATED;
3360 GameTextures[ship_pos.texture_id].flags &= ~TF_TEXTURE_32;
3361 GameTextures[ship_pos.texture_id].flags |= TF_TEXTURE_64;
3362 GameTextures[ship_pos.texture_id].bm_handle = BAD_BITMAP_HANDLE;
3363 } else {
3364 // Get the filename
3365 char *p = GetStringInList(c - 1, lp_cust_bmps->files, lp_cust_bmps->needed_size);
3366 if (p)
3367 strcpy(custom_texture, p);
3368 else
3369 custom_texture[0] = '\0';
3370 ship_pos.bm_handle = LoadTextureImage(IGNORE_TABLE(custom_texture), &ship_pos.texture_type, SMALL_TEXTURE, 1);
3371 if (ship_pos.bm_handle > BAD_BITMAP_HANDLE) {
3372 if (ship_pos.texture_type)
3373 GameTextures[ship_pos.texture_id].flags |= TF_ANIMATED;
3374 else
3375 GameTextures[ship_pos.texture_id].flags &= ~TF_ANIMATED;
3376
3377 GameTextures[ship_pos.texture_id].flags &= ~TF_TEXTURE_32;
3378 GameTextures[ship_pos.texture_id].flags |= TF_TEXTURE_64;
3379
3380 GameTextures[ship_pos.texture_id].bm_handle = ship_pos.bm_handle;
3381
3382 bmpwindow->SetInfo(ship_pos.texture_type ? true : false, ship_pos.bm_handle);
3383
3384 mprintf(0, "Loaded texture (%s). Type=%d, ID=%d\n", custom_texture, ship_pos.texture_type, ship_pos.texture_id);
3385 } else
3386 goto load_texture_err;
3387 }
3388
3389 return;
3390
3391load_texture_err:

Callers 1

UpdateGraphicsListboxFunction · 0.85

Calls 5

GetStringInListFunction · 0.85
FreeVClipFunction · 0.85
bm_FreeBitmapFunction · 0.85
LoadTextureImageFunction · 0.85
SetInfoMethod · 0.80

Tested by

no test coverage detected