MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / OnButtonClicked

Method OnButtonClicked

engine/Poseidon/UI/OptionsUIApp.cpp:1440–1529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
1454static 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).
1464static 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
1483void 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 {

Callers

nothing calls this directly

Calls 15

GetCtrlFunction · 0.85
WorkshopModsRootFunction · 0.85
GetNetworkProxyFunction · 0.85
LocalModsRootFunction · 0.85
IsCreditsConfiguredFunction · 0.85
PlayCreditsCutsceneFunction · 0.85
BuildModPathMethod · 0.80
GetSourceModeMethod · 0.80
SetSourceModeMethod · 0.80

Tested by

no test coverage detected