Mercurial > minori
diff src/config.cpp @ 7:07a9095eaeed
Update
Refactored some code, moved some around
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 24 Aug 2023 23:11:38 -0400 |
parents | 1d82f6e04d7d |
children |
line wrap: on
line diff
--- a/src/config.cpp Wed Aug 16 00:49:17 2023 -0400 +++ b/src/config.cpp Thu Aug 24 23:11:38 2023 -0400 @@ -41,6 +41,18 @@ {"AniList", ANILIST} }; +std::map<enum AnimeTitleLanguage, std::string> AnimeTitleToStringMap = { + {ROMAJI, "Romaji"}, + {NATIVE, "Native"}, + {ENGLISH, "English"} +}; + +std::map<std::string, enum AnimeTitleLanguage> StringToAnimeTitleMap = { + {"Romaji", ROMAJI}, + {"Native", NATIVE}, + {"English", ENGLISH} +}; + int Config::Load() { std::filesystem::path cfg_path = get_config_path(); if (!std::filesystem::exists(cfg_path)) @@ -48,6 +60,11 @@ std::ifstream config_in(cfg_path.string().c_str(), std::ifstream::in); auto config_js = nlohmann::json::parse(config_in); service = StringToService[JSON::GetString(config_js, "/General/Service"_json_pointer)]; + anime_list.language = StringToAnimeTitleMap[JSON::GetString(config_js, "/Anime List/Display only aired episodes"_json_pointer, "Romaji")]; + anime_list.display_aired_episodes = JSON::GetBoolean(config_js, "/Anime List/Display only aired episodes"_json_pointer, true); + anime_list.display_available_episodes = JSON::GetBoolean(config_js, "/Anime List/Display only available episodes in library"_json_pointer, true); + anime_list.highlight_anime_if_available = JSON::GetBoolean(config_js, "/Anime List/Highlight anime if available"_json_pointer, true); + anime_list.highlighted_anime_above_others = JSON::GetBoolean(config_js, "/Anime List/Display highlighted anime above others"_json_pointer); anilist.auth_token = JSON::GetString(config_js, "/Authorization/AniList/Auth Token"_json_pointer); anilist.username = JSON::GetString(config_js, "/Authorization/AniList/Username"_json_pointer); anilist.user_id = JSON::GetInt(config_js, "/Authorization/AniList/User ID"_json_pointer); @@ -65,6 +82,13 @@ {"General", { {"Service", ServiceToString[service]} }}, + {"Anime List", { + {"Title language", AnimeTitleToStringMap[anime_list.language]}, + {"Display only aired episodes", anime_list.display_aired_episodes}, + {"Display only available episodes in library", anime_list.display_available_episodes}, + {"Highlight anime if available", anime_list.highlight_anime_if_available}, + {"Display highlighted anime above others", anime_list.highlighted_anime_above_others} + }}, {"Authorization", { {"AniList", { {"Auth Token", anilist.auth_token},