| 7 | #pragma warning (disable : 4996) |
| 8 | |
| 9 | class ChampsTab |
| 10 | { |
| 11 | public: |
| 12 | static void Render() |
| 13 | { |
| 14 | static bool bOnOpen = true; |
| 15 | static unsigned iChampsOwned = 0; |
| 16 | static bool bSortOnOpen = false; |
| 17 | |
| 18 | if (ImGui::BeginTabItem("Champs")) |
| 19 | { |
| 20 | ImGui::Text("Sort by: "); |
| 21 | ImGui::SameLine(); |
| 22 | |
| 23 | static int iSort = 0; |
| 24 | static int iLastSort = -1; |
| 25 | ImGui::RadioButton("Alphabetically", &iSort, 0); |
| 26 | ImGui::SameLine(); |
| 27 | ImGui::RadioButton("Purchase date", &iSort, 1); |
| 28 | ImGui::SameLine(); |
| 29 | ImGui::RadioButton("Mastery points", &iSort, 2); |
| 30 | ImGui::SameLine(); |
| 31 | ImGui::RadioButton("ID", &iSort, 3); |
| 32 | |
| 33 | if (bOnOpen) |
| 34 | { |
| 35 | bOnOpen = false; |
| 36 | bSortOnOpen = true; |
| 37 | iChampsOwned = 0; |
| 38 | champsMinimal.clear(); |
| 39 | champsMastery.clear(); |
| 40 | |
| 41 | static Json::Value root; |
| 42 | static Json::CharReaderBuilder builder; |
| 43 | static const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 44 | static JSONCPP_STRING err; |
| 45 | std::string getSession = LCU::Request("GET", "https://127.0.0.1/lol-login/v1/session"); |
| 46 | if (reader->parse(getSession.c_str(), getSession.c_str() + static_cast<int>(getSession.length()), &root, &err)) |
| 47 | { |
| 48 | std::string summId = root["summonerId"].asString(); |
| 49 | |
| 50 | std::string getChampions = LCU::Request("GET", |
| 51 | std::format("https://127.0.0.1/lol-champions/v1/inventories/{}/champions-minimal", |
| 52 | summId)); |
| 53 | |
| 54 | if (reader->parse(getChampions.c_str(), getChampions.c_str() + static_cast<int>(getChampions.length()), &root, &err)) |
| 55 | { |
| 56 | if (root.isArray()) |
| 57 | { |
| 58 | for (auto& champObj : root) |
| 59 | { |
| 60 | ChampMinimal champ; |
| 61 | |
| 62 | champ.active = champObj["active"].asBool(); |
| 63 | champ.alias = champObj["alias"].asString(); |
| 64 | champ.banVoPath = champObj["banVoPath"].asString(); |
| 65 | champ.baseLoadScreenPath = champObj["baseLoadScreenPath"].asString(); |
| 66 | champ.botEnabled = champObj["botEnabled"].asBool(); |
nothing calls this directly
no outgoing calls
no test coverage detected