5 Commits

Author SHA1 Message Date
d93f4f9207 Add install BGM option 2017-09-01 12:31:55 -04:00
867f4b61ab Fix splash install when /luma/splash.bin or /luma/splashbottom.bin were missing 2017-09-01 12:11:25 -04:00
72153ba15d Make controls more untuitive 2017-09-01 12:02:09 -04:00
c4a096249c Fix softlock and make error more descriptive, and fixed preview offset 2017-09-01 11:55:32 -04:00
LiquidFenrir
91ba5fed49 previews overhaul (#13)
* allow quitting if there are no themes or splashes

* load preview only once if the user toggles more than once
2017-09-01 10:12:26 -04:00
8 changed files with 162 additions and 47 deletions

View File

@@ -35,6 +35,9 @@
#define THEMES_PATH "/Themes/"
#define SPLASHES_PATH "/Splashes/"
#define SINGLE_INSTALL 0
#define SHUFFLE_INSTALL 1
#define BGM_INSTALL 2
static const int THEMES_PER_SCREEN = 4;

View File

@@ -33,8 +33,9 @@
void init_screens(void);
void exit_screens(void);
void draw_theme_install(bool shuffle_install);
void draw_theme_install(int install_type);
void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode);
void draw_splash_install(void);
void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode);
#endif

View File

@@ -38,6 +38,7 @@ typedef struct {
ssize_t icon_id;
bool has_preview;
int preview_offset;
u16 path[0x106];
bool is_zip;
@@ -49,5 +50,6 @@ void load_theme_preview(Theme_s *theme);
Result get_themes(Theme_s **themes_list, int *theme_count);
Result single_install(Theme_s theme);
Result shuffle_install(Theme_s *themes_list, int theme_count);
Result bgm_install(Theme_s bgm_to_install);
#endif

View File

@@ -94,10 +94,23 @@ void draw_base_interface(void)
pp2d_draw_on(GFX_TOP);
}
void draw_theme_install(bool shuffle_install)
void draw_theme_install(int install_type)
{
draw_base_interface();
pp2d_draw_textf(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a %s theme...", !shuffle_install ? "single" : "shuffle");
switch(install_type)
{
case 0:
pp2d_draw_text(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a single theme...");
break;
case 1:
pp2d_draw_text(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a shuffle theme...");
break;
case 2:
pp2d_draw_text(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing BGM...");
break;
default:
break;
}
pp2d_end_draw();
}
@@ -107,7 +120,7 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
if (themes_list == NULL)
{
pp2d_begin_draw(GFX_TOP);
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "NO THEMES FOUND");
pp2d_end_draw();
return;
}
@@ -119,9 +132,9 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
if (current_theme.has_preview)
{
pp2d_begin_draw(GFX_TOP);
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 6, 0, 400, 240);
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, current_theme.preview_offset, 0, 400, 240);
pp2d_draw_on(GFX_BOTTOM);
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 46, 240, 320, 240);
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 40+current_theme.preview_offset, 240, 320, 240);
}
}
else
@@ -139,9 +152,12 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
utf16_to_utf32((u32*)description, current_theme.desc, 0x80);
pp2d_draw_wtext(20, 65, 0.5, 0.5, COLOR_WHITE, description);
pp2d_draw_wtext_center(GFX_TOP, 150, 0.7, 0.7, COLOR_WHITE, L"\uE000 Install Theme \uE004 Switch to Splashes");
pp2d_draw_wtext_center(GFX_TOP, 180, 0.7, 0.7, COLOR_WHITE, L"\uE001 Queue Shuffle \uE046 Install shuffle");
pp2d_draw_wtext_center(GFX_TOP, 210, 0.7, 0.7, COLOR_WHITE, L"\uE003 Preview Theme");
pp2d_draw_wtext(20, 150, 0.6, 0.6, COLOR_WHITE, L"\uE046 Install Shuffle Theme");
pp2d_draw_wtext(200, 150, 0.6, 0.6, COLOR_WHITE, L"\uE004 Switch to Splashes");
pp2d_draw_wtext(20, 180, 0.6, 0.6, COLOR_WHITE, L"\uE000 Install Theme");
pp2d_draw_wtext(200, 180, 0.6, 0.6, COLOR_WHITE, L"\uE001 Queue Shuffle");
pp2d_draw_wtext(20, 210, 0.6, 0.6, COLOR_WHITE, L"\uE002 Install BGM");
pp2d_draw_wtext(200, 210, 0.6, 0.6, COLOR_WHITE, L"\uE003 Preview Theme");
pp2d_draw_on(GFX_BOTTOM);
@@ -197,12 +213,19 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
pp2d_end_draw();
}
void draw_splash_install(void)
{
draw_base_interface();
pp2d_draw_textf(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a splash...");
pp2d_end_draw();
}
void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode)
{
if (splashes_list == NULL)
{
pp2d_begin_draw(GFX_TOP);
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "NO SPLASHES FOUND");
pp2d_end_draw();
return;
}

