Fixed some stuff.

This commit is contained in:
TheFloW 2016-09-03 22:14:07 +02:00
parent 9d1b3a420b
commit 6783b874a8
14 changed files with 83 additions and 53 deletions

View File

@ -4,7 +4,7 @@ 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/dialog.png resources/context.png \
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

View File

@ -428,7 +428,7 @@ int audioPlayer(char *file, FileList *list, FileListEntry *entry, int *base_pos,
}
// Start drawing
startDrawing();
startDrawing(NULL);
int nameLength = strlen(entry->name);
vita2d_pgf_draw_text(font, SCREEN_WIDTH / 2 - nameLength * 5.5, SCREEN_HEIGHT - 190, GENERAL_COLOR, 1.0f, entry->name);

2
hex.c
View File

@ -292,7 +292,7 @@ int hexViewer(char *file) {
}
// Start drawing
startDrawing();
startDrawing(bg_hex_image);
// Draw shell info
drawShellInfo(file);

6
init.c
View File

@ -31,10 +31,6 @@ extern unsigned char _binary_resources_image_icon_png_start;
extern unsigned char _binary_resources_image_icon_png_size;
extern unsigned char _binary_resources_ftp_png_start;
extern unsigned char _binary_resources_ftp_png_size;
extern unsigned char _binary_resources_dialog_png_start;
extern unsigned char _binary_resources_dialog_png_size;
extern unsigned char _binary_resources_context_png_start;
extern unsigned char _binary_resources_context_png_size;
extern unsigned char _binary_resources_battery_png_start;
extern unsigned char _binary_resources_battery_png_size;
extern unsigned char _binary_resources_battery_bar_red_png_start;
@ -68,8 +64,6 @@ static DefaultFile default_files[] = {
{ "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/ftp.png", (void *)&_binary_resources_ftp_png_start, (int)&_binary_resources_ftp_png_size },
{ "ux0:VitaShell/theme/Default/dialog.png", (void *)&_binary_resources_dialog_png_start, (int)&_binary_resources_dialog_png_size },
{ "ux0:VitaShell/theme/Default/context.png", (void *)&_binary_resources_context_png_start, (int)&_binary_resources_context_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 },
{ "ux0:VitaShell/theme/Default/battery_bar_green.png", (void *)&_binary_resources_battery_bar_green_png_start, (int)&_binary_resources_battery_bar_green_png_size },

20
main.c
View File

@ -1117,7 +1117,7 @@ int shellMain() {
}
// Start drawing
startDrawing();
startDrawing(bg_browser_image);
// Draw shell info
drawShellInfo(file_list.path);
@ -1137,20 +1137,16 @@ int shellMain() {
if (file_entry->is_folder) {
color = FOLDER_COLOR;
vita2d_draw_texture(folder_icon, SHELL_MARGIN_X, y + 3.0f);
}
// Images
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) {
color = IMAGE_COLOR;
vita2d_draw_texture(image_icon, SHELL_MARGIN_X, y + 3.0f);
}
// Archives
else if (!isInArchive()) {
if (file_entry->type == FILE_TYPE_VPK || file_entry->type == FILE_TYPE_ZIP) {
} 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
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 { // Other files
vita2d_draw_texture(file_icon, SHELL_MARGIN_X, y + 3.0f);
}
// Other file
else vita2d_draw_texture(file_icon, SHELL_MARGIN_X, y + 3.0f);
}
// Current position

View File

@ -345,7 +345,7 @@ int photoViewer(char *file, int type, FileList *list, FileListEntry *entry, int
}
// Start drawing
startDrawing();
startDrawing(bg_photo_image);
// Photo
vita2d_draw_texture_scale_rotate_hotspot(tex, SCREEN_HALF_WIDTH, SCREEN_HALF_HEIGHT, zoom, zoom, rad, x, y);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

6
sfo.c
View File

@ -79,7 +79,7 @@ int SFOReader(char *file) {
}
// Start drawing
startDrawing();
startDrawing(bg_text_image);
// Draw shell info
drawShellInfo(file);
@ -104,11 +104,11 @@ int SFOReader(char *file) {
break;
case PSF_TYPE_STR:
snprintf(string, sizeof(string), "%s", data);
snprintf(string, sizeof(string), "%s", (char *)data);
break;
case PSF_TYPE_VAL:
snprintf(string, sizeof(string), "%X", *(uint32_t *)data);
snprintf(string, sizeof(string), "%X", *(unsigned int *)data);
break;
}

2
text.c
View File

@ -247,7 +247,7 @@ int textViewer(char *file) {
}
// Start drawing
startDrawing();
startDrawing(bg_text_image);
// Draw shell info
drawShellInfo(file);

52
theme.c
View File

@ -20,14 +20,13 @@
#include "file.h"
#include "config.h"
#include "theme.h"
#include "utils.h"
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_ftp_png_start;
extern unsigned char _binary_resources_dialog_png_start;
extern unsigned char _binary_resources_context_png_start;
extern unsigned char _binary_resources_battery_png_start;
extern unsigned char _binary_resources_battery_bar_red_png_start;
extern unsigned char _binary_resources_battery_bar_green_png_start;
@ -57,7 +56,8 @@ 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;
*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];
@ -143,6 +143,18 @@ void loadTheme() {
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/battery_bar_charge.png", theme_name);
battery_bar_charge_image = vita2d_load_PNG_file(path);
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/bg_browser.png", theme_name);
bg_browser_image = vita2d_load_PNG_file(path);
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/bg_hexeditor.png", theme_name);
bg_hex_image = vita2d_load_PNG_file(path);
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/bg_texteditor.png", theme_name);
bg_text_image = vita2d_load_PNG_file(path);
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/bg_photo.png", theme_name);
bg_photo_image = vita2d_load_PNG_file(path);
// Wallpapers
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/wallpaper.png", theme_name);
vita2d_texture *image = vita2d_load_PNG_file(path);
@ -158,8 +170,10 @@ void loadTheme() {
}
// Set random wallpaper
int random_num = randomNumber(0, wallpaper_count - 1);
current_wallpaper_image = wallpaper_image[random_num];
if (wallpaper_count > 0) {
int random_num = randomNumber(0, wallpaper_count - 1);
current_wallpaper_image = wallpaper_image[random_num];
}
}
}
@ -179,11 +193,31 @@ void loadTheme() {
if (!ftp_image)
ftp_image = vita2d_load_PNG_buffer(&_binary_resources_ftp_png_start);
if (!dialog_image)
dialog_image = vita2d_load_PNG_buffer(&_binary_resources_dialog_png_start);
if (!dialog_image) {
dialog_image = vita2d_create_empty_texture(SCREEN_WIDTH, SCREEN_HEIGHT);
void *data = vita2d_texture_get_datap(dialog_image);
if (!context_image)
context_image = vita2d_load_PNG_buffer(&_binary_resources_context_png_start);
int y;
for (y = 0; y < SCREEN_HEIGHT; y++) {
int x;
for (x = 0; x < SCREEN_WIDTH; x++) {
((uint32_t *)data)[x + SCREEN_WIDTH * y] = DIALOG_BG_COLOR;
}
}
}
if (!context_image) {
context_image = vita2d_create_empty_texture(SCREEN_WIDTH, SCREEN_HEIGHT);
void *data = vita2d_texture_get_datap(context_image);
int y;
for (y = 0; y < SCREEN_HEIGHT; y++) {
int x;
for (x = 0; x < SCREEN_WIDTH; x++) {
((uint32_t *)data)[x + SCREEN_WIDTH * y] = CONTEXT_MENU_COLOR;
}
}
}
if (!battery_image)
battery_image = vita2d_load_PNG_buffer(&_binary_resources_battery_png_start);

View File

@ -42,7 +42,8 @@ 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;
*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;

37
utils.c
View File

@ -37,30 +37,35 @@ static uint64_t wallpaper_time_start = 0;
static int wallpaper_random_delay = 0;
static float wallpaper_alpha = 255.0f;
void startDrawing() {
void startDrawing(vita2d_texture *bg) {
vita2d_start_drawing();
vita2d_set_clear_color(BACKGROUND_COLOR);
vita2d_clear_screen();
if (wallpaper_time_start == 0) {
wallpaper_time_start = sceKernelGetProcessTimeWide();
wallpaper_random_delay = randomNumber(15, 30);
}
// Background image
if (bg)
vita2d_draw_texture(bg, 0.0f, 0.0f);
if ((sceKernelGetProcessTimeWide() - wallpaper_time_start) >= (wallpaper_random_delay * 1000 * 1000)) {
int random_num = randomNumber(0, wallpaper_count - 1);
vita2d_texture *random_wallpaper_image = wallpaper_image[random_num];
if (random_wallpaper_image != current_wallpaper_image) {
previous_wallpaper_image = current_wallpaper_image;
current_wallpaper_image = random_wallpaper_image;
wallpaper_alpha = 0.0f;
// Wallpaper
if (current_wallpaper_image) {
if (wallpaper_time_start == 0) {
wallpaper_time_start = sceKernelGetProcessTimeWide();
wallpaper_random_delay = randomNumber(15, 30);
}
wallpaper_time_start = 0;
}
if ((sceKernelGetProcessTimeWide() - wallpaper_time_start) >= (wallpaper_random_delay * 1000 * 1000)) {
int random_num = randomNumber(0, wallpaper_count - 1);
vita2d_texture *random_wallpaper_image = wallpaper_image[random_num];
if (random_wallpaper_image != current_wallpaper_image) {
previous_wallpaper_image = current_wallpaper_image;
current_wallpaper_image = random_wallpaper_image;
wallpaper_alpha = 0.0f;
}
wallpaper_time_start = 0;
}
if (current_wallpaper_image) {
if (previous_wallpaper_image) {
vita2d_draw_texture(previous_wallpaper_image, 0.0f, 0.0f);
}

View File

@ -50,7 +50,7 @@ enum {
extern SceCtrlData pad;
extern uint32_t old_buttons, current_buttons, pressed_buttons, hold_buttons, hold2_buttons, released_buttons;
void startDrawing();
void startDrawing(vita2d_texture *bg);
void endDrawing();
void errorDialog(int error);