adds dynamic preview loading and silence minizip warnings (#11)

* make use of the return value for safety

* get rid of warnings
(sizeof(wchar_t) is the same as sizeof(u32), so no problem there)

* dynamic preview loading
fix crash when too many themes have previews available
This commit is contained in:
LiquidFenrir
2017-09-01 03:57:08 +02:00
committed by Alex Taber
parent 4811fa1c4c
commit 70e086b20c
10 changed files with 117 additions and 68 deletions

View File

@@ -50,8 +50,15 @@ int main(void)
int theme_count = 0;
Theme_s * themes_list = NULL;
Result res = get_themes(&themes_list, &theme_count);
if (R_FAILED(res))
{
//don't need to worry about possible textures (icons, previews), that's freed by pp2d itself
free(themes_list);
themes_list = NULL;
}
int selected_theme = 0;
int previously_selected = ~selected_theme; //make sure it loads the preview the first time
bool preview_mode = false;
while(aptMainLoop())
@@ -124,6 +131,15 @@ int main(void)
{
selected_theme = theme_count-1;
}
//if the selected theme changed, load the preview
if (selected_theme != previously_selected)
{
current_theme->has_preview = false; //will be freed anyway
current_theme = &themes_list[selected_theme]; //update current_theme
load_theme_preview(current_theme);
previously_selected = selected_theme;
}
}
free(themes_list);