Stop loading previews without user button press
This commit is contained in:
6
Makefile
6
Makefile
@@ -49,8 +49,8 @@ ICON_FLAGS := nosavebackups,visible
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||||
|
|
||||||
CFLAGS := -g -Wall -Wextra -O2 -mword-relocations \
|
CFLAGS := -g -Wall -Wextra -mword-relocations \
|
||||||
-fomit-frame-pointer -ffunction-sections \
|
-ffunction-sections \
|
||||||
$(ARCH)
|
$(ARCH)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D_GNU_SOURCE
|
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D_GNU_SOURCE
|
||||||
@@ -60,7 +60,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
|||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
LIBS := -lcitro3d -lctru -lm -lz
|
LIBS := -lcitro3d -lctrud -lm -lz
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
|||||||
@@ -32,6 +32,6 @@
|
|||||||
void init_screens(void);
|
void init_screens(void);
|
||||||
void exit_screens(void);
|
void exit_screens(void);
|
||||||
|
|
||||||
void draw_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode);
|
void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -77,33 +77,10 @@ static int vertical_scroll = 0;
|
|||||||
// static int previous_selected = 0;
|
// static int previous_selected = 0;
|
||||||
// static int horizontal_scroll_change = 1;
|
// static int horizontal_scroll_change = 1;
|
||||||
|
|
||||||
void draw_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode)
|
void draw_base_interface(void)
|
||||||
{
|
{
|
||||||
pp2d_begin_draw(GFX_TOP);
|
pp2d_begin_draw(GFX_TOP);
|
||||||
|
|
||||||
if (themes_list == NULL)
|
|
||||||
{
|
|
||||||
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
|
|
||||||
pp2d_end_draw();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Theme_s current_theme = themes_list[selected_theme];
|
|
||||||
|
|
||||||
if (preview_mode)
|
|
||||||
{
|
|
||||||
if (current_theme.has_preview)
|
|
||||||
{
|
|
||||||
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 6, 0, 400, 240);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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[0x80] = {0};
|
|
||||||
utf16_to_utf32((u32*)title, current_theme.name, 0x80);
|
|
||||||
pp2d_draw_wtext(20, 30, 0.7, 0.7, COLOR_WHITE, title);
|
|
||||||
|
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm tm = *localtime(&t);
|
struct tm tm = *localtime(&t);
|
||||||
@@ -116,48 +93,43 @@ void draw_interface(Theme_s * themes_list, int theme_count, int selected_theme,
|
|||||||
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);
|
||||||
|
|
||||||
if (current_theme.has_preview)
|
pp2d_draw_on(GFX_BOTTOM);
|
||||||
|
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);
|
||||||
|
pp2d_draw_rectangle(0, 216, 320, 24, COLOR_ACCENT);
|
||||||
|
pp2d_draw_on(GFX_TOP);
|
||||||
|
}
|
||||||
|
void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (themes_list == NULL)
|
||||||
{
|
{
|
||||||
//skip the weird 6 pixels to the left
|
pp2d_begin_draw(GFX_TOP);
|
||||||
pp2d_texture_select_part(TEXTURE_PREVIEW, 220, 35, 6, 0, 400, 480);
|
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
|
||||||
pp2d_texture_scale(0.4, 0.4);
|
pp2d_end_draw();
|
||||||
pp2d_texture_draw();
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pp2d_draw_on(GFX_BOTTOM);
|
Theme_s current_theme = themes_list[selected_theme];
|
||||||
|
|
||||||
if (preview_mode)
|
if (preview_mode)
|
||||||
{
|
{
|
||||||
if (current_theme.has_preview)
|
if (current_theme.has_preview)
|
||||||
{
|
{
|
||||||
|
pp2d_begin_draw(GFX_TOP);
|
||||||
|
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 6, 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, 46, 240, 320, 240);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
draw_base_interface();
|
||||||
// Scroll the theme name if it's too large
|
pp2d_draw_text_center(GFX_TOP, 4, 0.5, 0.5, COLOR_WHITE, "Theme mode");
|
||||||
//----------------------------------------------------------------
|
wchar_t title[0x80] = {0};
|
||||||
if (previous_selected != selected_theme) {
|
utf16_to_utf32((u32*)title, current_theme.name, 0x80);
|
||||||
previous_selected = selected_theme;
|
pp2d_draw_wtext(20, 30, 0.7, 0.7, COLOR_WHITE, title);
|
||||||
frames_count = 0;
|
|
||||||
horizontal_scroll = 0;
|
|
||||||
horizontal_scroll_change = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
frames_count = (frames_count+1) % FRAMES_FOR_TEXT_SCROLL;
|
pp2d_draw_on(GFX_BOTTOM);
|
||||||
|
|
||||||
if (frames_count == 0 && (config.entries[selectedEntry].name.size() > MENU_WIDTH))
|
|
||||||
horizontal_scroll += horizontal_scroll_change;
|
|
||||||
|
|
||||||
if (horizontal_scroll == (config.entries[selected_theme].name.size() - MENU_WIDTH))
|
|
||||||
horizontal_scroll_change = -1;
|
|
||||||
|
|
||||||
if (horizontal_scroll == 0)
|
|
||||||
horizontal_scroll_change = 1;
|
|
||||||
//----------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Scroll the menu up or down if the selected theme is out of its bounds
|
// Scroll the menu up or down if the selected theme is out of its bounds
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
@@ -179,14 +151,6 @@ void draw_interface(Theme_s * themes_list, int theme_count, int selected_theme,
|
|||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);
|
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);
|
||||||
pp2d_draw_rectangle(0, 216, 320, 24, COLOR_ACCENT);
|
pp2d_draw_rectangle(0, 216, 320, 24, COLOR_ACCENT);
|
||||||
if (vertical_scroll > 0)
|
|
||||||
{
|
|
||||||
pp2d_draw_texture(TEXTURE_ARROW, 155, 6);
|
|
||||||
}
|
|
||||||
if (theme_count - vertical_scroll > THEMES_PER_SCREEN)
|
|
||||||
{
|
|
||||||
pp2d_draw_texture_flip(TEXTURE_ARROW, 155, 224, VERTICAL);
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
for (int i = vertical_scroll; i < (THEMES_PER_SCREEN + vertical_scroll); i++)
|
for (int i = vertical_scroll; i < (THEMES_PER_SCREEN + vertical_scroll); i++)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "minizip/unzip.h"
|
#include "minizip/unzip.h"
|
||||||
|
|
||||||
int filename_compare(unzFile file, const char *current_filename, const char *filename)
|
int filename_compare(__attribute__((unused)) unzFile file, const char *current_filename, const char *filename)
|
||||||
{
|
{
|
||||||
return strcasecmp(current_filename, filename);
|
return strcasecmp(current_filename, filename);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ int main(void)
|
|||||||
|
|
||||||
int selected_theme = 0;
|
int selected_theme = 0;
|
||||||
int shuffle_theme_count = 0;
|
int shuffle_theme_count = 0;
|
||||||
int previously_selected = ~selected_theme; //make sure it loads the preview the first time
|
|
||||||
bool preview_mode = false;
|
bool preview_mode = false;
|
||||||
|
|
||||||
while(aptMainLoop())
|
while(aptMainLoop())
|
||||||
@@ -68,8 +67,7 @@ int main(void)
|
|||||||
hidScanInput();
|
hidScanInput();
|
||||||
u32 kDown = hidKeysDown();
|
u32 kDown = hidKeysDown();
|
||||||
|
|
||||||
draw_interface(themes_list, theme_count, selected_theme, preview_mode);
|
draw_theme_interface(themes_list, theme_count, selected_theme, preview_mode);
|
||||||
|
|
||||||
|
|
||||||
if (themes_list == NULL)
|
if (themes_list == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -80,9 +78,12 @@ int main(void)
|
|||||||
{
|
{
|
||||||
if (!preview_mode)
|
if (!preview_mode)
|
||||||
{
|
{
|
||||||
|
load_theme_preview(current_theme);
|
||||||
if (current_theme->has_preview)
|
if (current_theme->has_preview)
|
||||||
|
{
|
||||||
preview_mode = true;
|
preview_mode = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
preview_mode = false;
|
preview_mode = false;
|
||||||
}
|
}
|
||||||
@@ -152,15 +153,6 @@ int main(void)
|
|||||||
PTMSYSM_RebootAsync(0);
|
PTMSYSM_RebootAsync(0);
|
||||||
ptmSysmExit();
|
ptmSysmExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//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);
|
free(themes_list);
|
||||||
|
|||||||
Reference in New Issue
Block a user