View File

@@ -51,6 +51,10 @@ Result open_archives(void)
CFGU_SecureInfoGetRegion(&regionCode);
switch(regionCode)
{
case 0:
archive1 = 0x000002cc;
archive2 = 0x00000082;
break;
case 1:
archive1 = 0x000002cd;
archive2 = 0x0000008f;
@@ -59,10 +63,6 @@ Result open_archives(void)
archive1 = 0x000002ce;
archive2 = 0x00000098;
break;
case 3:
archive1 = 0x000002cc;
archive2 = 0x00000082;
break;
default:
archive1 = 0x00;
archive2 = 0x00;

View File

@@ -72,6 +72,7 @@ int main(void)
bool splash_mode = false;
int selected_splash = 0;
int selected_theme = 0;
int previously_selected = 0;
int shuffle_theme_count = 0;
bool preview_mode = false;
@@ -83,6 +84,18 @@ int main(void)
if (!splash_mode) draw_theme_interface(themes_list, theme_count, selected_theme, preview_mode);
else draw_splash_interface(splashes_list, splash_count, selected_splash, preview_mode);
if (kDown & KEY_START)
{
exit_screens();
exit_services();
PTMSYSM_RebootAsync(0);
ptmSysmExit();
}
else if (kDown & KEY_L)
{
splash_mode = !splash_mode;
}
if (themes_list == NULL && !splash_mode)
continue;
@@ -96,11 +109,10 @@ int main(void)
{
if (!preview_mode)
{
if (!current_theme->has_preview)
load_theme_preview(current_theme);
if (current_theme->has_preview)
{
preview_mode = true;
}
preview_mode = current_theme->has_preview;
}
else
preview_mode = false;
@@ -111,21 +123,20 @@ int main(void)
continue;
// Actions
else if (kDown & KEY_L)
{
splash_mode = !splash_mode;
}
else if (kDown & KEY_X)
{
// install_bgm(current_theme);
draw_theme_install(BGM_INSTALL);
bgm_install(*current_theme);
}
else if (kDown & KEY_A)
{
if (splash_mode)
{
draw_splash_install();
splash_install(*current_splash);
svcSleepThread(5e8);
} else {
draw_theme_install(false);
draw_theme_install(SINGLE_INSTALL);
single_install(*current_theme);
}
}
@@ -158,7 +169,7 @@ int main(void)
} else {
if (shuffle_theme_count > 0)
{
draw_theme_install(true);
draw_theme_install(SHUFFLE_INSTALL);
shuffle_install(themes_list, theme_count);
}
}
@@ -171,11 +182,11 @@ int main(void)
{
selected_splash++;
if (selected_splash >= splash_count)
selected_splash = splash_count-1;
selected_splash = 0;
} else {
selected_theme++;
if (selected_theme >= theme_count)
selected_theme = theme_count-1;
selected_theme = 0;
}
}
else if (kDown & KEY_UP)
@@ -184,31 +195,41 @@ int main(void)
{
selected_splash--;
if (selected_splash < 0)
selected_splash = 0;
selected_splash = splash_count - 1;
} else {
selected_theme--;
if (selected_theme < 0)
selected_theme = 0;
selected_theme = theme_count - 1;
}
}
// Quick moving
else if (kDown & KEY_LEFT)
{
if (splash_mode) selected_splash = 0;
else selected_theme = 0;
if (splash_mode)
{
selected_splash -= 4;
if (selected_splash < 0) selected_splash = 0;
} else {
selected_theme -= 4;
if (selected_theme < 0) selected_theme = 0;
}
}
else if (kDown & KEY_RIGHT)
{
if (splash_mode) selected_splash = splash_count - 1;
else selected_theme = theme_count-1;
if (splash_mode)
{
selected_splash += 4;
if (selected_splash >= splash_count) selected_splash = splash_count-1;
} else {
selected_theme += 4;
if (selected_theme >= theme_count) selected_theme = theme_count-1;
}
}
if (kDown & KEY_START)
if (!splash_mode && selected_theme != previously_selected)
{
exit_screens();
exit_services();
PTMSYSM_RebootAsync(0);
ptmSysmExit();
current_theme->has_preview = false;
previously_selected = selected_theme;
}
}

View File

