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

Method OnGenericChangeModel

editor/WorldObjectsGenericDialog.cpp:991–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989}
990
991void CWorldObjectsGenericDialog::OnGenericChangeModel() {
992 char filename[255];
993 char curname[255];
994 char fname[255];
995 char dir[255];
996 char ext[100];
997 int img_handle;
998 int c = 1, finding_name = 1;
999 int model = 0;
1000
1001 // Get the filename of the representing image
1002
1003 CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||";
1004
1005 if (!OpenFileDialog(this, (LPCTSTR)filter, filename, Current_model_dir, sizeof(Current_model_dir)))
1006 return;
1007
1008 std::filesystem::path tmp = ChangePolyModelName(filename);
1009 strcpy(curname, tmp.u8string().c_str());
1010
1011 ddio_SplitPath(filename, dir, fname, ext);
1012
1013 if ((FindPolyModelName(curname)) != -1) {
1014
1015 int answer = MessageBox("There is already a model in memory with this name. Are you sure you want to replace it?",
1016 fname, MB_YESNO);
1017 if (answer == IDNO)
1018 return;
1019 }
1020
1021 // Okay, we selected a file. Lets do what needs to be done here.
1022 img_handle = LoadPolyModel(filename, 0);
1023
1024 if (img_handle < 0) {
1025 OutrageMessageBox("Couldn't open that animation/model file.");
1026 return;
1027 }
1028
1029 if (m_lod == 0) {
1030 ChangeOldModelsForObjects(Object_info[m_current].render_handle, img_handle);
1031 FreePolyModel(Object_info[m_current].render_handle);
1032 Object_info[m_current].render_handle = img_handle;
1033 } else if (m_lod == 1) {
1034 if (Object_info[m_current].med_render_handle != -1)
1035 FreePolyModel(Object_info[m_current].med_render_handle);
1036
1037 Object_info[m_current].med_render_handle = img_handle;
1038 } else {
1039 if (Object_info[m_current].lo_render_handle != -1)
1040 FreePolyModel(Object_info[m_current].lo_render_handle);
1041
1042 Object_info[m_current].lo_render_handle = img_handle;
1043 }
1044
1045 // A new model might induce a new weapon stucture
1046 if (OutrageMessageBox(MBOX_YESNO, "Would you like to clear the weapon battery info?") == IDYES) {
1047 WBClearInfo(Object_info[m_current].static_wb);
1048 }

Callers

nothing calls this directly

Calls 10

OpenFileDialogFunction · 0.85
ChangePolyModelNameFunction · 0.85
FindPolyModelNameFunction · 0.85
LoadPolyModelFunction · 0.85
OutrageMessageBoxFunction · 0.85
FreePolyModelFunction · 0.85
cf_CopyFileFunction · 0.85
ddio_SplitPathFunction · 0.50
WBClearInfoFunction · 0.50

Tested by

no test coverage detected