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

Function LoadGameDialogCB

Descent3/gamesave.cpp:519–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517void LoadGameDialogCB(newuiTiledWindow *wnd, void *data)
518#else
519void __cdecl LoadGameDialogCB(newuiTiledWindow *wnd, void *data)
520#endif
521{
522 tLoadGameDialogData *cb_data = (tLoadGameDialogData *)data;
523 UIGadget *cur_gadget;
524 int id;
525
526 cur_gadget = wnd->GetFocus();
527
528 for (id = SAVE_HOTSPOT_ID; id < (SAVE_HOTSPOT_ID + N_SAVE_SLOTS); id++) {
529 if (cur_gadget->GetID() == id) {
530 break;
531 }
532 }
533
534 if (id < (SAVE_HOTSPOT_ID + N_SAVE_SLOTS) && id != cb_data->cur_slot) {
535 // new bitmap to be displayed!
536 char filename[PSFILENAME_LEN + 1];
537 char pathname[_MAX_PATH];
538 char savegame_dir[_MAX_PATH];
539 char desc[GAMESAVE_DESCLEN + 1];
540 int bm_handle;
541
542 if (cb_data->chunk.bm_array) {
543 bm_DestroyChunkedBitmap(&cb_data->chunk);
544 }
545
546 mprintf(0, "savegame slot=%d\n", id - SAVE_HOTSPOT_ID);
547
548 ddio_MakePath(savegame_dir, Base_directory, "savegame", NULL);
549 snprintf(filename, sizeof(filename), "saveg00%d", (id - SAVE_HOTSPOT_ID));
550 ddio_MakePath(pathname, savegame_dir, filename, NULL);
551
552 if (GetGameStateInfo(pathname, desc, &bm_handle)) {
553 if (bm_handle > 0) {
554 bm_CreateChunkedBitmap(bm_handle, &cb_data->chunk);
555 bm_FreeBitmap(bm_handle);
556 }
557 }
558 cb_data->cur_slot = id;
559 }
560
561 // draw bitmap if there is one
562 if (cb_data->chunk.bm_array) {
563 UIBitmapItem bm_item;
564 int x, y;
565 bm_item.set_chunked_bitmap(&cb_data->chunk);
566 x = (wnd->W() - bm_item.width()) / 2;
567 y = (wnd->H() - bm_item.height()) / 4;
568 bm_item.draw(x, y);
569 }
570}
571
572bool LoadGameDialog() {
573 tLoadGameDialogData lgd_data;

Callers

nothing calls this directly

Calls 13

bm_DestroyChunkedBitmapFunction · 0.85
GetGameStateInfoFunction · 0.85
bm_CreateChunkedBitmapFunction · 0.85
bm_FreeBitmapFunction · 0.85
GetIDMethod · 0.80
set_chunked_bitmapMethod · 0.80
WMethod · 0.80
HMethod · 0.80
ddio_MakePathFunction · 0.50
GetFocusMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected