Citro2d switch (#175)

* Switch from pp2d to citro2d

* Fix various bugs by updating libarchive

* Begin work on translation infrastructure

* Switch to libpng for various improvements

* Fixed race condition in icon scrolling

* Use spritesheets to load sprites marginally faster and use less memory

* Various Readme fixes

* Huge improvements to QR reader speed and screen tearing

* Don't try to preview themes/splashes when there are none

* Prevent playing audio when ndspInit() fails

* Don't wait for audio to load before displaying preview

* Fix bug when shuffle themes didn't have BGM

* Fix bug caused by files not being zeroed out when created
This commit is contained in:
Alex Taber
2018-07-22 21:22:23 +03:00
committed by GitHub
parent aa3a00cedc
commit c40696e982
48 changed files with 1219 additions and 9887 deletions

View File

@@ -31,7 +31,8 @@
typedef struct {
u16 *camera_buffer;
u32 *texture_buffer;
C2D_Image image;
C3D_Tex *tex;
Handle mutex;
volatile bool finished;
volatile bool success;

View File

@@ -27,17 +27,23 @@
#ifndef COLORS_H
#define COLORS_H
#define ABGR8(a, b, g, r) ((((a)&0xFF)<<0) | (((b)&0xFF)<<8) | (((g)&0xFF)<<16) | (((r)&0xFF)<<24))
#define RGBA8(r, g, b, a) ((((r)&0xFF)<<0) | (((g)&0xFF)<<8) | (((b)&0xFF)<<16) | (((a)&0xFF)<<24))
#include "common.h"
typedef enum {
COLOR_BACKGROUND = ABGR8(255, 32, 28, 35), //silver-y black
COLOR_ACCENT = RGBA8(55, 122, 168, 255),
COLOR_WHITE = RGBA8(255, 255, 255, 255),
COLOR_CURSOR = RGBA8(200, 200, 200, 255),
COLOR_BLACK = RGBA8(0, 0, 0, 255),
COLOR_RED = RGBA8(200, 0, 0, 255),
COLOR_YELLOW = RGBA8(239, 220, 11, 255),
} Color;
typedef u32 Color;
enum {
COLOR_BACKGROUND, //silver-y black
COLOR_ACCENT,
COLOR_WHITE,
COLOR_CURSOR,
COLOR_BLACK,
COLOR_RED,
COLOR_YELLOW,
COLOR_AMOUNT,
} Colors_e;
extern Color colors[COLOR_AMOUNT];
void init_colors(void);
#endif

View File

@@ -28,6 +28,8 @@
#define COMMON_H
#include <3ds.h>
#include <citro3d.h>
#include <citro2d.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,7 +42,7 @@
POS(); \
DEBUG(__VA_ARGS__)
#define FASTSCROLL_WAIT 1.5e8
#define FASTSCROLL_WAIT 1e8
typedef enum {
MODE_THEMES = 0,
@@ -54,36 +56,6 @@ extern const int entries_per_screen_v[MODE_AMOUNT];
extern const int entries_per_screen_h[MODE_AMOUNT];
extern const int entry_size[MODE_AMOUNT];
extern bool quit;
enum TextureID {
TEXTURE_FONT_RESERVED = 0, // used by pp2d for the font
TEXTURE_ARROW,
TEXTURE_ARROW_SIDE,
TEXTURE_SHUFFLE,
TEXTURE_SHUFFLE_NO_BGM,
TEXTURE_INSTALLED,
TEXTURE_PREVIEW_ICON,
TEXTURE_SORT,
TEXTURE_DOWNLOAD,
TEXTURE_BROWSE,
TEXTURE_LIST,
TEXTURE_EXIT,
TEXTURE_BATTERY_0,
TEXTURE_BATTERY_1,
TEXTURE_BATTERY_2,
TEXTURE_BATTERY_3,
TEXTURE_BATTERY_4,
TEXTURE_BATTERY_5,
TEXTURE_BATTERY_CHARGE,
TEXTURE_QR,
TEXTURE_PREVIEW,
TEXTURE_REMOTE_PREVIEW,
TEXTURE_SELECT_BUTTON,
TEXTURE_START_BUTTON,
// always the last
TEXTURE_REMOTE_ICONS,
TEXTURE_ICON = TEXTURE_REMOTE_ICONS + 24,
};
extern bool dspfirm;
#endif

View File

@@ -31,6 +31,8 @@
#include "loading.h"
#include "colors.h"
#define MAX_LINES 10
typedef enum {
INSTALL_LOADING_THEMES,
INSTALL_LOADING_SPLASHES,
@@ -56,6 +58,63 @@ typedef enum {
INSTALL_NONE,
} InstallType;
typedef enum {
// InstallType text
TEXT_INSTALL_LOADING_THEMES,
TEXT_INSTALL_LOADING_SPLASHES,
TEXT_INSTALL_LOADING_ICONS,
TEXT_INSTALL_SPLASH,
TEXT_INSTALL_SPLASH_DELETE,
TEXT_INSTALL_SINGLE,
TEXT_INSTALL_SHUFFLE,
TEXT_INSTALL_BGM,
TEXT_INSTALL_NO_BGM,
TEXT_INSTALL_DOWNLOAD,
TEXT_INSTALL_CHECKING_DOWNLOAD,
TEXT_INSTALL_ENTRY_DELETE,
TEXT_INSTALL_LOADING_REMOTE_THEMES,
TEXT_INSTALL_LOADING_REMOTE_SPLASHES,
TEXT_INSTALL_LOADING_REMOTE_PREVIEW,
TEXT_INSTALL_LOADING_REMOTE_BGM,
// Other text
TEXT_VERSION,
TEXT_THEME_MODE,
TEXT_SPLASH_MODE,
TEXT_NO_THEME_FOUND,
TEXT_NO_SPLASH_FOUND,
TEXT_DOWNLOAD_FROM_QR,
TEXT_SWITCH_TO_SPLASHES,
TEXT_SWITCH_TO_THEMES,
TEXT_OR_START_TO_QUIT,
TEXT_BY_AUTHOR,
TEXT_SELECTED,
TEXT_SELECTED_SHORT,
TEXT_THEMEPLAZA_THEME_MODE,
TEXT_THEMEPLAZA_SPLASH_MODE,
TEXT_SEARCH,
TEXT_PAGE,
TEXT_ERROR_QUIT,
TEXT_ERROR_CONTINUE,
TEXT_CONFIRM_YES_NO,
TEXT_AMOUNT
} Text;
typedef enum {
ERROR_LEVEL_ERROR,
ERROR_LEVEL_WARNING,
@@ -76,25 +135,40 @@ enum {
BUTTONS_X_LEFT = 20,
BUTTONS_X_RIGHT = 200,
BUTTONS_X_MAX = 380,
} ButtonPos;
typedef struct {
const wchar_t * info_line;
Color info_line_color;
const wchar_t * instructions[BUTTONS_INFO_LINES][BUTTONS_INFO_COLUNMNS];
const char * info_line;
const char * instructions[BUTTONS_INFO_LINES][BUTTONS_INFO_COLUNMNS];
} Instructions_s;
extern C3D_RenderTarget* top;
extern C3D_RenderTarget* bottom;
extern C2D_TextBuf staticBuf, dynamicBuf;
extern C2D_Text text[TEXT_AMOUNT];
void init_screens(void);
void exit_screens(void);
void start_frame(void);
void end_frame(void);
void set_screen(C3D_RenderTarget * screen);
void throw_error(char* error, ErrorLevel level);
bool draw_confirm(const char* conf_msg, Entry_List_s* list);
void draw_preview(ssize_t previewID, int preview_offset);
void draw_preview(C2D_Image preview, int preview_offset);
void draw_install(InstallType type);
void draw_loading_bar(u32 current, u32 max, InstallType type);
void draw_text(float x, float y, float z, float scaleX, float scaleY, Color color, const char * text);
void draw_text_wrap(float x, float y, float z, float scaleX, float scaleY, Color color, const char * text, float max_width);
void draw_text_wrap_scaled(float x, float y, float z, Color color, const char * text, float max_scale, float min_scale, float max_width);
void draw_text_center(gfxScreen_t target, float y, float z, float scaleX, float scaleY, Color color, const char * text);
void draw_base_interface(void);
void draw_grid_interface(Entry_List_s* list, Instructions_s instructions);
void draw_interface(Entry_List_s* list, Instructions_s instructions);

View File

@@ -35,20 +35,20 @@ Instructions_s normal_instructions[MODE_AMOUNT] = {
.info_line = NULL,
.instructions = {
{
L"\uE000 Hold to install",
L"\uE001 Queue shuffle theme"
"\uE000 Hold to install",
"\uE001 Queue shuffle theme"
},
{
L"\uE002 Hold for more",
L"\uE003 Preview theme"
"\uE002 Hold for more",
"\uE003 Preview theme"
},
{
L"\uE004 Switch to splashes",
L"\uE005 Scan QR code"
"\uE004 Switch to splashes",
"\uE005 Scan QR code"
},
{
L"Exit",
L"Delete from SD"
"Exit",
"Delete from SD"
}
}
},
@@ -56,43 +56,42 @@ Instructions_s normal_instructions[MODE_AMOUNT] = {
.info_line = NULL,
.instructions = {
{
L"\uE000 Install splash",
L"\uE001 Delete installed splash"
"\uE000 Install splash",
"\uE001 Delete installed splash"
},
{
L"\uE002 Hold for more",
L"\uE003 Preview splash"
"\uE002 Hold for more",
"\uE003 Preview splash"
},
{
L"\uE004 Switch to themes",
L"\uE005 Scan QR code"
"\uE004 Switch to themes",
"\uE005 Scan QR code"
},
{
L"Exit",
L"Delete from SD"
"Exit",
"Delete from SD"
}
}
}
};
Instructions_s install_instructions = {
.info_line = L"Release \uE000 to cancel or hold \uE006 and release \uE000 to install",
.info_line_color = COLOR_WHITE,
.info_line = "Release \uE000 to cancel or hold \uE006 and release \uE000 to install",
.instructions = {
{
L"\uE079 Normal install",
L"\uE07A Shuffle install"
"\uE079 Normal install",
"\uE07A Shuffle install"
},
{
L"\uE07B BGM-only install",
L"\uE07C No-BGM install"
"\uE07B BGM-only install",
"\uE07C No-BGM install"
},
{
NULL,
NULL
},
{
L"Exit",
"Exit",
NULL
}
}
@@ -100,15 +99,14 @@ Instructions_s install_instructions = {
Instructions_s extra_instructions[3] = {
{
.info_line = L"Release \uE002 to cancel or hold \uE006 and release \uE002 to sort",
.info_line_color = COLOR_WHITE,
.info_line = "Release \uE002 to cancel or hold \uE006 and release \uE002 to sort",
.instructions = {
{
L"\uE079 Sort by name",
L"\uE07A Sort by author"
"\uE079 Sort by name",
"\uE07A Sort by author"
},
{
L"\uE07B Sort by filename",
"\uE07B Sort by filename",
NULL
},
{
@@ -116,29 +114,28 @@ Instructions_s extra_instructions[3] = {
NULL
},
{
L"Exit",
"Exit",
NULL
}
}
},
{
.info_line = L"Release \uE002 to cancel or hold \uE006 and release \uE002 to do stuff",
.info_line_color = COLOR_WHITE,
.info_line = "Release \uE002 to cancel or hold \uE006 and release \uE002 to do stuff",
.instructions = {
{
L"\uE079 Jump in the list",
L"\uE07A Reload broken icons"
"\uE079 Jump in the list",
"\uE07A Reload broken icons"
},
{
L"\uE07B Browse ThemePlaza",
"\uE07B Browse ThemePlaza",
NULL,
},
{
L"\uE004 Sorting menu",
"\uE004 Sorting menu",
NULL
},
{
L"Exit",
"Exit",
NULL
}
}

View File

@@ -81,8 +81,7 @@ typedef struct {
Entry_s * entries;
int entries_count;
ssize_t texture_id_offset;
ssize_t * icons_ids;
C2D_Image ** icons;
int previous_scroll;
int scroll;
@@ -110,13 +109,18 @@ typedef struct {
volatile bool run_thread;
} Thread_Arg_s;
C2D_Image * loadTextureIcon(Icon_s *icon);
void parse_smdh(Icon_s *icon, Entry_s * entry, const u16 * fallback_name);
void sort_by_name(Entry_List_s * list);
void sort_by_author(Entry_List_s * list);
void sort_by_filename(Entry_List_s * list);
void delete_entry(Entry_s * entry, bool is_file);
Result load_entries(const char * loading_path, Entry_List_s * list);
bool load_preview(Entry_List_s list, int * preview_offset);
bool load_preview_from_buffer(void * buf, u32 size, C2D_Image * preview_image, int * preview_offset);
bool load_preview(Entry_List_s list, C2D_Image * preview_image, int * preview_offset);
void free_preview(C2D_Image preview_image);
Result load_audio(Entry_s, audio_s *);
void load_icons_first(Entry_List_s * current_list, bool silent);
void handle_scrolling(Entry_List_s * list);