Automatically update themes list when a new theme is downloaded
This commit is contained in:
@@ -46,8 +46,12 @@ typedef struct {
|
|||||||
bool in_shuffle;
|
bool in_shuffle;
|
||||||
} Theme_s;
|
} Theme_s;
|
||||||
|
|
||||||
|
Theme_s * themes_list;
|
||||||
|
int theme_count;
|
||||||
|
|
||||||
void load_theme_preview(Theme_s *theme);
|
void load_theme_preview(Theme_s *theme);
|
||||||
Result get_themes(Theme_s **themes_list, int *theme_count);
|
Result get_themes(Theme_s **themes_list, int *theme_count);
|
||||||
|
void add_theme(Theme_s **themes_list, int *theme_count, char *path, char *filename);
|
||||||
Result single_install(Theme_s theme);
|
Result single_install(Theme_s theme);
|
||||||
Result shuffle_install(Theme_s *themes_list, int theme_count);
|
Result shuffle_install(Theme_s *themes_list, int theme_count);
|
||||||
Result bgm_install(Theme_s bgm_to_install);
|
Result bgm_install(Theme_s bgm_to_install);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "quirc/quirc.h"
|
#include "quirc/quirc.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
|
#include "themes.h"
|
||||||
|
|
||||||
void init_qr(void)
|
void init_qr(void)
|
||||||
{
|
{
|
||||||
@@ -187,5 +188,9 @@ Result http_get(char *url, char *path)
|
|||||||
remake_file(path_to_file, ArchiveSD, size);
|
remake_file(path_to_file, ArchiveSD, size);
|
||||||
buf_to_file(size, path_to_file, ArchiveSD, (char*)buf);
|
buf_to_file(size, path_to_file, ArchiveSD, (char*)buf);
|
||||||
|
|
||||||
|
add_theme(&themes_list, &theme_count, path_to_file, filename);
|
||||||
|
|
||||||
|
exit_qr();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -69,10 +69,9 @@ int main(void)
|
|||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
bool homebrew = init_services();
|
bool homebrew = init_services();
|
||||||
init_screens();
|
init_screens();
|
||||||
init_qr();
|
|
||||||
|
|
||||||
int theme_count = 0;
|
themes_list = NULL;
|
||||||
Theme_s * themes_list = NULL;
|
theme_count = 0;
|
||||||
Result res = get_themes(&themes_list, &theme_count);
|
Result res = get_themes(&themes_list, &theme_count);
|
||||||
if (R_FAILED(res))
|
if (R_FAILED(res))
|
||||||
{
|
{
|
||||||
@@ -126,9 +125,13 @@ int main(void)
|
|||||||
} else if (kDown & KEY_R)
|
} else if (kDown & KEY_R)
|
||||||
{
|
{
|
||||||
qr_mode = !qr_mode;
|
qr_mode = !qr_mode;
|
||||||
|
if (qr_mode) init_qr();
|
||||||
|
else exit_qr();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qr_mode) continue;
|
||||||
|
|
||||||
if (themes_list == NULL && !splash_mode)
|
if (themes_list == NULL && !splash_mode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,27 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_theme(Theme_s **themes_list, int *theme_count, char *path, char *filename)
|
||||||
|
{
|
||||||
|
*theme_count += 1;
|
||||||
|
*themes_list = realloc(*themes_list, (*theme_count) * sizeof(Theme_s));
|
||||||
|
|
||||||
|
Theme_s *current_theme = &(*themes_list)[*theme_count - 1];
|
||||||
|
memset(current_theme, 0, sizeof(Theme_s));
|
||||||
|
|
||||||
|
u16 theme_path[0x106] = {0};
|
||||||
|
utf8_to_utf16(theme_path, (u8*)path, 0x106);
|
||||||
|
|
||||||
|
u16 ufilename[0x106] = {0};
|
||||||
|
utf8_to_utf16(ufilename, (u8*)filename, 0x106);
|
||||||
|
|
||||||
|
memcpy(current_theme->path, theme_path, 0x106 * sizeof(u16));
|
||||||
|
current_theme->is_zip = true;
|
||||||
|
|
||||||
|
ssize_t iconID = TEXTURE_PREVIEW + *theme_count;
|
||||||
|
parse_smdh(current_theme, iconID, ufilename);
|
||||||
|
}
|
||||||
|
|
||||||
Result bgm_install(Theme_s bgm_to_install)
|
Result bgm_install(Theme_s bgm_to_install)
|
||||||
{
|
{
|
||||||
char *savedata_buf;
|
char *savedata_buf;
|
||||||
|
|||||||
Reference in New Issue
Block a user