MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / SaveLevel

Method SaveLevel

Source/XML/level_loader.cpp:595–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593}
594
595void LevelLoader::SaveLevel(SceneGraph& s, SaveLevelType type) {
596 /*if(s.VerifySanity() == false ) {
597 SDL_MessageBoxData message_box_data;
598 message_box_data.title = "Overgrowth";
599 message_box_data.message = "Your level has some sanity warnings that should be fixed, are you sure you wish to save?";
600 message_box_data.colorScheme = NULL;
601 message_box_data.window = NULL;
602 message_box_data.flags = SDL_MESSAGEBOX_WARNING;
603 message_box_data.numbuttons = 2;
604 SDL_MessageBoxButtonData buttons[3];
605 buttons[0].text = "Yes";
606 buttons[0].flags = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
607 buttons[0].buttonid = 0;
608 buttons[1].text = "No";
609 buttons[1].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
610 buttons[1].buttonid = 1;
611 message_box_data.buttons = buttons;
612 int button_id;
613 SDL_ShowMessageBox(&message_box_data, &button_id);
614 if(button_id == 1){
615 return;
616 }
617 }*/
618
619 std::string save_path;
620 std::string old_path;
621 if (s.level_path_.isValid()) {
622 save_path = s.level_path_.GetFullPath();
623 old_path = save_path;
624 }
625
626 if (type == kSaveAs || s.level_path_.isValid() == false || (((s.level_path_.source & kModPaths) || (s.level_path_.source & kDataPaths)) && (!s.level_has_been_previously_saved_ && config["allow_game_dir_save"].toBool() == false))) {
627 std::string start_dir;
628 if (config["allow_game_dir_save"].toBool()) {
629 if (save_path.empty()) {
630 start_dir = std::string(GetDataPath(0)) + "/Data/";
631 } else {
632 start_dir = SplitPathFileName(save_path).first;
633 }
634 } else {
635 start_dir = std::string(GetWritePath(CoreGameModID).c_str()) + "/Data/";
636 }
637
638 bool valid = false;
639
640 while (!valid) {
641 const int BUF_SIZE = 512;
642 char buf[BUF_SIZE];
643 Dialog::DialogErr err = Dialog::writeFile("xml", 1, start_dir.c_str(), buf, BUF_SIZE);
644 if (err) {
645 LOGE << "Cancelling level save due to dialog close" << std::endl;
646 return;
647 } else {
648 save_path = buf;
649 old_path = save_path;
650
651 std::string temp = save_path.substr(0, save_path.find_last_of("\\/"));
652 if (CheckWritePermissions(temp.c_str()) != 0) {

Callers 1

DrawImGuiFunction · 0.45

Calls 15

GetDataPathFunction · 0.85
SplitPathFileNameFunction · 0.85
GetWritePathFunction · 0.85
CheckWritePermissionsFunction · 0.85
fileexistsFunction · 0.85
CreateBackupFunction · 0.85
createfileFunction · 0.85
FindShortestPath2Function · 0.85
HashNavMeshParametersFunction · 0.85
WriteScriptParamsToXMLFunction · 0.85
GetFullPathMethod · 0.80

Tested by

no test coverage detected