Mercurial > minori
annotate include/core/anime.h @ 260:dd211ff68b36
pages/seasons: add initial functionality
the menu doesn't work yet, but it's a good start
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Wed, 03 Apr 2024 19:48:38 -0400 |
| parents | 862d0d8619f6 |
| children | 3ec7804abf17 |
| rev | line source |
|---|---|
| 9 | 1 #ifndef __core__anime_h |
| 2 #define __core__anime_h | |
| 3 #include "core/date.h" | |
| 4 #include <array> | |
| 5 #include <map> | |
| 6 #include <vector> | |
| 7 | |
| 8 namespace Anime { | |
| 9 | |
| 10 enum class ListStatus { | |
| 11 NOT_IN_LIST, | |
| 12 CURRENT, | |
| 13 COMPLETED, | |
| 51 | 14 PAUSED, |
| 9 | 15 DROPPED, |
| 51 | 16 PLANNING |
| 9 | 17 }; |
| 18 | |
| 15 | 19 constexpr std::array<ListStatus, 5> ListStatuses{ListStatus::CURRENT, ListStatus::COMPLETED, ListStatus::PAUSED, |
| 20 ListStatus::DROPPED, ListStatus::PLANNING}; | |
| 9 | 21 |
| 22 enum class SeriesStatus { | |
| 23 UNKNOWN, | |
| 24 FINISHED, | |
| 25 RELEASING, | |
| 26 NOT_YET_RELEASED, | |
| 27 CANCELLED, | |
| 28 HIATUS | |
| 29 }; | |
| 30 | |
| 31 enum class SeriesFormat { | |
| 32 UNKNOWN, | |
| 33 TV, | |
| 34 TV_SHORT, | |
| 35 MOVIE, | |
| 36 SPECIAL, | |
| 37 OVA, | |
| 38 ONA, | |
| 39 MUSIC, | |
| 40 MANGA, | |
| 41 NOVEL, | |
| 42 ONE_SHOT | |
| 43 }; | |
| 44 | |
| 45 enum class SeriesSeason { | |
| 46 UNKNOWN, | |
| 47 WINTER, | |
| 48 SPRING, | |
| 49 SUMMER, | |
| 50 FALL | |
| 51 }; | |
| 52 | |
|
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
53 constexpr std::array<SeriesSeason, 4> SeriesSeasons{ |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
54 SeriesSeason::WINTER, SeriesSeason::SPRING, |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
55 SeriesSeason::SUMMER, SeriesSeason::FALL |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
56 }; |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
57 |
| 9 | 58 enum class TitleLanguage { |
| 59 ROMAJI, | |
| 60 NATIVE, | |
| 61 ENGLISH | |
| 62 }; | |
| 63 | |
| 64 enum class Services { | |
| 65 NONE, | |
| 66 ANILIST, | |
| 67 NB_SERVICES | |
| 68 }; | |
| 69 | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
70 enum class ScoreFormat { |
| 258 | 71 POINT_100, // 0-100 |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
72 POINT_10_DECIMAL, // 0.0-10.0 |
| 258 | 73 POINT_10, // 0-10 |
| 74 POINT_5, // 0-5, should be represented in stars | |
| 75 POINT_3 // 1-3, should be represented in smileys | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
76 }; |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
77 |
| 258 | 78 constexpr std::array<ScoreFormat, 5> ScoreFormats{ScoreFormat::POINT_100, ScoreFormat::POINT_10_DECIMAL, |
| 79 ScoreFormat::POINT_10, ScoreFormat::POINT_5, ScoreFormat::POINT_3}; | |
| 189 | 80 |
| 9 | 81 struct ListInformation { |
| 258 | 82 int id = 0; |
| 83 int progress = 0; | |
| 84 int score = 0; // note that this will ALWAYS be in POINT_100 format and must be converted | |
| 85 ListStatus status = ListStatus::NOT_IN_LIST; | |
| 86 Date started; | |
| 87 Date completed; | |
| 88 bool is_private = false; | |
| 89 unsigned int rewatched_times = 0; | |
| 90 bool rewatching = false; | |
| 91 uint64_t updated = 0; | |
| 92 std::string notes; | |
| 9 | 93 }; |
| 94 | |
| 95 struct SeriesInformation { | |
| 258 | 96 int id; |
| 97 struct { | |
| 98 std::string romaji; | |
| 99 std::string english; | |
| 100 std::string native; | |
| 101 } title; | |
| 102 std::vector<std::string> synonyms; | |
| 103 int episodes = 0; | |
| 104 SeriesStatus status = SeriesStatus::UNKNOWN; | |
| 105 Date air_date; | |
| 106 std::vector<std::string> genres; | |
| 107 std::vector<std::string> producers; | |
| 108 SeriesFormat format = SeriesFormat::UNKNOWN; | |
| 109 SeriesSeason season = SeriesSeason::UNKNOWN; | |
| 110 int audience_score = 0; | |
| 111 std::string synopsis; | |
| 112 int duration = 0; | |
| 113 std::string poster_url; | |
| 9 | 114 }; |
| 115 | |
| 116 class Anime { | |
| 258 | 117 public: |
| 118 /* User list data */ | |
| 119 ListStatus GetUserStatus() const; | |
| 120 int GetUserProgress() const; | |
| 121 int GetUserScore() const; | |
| 122 std::string GetUserPresentableScore() const; | |
| 123 Date GetUserDateStarted() const; | |
| 124 Date GetUserDateCompleted() const; | |
| 125 bool GetUserIsPrivate() const; | |
| 126 unsigned int GetUserRewatchedTimes() const; | |
| 127 bool GetUserIsRewatching() const; | |
| 128 uint64_t GetUserTimeUpdated() const; | |
| 129 std::string GetUserNotes() const; | |
| 9 | 130 |
| 258 | 131 void SetUserStatus(ListStatus status); |
| 132 void SetUserScore(int score); | |
| 133 void SetUserProgress(int progress); | |
| 134 void SetUserDateStarted(Date const& started); | |
| 135 void SetUserDateCompleted(Date const& completed); | |
| 136 void SetUserIsPrivate(bool is_private); | |
| 137 void SetUserRewatchedTimes(int rewatched); | |
| 138 void SetUserIsRewatching(bool rewatching); | |
| 139 void SetUserTimeUpdated(uint64_t updated); | |
| 140 void SetUserNotes(std::string const& notes); | |
| 9 | 141 |
| 258 | 142 /* Series data */ |
| 143 int GetId() const; | |
| 144 std::string GetRomajiTitle() const; | |
| 145 std::string GetEnglishTitle() const; | |
| 146 std::string GetNativeTitle() const; | |
| 147 std::vector<std::string> GetTitleSynonyms() const; | |
| 148 int GetEpisodes() const; | |
| 149 SeriesStatus GetAiringStatus() const; | |
| 150 Date GetAirDate() const; | |
| 151 std::vector<std::string> GetGenres() const; | |
| 152 std::vector<std::string> GetProducers() const; | |
| 153 SeriesFormat GetFormat() const; | |
| 154 SeriesSeason GetSeason() const; | |
| 155 int GetAudienceScore() const; | |
| 156 std::string GetSynopsis() const; | |
| 157 int GetDuration() const; | |
| 158 std::string GetPosterUrl() const; | |
| 159 std::string GetServiceUrl() const; | |
| 9 | 160 |
| 258 | 161 void SetId(int id); |
| 162 void SetRomajiTitle(std::string const& title); | |
| 163 void SetEnglishTitle(std::string const& title); | |
| 164 void SetNativeTitle(std::string const& title); | |
| 165 void SetTitleSynonyms(std::vector<std::string> const& synonyms); | |
| 166 void AddTitleSynonym(std::string const& synonym); | |
| 167 void SetEpisodes(int episodes); | |
| 168 void SetAiringStatus(SeriesStatus status); | |
| 169 void SetAirDate(Date const& date); | |
| 170 void SetGenres(std::vector<std::string> const& genres); | |
| 171 void SetProducers(std::vector<std::string> const& producers); | |
| 172 void SetFormat(SeriesFormat format); | |
| 173 void SetSeason(SeriesSeason season); | |
| 174 void SetAudienceScore(int audience_score); | |
| 175 void SetSynopsis(std::string synopsis); | |
| 176 void SetDuration(int duration); | |
| 177 void SetPosterUrl(std::string poster); | |
| 9 | 178 |
| 258 | 179 std::string GetUserPreferredTitle() const; |
| 9 | 180 |
| 258 | 181 /* User stuff */ |
| 182 void AddToUserList(); | |
| 183 bool IsInUserList() const; | |
| 184 void RemoveFromUserList(); | |
| 9 | 185 |
| 258 | 186 private: |
| 187 SeriesInformation info_; | |
| 188 std::shared_ptr<struct ListInformation> list_info_; | |
| 9 | 189 }; |
| 190 | |
| 191 } // namespace Anime | |
| 192 | |
| 51 | 193 #endif // __core__anime_h |
