2016-08-27 10:49:03 +00:00
|
|
|
/*
|
|
|
|
VitaShell
|
|
|
|
Copyright (C) 2015-2016, TheFloW
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "main.h"
|
2016-08-28 14:36:27 +00:00
|
|
|
#include "file.h"
|
2016-08-27 10:49:03 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "theme.h"
|
2016-09-03 20:14:07 +00:00
|
|
|
#include "utils.h"
|
2016-08-27 10:49:03 +00:00
|
|
|
|
2016-09-03 19:04:38 +00:00
|
|
|
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;
|
2016-09-03 21:35:34 +00:00
|
|
|
extern unsigned char _binary_resources_audio_icon_png_start;
|
|
|
|
extern unsigned char _binary_resources_sfo_icon_png_start;
|
2016-09-03 22:08:22 +00:00
|
|
|
extern unsigned char _binary_resources_text_icon_png_start;
|
2016-08-28 14:36:27 +00:00
|
|
|
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;
|
|
|
|
extern unsigned char _binary_resources_battery_bar_green_png_start;
|
2016-09-03 19:24:37 +00:00
|
|
|
extern unsigned char _binary_resources_battery_bar_charge_png_start;
|
2016-08-28 14:36:27 +00:00
|
|
|
|
2016-08-27 10:49:03 +00:00
|
|
|
extern unsigned char _binary_resources_colors_txt_start;
|
|
|
|
extern unsigned char _binary_resources_colors_txt_size;
|
|
|
|
|
2016-09-08 20:09:31 +00:00
|
|
|
// Shell colors
|
2016-08-27 10:49:03 +00:00
|
|
|
int BACKGROUND_COLOR;
|
|
|
|
int TITLE_COLOR;
|
|
|
|
int PATH_COLOR;
|
|
|
|
int DATE_TIME_COLOR;
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// File browser colors
|
2016-08-27 10:49:03 +00:00
|
|
|
int FOCUS_COLOR;
|
2016-09-07 20:36:37 +00:00
|
|
|
int FILE_COLOR;
|
2016-09-09 17:50:19 +00:00
|
|
|
int SFO_COLOR;
|
|
|
|
int TXT_COLOR;
|
2016-08-27 10:49:03 +00:00
|
|
|
int FOLDER_COLOR;
|
|
|
|
int IMAGE_COLOR;
|
|
|
|
int ARCHIVE_COLOR;
|
|
|
|
int SCROLL_BAR_COLOR;
|
|
|
|
int SCROLL_BAR_BG_COLOR;
|
|
|
|
int MARKED_COLOR;
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Context menu colors
|
|
|
|
int CONTEXT_MENU_TEXT_COLOR;
|
|
|
|
int CONTEXT_MENU_FOCUS_COLOR;
|
2016-08-27 10:49:03 +00:00
|
|
|
int CONTEXT_MENU_COLOR;
|
2016-09-07 20:36:37 +00:00
|
|
|
int CONTEXT_MENU_MORE_COLOR;
|
2016-09-08 20:09:31 +00:00
|
|
|
int INVISIBLE_COLOR;
|
|
|
|
|
|
|
|
// Dialog colors
|
|
|
|
int DIALOG_COLOR;
|
|
|
|
int DIALOG_BG_COLOR;
|
2016-08-27 10:49:03 +00:00
|
|
|
int PROGRESS_BAR_COLOR;
|
|
|
|
int PROGRESS_BAR_BG_COLOR;
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Hex editor colors
|
|
|
|
int HEX_COLOR;
|
2016-08-27 10:49:03 +00:00
|
|
|
int HEX_OFFSET_COLOR;
|
|
|
|
int HEX_NIBBLE_COLOR;
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Text editor colors
|
|
|
|
int TEXT_COLOR;
|
|
|
|
int TEXT_FOCUS_COLOR;
|
2016-09-07 18:53:10 +00:00
|
|
|
int TEXT_LINE_NUMBER_COLOR;
|
|
|
|
int TEXT_LINE_NUMBER_COLOR_FOCUS;
|
2016-09-08 18:49:26 +00:00
|
|
|
int TEXT_HIGHLIGHT_COLOR;
|
2016-08-27 10:49:03 +00:00
|
|
|
|
2016-09-08 20:09:31 +00:00
|
|
|
// Photo viewer colors
|
|
|
|
int PHOTO_ZOOM_COLOR;
|
|
|
|
|
2016-09-03 22:08:22 +00:00
|
|
|
vita2d_texture *folder_icon = NULL, *file_icon = NULL, *archive_icon = NULL, *image_icon = NULL, *audio_icon = NULL, *sfo_icon = NULL, *text_icon = NULL,
|
2016-09-07 20:36:37 +00:00
|
|
|
*ftp_image = NULL, *dialog_image = NULL, *context_image = NULL, *context_more_image = NULL, *battery_image = NULL, *battery_bar_red_image = NULL,
|
2016-09-03 21:35:34 +00:00
|
|
|
*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;
|
2016-08-28 14:36:27 +00:00
|
|
|
|
|
|
|
vita2d_texture *wallpaper_image[MAX_WALLPAPERS];
|
|
|
|
|
|
|
|
vita2d_texture *previous_wallpaper_image = NULL, *current_wallpaper_image = NULL;
|
|
|
|
|
|
|
|
int wallpaper_count = 0;
|
2016-08-27 10:49:03 +00:00
|
|
|
|
|
|
|
void loadTheme() {
|
|
|
|
#define COLOR_ENTRY(name) { #name, CONFIG_TYPE_HEXDECIMAL, (void *)&name }
|
|
|
|
ConfigEntry colors_entries[] = {
|
2016-09-08 20:09:31 +00:00
|
|
|
// Shell colors
|
2016-08-27 10:49:03 +00:00
|
|
|
COLOR_ENTRY(BACKGROUND_COLOR),
|
|
|
|
COLOR_ENTRY(TITLE_COLOR),
|
|
|
|
COLOR_ENTRY(PATH_COLOR),
|
|
|
|
COLOR_ENTRY(DATE_TIME_COLOR),
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// File browser colors
|
2016-08-27 10:49:03 +00:00
|
|
|
COLOR_ENTRY(FOCUS_COLOR),
|
2016-09-07 20:36:37 +00:00
|
|
|
COLOR_ENTRY(FILE_COLOR),
|
2016-09-09 17:50:19 +00:00
|
|
|
COLOR_ENTRY(SFO_COLOR),
|
|
|
|
COLOR_ENTRY(TXT_COLOR),
|
2016-08-27 10:49:03 +00:00
|
|
|
COLOR_ENTRY(FOLDER_COLOR),
|
|
|
|
COLOR_ENTRY(IMAGE_COLOR),
|
|
|
|
COLOR_ENTRY(ARCHIVE_COLOR),
|
|
|
|
COLOR_ENTRY(SCROLL_BAR_COLOR),
|
|
|
|
COLOR_ENTRY(SCROLL_BAR_BG_COLOR),
|
|
|
|
COLOR_ENTRY(MARKED_COLOR),
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Context menu colors
|
|
|
|
COLOR_ENTRY(CONTEXT_MENU_TEXT_COLOR),
|
|
|
|
COLOR_ENTRY(CONTEXT_MENU_FOCUS_COLOR),
|
2016-08-27 10:49:03 +00:00
|
|
|
COLOR_ENTRY(CONTEXT_MENU_COLOR),
|
2016-09-07 20:36:37 +00:00
|
|
|
COLOR_ENTRY(CONTEXT_MENU_MORE_COLOR),
|
2016-09-08 20:09:31 +00:00
|
|
|
COLOR_ENTRY(INVISIBLE_COLOR),
|
|
|
|
|
|
|
|
// Dialog colors
|
|
|
|
COLOR_ENTRY(DIALOG_COLOR),
|
|
|
|
COLOR_ENTRY(DIALOG_BG_COLOR),
|
2016-08-27 10:49:03 +00:00
|
|
|
COLOR_ENTRY(PROGRESS_BAR_COLOR),
|
|
|
|
COLOR_ENTRY(PROGRESS_BAR_BG_COLOR),
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Hex editor colors
|
|
|
|
COLOR_ENTRY(HEX_COLOR),
|
2016-08-27 10:49:03 +00:00
|
|
|
COLOR_ENTRY(HEX_OFFSET_COLOR),
|
|
|
|
COLOR_ENTRY(HEX_NIBBLE_COLOR),
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Text editor colors
|
|
|
|
COLOR_ENTRY(TEXT_COLOR),
|
|
|
|
COLOR_ENTRY(TEXT_FOCUS_COLOR),
|
2016-09-07 18:53:10 +00:00
|
|
|
COLOR_ENTRY(TEXT_LINE_NUMBER_COLOR),
|
|
|
|
COLOR_ENTRY(TEXT_LINE_NUMBER_COLOR_FOCUS),
|
2016-09-08 18:49:26 +00:00
|
|
|
COLOR_ENTRY(TEXT_HIGHLIGHT_COLOR),
|
2016-09-08 20:09:31 +00:00
|
|
|
|
|
|
|
// Photo viewer colors
|
|
|
|
COLOR_ENTRY(PHOTO_ZOOM_COLOR),
|
2016-08-27 10:49:03 +00:00
|
|
|
};
|
|
|
|
|
2016-08-27 17:16:39 +00:00
|
|
|
// Load default config file
|
|
|
|
readConfigBuffer(&_binary_resources_colors_txt_start, (int)&_binary_resources_colors_txt_size, colors_entries, sizeof(colors_entries) / sizeof(ConfigEntry));
|
2016-08-27 10:49:03 +00:00
|
|
|
|
2016-08-27 17:16:39 +00:00
|
|
|
// Load custom config file
|
2016-08-27 10:49:03 +00:00
|
|
|
if (use_custom_config) {
|
2016-08-28 14:36:27 +00:00
|
|
|
char path[MAX_PATH_LENGTH];
|
|
|
|
|
|
|
|
char *theme_name = NULL;
|
|
|
|
ConfigEntry theme_entries[] = {
|
|
|
|
{ "THEME_NAME", CONFIG_TYPE_STRING, (void *)&theme_name },
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load theme config
|
|
|
|
readConfig("ux0:VitaShell/theme/theme.txt", theme_entries, sizeof(theme_entries) / sizeof(ConfigEntry));
|
|
|
|
|
|
|
|
if (theme_name) {
|
|
|
|
// Load colors config
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/colors.txt", theme_name);
|
|
|
|
readConfig(path, colors_entries, sizeof(colors_entries) / sizeof(ConfigEntry));
|
|
|
|
|
|
|
|
// Load pngs
|
2016-09-03 19:04:38 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/folder_icon.png", theme_name);
|
|
|
|
folder_icon = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/file_icon.png", theme_name);
|
|
|
|
file_icon = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/archive_icon.png", theme_name);
|
|
|
|
archive_icon = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/image_icon.png", theme_name);
|
|
|
|
image_icon = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-09-03 21:35:34 +00:00
|
|
|
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);
|
|
|
|
|
2016-09-03 22:08:22 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/text_icon.png", theme_name);
|
|
|
|
text_icon = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-08-28 14:36:27 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/ftp.png", theme_name);
|
|
|
|
ftp_image = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/dialog.png", theme_name);
|
|
|
|
dialog_image = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/context.png", theme_name);
|
|
|
|
context_image = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-09-07 20:36:37 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/context_more.png", theme_name);
|
|
|
|
context_more_image = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-08-28 14:36:27 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/battery.png", theme_name);
|
|
|
|
battery_image = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/battery_bar_red.png", theme_name);
|
|
|
|
battery_bar_red_image = vita2d_load_PNG_file(path);
|
|
|
|
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/battery_bar_green.png", theme_name);
|
|
|
|
battery_bar_green_image = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-09-03 19:24:37 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/battery_bar_charge.png", theme_name);
|
|
|
|
battery_bar_charge_image = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-09-03 20:14:07 +00:00
|
|
|
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);
|
|
|
|
|
2016-09-03 20:21:12 +00:00
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/bg_photoviewer.png", theme_name);
|
2016-09-03 20:14:07 +00:00
|
|
|
bg_photo_image = vita2d_load_PNG_file(path);
|
|
|
|
|
2016-08-28 14:36:27 +00:00
|
|
|
// Wallpapers
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/wallpaper.png", theme_name);
|
|
|
|
vita2d_texture *image = vita2d_load_PNG_file(path);
|
|
|
|
if (image)
|
|
|
|
wallpaper_image[wallpaper_count++] = image;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 1; i < MAX_WALLPAPERS; i++) {
|
|
|
|
snprintf(path, MAX_PATH_LENGTH, "ux0:VitaShell/theme/%s/wallpaper%d.png", theme_name, i + 1);
|
|
|
|
vita2d_texture *image = vita2d_load_PNG_file(path);
|
|
|
|
if (image)
|
|
|
|
wallpaper_image[wallpaper_count++] = image;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set random wallpaper
|
2016-09-03 20:14:07 +00:00
|
|
|
if (wallpaper_count > 0) {
|
|
|
|
int random_num = randomNumber(0, wallpaper_count - 1);
|
|
|
|
current_wallpaper_image = wallpaper_image[random_num];
|
|
|
|
}
|
2016-08-28 14:36:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load default pngs
|
2016-09-03 19:04:38 +00:00
|
|
|
if (!folder_icon)
|
|
|
|
folder_icon = vita2d_load_PNG_buffer(&_binary_resources_folder_icon_png_start);
|
|
|
|
|
|
|
|
if (!file_icon)
|
|
|
|
file_icon = vita2d_load_PNG_buffer(&_binary_resources_file_icon_png_start);
|
|
|
|
|
|
|
|
if (!archive_icon)
|
|
|
|
archive_icon = vita2d_load_PNG_buffer(&_binary_resources_archive_icon_png_start);
|
|
|
|
|
|
|
|
if (!image_icon)
|
|
|
|
image_icon = vita2d_load_PNG_buffer(&_binary_resources_image_icon_png_start);
|
|
|
|
|
2016-09-03 21:35:34 +00:00
|
|
|
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);
|
|
|
|
|
2016-09-03 22:08:22 +00:00
|
|
|
if (!text_icon)
|
|
|
|
text_icon = vita2d_load_PNG_buffer(&_binary_resources_text_icon_png_start);
|
|
|
|
|
2016-08-28 14:36:27 +00:00
|
|
|
if (!ftp_image)
|
|
|
|
ftp_image = vita2d_load_PNG_buffer(&_binary_resources_ftp_png_start);
|
|
|
|
|
2016-09-03 20:14:07 +00:00
|
|
|
if (!dialog_image) {
|
|
|
|
dialog_image = vita2d_create_empty_texture(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
|
|
void *data = vita2d_texture_get_datap(dialog_image);
|
2016-08-28 14:36:27 +00:00
|
|
|
|
2016-09-03 20:14:07 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-28 14:36:27 +00:00
|
|
|
|
2016-09-07 20:36:37 +00:00
|
|
|
if (!context_more_image) {
|
|
|
|
context_more_image = vita2d_create_empty_texture(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
|
|
void *data = vita2d_texture_get_datap(context_more_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_MORE_COLOR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:36:27 +00:00
|
|
|
if (!battery_image)
|
|
|
|
battery_image = vita2d_load_PNG_buffer(&_binary_resources_battery_png_start);
|
|
|
|
|
|
|
|
if (!battery_bar_red_image)
|
|
|
|
battery_bar_red_image = vita2d_load_PNG_buffer(&_binary_resources_battery_bar_red_png_start);
|
|
|
|
|
|
|
|
if (!battery_bar_green_image)
|
|
|
|
battery_bar_green_image = vita2d_load_PNG_buffer(&_binary_resources_battery_bar_green_png_start);
|
2016-09-03 19:24:37 +00:00
|
|
|
|
|
|
|
if (!battery_bar_charge_image)
|
|
|
|
battery_bar_charge_image = vita2d_load_PNG_buffer(&_binary_resources_battery_bar_charge_png_start);
|
2016-08-27 10:49:03 +00:00
|
|
|
}
|