From cf01c8e1a2a0ab4f03fb05577ea4e1812c27b4ce Mon Sep 17 00:00:00 2001 From: Joel16 Date: Fri, 29 Jun 2018 18:28:09 -0500 Subject: [PATCH] Bump version and other minor changes/fixes Added touch controls for gallery and ebook reader. - Touching the left/right will skip left/right - Added document icon for ebooks. - Increased playlist/album buffers to 512. - Fixed 'parent folder' not using the right colour in dark theme. --- Makefile | 2 +- include/textures.h | 2 +- romfs/res/drawable/ic_fso_type_document.png | Bin 0 -> 957 bytes source/dirbrowse.c | 27 +++++++-------- .../menu_book_reader/menu_book_reader.cpp | 31 +++++++++++++----- source/menus/menu_gallery.c | 23 +++++++++++-- source/menus/menu_music.c | 4 +-- source/textures.c | 2 ++ 8 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 romfs/res/drawable/ic_fso_type_document.png diff --git a/Makefile b/Makefile index f407af4..ca9d9cc 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ ROMFS := romfs VERSION_MAJOR := 1 VERSION_MINOR := 0 -VERSION_MICRO := 2 +VERSION_MICRO := 3 APP_TITLE := NX-Shell APP_AUTHOR := Joel16 diff --git a/include/textures.h b/include/textures.h index ec8a45f..1dc2be4 100644 --- a/include/textures.h +++ b/include/textures.h @@ -3,7 +3,7 @@ SDL_Texture *icon_app, *icon_archive, *icon_audio, *icon_dir, *icon_file, *icon_image, *icon_text, *icon_dir_dark, \ - *icon_check, *icon_uncheck, *icon_check_dark, *icon_uncheck_dark, *icon_radio_off, *icon_radio_on, \ + *icon_doc, *icon_check, *icon_uncheck, *icon_check_dark, *icon_uncheck_dark, *icon_radio_off, *icon_radio_on, \ *icon_radio_dark_off, *icon_radio_dark_on, *icon_toggle_on, *icon_toggle_dark_on, *icon_toggle_off, \ *dialog, *options_dialog, *properties_dialog, *dialog_dark, *options_dialog_dark, *properties_dialog_dark, \ *bg_header, *icon_settings, *icon_sd, *icon_secure, *icon_settings_dark, *icon_sd_dark, *icon_secure_dark, \ diff --git a/romfs/res/drawable/ic_fso_type_document.png b/romfs/res/drawable/ic_fso_type_document.png new file mode 100644 index 0000000000000000000000000000000000000000..7ad250e15fca365b594e208f45ce73e886e8cf14 GIT binary patch literal 957 zcmaiyYe-XJ7{^bRutdYGK>d(I3=T5V;fKDin7fotH-}8iUEHS5>vHa*1?A|AH)4w@ zMum8Gw&U4F(`@(6F4~;B!cW6bVFuQRoaSZprQXwtSRnN0dCz&Cm*4Y059fV{YI*FO ztimh^f^xVVrU1NI#G)K0p2@tI5OnNWZI!SRlx(pF1V`fGO1xKP-YU6|r|{LZ`1q~< zI+b785vcD9hfrU>U{ha6q7BLPp=Lu^J`h&kB7!CMvc+DG*vplAc}ibxt6!k< zi@F11O-SAkfCz|cg^%Cn7x#q#S)=p`JN)&XfhJ8*st>W7$N@mRha3RFfFTBG2LlkK zs5{uG4&3MsiZwxrHVnFm0sfeWClHhfD~fk(BdUn*vXLQX+->$rlEyiChEv&v- zepg0?OK8QVtQq=7o>{<7X-t$wjL)2bp@H! z_?a!lP*QXu`^5+bgw`x84SZTTIqx- zuw&dXo6T!$GrPOP!?75Sf3;XF>;4}Df-zNeevkiYK1HEerc;;?Md#)omdMvZ9zu}W h*$1p|=gB{2%7(V7Jp&a+&mlNvh+D~Hy01u$zW^Oh{lEYK literal 0 HcmV?d00001 diff --git a/source/dirbrowse.c b/source/dirbrowse.c index 28a8edb..9a9f216 100644 --- a/source/dirbrowse.c +++ b/source/dirbrowse.c @@ -191,22 +191,23 @@ void Dirbrowse_DisplayFiles(void) if (file->isDir) SDL_DrawImage(RENDERER, config_dark_theme? icon_dir_dark : icon_dir, 80, 141 + (73 * printed), 72, 72); else if ((strncasecmp(FS_GetFileExt(file->name), "nro", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "elf", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "bin", 3) == 0)) + || (strncasecmp(FS_GetFileExt(file->name), "bin", 3) == 0)) SDL_DrawImage(RENDERER, icon_app, 80, 141 + (73 * printed), 72, 72); else if ((strncasecmp(FS_GetFileExt(file->name), "zip", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "tar", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "lz4", 3) == 0)) + || (strncasecmp(FS_GetFileExt(file->name), "lz4", 3) == 0)) SDL_DrawImage(RENDERER, icon_archive, 80, 141 + (73 * printed), 72, 72); else if ((strncasecmp(FS_GetFileExt(file->name), "mp3", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "ogg", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "wav", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "mod", 3) == 0)) + || (strncasecmp(FS_GetFileExt(file->name), "wav", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "mod", 3) == 0)) SDL_DrawImage(RENDERER, icon_audio, 80, 141 + (73 * printed), 72, 72); - else if ((strncasecmp(FS_GetFileExt(file->name), "png", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "jpg", 3) == 0) || - (strncasecmp(FS_GetFileExt(file->name), "bmp", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "gif", 3) == 0)) + else if ((strncasecmp(FS_GetFileExt(file->name), "png", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "jpg", 3) == 0) + || (strncasecmp(FS_GetFileExt(file->name), "bmp", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "gif", 3) == 0)) SDL_DrawImage(RENDERER, icon_image, 80, 141 + (73 * printed), 72, 72); else if ((strncasecmp(FS_GetFileExt(file->name), "txt", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "lua", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "cfg", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "pdf", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "cbz", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "fb2", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "epub", 4) == 0)) + || (strncasecmp(FS_GetFileExt(file->name), "cfg", 3) == 0)) SDL_DrawImage(RENDERER, icon_text, 80, 141 + (73 * printed), 72, 72); + else if ((strncasecmp(FS_GetFileExt(file->name), "pdf", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "cbz", 3) == 0) + || (strncasecmp(FS_GetFileExt(file->name), "fb2", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "epub", 4) == 0)) + SDL_DrawImage(RENDERER, icon_doc, 80, 141 + (73 * printed), 72, 72); else SDL_DrawImage(RENDERER, icon_file, 80, 141 + (73 * printed), 72, 72); @@ -226,7 +227,7 @@ void Dirbrowse_DisplayFiles(void) TTF_SizeText(Roboto, buf, NULL, &height); if (strncmp(file->name, "..", 2) == 0) - SDL_DrawText(Roboto, 170, 140 + ((73 - height)/2) + (73 * printed), BLACK, "Parent folder"); + SDL_DrawText(Roboto, 170, 140 + ((73 - height)/2) + (73 * printed), config_dark_theme? WHITE : BLACK, "Parent folder"); else SDL_DrawText(Roboto, 170, 140 + ((73 - height)/2) + (73 * printed), config_dark_theme? WHITE : BLACK, buf); @@ -285,7 +286,7 @@ void Dirbrowse_OpenFile(void) } } else if ((strncasecmp(FS_GetFileExt(file->name), "png", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "jpg", 3) == 0) || - (strncasecmp(FS_GetFileExt(file->name), "bmp", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "gif", 3) == 0)) + (strncasecmp(FS_GetFileExt(file->name), "bmp", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "gif", 3) == 0)) Gallery_DisplayImage(path); else if (strncasecmp(FS_GetFileExt(file->name), "zip", 3) == 0) { @@ -295,9 +296,9 @@ void Dirbrowse_OpenFile(void) else if ((strncasecmp(FS_GetFileExt(file->name), "mp3", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "ogg", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "wav", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "mod", 3) == 0)) Menu_PlayMusic(path); - else if ((strncasecmp(FS_GetFileExt(file->name), "pdf", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "cbz", 3) == 0) - || (strncasecmp(FS_GetFileExt(file->name), "fb2", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "epub", 4) == 0)) - Menu_OpenBook(path); + else if ((strncasecmp(FS_GetFileExt(file->name), "pdf", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "cbz", 3) == 0) + || (strncasecmp(FS_GetFileExt(file->name), "fb2", 3) == 0) || (strncasecmp(FS_GetFileExt(file->name), "epub", 4) == 0)) + Menu_OpenBook(path); /*else if (strncasecmp(file->ext, "txt", 3) == 0) TextViewer_DisplayText(path);*/ diff --git a/source/menus/menu_book_reader/menu_book_reader.cpp b/source/menus/menu_book_reader/menu_book_reader.cpp index 6279213..2fdb742 100644 --- a/source/menus/menu_book_reader/menu_book_reader.cpp +++ b/source/menus/menu_book_reader/menu_book_reader.cpp @@ -1,5 +1,6 @@ extern "C" { -#include "menu_book_reader.h" + #include "menu_book_reader.h" + #include "touch_helper.h" } #include "BookReader.hpp" @@ -8,21 +9,27 @@ void Menu_OpenBook(char *path) { BookReader *reader = new BookReader(path); + TouchInfo touchInfo; + Touch_Init(&touchInfo); + while(appletMainLoop()) { + reader->draw(); + hidScanInput(); + Touch_Process(&touchInfo); u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO); - + if (kDown & KEY_B) break; - if (kDown & KEY_DLEFT) + if ((kDown & KEY_DLEFT) || (kDown & KEY_L)) reader->previous_page(); - - if (kDown & KEY_DRIGHT) + + if ((kDown & KEY_DRIGHT) || (kDown & KEY_R)) reader->next_page(); - + if (kDown & KEY_LSTICK) reader->reset_page(); @@ -43,9 +50,15 @@ void Menu_OpenBook(char *path) if (kHeld & KEY_LSTICK_RIGHT) reader->move_page_right(); - - reader->draw(); + + if (touchInfo.state == TouchEnded && touchInfo.tapType != TapNone) + { + if (tapped_inside(touchInfo, 0, 0, 120, 720)) + reader->previous_page(); + else if (tapped_inside(touchInfo, 1160, 0, 1280, 720)) + reader->next_page(); + } } - + delete reader; } diff --git a/source/menus/menu_gallery.c b/source/menus/menu_gallery.c index 70027b6..9082972 100644 --- a/source/menus/menu_gallery.c +++ b/source/menus/menu_gallery.c @@ -4,9 +4,10 @@ #include "fs.h" #include "menu_gallery.h" #include "SDL_helper.h" +#include "touch_helper.h" #include "utils.h" -static char album[256][256]; +static char album[512][512]; static int count = 0, selection = 0; static SDL_Texture *image = NULL; static int width = 0, height = 0; @@ -89,6 +90,9 @@ void Gallery_DisplayImage(char *path) Gallery_GetImageList(); selection = Gallery_GetCurrentIndex(path); + + TouchInfo touchInfo; + Touch_Init(&touchInfo); while(appletMainLoop()) { @@ -97,6 +101,7 @@ void Gallery_DisplayImage(char *path) SDL_DrawImage(RENDERER, image, (1280 - width) / 2, (720 - height) / 2, width, height); hidScanInput(); + Touch_Process(&touchInfo); u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); if ((kDown & KEY_LEFT) || (kDown & KEY_L)) @@ -109,6 +114,20 @@ void Gallery_DisplayImage(char *path) wait(1); Gallery_HandleNext(true); } + + if (touchInfo.state == TouchEnded && touchInfo.tapType != TapNone) + { + if (tapped_inside(touchInfo, 0, 0, 120, 720)) + { + wait(1); + Gallery_HandleNext(false); + } + else if (tapped_inside(touchInfo, 1160, 0, 1280, 720)) + { + wait(1); + Gallery_HandleNext(true); + } + } SDL_RenderPresent(RENDERER); @@ -117,7 +136,7 @@ void Gallery_DisplayImage(char *path) } SDL_DestroyTexture(image); - memset(album, 0, sizeof(album[0][0]) * 256 * 256); + memset(album, 0, sizeof(album[0][0]) * 512 * 512); count = 0; MENU_DEFAULT_STATE = MENU_STATE_HOME; } \ No newline at end of file diff --git a/source/menus/menu_music.c b/source/menus/menu_music.c index d0dc73f..7d6cdc3 100644 --- a/source/menus/menu_music.c +++ b/source/menus/menu_music.c @@ -24,7 +24,7 @@ typedef enum MUSIC_STATE_SHUFFLE // 2 } Music_State; -static char playlist[256][256], title[128]; +static char playlist[512][512], title[128]; static int count = 0, selection = 0, state = 0; static Mix_Music *audio; @@ -325,7 +325,7 @@ void Menu_PlayMusic(char *path) } Mix_FreeMusic(audio); - memset(playlist, 0, sizeof(playlist[0][0]) * 256 * 256); + memset(playlist, 0, sizeof(playlist[0][0]) * 512 * 512); count = 0; MENU_DEFAULT_STATE = MENU_STATE_HOME; } \ No newline at end of file diff --git a/source/textures.c b/source/textures.c index 24578ba..f67384b 100644 --- a/source/textures.c +++ b/source/textures.c @@ -9,6 +9,7 @@ void Textures_Load(void) SDL_LoadImage(RENDERER, &icon_audio, "romfs:/res/drawable/ic_fso_type_audio.png"); SDL_LoadImage(RENDERER, &icon_dir, "romfs:/res/drawable/ic_fso_folder.png"); SDL_LoadImage(RENDERER, &icon_dir_dark, "romfs:/res/drawable/ic_fso_folder_dark.png"); + SDL_LoadImage(RENDERER, &icon_doc, "romfs:/res/drawable/ic_fso_type_document.png"); SDL_LoadImage(RENDERER, &icon_file, "romfs:/res/drawable/ic_fso_default.png"); SDL_LoadImage(RENDERER, &icon_image, "romfs:/res/drawable/ic_fso_type_image.png"); SDL_LoadImage(RENDERER, &icon_text, "romfs:/res/drawable/ic_fso_type_text.png"); @@ -101,6 +102,7 @@ void Textures_Free(void) SDL_DestroyTexture(icon_text); SDL_DestroyTexture(icon_image); SDL_DestroyTexture(icon_file); + SDL_DestroyTexture(icon_doc); SDL_DestroyTexture(icon_dir_dark); SDL_DestroyTexture(icon_dir); SDL_DestroyTexture(icon_audio);