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

Method OnGenericAddNew

editor/WorldObjectsGenericDialog.cpp:637–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635}
636
637void CWorldObjectsGenericDialog::OnGenericAddNew() {
638 char filename[256], dir[256], fname[256], ext[32];
639 char cur_name[100], *t;
640 int img_handle;
641 int object_handle;
642 int c = 1, finding_name = 1;
643
644 ASSERT(Network_up);
645
646 // Get the filename of the representing image
647
648 CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||";
649
650 if (!OpenFileDialog(this, (LPCTSTR)filter, filename, Current_model_dir, sizeof(Current_model_dir)))
651 return;
652
653 ddio_SplitPath(filename, dir, fname, ext);
654
655 std::filesystem::path tmp = ChangePolyModelName(filename);
656 strcpy(cur_name, tmp.u8string().c_str());
657
658 if ((FindPolyModelName(fname)) != -1) {
659 OutrageMessageBox("You must rename your model to something else because there is already a model with that name!");
660 return;
661 }
662
663 // Okay, we selected a file. Lets do what needs to be done here.
664 img_handle = LoadPolyModel(filename, 0);
665
666 if (img_handle < 0) {
667 OutrageMessageBox("Couldn't open that model file.");
668 return;
669 }
670
671 // Get a default name
672 strcpy(cur_name, fname); // Start with the filename
673 t = strchr(cur_name, '.'); // Strip the extention
674 if (!t)
675 t = cur_name + strlen(cur_name);
676 *t = 0;
677 do { // Make sure the name not already in use
678 int c = 0;
679
680 if (FindObjectIDName(cur_name) == -1)
681 break;
682
683 *t = 0;
684 sprintf(cur_name, "%s%d", cur_name, ++c);
685 } while (1);
686 cur_name[0] = toupper(cur_name[0]); // make first char uppercase
687
688// Get the object name from the user
689retry_name:
690
691 if (!InputObjectName(cur_name, sizeof(cur_name), "Object name", "Enter a name for your object:", this))
692 return;
693
694 if (FindObjectIDName(cur_name) != -1) {

Callers

nothing calls this directly

Calls 13

OpenFileDialogFunction · 0.85
ChangePolyModelNameFunction · 0.85
FindPolyModelNameFunction · 0.85
OutrageMessageBoxFunction · 0.85
LoadPolyModelFunction · 0.85
FindObjectIDNameFunction · 0.85
InputObjectNameFunction · 0.85
AllocObjectIDFunction · 0.85
ComputeDefaultSizeFunction · 0.85
cf_CopyFileFunction · 0.85
mng_AllocTrackLockFunction · 0.85
RemapStaticIDsFunction · 0.85

Tested by

no test coverage detected