Skip to content

Commit

Permalink
Bump version and other minor changes/fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joel16 committed Jun 29, 2018
1 parent 74b0d38 commit cf01c8e
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
Binary file added romfs/res/drawable/ic_fso_type_document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 14 additions & 13 deletions source/dirbrowse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand All @@ -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);*/
Expand Down
31 changes: 22 additions & 9 deletions source/menus/menu_book_reader/menu_book_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern "C" {
#include "menu_book_reader.h"
#include "menu_book_reader.h"
#include "touch_helper.h"
}

#include "BookReader.hpp"
Expand All @@ -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();

Expand All @@ -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;
}
23 changes: 21 additions & 2 deletions source/menus/menu_gallery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,6 +90,9 @@ void Gallery_DisplayImage(char *path)

Gallery_GetImageList();
selection = Gallery_GetCurrentIndex(path);

TouchInfo touchInfo;
Touch_Init(&touchInfo);

while(appletMainLoop())
{
Expand All @@ -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))
Expand All @@ -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);

Expand All @@ -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;
}
4 changes: 2 additions & 2 deletions source/menus/menu_music.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions source/textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cf01c8e

Please sign in to comment.