TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ LoadcontributorsData()

void SupportersTribute::LoadcontributorsData ( nlohmann::json data)
private

Definition at line 42 of file SupportersTribute.cpp.

43{
44 bool isNetWorkConnected = IsNetWorkConnected();
45
46 for (nlohmann::json item : data)
47 {
48 GitHubData st;
49 st.name = item["login"];
50
51 if (!PathExist(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars"))
52 {
53 MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars");
54 }
55
56 if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected)
57 {
58 std::string urlFull = item["avatar_url"];
59 std::string baseURL = urlFull.substr(0, 37);
60 std::string pathURL = urlFull.substr(38);
61 DownloadFile(baseURL, pathURL, GetExecutableDir() + PATH_SEPARATOR
62 "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR
63 "github_avatars" PATH_SEPARATOR + st.name + "_" +
64 std::string(item["node_id"]));
65 }
66
67 st.avatar = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data"
68 PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars"
69 PATH_SEPARATOR + st.name + "_" +
70 std::string(item["node_id"]));
71 contributors.push_back(st);
72 }
73}
a class to store JSON values
Definition: json.hpp:17860