| 9 | { |
| 10 | public: |
| 11 | static void Render() |
| 12 | { |
| 13 | if (ImGui::BeginTabItem("Info")) |
| 14 | { |
| 15 | static bool once = true; |
| 16 | static std::string result; |
| 17 | static bool bPressed = false; |
| 18 | |
| 19 | static std::string accID; |
| 20 | static std::string summID; |
| 21 | static std::string summName; |
| 22 | static std::string gameName; |
| 23 | static std::string tagLine; |
| 24 | |
| 25 | static char playerName[50]; |
| 26 | if (once) |
| 27 | { |
| 28 | once = false; |
| 29 | std::ranges::copy(S.infoTab.playerName, playerName); |
| 30 | } |
| 31 | |
| 32 | ImGui::Text("Input player name:"); |
| 33 | ImGui::InputText("##inputPlayerName", playerName, IM_ARRAYSIZE(playerName)); |
| 34 | S.infoTab.playerName = playerName; |
| 35 | ImGui::SameLine(); |
| 36 | |
| 37 | if (ImGui::Button("Submit##playerName") || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter), false)) |
| 38 | { |
| 39 | std::string tempName = std::string(playerName); |
| 40 | tempName.erase(std::remove_if(tempName.begin(), tempName.end(), |
| 41 | [](unsigned char x) { return std::isspace(x); }), tempName.end()); |
| 42 | |
| 43 | size_t found; |
| 44 | while ((found = tempName.find("#")) != std::string::npos) |
| 45 | { |
| 46 | tempName.replace(found, 1, "%23"); |
| 47 | } |
| 48 | |
| 49 | result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners?name=" + tempName); |
| 50 | |
| 51 | // 2nd method |
| 52 | /*auto riotId = Utils::StringSplit(tempName, "#"); |
| 53 | if (riotId.size() > 1) |
| 54 | { |
| 55 | result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/alias/lookup?gameName=" + riotId[0] + "&tagLine=" + riotId[1]); |
| 56 | |
| 57 | Json::CharReaderBuilder builder; |
| 58 | const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 59 | JSONCPP_STRING err; |
| 60 | Json::Value root; |
| 61 | if (reader->parse(result.c_str(), result.c_str() + static_cast<int>(result.length()), &root, &err)) |
| 62 | { |
| 63 | std::string puuid = root["puuid"].asString(); |
| 64 | if (puuid != "") |
| 65 | { |
| 66 | result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners-by-puuid-cached/" + puuid); |
| 67 | } |
| 68 | } |