MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / Render

Method Render

KBotExt/ProfileTab.h:10–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8{
9public:
10 static void Render()
11 {
12 if (ImGui::BeginTabItem("Profile"))
13 {
14 static char statusText[1024 * 16];
15 ImGui::Text("Status:");
16 const ImVec2 label_size = ImGui::CalcTextSize("W", nullptr, true);
17
18 ImGui::InputTextMultiline("##inputStatus", statusText, IM_ARRAYSIZE(statusText), ImVec2(S.Window.width - 230.f,
19 (label_size.y + ImGui::GetStyle().FramePadding.y) * 6.f), ImGuiInputTextFlags_AllowTabInput);
20 if (ImGui::Button("Submit status"))
21 {
22 std::string body = R"({"statusMessage":")" + std::string(statusText) + "\"}";
23
24 size_t nPos = 0;
25 while (nPos != std::string::npos)
26 {
27 nPos = body.find('\n', nPos);
28 if (nPos != std::string::npos)
29 {
30 body.erase(body.begin() + nPos);
31 body.insert(nPos, "\\n");
32 }
33 }
34 std::string result = LCU::Request("PUT", "https://127.0.0.1/lol-chat/v1/me", body);
35 if (result.find("errorCode") != std::string::npos)
36 MessageBoxA(nullptr, result.c_str(), nullptr, 0);
37 }
38
39 ImGui::SameLine();
40 static int availability = 0;
41 static int lastAvailability = 0;
42 ImGui::RadioButton("Online", &availability, 0);
43 ImGui::SameLine();
44 ImGui::RadioButton("Mobile", &availability, 1);
45 ImGui::SameLine();
46 ImGui::RadioButton("Away", &availability, 2);
47 ImGui::SameLine();
48 ImGui::RadioButton("Offline", &availability, 3);
49
50 if (availability != lastAvailability)
51 {
52 lastAvailability = availability;
53 std::string body = R"({"availability":")";
54 switch (availability)
55 {
56 case 0:
57 body += "online";
58 break;
59 case 1:
60 body += "mobile";
61 break;
62 case 2:
63 body += "away";
64 break;
65 case 3:
66 body += "offline";
67 break;

Callers

nothing calls this directly

Calls 6

ImVec2Function · 0.85
HelpMarkerFunction · 0.85
c_strMethod · 0.80
appendMethod · 0.80
beginMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected