From 58481b46a2c64fda4f506e15ee94dd97f527d552 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 6 Aug 2019 03:12:16 +0200 Subject: Save and show progress in manga and return to last page" --- include/Body.hpp | 3 +++ include/Path.hpp | 26 ++++++++++++++++++++++ include/QuickMedia.hpp | 6 +++++ include/Storage.hpp | 18 +++++++++++++++ include/env.hpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 include/Path.hpp create mode 100644 include/Storage.hpp create mode 100644 include/env.hpp (limited to 'include') diff --git a/include/Body.hpp b/include/Body.hpp index e09017d..e854e76 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace QuickMedia { @@ -35,6 +36,7 @@ namespace QuickMedia { void clamp_selection(); void draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size); + void draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const Json::Value &content_progress); static bool string_find_case_insensitive(const std::string &str, const std::string &substr); // TODO: Make this actually fuzzy... Right now it's just a case insensitive string find. @@ -42,6 +44,7 @@ namespace QuickMedia { void filter_search_fuzzy(const std::string &text); sf::Text title_text; + sf::Text progress_text; int selected_item; std::vector> items; std::vector> item_thumbnail_textures; diff --git a/include/Path.hpp b/include/Path.hpp new file mode 100644 index 0000000..351fd5d --- /dev/null +++ b/include/Path.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace QuickMedia { + class Path { + public: + Path() = default; + ~Path() = default; + Path(const Path &other) = default; + Path& operator=(const Path &other) = default; + Path(const char *path) : data(path) {} + Path(const std::string &path) : data(path) {} + Path(Path &&other) { + data = std::move(other.data); + } + + Path& join(const Path &other) { + data += "/"; + data += other.data; + return *this; + } + + std::string data; + }; +} \ No newline at end of file diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index e5f4f2d..48a2d8a 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -2,10 +2,12 @@ #include "SearchBar.hpp" #include "Page.hpp" +#include "Storage.hpp" #include #include #include #include +#include namespace QuickMedia { class Body; @@ -34,6 +36,10 @@ namespace QuickMedia { // TODO: Combine these std::string video_url; std::string images_url; + std::string content_title; + std::string chapter_title; int image_index; + Path content_storage_file; + Json::Value content_storage_json; }; } \ No newline at end of file diff --git a/include/Storage.hpp b/include/Storage.hpp new file mode 100644 index 0000000..bd4283c --- /dev/null +++ b/include/Storage.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "Path.hpp" + +namespace QuickMedia { + enum class FileType { + FILE_NOT_FOUND, + REGULAR, + DIRECTORY + }; + + Path get_home_dir(); + Path get_storage_dir(); + int create_directory_recursive(const Path &path); + FileType get_file_type(const Path &path); + int file_get_content(const Path &path, std::string &result); + int file_overwrite(const Path &path, const std::string &data); +} \ No newline at end of file diff --git a/include/env.hpp b/include/env.hpp new file mode 100644 index 0000000..b842ff3 --- /dev/null +++ b/include/env.hpp @@ -0,0 +1,59 @@ +#pragma once + +#define OS_FAMILY_WINDOWS 0 +#define OS_FAMILY_POSIX 1 + +#define OS_TYPE_WINDOWS 0 +#define OS_TYPE_LINUX 1 + +#if defined(_WIN32) || defined(_WIN64) + #if defined(_WIN64) + #define SYS_ENV_64BIT + #else + #define SYS_ENV_32BIT + #endif + #define OS_FAMILY OS_FAMILY_WINDOWS + #define OS_TYPE OS_TYPE_WINDOWS + + #ifndef UNICODE + #define UNICODE + #endif + + #ifndef _UNICODE + #define _UNICODE + #endif + + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN + #endif + + #include +#endif + +#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION) + #define OS_FAMILY OS_FAMILY_POSIX +#endif + +#if defined(__linux__) || defined(__CYGWIN__) + #define OS_TYPE OS_TYPE_LINUX +#endif + +#if defined(__GNUC__) + #if defined(__x86_64__) || defined(__pc64__) + #define SYS_ENV_64BIT + #else + #define SYS_ENV_32BIT + #endif +#endif + +#if !defined(SYS_ENV_32BIT) && !defined(SYS_ENV_64BIT) + #error "System is not detected as either 32-bit or 64-bit" +#endif + +#if !defined(OS_FAMILY) + #error "System not supported. Only Windows and Posix systems supported right now" +#endif + +#if !defined(OS_TYPE) + #error "System not supported. Only Windows and linux systems supported right now" +#endif -- cgit v1.2.3