Skip to content

Commit

Permalink
Merge pull request #35 from littlebalup/master
Browse files Browse the repository at this point in the history
Added audio, text and SFO file icons
  • Loading branch information
TheOfficialFloW authored Sep 4, 2016
2 parents 93b7a2b + 41c25be commit 593010c
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 18 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ OBJS = main.o init.o io_process.o package_installer.o archive.o photo.o file
uncommon_dialog.o message_dialog.o ime_dialog.o config.o theme.o language.o utils.o sha1.o \
audioplayer.o minizip/unzip.o minizip/ioapi.o

RESOURCES_PNG = resources/folder_icon.png resources/file_icon.png resources/archive_icon.png resources/image_icon.png resources/ftp.png \
resources/battery.png resources/battery_bar_green.png resources/battery_bar_red.png resources/battery_bar_charge.png \
resources/headphone.png resources/audio_previous.png resources/audio_pause.png resources/audio_play.png \
resources/audio_next.png
RESOURCES_PNG = resources/folder_icon.png resources/file_icon.png resources/archive_icon.png resources/image_icon.png \
resources/audio_icon.png resources/sfo_icon.png resources/text_icon.png\
resources/ftp.png resources/battery.png resources/battery_bar_green.png resources/battery_bar_red.png \
resources/battery_bar_charge.png resources/headphone.png resources/audio_previous.png resources/audio_pause.png \
resources/audio_play.png resources/audio_next.png
RESOURCES_TXT = resources/theme.txt resources/colors.txt resources/english_us.txt
OBJS += $(RESOURCES_PNG:.png=.o) $(RESOURCES_TXT:.txt=.o)

Expand Down
15 changes: 8 additions & 7 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ int WriteFile(char *file, void *buf, int size) {
return written;
}

int getFileSize(char *pInputFileName)
{
SceUID fd = sceIoOpen(pInputFileName, SCE_O_RDONLY, 0);
int getFileSize(char *pInputFileName)
{
SceUID fd = sceIoOpen(pInputFileName, SCE_O_RDONLY, 0);
if (fd < 0)
return fd;

int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);

int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);

sceIoClose(fd);
return fileSize;
sceIoClose(fd);
return fileSize;
}

