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

Method DeleteLevel

editor/ScriptLevelInterface.cpp:1283–1426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1281}
1282
1283bool CScriptLevelInterface::DeleteLevel() {
1284 CCheckListBox *list = (CCheckListBox *)GetDlgItem(IDC_LIST_CHECKEDOUT);
1285 int listbox_size = list->GetCount();
1286 int list_size = 0;
1287 int i;
1288 for (i = 0; i < listbox_size; i++) {
1289 if (list->GetCheck(i)) {
1290 list_size++;
1291 }
1292 }
1293
1294 if (list_size == 0)
1295 return false;
1296 int *index_map = (int *)mem_malloc(list_size * sizeof(int));
1297 if (!index_map)
1298 return false;
1299
1300 int index = 0;
1301 for (i = 0; i < listbox_size; i++) {
1302 if (list->GetCheck(i)) {
1303 index_map[index] = i;
1304 index++;
1305 }
1306 }
1307
1308 if (!mng_MakeLocker()) {
1309 mem_free(index_map);
1310 return false;
1311 }
1312
1313 int j;
1314 bool changed = false;
1315 char buffer[_MAX_PATH + 200];
1316 char tempbuffer[_MAX_PATH];
1317 char savename[_MAX_PATH];
1318
1319 for (i = 0; i < list_size; i++) {
1320 index = index_map[i];
1321
1322 list->GetText(index, tempbuffer);
1323 strcpy(savename, tempbuffer);
1324 strcat(tempbuffer, ".d3l");
1325
1326 // this item is checked...we wish to delete
1327 sprintf(buffer, "Are you sure you want to delete the level\n%s?", tempbuffer);
1328 if (MessageBox(buffer, "Friendly Warning", MB_YESNO) == IDYES) {
1329 // go ahead and delete the sucker!
1330 char t[256];
1331 sprintf(t, "Deleting: %s", tempbuffer);
1332 SetStatus(t);
1333 if (DeleteGamefile(tempbuffer))
1334 changed = true;
1335 }
1336
1337 bool script_also;
1338 script_also = false;
1339
1340 // ok the level has been deleted, see if there is a corresponding .cpp file

Callers

nothing calls this directly

Calls 4

mng_MakeLockerFunction · 0.85
DeleteGamefileFunction · 0.85
mng_EraseLockerFunction · 0.85
GetTextMethod · 0.45

Tested by

no test coverage detected