diff src/gui/translate/anime.cc @ 185:62e336597bb7

anime list: add support for different score formats
author Paper <mrpapersonic@gmail.com>
date Tue, 05 Dec 2023 13:45:23 -0500
parents 9b10175be389
children 9613d72b097e
line wrap: on
line diff
--- a/src/gui/translate/anime.cc	Mon Dec 04 13:44:42 2023 -0500
+++ b/src/gui/translate/anime.cc	Tue Dec 05 13:45:23 2023 -0500
@@ -71,6 +71,17 @@
 	}
 }
 
+std::string ToString(const Anime::ScoreFormat format) {
+	switch (format) {
+		case Anime::ScoreFormat::POINT_3: return "POINT_3";
+		case Anime::ScoreFormat::POINT_5: return "POINT_5";
+		case Anime::ScoreFormat::POINT_10: return "POINT_10";
+		case Anime::ScoreFormat::POINT_10_DECIMAL: return "POINT_10_DECIMAL";
+		default:
+		case Anime::ScoreFormat::POINT_100: return "POINT_100";
+	}
+}
+
 Anime::ListStatus ToListStatus(const std::string& str) {
 	const std::unordered_map<std::string, Anime::ListStatus> map = {
 	    {"Currently watching", Anime::ListStatus::CURRENT},
@@ -150,6 +161,20 @@
 	return map.at(str);
 }
 
+Anime::ScoreFormat ToScoreFormat(const std::string& str) {
+	const std::unordered_map<std::string, Anime::ScoreFormat> map = {
+	    {"POINT_3", Anime::ScoreFormat::POINT_3},
+	    {"POINT_5", Anime::ScoreFormat::POINT_5},
+	    {"POINT_10", Anime::ScoreFormat::POINT_10},
+	    {"POINT_10_DECIMAL", Anime::ScoreFormat::POINT_10_DECIMAL},
+	    {"POINT_100", Anime::ScoreFormat::POINT_100}
+	};
+
+	if (map.find(str) == map.end())
+		return Anime::ScoreFormat::POINT_100;
+	return map.at(str);
+}
+
 /* Localized versions of ToString() functions */
 
 std::string ToLocalString(const Anime::ListStatus status) {