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