Mercurial > minori
diff src/core/anime.cc @ 279:657fda1b9cac
*: clean up enums
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 19 Apr 2024 13:24:06 -0400 |
parents | ff0b2052b234 |
children | 9b6e12c14a1e |
line wrap: on
line diff
--- a/src/core/anime.cc Thu Apr 18 17:24:42 2024 -0400 +++ b/src/core/anime.cc Fri Apr 19 13:24:06 2024 -0400 @@ -3,6 +3,7 @@ * datatypes & variables */ #include "core/anime.h" +#include "core/anime_season.h" #include "core/date.h" #include "core/session.h" #include "core/strings.h" @@ -46,15 +47,16 @@ std::string Anime::GetUserPresentableScore() const { assert(list_info_.has_value()); + const int score = list_info_->score; if (score == 0) return ""; switch (session.config.anime_list.score_format) { - case ScoreFormat::POINT_10_DECIMAL: + case ScoreFormat::Point10Decimal: return Strings::ToUtf8String(score / 10) + "." + Strings::ToUtf8String(score % 10); - case ScoreFormat::POINT_10: return Strings::ToUtf8String(score / 10); - case ScoreFormat::POINT_5: { + case ScoreFormat::Point10: return Strings::ToUtf8String(score / 10); + case ScoreFormat::Point5: { std::string stars = ""; for (int i = 0; i < 100; i += 20) @@ -62,7 +64,7 @@ return stars; } - case ScoreFormat::POINT_3: { + case ScoreFormat::Point3: { if (score >= 100) return ":)"; else if (score >= 66) @@ -73,7 +75,7 @@ return ""; } default: - case ScoreFormat::POINT_100: return Strings::ToUtf8String(score); + case ScoreFormat::Point100: return Strings::ToUtf8String(score); } } @@ -222,7 +224,8 @@ } SeriesSeason Anime::GetSeason() const { - return info_.season; + std::optional<Date::Month> month = info_.air_date.GetMonth(); + return (month.has_value() ? GetSeasonForMonth(month.value()) : SeriesSeason::Unknown); } int Anime::GetAudienceScore() const { @@ -243,7 +246,10 @@ std::string Anime::GetServiceUrl() const { /* todo: add support for other services... */ - return "https://anilist.co/anime/" + Strings::ToUtf8String(GetId()); + switch (session.config.service) { + case Service::AniList: return "https://anilist.co/anime/" + Strings::ToUtf8String(GetId()); + default: return ""; + } } void Anime::SetId(int id) { @@ -294,10 +300,6 @@ info_.format = format; } -void Anime::SetSeason(SeriesSeason season) { - info_.season = season; -} - void Anime::SetAudienceScore(int audience_score) { info_.audience_score = audience_score; } @@ -316,8 +318,8 @@ std::string Anime::GetUserPreferredTitle() const { switch (session.config.anime_list.language) { - case TitleLanguage::NATIVE: return (GetNativeTitle().empty()) ? GetRomajiTitle() : GetNativeTitle(); - case TitleLanguage::ENGLISH: return (GetEnglishTitle().empty()) ? GetRomajiTitle() : GetEnglishTitle(); + case TitleLanguage::Native: return (GetNativeTitle().empty()) ? GetRomajiTitle() : GetNativeTitle(); + case TitleLanguage::Romaji: return (GetEnglishTitle().empty()) ? GetRomajiTitle() : GetEnglishTitle(); default: break; } return GetRomajiTitle();