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

Method startScriptPicker

switch/source/MainScreen.cpp:788–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

786}
787
788void MainScreen::startScriptPicker(void)
789{
790 if (TransferJob::get().active() || ScriptRunner::get().active()) {
791 return;
792 }
793
794 // The highlighted grid title (if any) picks the specific-script folder and
795 // becomes the script's selected title.
796 Title title;
797 const bool hasTitle = TitleCatalog::get().getFilteredTitleCount(g_currentUId, mSaveTypeFilter) > 0;
798 if (hasTitle) {
799 TitleCatalog::get().getFilteredTitle(title, g_currentUId, mSaveTypeFilter, mCursor);
800 }
801 const u64 titleId = hasTitle ? title.id() : 0;
802
803 // Bundled (romfs) scripts first, then SD: an SD file of the same name wins.
804 std::vector<ScriptCatalog::Root> universalRoots = {
805 {Paths::bundledUniversalScriptsDir(), ScriptCatalog::Source::Bundled},
806 {Paths::universalScriptsDir(), ScriptCatalog::Source::Sd},
807 };
808 std::vector<ScriptCatalog::Root> specificRoots;
809 if (hasTitle) {
810 specificRoots = {
811 {Paths::bundledScriptsDirFor(titleId), ScriptCatalog::Source::Bundled},
812 {Paths::scriptsDirFor(titleId), ScriptCatalog::Source::Sd},
813 };
814 }
815 auto entries = ScriptCatalog::scan(universalRoots, specificRoots);
816 currentOverlay = std::make_shared<ScriptPickerOverlay>(
817 *this, std::move(entries), hasTitle ? title.displayName() : "", [this, hasTitle, titleId](const ScriptCatalog::Entry& entry) {
818 currentOverlay = std::make_shared<YesNoOverlay>(
819 *this, i18n::t("scripts.confirm_run", {entry.name}),
820 [this, entry, hasTitle, titleId]() {
821 this->removeOverlay();
822 std::string idHex = hasTitle ? StringUtils::format("%016llX", (unsigned long long)titleId) : "";
823 // HOME stays blocked for the whole run (PKSM precedent): picoc
824 // cannot be preempted, so a buggy script requires a reboot.
825 appletBeginBlockingHomeButton(0);
826 if (ScriptRunner::get().start(entry.path, entry.name, std::move(idHex))) {
827 // The run owns the screen from here: ScriptScreen holds
828 // this one alive and hands control back when it is closed.
829 g_pendingScreen = std::make_shared<ScriptScreen>(g_screen, entry.name);
830 }
831 else {
832 appletEndBlockingHomeButton();
833 currentOverlay = std::make_shared<ErrorOverlay>(*this, -1, i18n::t("scripts.start_failed"));
834 }
835 },
836 [this]() { this->removeOverlay(); });
837 });
838}
839
840void MainScreen::updateSelector(const InputState& input)
841{

Callers

nothing calls this directly

Calls 9

getFunction · 0.85
scanFunction · 0.85
getFilteredTitleCountMethod · 0.80
getFilteredTitleMethod · 0.80
displayNameMethod · 0.80
removeOverlayMethod · 0.80
activeMethod · 0.45
idMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected