Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3DS Theme: Fix crash when launching apps from top bar on empty selection #2498

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions romsel_dsimenutheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ void launchSettings(void) {
stop();
}

void launchPictochat(std::string filename, bool isDir) {
void launchPictochat(const vector<DirEntry>& dirContents) {
const char* pictochatPath = sys().isRunFromSD() ? "sd:/_nds/pictochat.nds" : "fat:/_nds/pictochat.nds";

if (access(pictochatPath, F_OK) != 0) {
Expand Down Expand Up @@ -736,7 +736,13 @@ void launchPictochat(std::string filename, bool isDir) {
}
}
}
titleUpdate(isDir, filename.c_str(), CURPOS);
if (CURPOS + PAGENUM * 40 < (int)dirContents.size()) {
titleUpdate(
dirContents[CURPOS + PAGENUM * 40].isDirectory,
dirContents[CURPOS + PAGENUM * 40].name,
CURPOS
);
}
updateText(false);
return;
}
Expand Down Expand Up @@ -826,7 +832,7 @@ void launchPictochat(std::string filename, bool isDir) {
stop();
}

void launchDownloadPlay(std::string filename, bool isDir) {
void launchDownloadPlay(const vector<DirEntry>& dirContents) {
const char* dlplayPath = sys().isRunFromSD() ? "sd:/_nds/dlplay.nds" : "fat:/_nds/dlplay.nds";

if ((!isDSiMode() || ms().consoleModel < 2) && access(dlplayPath, F_OK) != 0) {
Expand Down Expand Up @@ -881,7 +887,13 @@ void launchDownloadPlay(std::string filename, bool isDir) {
}
}
}
titleUpdate(isDir, filename.c_str(), CURPOS);
if (CURPOS + PAGENUM * 40 < (int)dirContents.size()) {
titleUpdate(
dirContents[CURPOS + PAGENUM * 40].isDirectory,
dirContents[CURPOS + PAGENUM * 40].name,
CURPOS
);
}
updateText(false);
return;
}
Expand Down Expand Up @@ -1004,7 +1016,7 @@ void launchDownloadPlay(std::string filename, bool isDir) {
stop();
}

void launchInternetBrowser(std::string filename, bool isDir) {
void launchInternetBrowser(const vector<DirEntry>& dirContents) {
if (ms().internetBrowserPath == "" || access(ms().internetBrowserPath.c_str(), F_OK) != 0) {
if (ms().theme == TWLSettings::EThemeSaturn) {
snd().playStartup();
Expand Down Expand Up @@ -1057,7 +1069,13 @@ void launchInternetBrowser(std::string filename, bool isDir) {
}
}
}
titleUpdate(isDir, filename.c_str(), CURPOS);
if (CURPOS + PAGENUM * 40 < (int)dirContents.size()) {
titleUpdate(
dirContents[CURPOS + PAGENUM * 40].isDirectory,
dirContents[CURPOS + PAGENUM * 40].name,
CURPOS
);
}
updateText(false);
return;
}
Expand Down Expand Up @@ -4172,13 +4190,13 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
launchGba();
break;
case 2: // Launch Pictochat
launchPictochat(dirContents[scrn].at(CURPOS + PAGENUM * 40).name, dirContents[scrn].at(CURPOS + PAGENUM * 40).isDirectory);
launchPictochat(dirContents[scrn]);
break;
case 3: // Launch DS Download Play
launchDownloadPlay(dirContents[scrn].at(CURPOS + PAGENUM * 40).name, dirContents[scrn].at(CURPOS + PAGENUM * 40).isDirectory);
launchDownloadPlay(dirContents[scrn]);
break;
case 4: // Launch Internet Browser
launchInternetBrowser(dirContents[scrn].at(CURPOS + PAGENUM * 40).name, dirContents[scrn].at(CURPOS + PAGENUM * 40).isDirectory);
launchInternetBrowser(dirContents[scrn]);
break;
case 5: // Open the manual
launchManual();
Expand Down
Loading