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

Function LoadGameDialog

Descent3/gamesave.cpp:572–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570}
571
572bool LoadGameDialog() {
573 tLoadGameDialogData lgd_data;
574 newuiTiledWindow wnd;
575 newuiSheet *sheet;
576 int i, res;
577 bool retval = true;
578
579 char savegame_dir[_MAX_PATH];
580 char pathname[_MAX_PATH];
581 char filename[PSFILENAME_LEN + 1];
582 char desc[GAMESAVE_DESCLEN + 1];
583 bool occupied_slot[N_SAVE_SLOTS], loadgames_avail = false;
584
585 if (Game_mode & GM_MULTI) {
586 DoMessageBox(TXT_ERROR, TXT_CANT_LOAD_MULTI, MSGBOX_OK);
587 return false;
588 }
589
590 // setup paths.
591 ddio_MakePath(savegame_dir, Base_directory, "savegame", NULL);
592 ddio_MakePath(pathname, savegame_dir, "*.sav", NULL);
593
594 // create savegame directory if it didn't exist before.
595 if (!std::filesystem::is_directory(savegame_dir)) {
596 DoMessageBox(TXT_ERROR, TXT_ERRNOSAVEGAMES, MSGBOX_OK);
597 return false;
598 }
599
600 // open window
601 wnd.Create(TXT_LOADGAME, 0, 0, GAMESAVE_WND_W, GAMESAVE_WND_H);
602 wnd.Open();
603 sheet = wnd.GetSheet();
604
605 sheet->NewGroup(NULL, GAMESAVE_HELP_X, GAMESAVE_HELP_Y);
606 sheet->AddText(TXT_LOADGAMEHELP);
607
608 sheet->NewGroup(NULL, GAMESAVE_SLOT_X, GAMESAVE_SLOT_Y);
609
610 // generate save slots.
611 lgd_data.cur_slot = SAVE_HOTSPOT_ID;
612 lgd_data.chunk.bm_array = NULL;
613
614 for (i = 0; i < N_SAVE_SLOTS; i++) {
615 FILE *fp;
616 bool ingroup = (i == 0 || i == (N_SAVE_SLOTS - 1)) ? true : false;
617
618 snprintf(filename, sizeof(filename), "saveg00%d", i);
619 ddio_MakePath(pathname, savegame_dir, filename, NULL);
620
621 occupied_slot[i] = false;
622
623 fp = fopen(pathname, "rb");
624 if (fp) {
625 int bm_handle = -1;
626 int *pbm_handle;
627 fclose(fp);
628
629 if (lgd_data.cur_slot == (SAVE_HOTSPOT_ID + i)) {

Callers 2

RunGameMenuFunction · 0.85
MainMenuFunction · 0.85

Calls 15

DoMessageBoxFunction · 0.85
GetGameStateInfoFunction · 0.85
bm_DestroyChunkedBitmapFunction · 0.85
bm_CreateChunkedBitmapFunction · 0.85
bm_FreeBitmapFunction · 0.85
ddio_MouseQueueFlushFunction · 0.85
SetGameStateFunction · 0.85
GetSheetMethod · 0.80
NewGroupMethod · 0.80
AddTextMethod · 0.80
AddHotspotMethod · 0.80
AddButtonMethod · 0.80

Tested by

no test coverage detected