Major rewrite: less repetition (#101)
* first step of rewriting: at least it compiles™ * fix tabs/spaces * fix dabort on load * fix preview crash * sorting isnt done outside of loading * step one of making remake_file useless * camera/qr code cleanup * fix dabort when folder is empty, and bring back preview optimization * fix button for switching modes and show mode when folder is empty * fix scanning qrs * no more splash discrimination * add debug helpers * fix theme installing turns out that wasnt such a good idea * fix battery icon * mistake * themeplaza compatibility * make use of load_data * don't drink and copy-paste, kids * fix user-agent * remove useless * cleanup includes * not even used * add splash buttons * upgrade buttons drawing * fix controls while preview is up * improve positions
This commit is contained in:
@@ -29,11 +29,10 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
bool qr_mode;
|
||||
|
||||
void init_qr(void);
|
||||
void exit_qr(void);
|
||||
void take_picture(void);
|
||||
Result http_get(char *url, char *path);
|
||||
bool scan_qr(EntryMode current_mode);
|
||||
Result http_get(char *url, const char *path);
|
||||
|
||||
#endif
|
||||
@@ -33,25 +33,26 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define THEMES_PATH "/Themes/"
|
||||
#define SPLASHES_PATH "/Splashes/"
|
||||
#define ENTRIES_PER_SCREEN 4
|
||||
|
||||
#define SINGLE_INSTALL 0
|
||||
#define SHUFFLE_INSTALL 1
|
||||
#define BGM_INSTALL 2
|
||||
#define UNINSTALL 3
|
||||
#define DOWNLOADING 3
|
||||
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
|
||||
#define POS() DEBUG("%s (line %d)...\n", __func__, __LINE__)
|
||||
|
||||
#define ERROR 0
|
||||
#define WARNING 1
|
||||
static const int THEMES_PER_SCREEN = 4;
|
||||
#define DEBUGPOS(...) \
|
||||
POS(); \
|
||||
DEBUG(__VA_ARGS__)
|
||||
|
||||
bool homebrew;
|
||||
bool splash_mode;
|
||||
int shuffle_theme_count;
|
||||
typedef enum {
|
||||
MODE_THEMES = 0,
|
||||
MODE_SPLASHES,
|
||||
|
||||
MODE_AMOUNT,
|
||||
} EntryMode;
|
||||
|
||||
extern const char * main_paths[MODE_AMOUNT];
|
||||
|
||||
enum TextureID {
|
||||
TEXTURE_FONT_RESERVED = 0, //used by pp2d for the font
|
||||
TEXTURE_FONT_RESERVED = 0, // used by pp2d for the font
|
||||
TEXTURE_ARROW,
|
||||
TEXTURE_SHUFFLE,
|
||||
TEXTURE_BATTERY_1,
|
||||
@@ -62,6 +63,10 @@ enum TextureID {
|
||||
TEXTURE_BATTERY_CHARGE,
|
||||
TEXTURE_QR,
|
||||
TEXTURE_PREVIEW,
|
||||
|
||||
TEXTURE_ICON, // always the last
|
||||
};
|
||||
|
||||
void exit_function(void);
|
||||
|
||||
#endif
|
||||
@@ -27,18 +27,49 @@
|
||||
#ifndef DRAW_H
|
||||
#define DRAW_H
|
||||
|
||||
#include "themes.h"
|
||||
#include "splashes.h"
|
||||
#include "camera.h"
|
||||
#include "common.h"
|
||||
#include "loading.h"
|
||||
|
||||
typedef enum {
|
||||
INSTALL_SPLASH,
|
||||
INSTALL_SPLASH_DELETE,
|
||||
|
||||
INSTALL_SINGLE,
|
||||
INSTALL_SHUFFLE,
|
||||
INSTALL_BGM,
|
||||
|
||||
INSTALL_DOWNLOAD,
|
||||
} InstallType;
|
||||
|
||||
typedef enum {
|
||||
ERROR_LEVEL_ERROR,
|
||||
ERROR_LEVEL_WARNING,
|
||||
} ErrorLevel;
|
||||
|
||||
#define BUTTONS_START_Y 140
|
||||
#define BUTTONS_STEP 25
|
||||
|
||||
enum {
|
||||
BUTTONS_Y_PREVIEW = BUTTONS_START_Y+5,
|
||||
|
||||
BUTTONS_Y_LINE_1 = BUTTONS_START_Y + BUTTONS_STEP*1,
|
||||
BUTTONS_Y_LINE_2 = BUTTONS_START_Y + BUTTONS_STEP*2,
|
||||
BUTTONS_Y_LINE_3 = BUTTONS_START_Y + BUTTONS_STEP*3,
|
||||
|
||||
BUTTONS_X_LEFT = 20,
|
||||
BUTTONS_X_RIGHT = 200,
|
||||
} ButtonPos;
|
||||
|
||||
void init_screens(void);
|
||||
void exit_screens(void);
|
||||
|
||||
void draw_themext_error(void);
|
||||
void draw_base_interface(void);
|
||||
void draw_theme_install(int install_type);
|
||||
void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode, int shuffle_theme_count);
|
||||
void draw_splash_install(int install_type);
|
||||
void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode);
|
||||
void throw_error(char* error, int error_type);
|
||||
void throw_error(char* error, ErrorLevel level);
|
||||
|
||||
void draw_preview(int preview_offset);
|
||||
|
||||
void draw_install(InstallType type);
|
||||
|
||||
void draw_interface(Entry_List_s* list, EntryMode current_mode);
|
||||
|
||||
#endif
|
||||
@@ -36,7 +36,7 @@ FS_Archive ArchiveThemeExt;
|
||||
Result open_archives(void);
|
||||
Result close_archives(void);
|
||||
|
||||
u64 file_to_buf(FS_Path path, FS_Archive archive, char** buf);
|
||||
u32 file_to_buf(FS_Path path, FS_Archive archive, char** buf);
|
||||
u32 zip_file_to_buf(char *file_name, u16 *zip_path, char **buf);
|
||||
|
||||
Result buf_to_file(u32 size, char *path, FS_Archive archive, char *buf);
|
||||
|
||||
60
include/loading.h
Normal file
60
include/loading.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of Anemone3DS
|
||||
* Copyright (C) 2016-2017 Alex Taber ("astronautlevel"), Dawid Eckert ("daedreth")
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#ifndef LOADING_H
|
||||
#define LOADING_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct {
|
||||
u16 name[0x41];
|
||||
u16 desc[0x81];
|
||||
u16 author[0x41];
|
||||
|
||||
u32 placeholder_color;
|
||||
ssize_t icon_id;
|
||||
|
||||
u16 path[0x106];
|
||||
bool is_zip;
|
||||
|
||||
bool in_shuffle;
|
||||
} Entry_s;
|
||||
|
||||
typedef struct {
|
||||
Entry_s * entries;
|
||||
int entries_count;
|
||||
|
||||
int scroll;
|
||||
int selected_entry;
|
||||
|
||||
int shuffle_count;
|
||||
} Entry_List_s;
|
||||
|
||||
Result load_entries(const char * loading_path, Entry_List_s * list);
|
||||
bool load_preview(Entry_List_s list, int * preview_offset);
|
||||
u32 load_data(char * filename, Entry_s entry, char ** buf);
|
||||
|
||||
#endif
|
||||
@@ -28,26 +28,9 @@
|
||||
#define SPLASHES_H
|
||||
|
||||
#include "common.h"
|
||||
#include "loading.h"
|
||||
|
||||
typedef struct {
|
||||
u16 name[0x41];
|
||||
u16 desc[0x81];
|
||||
u16 author[0x41];
|
||||
|
||||
u32 placeholder_color;
|
||||
ssize_t icon_id;
|
||||
|
||||
u16 path[0x106];
|
||||
bool is_zip;
|
||||
} Splash_s;
|
||||
|
||||
Splash_s *splashes_list;
|
||||
int splash_count;
|
||||
|
||||
Result get_splashes(Splash_s** splashes_list, int *splash_count);
|
||||
int splashcmp(const void* a, const void* b);
|
||||
void splash_install(Splash_s splash_to_install);
|
||||
void splash_delete();
|
||||
void load_splash_preview(Splash_s *splash);
|
||||
void splash_delete(void);
|
||||
void splash_install(Entry_s splash);
|
||||
|
||||
#endif
|
||||
@@ -28,33 +28,12 @@
|
||||
#define THEMES_H
|
||||
|
||||
#include "common.h"
|
||||
#include "loading.h"
|
||||
|
||||
typedef struct {
|
||||
u16 name[0x41];
|
||||
u16 desc[0x81];
|
||||
u16 author[0x41];
|
||||
|
||||
u32 placeholder_color;
|
||||
ssize_t icon_id;
|
||||
|
||||
bool has_preview;
|
||||
int preview_offset;
|
||||
|
||||
u16 path[0x106];
|
||||
bool is_zip;
|
||||
|
||||
bool in_shuffle;
|
||||
} Theme_s;
|
||||
void delete_theme(Entry_s theme);
|
||||
Result theme_install(Entry_s theme);
|
||||
|
||||
Theme_s * themes_list;
|
||||
int theme_count;
|
||||
|
||||
void load_theme_preview(Theme_s *theme);
|
||||
Result get_themes(Theme_s **themes_list, int *theme_count);
|
||||
int themecmp(const void* a, const void* b);
|
||||
void del_theme(u16 *path);
|
||||
Result single_install(Theme_s theme);
|
||||
Result shuffle_install(Theme_s *themes_list, int theme_count);
|
||||
Result bgm_install(Theme_s bgm_to_install);
|
||||
Result shuffle_install(Entry_s* themes_list, int themes_count);
|
||||
Result bgm_install(Entry_s bgm_to_install);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user