Stop loading previews without user button press

This commit is contained in:
2017-09-01 00:29:09 -04:00
parent d5d48228b3
commit 37f0de5756
5 changed files with 39 additions and 83 deletions

View File

@@ -49,8 +49,8 @@ ICON_FLAGS := nosavebackups,visible
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -Wextra -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
CFLAGS := -g -Wall -Wextra -mword-relocations \
-ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D_GNU_SOURCE
@@ -60,7 +60,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
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

View File

@@ -32,6 +32,6 @@
void init_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

View File

@@ -77,33 +77,10 @@ static int vertical_scroll = 0;
// static int previous_selected = 0;
// 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);
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_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);
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);
pp2d_draw_textf(350, 2, 0.6, 0.6, COLOR_WHITE, "%i%%", battery_val);
if (current_theme.has_preview)
{
//skip the weird 6 pixels to the left
pp2d_texture_select_part(TEXTURE_PREVIEW, 220, 35, 6, 0, 400, 480);
pp2d_texture_scale(0.4, 0.4);
pp2d_texture_draw();
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)
{
pp2d_begin_draw(GFX_TOP);
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
pp2d_end_draw();
return;
}
pp2d_draw_on(GFX_BOTTOM);
Theme_s current_theme = themes_list[selected_theme];
if (preview_mode)
{
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);
}
}
else
{
/*
// Scroll the theme name if it's too large
//----------------------------------------------------------------
if (previous_selected != selected_theme) {
previous_selected = selected_theme;
frames_count = 0;
horizontal_scroll = 0;
horizontal_scroll_change = 1;
}
draw_base_interface();
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);
frames_count = (frames_count+1) % FRAMES_FOR_TEXT_SCROLL;
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;
//----------------------------------------------------------------
*/
pp2d_draw_on(GFX_BOTTOM);
// 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, 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++)

View File

@@ -31,7 +31,7 @@
#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);
}

View File

@@ -60,7 +60,6 @@ int main(void)
int selected_theme = 0;
int shuffle_theme_count = 0;
int previously_selected = ~selected_theme; //make sure it loads the preview the first time
bool preview_mode = false;
while(aptMainLoop())
@@ -68,8 +67,7 @@ int main(void)
hidScanInput();
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)
continue;
@@ -80,9 +78,12 @@ int main(void)
{
if (!preview_mode)
{
load_theme_preview(current_theme);
if (current_theme->has_preview)
{
preview_mode = true;
}
}
else
preview_mode = false;
}
@@ -152,15 +153,6 @@ int main(void)
PTMSYSM_RebootAsync(0);
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);