| 1438 | t.destPath = destDir + ".pbo.zst"; |
| 1439 | t.expectedBytes = r.sizeBytes; |
| 1440 | t.postStep = [destDir, modId, name = std::string((const char*)r.name), |
| 1441 | version = std::string((const char*)r.version), folderName, |
| 1442 | downloadUrl = std::string((const char*)r.downloadUrl), |
| 1443 | sizeBytes = r.sizeBytes](const DownloadTask& task, std::string& error) -> bool |
| 1444 | { |
| 1445 | if (!ModArchive::Unpack(task.destPath.c_str(), destDir.c_str(), &error)) |
| 1446 | return false; |
| 1447 | return WriteInstalledModManifest(destDir, modId, name, version, folderName, downloadUrl, sizeBytes, &error); |
| 1448 | }; |
| 1449 | tasks.push_back(std::move(t)); |
| 1450 | } |
| 1451 | return !tasks.empty(); |
| 1452 | } |
| 1453 | |
| 1454 | static RString LocalizedDownloadUnitNoun(const char* unitNoun, int count) |
| 1455 | { |
| 1456 | const bool plural = count != 1; |
| 1457 | if (unitNoun != nullptr && stricmp(unitNoun, "mod") == 0) |
| 1458 | return LocalizeString(plural ? "STR_DISP_MODS_NOUN_MODS" : "STR_DISP_MODS_NOUN_MOD"); |
| 1459 | return LocalizeString(plural ? "STR_DISP_MODS_NOUN_ADDONS" : "STR_DISP_MODS_NOUN_ADDON"); |
| 1460 | } |
| 1461 | |
| 1462 | // After a successful download, flip the now-installed rows off Missing so |
| 1463 | // BuildModPath mounts them. Preserves ticks (SetRows copies the rows back). |
| 1464 | static void RefreshInstalledStates(CModsList* list, const std::string& root) |
| 1465 | { |
| 1466 | AutoArray<ModRow> rows = list->GetRows(); |
| 1467 | bool changed = false; |
| 1468 | for (int i = 0; i < rows.Size(); i++) |
| 1469 | { |
| 1470 | if (rows[i].state != ModRowState::Missing) |
| 1471 | continue; |
| 1472 | const ModInstallStatus st = GetModInstallStatus(root, BareModId(rows[i].modId), (const char*)rows[i].version); |
| 1473 | if (st != ModInstallStatus::NotInstalled) |
| 1474 | { |
| 1475 | rows[i].state = ModRowState::Downloaded; |
| 1476 | changed = true; |
| 1477 | } |
| 1478 | } |
| 1479 | if (changed) |
| 1480 | list->SetRows(rows); |
| 1481 | } |
| 1482 | |
| 1483 | void DisplayMods::OnButtonClicked(int idc) |
| 1484 | { |
| 1485 | if (idc == IDC_CANCEL) |
| 1486 | { |
| 1487 | _exitWhenClose = idc; |
| 1488 | ControlObjectContainerAnim* notebook = dynamic_cast<ControlObjectContainerAnim*>(GetCtrl(IDC_MODS_NOTEBOOK)); |
| 1489 | if (notebook) |
| 1490 | notebook->Close(); |
| 1491 | else |
| 1492 | Exit(idc); // no notebook control (minimal/absent rsc) — close at once |
| 1493 | return; |
| 1494 | } |
| 1495 | |
| 1496 | if (idc == IDC_MODS_APPLY) |
| 1497 | { |
nothing calls this directly
no test coverage detected