MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / refreshSelected

Method refreshSelected

3ds/source/MainScreen.cpp:527–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527void MainScreen::refreshSelected(void)
528{
529 TitleCatalog& catalog = TitleCatalog::get();
530
531 // While the catalog reloads, show no detail card; the generation bump at the
532 // end of the load triggers the rebuild.
533 if (catalog.progress().active) {
534 if (selected.valid) {
535 selected.valid = false;
536 directoryList->clear();
537 }
538 return;
539 }
540
541 const u32 catalogGen = catalog.generation();
542 const u32 sizeGen = BackupSizeCache::get().generation();
543 const size_t count = (size_t)catalog.getTitleCount(backupKind);
544
545 if (selected.valid == (count > 0) && selected.fullIndex == hid.fullIndex() && selected.kind == backupKind && selected.catalogGen == catalogGen &&
546 selected.sizeGen == sizeGen && selected.transferRow == transferEnabled) {
547 return; // snapshot still describes what is on screen
548 }
549
550 if (!selected.valid || selected.kind != backupKind || selected.catalogGen != catalogGen) {
551 gridFavorites.assign(count, 0);
552 for (size_t i = 0; i < count; i++) {
553 gridFavorites[i] = catalog.favorite(i, backupKind) ? 1 : 0;
554 }
555 }
556
557 selected.valid = count > 0;
558 selected.fullIndex = hid.fullIndex();
559 selected.kind = backupKind;
560 selected.catalogGen = catalogGen;
561 selected.sizeGen = sizeGen;
562 selected.transferRow = transferEnabled;
563
564 if (!selected.valid) {
565 directoryList->clear();
566 return;
567 }
568
569 Title title;
570 catalog.getTitle(title, selected.fullIndex, backupKind);
571 BackupTarget target = title.backup(backupKind);
572
573 selected.id = title.id();
574 selected.rootPath = target.rootPath();
575 selected.name = title.shortDescription();
576 selected.cartId = title.productCode[0] != '\0' ? std::string(title.productCode) : i18n::t("main.system_title");
577 selected.mediaType = title.mediaTypeString();
578 selected.favorite = catalog.favorite(selected.fullIndex, backupKind);
579 selected.totalSize = BackupSizeCache::get().total(selected.id, backupKind);
580
581 // Rows: entry 0 is the "New backup" affordance, entry 1 the "Receive" action
582 // (while the transfer feature is enabled), the rest are existing backups
583 // labelled with their (async) size. rowToCell()/cellToRow() depend on this
584 // layout.

Callers

nothing calls this directly

Calls 15

getFunction · 0.85
stringFunction · 0.85
humanBytesFunction · 0.85
fullIndexMethod · 0.80
rootPathMethod · 0.80
mediaTypeStringMethod · 0.80
backupsMethod · 0.80
atMethod · 0.80
progressMethod · 0.45
clearMethod · 0.45
generationMethod · 0.45
getTitleCountMethod · 0.45

Tested by

no test coverage detected