diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Body.hpp | 3 | ||||
-rw-r--r-- | include/Path.hpp | 26 | ||||
-rw-r--r-- | include/QuickMedia.hpp | 6 | ||||
-rw-r--r-- | include/Storage.hpp | 18 | ||||
-rw-r--r-- | include/env.hpp | 59 |
5 files changed, 112 insertions, 0 deletions
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 <SFML/Graphics/Text.hpp> #include <SFML/Graphics/Texture.hpp> #include <SFML/Graphics/RenderWindow.hpp> +#include <json/value.h> #include <thread> 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<std::unique_ptr<BodyItem>> items; std::vector<std::shared_ptr<sf::Texture>> 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 <string> + +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 <vector> #include <memory> #include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/RenderWindow.hpp> +#include <json/value.h> 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 <windows.h> +#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 |