| 310 | } |
| 311 | |
| 312 | static void Invoke() |
| 313 | { |
| 314 | static bool once = true; |
| 315 | |
| 316 | static char destination[1024]; |
| 317 | static char method[1024]; |
| 318 | static char args[1024 * 32]; |
| 319 | |
| 320 | if (once) |
| 321 | { |
| 322 | once = false; |
| 323 | std::ranges::copy(S.invokeTab.destination, destination); |
| 324 | std::ranges::copy(S.invokeTab.method, method); |
| 325 | std::ranges::copy(S.invokeTab.args, args); |
| 326 | } |
| 327 | |
| 328 | ImGui::Text("Destination:"); |
| 329 | ImGui::InputTextMultiline("##inputDestination", destination, IM_ARRAYSIZE(destination), ImVec2(600, 20)); |
| 330 | |
| 331 | ImGui::Text("Method:"); |
| 332 | ImGui::InputTextMultiline("##inputMethod", method, IM_ARRAYSIZE(method), ImVec2(600, 20)); |
| 333 | |
| 334 | ImGui::Text("Args:"); |
| 335 | ImGui::InputTextMultiline("##inputArgs", args, IM_ARRAYSIZE(args), ImVec2(600, 50)); |
| 336 | |
| 337 | S.invokeTab.destination = destination; |
| 338 | S.invokeTab.method = method; |
| 339 | S.invokeTab.args = args; |
| 340 | |
| 341 | static std::string result; |
| 342 | if (ImGui::Button("Submit##submitInvoke")) |
| 343 | { |
| 344 | const std::string req = std::format("https://127.0.0.1/lol-login/v1/session/invoke?destination={0}&method={1}&args=[{2}]", |
| 345 | destination, method, args); |
| 346 | result = LCU::Request("POST", req, ""); |
| 347 | } |
| 348 | |
| 349 | ImGui::Text("Result:"); |
| 350 | ImGui::SameLine(); |
| 351 | |
| 352 | if (ImGui::Button("Copy to clipboard##invokeTab")) |
| 353 | { |
| 354 | Utils::CopyToClipboard(result); |
| 355 | } |
| 356 | |
| 357 | static Json::StreamWriterBuilder wBuilder; |
| 358 | static std::string sResultJson; |
| 359 | static char* cResultJson; |
| 360 | |
| 361 | if (!result.empty()) |
| 362 | { |
| 363 | const Json::CharReaderBuilder builder; |
| 364 | const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 365 | JSONCPP_STRING err; |
| 366 | Json::Value root; |
| 367 | if (!reader->parse(result.c_str(), result.c_str() + static_cast<int>(result.length()), &root, &err)) |
| 368 | sResultJson = result; |
| 369 | else |