-
Notifications
You must be signed in to change notification settings - Fork 559
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
screenshots: use subdirectories for the date and include the title ID #1488
Open
ioistired
wants to merge
5
commits into
LumaTeam:master
Choose a base branch
from
ioistired:screenshot-filename-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7a4a6c9
screenshots: use subdirectories for the date and include the title ID
ioistired c5a9715
remove unnecessary memset calls by replacing strcat with sprintf
ioistired 50d9fa2
Merge remote-tracking branch 'origin/master' into screenshot-filename…
ioistired 89a872e
Merge remote-tracking branch 'origin/master' into screenshot-filename…
ioistired b2ded68
Merge remote-tracking branch 'origin/master' into screenshot-filename…
ioistired File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
|
||
#include <3ds.h> | ||
#include <3ds/os.h> | ||
#include "pmdbgext.h" | ||
#include "menus.h" | ||
#include "menu.h" | ||
#include "draw.h" | ||
|
@@ -371,7 +372,8 @@ void RosalinaMenu_TakeScreenshot(void) | |
IFile file; | ||
Result res = 0; | ||
|
||
char filename[64]; | ||
char directory[32]; | ||
char filename[90]; | ||
|
||
FS_Archive archive; | ||
FS_ArchiveID archiveId; | ||
|
@@ -397,15 +399,6 @@ void RosalinaMenu_TakeScreenshot(void) | |
Draw_GetCurrentScreenInfo(&bottomWidth, &is3d, false); | ||
Draw_GetCurrentScreenInfo(&topWidth, &is3d, true); | ||
|
||
res = FSUSER_OpenArchive(&archive, archiveId, fsMakePath(PATH_EMPTY, "")); | ||
if(R_SUCCEEDED(res)) | ||
{ | ||
res = FSUSER_CreateDirectory(archive, fsMakePath(PATH_ASCII, "/luma/screenshots"), 0); | ||
if((u32)res == 0xC82044BE) // directory already exists | ||
res = 0; | ||
FSUSER_CloseArchive(archive); | ||
} | ||
|
||
u32 seconds, minutes, hours, days, year, month; | ||
u64 milliseconds = osGetTime(); | ||
seconds = milliseconds/1000; | ||
|
@@ -449,23 +442,51 @@ void RosalinaMenu_TakeScreenshot(void) | |
days++; | ||
month++; | ||
|
||
sprintf(filename, "/luma/screenshots/%04lu-%02lu-%02lu_%02lu-%02lu-%02lu.%03llu_top.bmp", year, month, days, hours, minutes, seconds, milliseconds); | ||
TRY(IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, filename), FS_OPEN_CREATE | FS_OPEN_WRITE)); | ||
TRY(RosalinaMenu_WriteScreenshot(&file, topWidth, true, true)); | ||
TRY(IFile_Close(&file)); | ||
res = FSUSER_OpenArchive(&archive, archiveId, fsMakePath(PATH_EMPTY, "")); | ||
if(R_SUCCEEDED(res)) | ||
{ | ||
sprintf(directory, "/luma/screenshots"); | ||
char dirName[16]; | ||
#define CREATE_SUBDIR(length, name) do { \ | ||
sprintf(dirName, "/%0" #length "lu", name); \ | ||
strcat(directory, dirName); \ | ||
res = FSUSER_CreateDirectory(archive, fsMakePath(PATH_ASCII, directory), 0); \ | ||
if((u32)res == 0xC82044BE) /* directory already exists */ \ | ||
res = 0; \ | ||
} while(false) | ||
|
||
CREATE_SUBDIR(4, year); | ||
CREATE_SUBDIR(2, month); | ||
CREATE_SUBDIR(2, days); | ||
|
||
#undef CREATE_SUBDIR | ||
|
||
FSUSER_CloseArchive(archive); | ||
} | ||
|
||
sprintf(filename, "/luma/screenshots/%04lu-%02lu-%02lu_%02lu-%02lu-%02lu.%03llu_bot.bmp", year, month, days, hours, minutes, seconds, milliseconds); | ||
TRY(IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, filename), FS_OPEN_CREATE | FS_OPEN_WRITE)); | ||
TRY(RosalinaMenu_WriteScreenshot(&file, bottomWidth, false, true)); | ||
TRY(IFile_Close(&file)); | ||
FS_ProgramInfo programInfo; | ||
u32 unused; | ||
res = PMDBG_GetCurrentAppInfo(&programInfo, &unused, &unused); | ||
|
||
#define WRITE_SCREENSHOT(screenName, screenWidth, top, left) do { \ | ||
sprintf( \ | ||
filename, \ | ||
"%s/%04lu-%02lu-%02lu_%02lu-%02lu-%02lu.%03llu_%016llx_%s.bmp", \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checkpoint uses the lower 4 bytes (8 nybbles) of the program's title ID. Should I do the same here? |
||
directory, \ | ||
year, month, days, hours, minutes, seconds, milliseconds, \ | ||
programInfo.programId, screenName); \ | ||
TRY(IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, filename), FS_OPEN_CREATE | FS_OPEN_WRITE)); \ | ||
TRY(RosalinaMenu_WriteScreenshot(&file, screenWidth, top, left)); \ | ||
TRY(IFile_Close(&file)); \ | ||
} while(false) | ||
|
||
WRITE_SCREENSHOT("top", topWidth, true, true); | ||
WRITE_SCREENSHOT("bot", bottomWidth, false, true); | ||
|
||
if(is3d && (Draw_GetCurrentFramebufferAddress(true, true) != Draw_GetCurrentFramebufferAddress(true, false))) | ||
{ | ||
sprintf(filename, "/luma/screenshots/%04lu-%02lu-%02lu_%02lu-%02lu-%02lu.%03llu_top_right.bmp", year, month, days, hours, minutes, seconds, milliseconds); | ||
TRY(IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, filename), FS_OPEN_CREATE | FS_OPEN_WRITE)); | ||
TRY(RosalinaMenu_WriteScreenshot(&file, topWidth, true, false)); | ||
TRY(IFile_Close(&file)); | ||
} | ||
WRITE_SCREENSHOT("top_right", topWidth, true, false); | ||
|
||
#undef WRITE_SCREENSHOT | ||
|
||
end: | ||
IFile_Close(&file); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized there's a bug in this approach: screenshots taken of the home menu while software is suspended, and screenshots taken of applets while software is suspended, will result in the wrong title ID written. Is that an issue?