@@ -93,6 +93,7 @@ void splash_install(Splash_s splash_to_install)
u32 size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.top_path), ArchiveSD, &screen_buf);
if (size)
{
remake_file("/luma/splash.bin", ArchiveSD, size);
buf_to_file(size, "/luma/splash.bin", ArchiveSD, screen_buf);
free(screen_buf);
}
@@ -100,6 +101,7 @@ void splash_install(Splash_s splash_to_install)
size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.bottom_path), ArchiveSD, &screen_buf);
if (size)
{
remake_file("/luma/splashbottom.bin", ArchiveSD, size);
buf_to_file(size, "/luma/splashbottom.bin", ArchiveSD, screen_buf);
free(screen_buf);
}

View File

@@ -80,6 +80,7 @@ void load_theme_preview(Theme_s *theme)
theme->has_preview = true;
pp2d_load_texture_memory(TEXTURE_PREVIEW, image, (u32)width, (u32)height);
theme->preview_offset = (width-400)/2;
}
free(image);
@@ -188,6 +189,75 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
return res;
}
Result bgm_install(Theme_s bgm_to_install)
{
char *savedata_buf;
char *thememanage_buf;
char *music;
u32 music_size = 0;
u32 savedata_size;
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf);
savedata_buf[0x141b] = 0;
memset(&savedata_buf[0x13b8], 0, 8);
savedata_buf[0x13bd] = 3;
savedata_buf[0x13b8] = 0xff;
u32 size = buf_to_file(savedata_size, "/SaveData.dat", ArchiveHomeExt, savedata_buf);
free(savedata_buf);
if (bgm_to_install.is_zip) // Same as above but this time with bgm
{
music_size = zip_file_to_buf("bgm.bcstm", bgm_to_install.path, &music);
} else {
u16 path[0x106] = {0};
memcpy(path, bgm_to_install.path, 0x106 * sizeof(u16));
struacat(path, "/bgm.bcstm");
music_size = file_to_buf(fsMakePath(PATH_UTF16, path), ArchiveSD, &music);
}
if (music_size == 0)
{
free(music);
music = calloc(1, 3371008);
} else if (music_size > 3371008) {
free(music);
puts("musicrip");
return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_TOO_LARGE);
}
size = buf_to_file(music_size, "/BgmCache.bin", ArchiveThemeExt, music);
free(music);
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, &thememanage_buf);
thememanage_buf[0x00] = 1;
thememanage_buf[0x01] = 0;
thememanage_buf[0x02] = 0;
thememanage_buf[0x03] = 0;
thememanage_buf[0x04] = 0;
thememanage_buf[0x05] = 0;
thememanage_buf[0x06] = 0;
thememanage_buf[0x07] = 0;
u32 *music_size_location = (u32*)(&thememanage_buf[0xC]);
*music_size_location = music_size;
thememanage_buf[0x10] = 0xFF;
thememanage_buf[0x14] = 0x01;
thememanage_buf[0x18] = 0xFF;
thememanage_buf[0x1D] = 0x02;
memset(&thememanage_buf[0x338], 0, 4);
memset(&thememanage_buf[0x340], 0, 4);
memset(&thememanage_buf[0x360], 0, 4);
memset(&thememanage_buf[0x368], 0, 4);
size = buf_to_file(0x800, "/ThemeManage.bin", ArchiveThemeExt, thememanage_buf);
free(thememanage_buf);
return 0;
}
// Install a single theme
Result single_install(Theme_s theme_to_install)
{
@@ -199,8 +269,6 @@ Result single_install(Theme_s theme_to_install)
u32 music_size;
u32 savedata_size;
printf("Writing SaveData.dat...\n");
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf);
savedata_buf[0x141b] = 0;
memset(&savedata_buf[0x13b8], 0, 8);
@@ -210,7 +278,6 @@ Result single_install(Theme_s theme_to_install)
free(savedata_buf);
// Open body cache file. Test if theme is zipped
printf("Writing BodyCache.bin...\n");
if (theme_to_install.is_zip)
{
body_size = zip_file_to_buf("body_LZ.bin", theme_to_install.path, &body);
@@ -235,7 +302,6 @@ Result single_install(Theme_s theme_to_install)
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
printf("Writing BgmCache.bin...\n");
if (theme_to_install.is_zip) // Same as above but this time with bgm
{
music_size = zip_file_to_buf("bgm.bcstm", theme_to_install.path, &music);
@@ -261,7 +327,6 @@ Result single_install(Theme_s theme_to_install)
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
printf("Writing ThemeManage.bin...\n");
file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, &thememanage_buf);
thememanage_buf[0x00] = 1;
thememanage_buf[0x01] = 0;
@@ -289,8 +354,6 @@ Result single_install(Theme_s theme_to_install)
size = buf_to_file(0x800, "/ThemeManage.bin", ArchiveThemeExt, thememanage_buf);
free(thememanage_buf);
printf("Done!\n");
return 0;
}