Adding controls and (some) theme previews, this feature really needs to improve

This commit is contained in:
2017-08-29 23:49:54 -04:00
parent 28d55c7a6a
commit e82a0a3882
4 changed files with 43 additions and 2 deletions

View File

@@ -29,6 +29,8 @@
#include <3ds.h> #include <3ds.h>
#define TEX_COUNT 1
typedef struct { typedef struct {
u16 name[0x40]; u16 name[0x40];
u16 desc[0x80]; u16 desc[0x80];
@@ -37,6 +39,9 @@ typedef struct {
u16 path[262]; u16 path[262];
bool is_zip; bool is_zip;
bool selected; bool selected;
ssize_t preview_id;
bool has_preview;
char preview_path[0x106];
} theme; } theme;
void parse_smdh(theme *entry, u16 *path); void parse_smdh(theme *entry, u16 *path);

View File

@@ -125,11 +125,22 @@ int main(void)
while(aptMainLoop()) while(aptMainLoop())
{ {
theme *current_theme = themes_list[cursor_pos + top_pos - 1];
hidScanInput(); hidScanInput();
u32 kDown = hidKeysDown(); u32 kDown = hidKeysDown();
pp2d_begin_draw(GFX_TOP); pp2d_begin_draw(GFX_TOP);
pp2d_draw_rectangle(0, 0, 400, 23, color_accent); pp2d_draw_rectangle(0, 0, 400, 23, color_accent);
pp2d_draw_text_center(GFX_TOP, 4, 0.5, 0.5, color_white, "Theme mode");
wchar_t title[0x40] = {0};
utf16_to_utf32((u32*)title, current_theme->name, 0x40);
pp2d_draw_wtext(20, 30, 0.7, 0.7, color_white, title);
if (current_theme->has_preview)
{
pp2d_draw_texture_scale(current_theme->preview_id, 220, 35, 0.4, 0.4);
}
char time_string[6] = {0}; char time_string[6] = {0};
format_time(time_string); format_time(time_string);
@@ -138,7 +149,6 @@ int main(void)
u8 battery_val; u8 battery_val;
MCUHWC_GetBatteryLevel(&battery_val); MCUHWC_GetBatteryLevel(&battery_val);
pp2d_draw_textf(350, 2, 0.6, 0.6, color_white, "%i%%", battery_val); pp2d_draw_textf(350, 2, 0.6, 0.6, color_white, "%i%%", battery_val);
pp2d_draw_textf(20, 50, 0.7, 0.7, color_white, "top_pos: %i", top_pos);
pp2d_draw_on(GFX_BOTTOM); pp2d_draw_on(GFX_BOTTOM);
pp2d_draw_rectangle(0, 0, 320, 24, color_accent); pp2d_draw_rectangle(0, 0, 320, 24, color_accent);
@@ -164,16 +174,33 @@ int main(void)
else pp2d_draw_wtext(50, 40 + (48 * i), 0.55, 0.55, color_white, name); else pp2d_draw_wtext(50, 40 + (48 * i), 0.55, 0.55, color_white, name);
} }
if (kDown & KEY_A)
{
single_install(*current_theme);
}
if (kDown & KEY_B)
{
current_theme->selected = true;
}
if (kDown & KEY_SELECT)
{
shuffle_install(themes_list, theme_count);
}
if (kDown & KEY_DOWN) if (kDown & KEY_DOWN)
{ {
if (cursor_pos < MAX_THEMES && cursor_pos < theme_count) cursor_pos++; if (cursor_pos < MAX_THEMES && cursor_pos < theme_count) cursor_pos++;
else if (cursor_pos + top_pos < theme_count) top_pos++; else if (cursor_pos + top_pos < theme_count) top_pos++;
} }
if (kDown & KEY_UP) if (kDown & KEY_UP)
{ {
if (cursor_pos > 1) cursor_pos--; if (cursor_pos > 1) cursor_pos--;
else if (top_pos > 0) top_pos--; else if (top_pos > 0) top_pos--;
} }
if (kDown & KEY_START) if (kDown & KEY_START)
{ {
// close_archives(); // close_archives();

View File

@@ -32,6 +32,7 @@
#include "themes.h" #include "themes.h"
#include "unicode.h" #include "unicode.h"
#include "fs.h" #include "fs.h"
#include "pp2d/pp2d/pp2d.h"
void parse_smdh(theme *entry, u16 *path) void parse_smdh(theme *entry, u16 *path)
{ {
@@ -74,8 +75,16 @@ int scan_themes(theme **themes, int num_themes)
if (!strcmp(entry->shortExt, "ZIP")) if (!strcmp(entry->shortExt, "ZIP"))
{ {
theme_info->is_zip = true; theme_info->is_zip = true;
theme_info->has_preview = false;
} else { } else {
theme_info->is_zip = false; theme_info->is_zip = false;
char u8_path[0x106] = {0};
utf16_to_utf8((u8*)u8_path, theme_path, 0x106);
strcat(u8_path, "/Preview.png");
strcpy(theme_info->preview_path, u8_path);
pp2d_load_texture_png(TEX_COUNT + 1 + i, u8_path);
theme_info->preview_id = TEX_COUNT + 1 + i;
theme_info->has_preview = true;
} }
parse_smdh(theme_info, theme_path); parse_smdh(theme_info, theme_path);
memcpy(theme_info->path, theme_path, 0x106 * sizeof(u16)); memcpy(theme_info->path, theme_path, 0x106 * sizeof(u16));