int getPathInfo(char *path, uint64_t *size, uint32_t *folders, uint32_t *files) {
Expand Down Expand Up @@ -363,6 +363,7 @@ static ExtensionType extension_types[] = {
{ ".SFO", FILE_TYPE_SFO },
{ ".VPK", FILE_TYPE_VPK },
{ ".ZIP", FILE_TYPE_ZIP },
{ ".TXT", FILE_TYPE_TXT },
};

int getFileType(char *file) {
Expand Down
1 change: 1 addition & 0 deletions file.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum FileTypes {
FILE_TYPE_SFO,
FILE_TYPE_VPK,
FILE_TYPE_ZIP,
FILE_TYPE_TXT,
};

enum SortFlags {
Expand Down
9 changes: 9 additions & 0 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ extern unsigned char _binary_resources_archive_icon_png_start;
extern unsigned char _binary_resources_archive_icon_png_size;
extern unsigned char _binary_resources_image_icon_png_start;
extern unsigned char _binary_resources_image_icon_png_size;
extern unsigned char _binary_resources_audio_icon_png_start;
extern unsigned char _binary_resources_audio_icon_png_size;
extern unsigned char _binary_resources_sfo_icon_png_start;
extern unsigned char _binary_resources_sfo_icon_png_size;
extern unsigned char _binary_resources_text_icon_png_start;
extern unsigned char _binary_resources_text_icon_png_size;
extern unsigned char _binary_resources_ftp_png_start;
extern unsigned char _binary_resources_ftp_png_size;
extern unsigned char _binary_resources_battery_png_start;
Expand Down Expand Up @@ -63,6 +69,9 @@ static DefaultFile default_files[] = {
{ "ux0:VitaShell/theme/Default/file_icon.png", (void *)&_binary_resources_file_icon_png_start, (int)&_binary_resources_file_icon_png_size },
{ "ux0:VitaShell/theme/Default/archive_icon.png", (void *)&_binary_resources_archive_icon_png_start, (int)&_binary_resources_archive_icon_png_size },
{ "ux0:VitaShell/theme/Default/image_icon.png", (void *)&_binary_resources_image_icon_png_start, (int)&_binary_resources_image_icon_png_size },
{ "ux0:VitaShell/theme/Default/audio_icon.png", (void *)&_binary_resources_audio_icon_png_start, (int)&_binary_resources_audio_icon_png_size },
{ "ux0:VitaShell/theme/Default/sfo_icon.png", (void *)&_binary_resources_sfo_icon_png_start, (int)&_binary_resources_sfo_icon_png_size },
{ "ux0:VitaShell/theme/Default/text_icon.png", (void *)&_binary_resources_text_icon_png_start, (int)&_binary_resources_text_icon_png_size },
{ "ux0:VitaShell/theme/Default/ftp.png", (void *)&_binary_resources_ftp_png_start, (int)&_binary_resources_ftp_png_size },
{ "ux0:VitaShell/theme/Default/battery.png", (void *)&_binary_resources_battery_png_start, (int)&_binary_resources_battery_png_size },
{ "ux0:VitaShell/theme/Default/battery_bar_red.png", (void *)&_binary_resources_battery_bar_red_png_start, (int)&_binary_resources_battery_bar_red_png_size },
Expand Down
12 changes: 11 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ int handleFile(char *file, FileListEntry *entry) {
}

switch (type) {
case FILE_TYPE_TXT:
case FILE_TYPE_UNKNOWN:
res = textViewer(file);
break;
Expand Down Expand Up @@ -1138,12 +1139,21 @@ int shellMain() {
color = FOLDER_COLOR;
vita2d_draw_texture(folder_icon, SHELL_MARGIN_X, y + 3.0f);
} else {
if (file_entry->type == FILE_TYPE_BMP || file_entry->type == FILE_TYPE_PNG || file_entry->type == FILE_TYPE_JPEG || file_entry->type == FILE_TYPE_MP3) { // Images
if (file_entry->type == FILE_TYPE_BMP || file_entry->type == FILE_TYPE_PNG || file_entry->type == FILE_TYPE_JPEG) { // Images
color = IMAGE_COLOR;
vita2d_draw_texture(image_icon, SHELL_MARGIN_X, y + 3.0f);
} else if (file_entry->type == FILE_TYPE_VPK || file_entry->type == FILE_TYPE_ZIP) { // Archive
color = ARCHIVE_COLOR;
vita2d_draw_texture(archive_icon, SHELL_MARGIN_X, y + 3.0f);
} else if (file_entry->type == FILE_TYPE_MP3) { // Audio
color = IMAGE_COLOR;
vita2d_draw_texture(audio_icon, SHELL_MARGIN_X, y + 3.0f);
} else if (file_entry->type == FILE_TYPE_SFO) { // SFO
// note: specific color to be determined
vita2d_draw_texture(sfo_icon, SHELL_MARGIN_X, y + 3.0f);
} else if (file_entry->type == FILE_TYPE_TXT) { // TXT
// note: specific color to be determined
vita2d_draw_texture(text_icon, SHELL_MARGIN_X, y + 3.0f);
} else { // Other files
vita2d_draw_texture(file_icon, SHELL_MARGIN_X, y + 3.0f);
}
Expand Down
Binary file added resources/audio_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/sfo_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/text_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 25 additions & 3 deletions theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ extern unsigned char _binary_resources_folder_icon_png_start;
extern unsigned char _binary_resources_file_icon_png_start;
extern unsigned char _binary_resources_archive_icon_png_start;
extern unsigned char _binary_resources_image_icon_png_start;
extern unsigned char _binary_resources_audio_icon_png_start;
extern unsigned char _binary_resources_sfo_icon_png_start;
extern unsigned char _binary_resources_text_icon_png_start;
extern unsigned char _binary_resources_ftp_png_start;
extern unsigned char _binary_resources_battery_png_start;
extern unsigned char _binary_resources_battery_bar_red_png_start;
Expand Down Expand Up @@ -55,9 +58,10 @@ int PROGRESS_BAR_BG_COLOR;
int HEX_OFFSET_COLOR;
int HEX_NIBBLE_COLOR;

vita2d_texture *folder_icon = NULL, *file_icon = NULL, *archive_icon = NULL, *image_icon = NULL, *ftp_image = NULL, *dialog_image = NULL, *context_image = NULL,
*battery_image = NULL, *battery_bar_red_image = NULL, *battery_bar_green_image = NULL, *battery_bar_charge_image = NULL,
*bg_browser_image = NULL, *bg_hex_image = NULL, *bg_text_image = NULL, *bg_photo_image = NULL;
vita2d_texture *folder_icon = NULL, *file_icon = NULL, *archive_icon = NULL, *image_icon = NULL, *audio_icon = NULL, *sfo_icon = NULL, *text_icon = NULL,
*ftp_image = NULL, *dialog_image = NULL, *context_image = NULL, *battery_image = NULL, *battery_bar_red_image = NULL,
*battery_bar_green_image = NULL, *battery_bar_charge_image = NULL, *bg_browser_image = NULL, *bg_hex_image = NULL,
*bg_text_image = NULL, *bg_photo_image = NULL;

vita2d_texture *wallpaper_image[MAX_WALLPAPERS];

Expand Down Expand Up @@ -122,6 +126,15 @@ void loadTheme() {
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/image_icon.png", theme_name);
image_icon = vita2d_load_PNG_file(path);

snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/audio_icon.png", theme_name);
audio_icon = vita2d_load_PNG_file(path);

snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/sfo_icon.png", theme_name);
sfo_icon = vita2d_load_PNG_file(path);

snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/text_icon.png", theme_name);
text_icon = vita2d_load_PNG_file(path);

snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/ftp.png", theme_name);
ftp_image = vita2d_load_PNG_file(path);

Expand Down Expand Up @@ -190,6 +203,15 @@ void loadTheme() {
if (!image_icon)
image_icon = vita2d_load_PNG_buffer(&_binary_resources_image_icon_png_start);

if (!audio_icon)
audio_icon = vita2d_load_PNG_buffer(&_binary_resources_audio_icon_png_start);

if (!sfo_icon)
sfo_icon = vita2d_load_PNG_buffer(&_binary_resources_sfo_icon_png_start);

if (!text_icon)
text_icon = vita2d_load_PNG_buffer(&_binary_resources_text_icon_png_start);

if (!ftp_image)
ftp_image = vita2d_load_PNG_buffer(&_binary_resources_ftp_png_start);

Expand Down
6 changes: 3 additions & 3 deletions theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ extern int PROGRESS_BAR_BG_COLOR;
extern int HEX_OFFSET_COLOR;
extern int HEX_NIBBLE_COLOR;

extern vita2d_texture *folder_icon, *file_icon, *archive_icon, *image_icon, *ftp_image, *dialog_image, *context_image,
*battery_image, *battery_bar_red_image, *battery_bar_green_image, *battery_bar_charge_image,
*bg_browser_image, *bg_hex_image, *bg_text_image, *bg_photo_image;
extern vita2d_texture *folder_icon, *file_icon, *archive_icon, *image_icon, *audio_icon, *sfo_icon, *text_icon,
*ftp_image, *dialog_image, *context_image, *battery_image, *battery_bar_red_image, *battery_bar_green_image,
*battery_bar_charge_image, *bg_browser_image, *bg_hex_image, *bg_text_image, *bg_photo_image;

extern vita2d_texture *wallpaper_image[MAX_WALLPAPERS];
extern vita2d_texture *previous_wallpaper_image, *current_wallpaper_image;
Expand Down

0 comments on commit 593010c

Please sign in to comment.