Themeplaza browser (#140)
* builds at least * meh, multithreading will come later. or never * movement added, and correct grid mode * switching splash/themes when in browser mode * closer to the actual themeplaza menu * bring back downloading from qr * show a download screen when downloading from browser * fix selecting with touchscreen in browser mode * update readme for jansson * fix quitting with start in browser mode * add jump menu for browser mode * rotate is broken, add working touchscreen page changing * allow quitting preview mode with B in browser mode * proper way to have portlibs * add searching * show error when search has no results * always free entries and icon ids
This commit is contained in:
@@ -44,6 +44,5 @@ typedef struct {
|
||||
bool init_qr(EntryMode current_mode);
|
||||
void exit_qr(qr_data *data);
|
||||
void take_picture(void);
|
||||
Result http_get(char *url, const char *path);
|
||||
|
||||
#endif
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ENTRIES_PER_SCREEN 4
|
||||
|
||||
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
|
||||
#define POS() DEBUG("%s (line %d)...\n", __func__, __LINE__)
|
||||
|
||||
@@ -42,6 +40,8 @@
|
||||
POS(); \
|
||||
DEBUG(__VA_ARGS__)
|
||||
|
||||
#define FASTSCROLL_WAIT 1.5e8
|
||||
|
||||
typedef enum {
|
||||
MODE_THEMES = 0,
|
||||
MODE_SPLASHES,
|
||||
@@ -50,15 +50,22 @@ typedef enum {
|
||||
} EntryMode;
|
||||
|
||||
extern const char * main_paths[MODE_AMOUNT];
|
||||
extern const int entries_per_screen_v[MODE_AMOUNT];
|
||||
extern const int entries_per_screen_h[MODE_AMOUNT];
|
||||
extern const int entry_size[MODE_AMOUNT];
|
||||
extern bool quit;
|
||||
|
||||
enum TextureID {
|
||||
TEXTURE_FONT_RESERVED = 0, // used by pp2d for the font
|
||||
TEXTURE_ARROW,
|
||||
TEXTURE_ARROW_SIDE,
|
||||
TEXTURE_SHUFFLE,
|
||||
TEXTURE_INSTALLED,
|
||||
TEXTURE_PREVIEW_ICON,
|
||||
TEXTURE_DOWNLOAD,
|
||||
TEXTURE_RELOAD,
|
||||
TEXTURE_BROWSE,
|
||||
TEXTURE_LIST,
|
||||
TEXTURE_EXIT,
|
||||
TEXTURE_BATTERY_0,
|
||||
TEXTURE_BATTERY_1,
|
||||
TEXTURE_BATTERY_2,
|
||||
@@ -68,10 +75,13 @@ enum TextureID {
|
||||
TEXTURE_BATTERY_CHARGE,
|
||||
TEXTURE_QR,
|
||||
TEXTURE_PREVIEW,
|
||||
TEXTURE_REMOTE_PREVIEW,
|
||||
TEXTURE_SELECT_BUTTON,
|
||||
TEXTURE_START_BUTTON,
|
||||
|
||||
TEXTURE_ICON, // always the last
|
||||
// always the last
|
||||
TEXTURE_REMOTE_ICONS,
|
||||
TEXTURE_ICON = TEXTURE_REMOTE_ICONS + 24,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -47,6 +47,10 @@ typedef enum {
|
||||
INSTALL_DOWNLOAD,
|
||||
INSTALL_ENTRY_DELETE,
|
||||
|
||||
INSTALL_LOADING_REMOTE_THEMES,
|
||||
INSTALL_LOADING_REMOTE_SPLASHES,
|
||||
INSTALL_LOADING_REMOTE_PREVIEW,
|
||||
|
||||
INSTALL_NONE,
|
||||
} InstallType;
|
||||
|
||||
@@ -84,11 +88,12 @@ void exit_screens(void);
|
||||
void throw_error(char* error, ErrorLevel level);
|
||||
bool draw_confirm(const char* conf_msg, Entry_List_s* list);
|
||||
|
||||
void draw_preview(int preview_offset);
|
||||
void draw_preview(ssize_t previewID, int preview_offset);
|
||||
|
||||
void draw_install(InstallType type);
|
||||
|
||||
void draw_base_interface(void);
|
||||
void draw_grid_interface(Entry_List_s* list, Instructions_s instructions);
|
||||
void draw_interface(Entry_List_s* list, Instructions_s instructions);
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,7 @@
|
||||
#define LOADING_H
|
||||
|
||||
#include "common.h"
|
||||
#include <jansson.h>
|
||||
|
||||
enum ICON_IDS_OFFSET {
|
||||
ICONS_ABOVE = 0,
|
||||
@@ -62,6 +63,8 @@ typedef struct {
|
||||
|
||||
bool in_shuffle;
|
||||
bool installed;
|
||||
|
||||
json_int_t tp_download_id;
|
||||
} Entry_s;
|
||||
|
||||
typedef struct {
|
||||
@@ -69,7 +72,7 @@ typedef struct {
|
||||
int entries_count;
|
||||
|
||||
ssize_t texture_id_offset;
|
||||
ssize_t icons_ids[ICONS_OFFSET_AMOUNT][ENTRIES_PER_SCREEN];
|
||||
ssize_t * icons_ids;
|
||||
|
||||
int previous_scroll;
|
||||
int scroll;
|
||||
@@ -80,6 +83,14 @@ typedef struct {
|
||||
int shuffle_count;
|
||||
|
||||
EntryMode mode;
|
||||
int entries_per_screen_v;
|
||||
int entries_per_screen_h;
|
||||
int entries_loaded;
|
||||
int entry_size;
|
||||
|
||||
json_int_t tp_current_page;
|
||||
json_int_t tp_page_count;
|
||||
char * tp_search;
|
||||
} Entry_List_s;
|
||||
|
||||
typedef struct {
|
||||
@@ -87,8 +98,8 @@ typedef struct {
|
||||
volatile bool run_thread;
|
||||
} Thread_Arg_s;
|
||||
|
||||
void delete_entry(Entry_s entry);
|
||||
Result load_entries(const char * loading_path, Entry_List_s * list, EntryMode mode);
|
||||
void delete_entry(Entry_s * entry, bool is_file);
|
||||
Result load_entries(const char * loading_path, Entry_List_s * list);
|
||||
bool load_preview(Entry_List_s list, int * preview_offset);
|
||||
void load_icons_first(Entry_List_s * current_list, bool silent);
|
||||
void handle_scrolling(Entry_List_s * list);
|
||||
|
||||
57
include/remote.h
Normal file
57
include/remote.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 REMOTE_H
|
||||
#define REMOTE_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define THEMEPLAZA_BASE_URL "https://themeplaza.eu"
|
||||
#define THEMEPLAZA_API_URL "/api/anemone/v1"
|
||||
#define THEMEPLAZA_BASE_API_URL THEMEPLAZA_BASE_URL THEMEPLAZA_API_URL
|
||||
|
||||
#define THEMEPLAZA_PAGE_FORMAT THEMEPLAZA_BASE_API_URL "/list?page=%" JSON_INTEGER_FORMAT "&category=%i&query=%s"
|
||||
#define THEMEPLAZA_JSON_PAGE_COUNT "pages"
|
||||
#define THEMEPLAZA_JSON_PAGE_IDS "items"
|
||||
|
||||
#define THEMEPLAZA_JSON_ERROR_MESSAGE "message"
|
||||
#define THEMEPLAZA_JSON_ERROR_MESSAGE_NOT_FOUND "No items found"
|
||||
|
||||
|
||||
#define THEMEPLAZA_ENTRY_FORMAT THEMEPLAZA_BASE_API_URL "/query?item_id=%" JSON_INTEGER_FORMAT
|
||||
#define THEMEPLAZA_JSON_ENTRY_NAME "title"
|
||||
#define THEMEPLAZA_JSON_ENTRY_DESC "description"
|
||||
#define THEMEPLAZA_JSON_ENTRY_AUTH "author"
|
||||
|
||||
#define THEMEPLAZA_DOWNLOAD_FORMAT THEMEPLAZA_BASE_URL "/download/%" JSON_INTEGER_FORMAT
|
||||
#define THEMEPLAZA_PREVIEW_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/preview"
|
||||
#define THEMEPLAZA_BGM_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/bgm"
|
||||
#define THEMEPLAZA_ICON_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/preview/icon"
|
||||
|
||||
bool themeplaza_browser(EntryMode mode);
|
||||
u32 http_get(const char *url, char ** filename, char ** buf);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user