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

Method startScriptPicker

3ds/source/MainScreen.cpp:741–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739}
740
741void MainScreen::startScriptPicker(void)
742{
743 if (TitleCatalog::get().progress().active || TransferJob::get().active() || ScriptRunner::get().active()) {
744 return;
745 }
746
747 const bool hasTitle = selected.valid;
748 const u64 titleId = selected.id;
749 // Bundled (romfs) scripts first, then SD: an SD file of the same name wins.
750 std::vector<ScriptCatalog::Root> universalRoots = {
751 {Paths::bundledUniversalScriptsDir(), ScriptCatalog::Source::Bundled},
752 {Paths::universalScriptsDir(), ScriptCatalog::Source::Sd},
753 };
754 std::vector<ScriptCatalog::Root> specificRoots;
755 if (hasTitle) {
756 specificRoots = {
757 {Paths::bundledScriptsDirFor(titleId), ScriptCatalog::Source::Bundled},
758 {Paths::scriptsDirFor(titleId), ScriptCatalog::Source::Sd},
759 };
760 }
761 auto entries = ScriptCatalog::scan(universalRoots, specificRoots);
762 currentOverlay = std::make_shared<ScriptPickerOverlay>(
763 *this, std::move(entries), hasTitle ? selected.name : "", [this, hasTitle, titleId](const ScriptCatalog::Entry& entry) {
764 currentOverlay = std::make_shared<YesNoOverlay>(
765 *this, i18n::t("scripts.confirm_run", {entry.name}),
766 [this, entry, hasTitle, titleId]() {
767 this->removeOverlay();
768 std::string idHex = hasTitle ? StringUtils::format("%016llX", titleId) : "";
769 // HOME stays blocked for the whole run (PKSM precedent): picoc
770 // cannot be preempted, so a buggy script requires a reboot.
771 aptSetHomeAllowed(false);
772 if (ScriptRunner::get().start(entry.path, entry.name, std::move(idHex))) {
773 // The run owns both screens from here: ScriptScreen holds
774 // this one alive and hands control back when it is closed.
775 g_pendingScreen = std::make_shared<ScriptScreen>(g_screen, entry.name);
776 }
777 else {
778 aptSetHomeAllowed(true);
779 currentOverlay = std::make_shared<ErrorOverlay>(*this, -1, i18n::t("scripts.start_failed"));
780 }
781 },
782 [this]() { this->removeOverlay(); });
783 });
784}
785
786void MainScreen::handleEvents(const InputState& input)
787{

Callers

nothing calls this directly

Calls 6

getFunction · 0.85
scanFunction · 0.85
removeOverlayMethod · 0.80
progressMethod · 0.45
activeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected