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

Method OnPshipLoadModel

editor/WorldObjectsPlayerDialog.cpp:407–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407void CWorldObjectsPlayerDialog::OnPshipLoadModel() {
408 char filename[255];
409 int img_handle;
410 int ship_handle;
411 int c = 1, finding_name = 1;
412 int model = 0;
413
414 // Get the filename of the representing image
415
416 CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||";
417
418 if (!OpenFileDialog(this, (LPCTSTR)filter, filename, Current_model_dir, sizeof(Current_model_dir)))
419 return;
420
421 // Okay, we selected a file. Lets do what needs to be done here.
422 img_handle = LoadPolyModel(filename, 0);
423
424 if (img_handle < 0) {
425 OutrageMessageBox("Couldn't open that animation/model file.");
426 return;
427 }
428
429 ship_handle = D3EditState.current_ship;
430
431 // Get rid of the old one possibly
432 if (m_lod == 0) {
433 ChangeOldModelsForObjects(Ships[ship_handle].model_handle, img_handle);
434 FreePolyModel(Ships[ship_handle].model_handle);
435 Ships[ship_handle].model_handle = img_handle;
436 } else if (m_lod == 1) {
437 if (Ships[ship_handle].med_render_handle != -1)
438 FreePolyModel(Ships[ship_handle].med_render_handle);
439
440 Ships[ship_handle].med_render_handle = img_handle;
441 } else {
442 if (Ships[ship_handle].lo_render_handle != -1)
443 FreePolyModel(Ships[ship_handle].lo_render_handle);
444
445 Ships[ship_handle].lo_render_handle = img_handle;
446 }
447
448 // A new model might induce a new weapon stucture
449 if (OutrageMessageBox(MBOX_YESNO, "Would you like to clear the weapon battery info?") == IDYES) {
450 WBClearInfo(Ships[ship_handle].static_wb);
451 }
452
453 // Finally, save a local copy of the model
454 std::filesystem::path curname = LocalModelsDir / Poly_models[img_handle].name;
455 cf_CopyFile(curname, filename);
456
457 UpdateDialog();
458}
459
460void CWorldObjectsPlayerDialog::OnPshipLock() {
461 int n = D3EditState.current_ship;

Callers

nothing calls this directly

Calls 7

OpenFileDialogFunction · 0.85
LoadPolyModelFunction · 0.85
OutrageMessageBoxFunction · 0.85
FreePolyModelFunction · 0.85
cf_CopyFileFunction · 0.85
WBClearInfoFunction · 0.50

Tested by

no test coverage detected