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

Function SaveGameDialog

Descent3/gamesave.cpp:372–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void SaveGameDialog() {
373 newuiTiledWindow wnd;
374 newuiSheet *sheet;
375 int i, res;
376
377 char savegame_dir[_MAX_PATH];
378 char pathname[_MAX_PATH];
379 char filename[PSFILENAME_LEN + 1];
380 char desc[GAMESAVE_DESCLEN + 1];
381 bool occupied_slot[N_SAVE_SLOTS];
382
383 if (Game_mode & GM_MULTI) {
384 DoMessageBox(TXT_ERROR, TXT_CANT_SAVE_MULTI, MSGBOX_OK);
385 return;
386 }
387
388#ifdef _DEBUG
389 if (!Current_mission.filename) {
390 DoMessageBox(TXT_ERROR, "You need to be playing a mission.", MSGBOX_OK);
391 return;
392 }
393#endif
394
395 // setup paths.
396 ddio_MakePath(savegame_dir, Base_directory, "savegame", NULL);
397 // ddio_MakePath(pathname, savegame_dir, "*.sav", NULL); -unused
398
399 // create savegame directory if it didn't exist before.
400 std::error_code ec;
401 if (!std::filesystem::create_directories(savegame_dir, ec)) {
402 if (ec) {
403 DoMessageBox(TXT_ERROR, TXT_ERRCREATEDIR, MSGBOX_OK);
404 return;
405 }
406 }
407
408 // open window
409 wnd.Create(TXT_SAVEGAME, 0, 0, GAMESAVE_WND_W, GAMESAVE_WND_H);
410 wnd.Open();
411 sheet = wnd.GetSheet();
412
413 sheet->NewGroup(NULL, GAMESAVE_HELP_X, GAMESAVE_HELP_Y);
414 sheet->AddText(TXT_SAVEGAMEHELP);
415
416 sheet->NewGroup(NULL, GAMESAVE_SLOT_X, GAMESAVE_SLOT_Y2);
417 // generate save slots.
418 for (i = 0; i < N_SAVE_SLOTS; i++) {
419 FILE *fp;
420 bool ingroup = (i == 0 || i == (N_SAVE_SLOTS - 1)) ? true : false;
421
422 snprintf(filename, sizeof(filename), "saveg00%d", i);
423 ddio_MakePath(pathname, savegame_dir, filename, NULL);
424
425 occupied_slot[i] = false;
426
427 fp = fopen(pathname, "rb");
428 if (fp) {
429 fclose(fp);

Callers 2

RunGameMenuFunction · 0.85
QuickSaveGameFunction · 0.85

Calls 15

DoMessageBoxFunction · 0.85
GetGameStateInfoFunction · 0.85
ddio_MouseQueueFlushFunction · 0.85
DoEditDialogFunction · 0.85
SaveGameStateFunction · 0.85
AddHUDMessageFunction · 0.85
GetSheetMethod · 0.80
NewGroupMethod · 0.80
AddTextMethod · 0.80
AddHotspotMethod · 0.80
AddButtonMethod · 0.80
GetGadgetMethod · 0.80

Tested by

no test coverage detected