Skip to content

Commit 26bf960

Browse files
committed
league args, more config stuff, stream proof
1 parent 2d85d46 commit 26bf960

9 files changed

Lines changed: 183 additions & 26 deletions

File tree

KBotExt/CustomTab.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,33 @@ class CustomTab
1212
{
1313
if (ImGui::BeginTabItem("Custom"))
1414
{
15+
static bool once = true;
16+
1517
static char method[50];
18+
static char urlText[1024 * 16];
19+
static char requestText[1024 * 16];
20+
21+
if (once)
22+
{
23+
once = false;
24+
std::copy(S.customTab.method.begin(), S.customTab.method.end(), method);
25+
std::copy(S.customTab.urlText.begin(), S.customTab.urlText.end(), urlText);
26+
std::copy(S.customTab.requestText.begin(), S.customTab.requestText.end(), requestText);
27+
}
28+
1629
ImGui::Text("Method:");
1730
ImGui::InputText("##inputMethod", method, IM_ARRAYSIZE(method));
1831

19-
static char urlText[1024 * 16];
2032
ImGui::Text("URL:");
2133
ImGui::InputTextMultiline("##inputUrl", urlText, IM_ARRAYSIZE(urlText), ImVec2(600, 20));
2234

23-
static char requestText[1024 * 16];
2435
ImGui::Text("Body:");
2536
ImGui::InputTextMultiline("##inputBody", (requestText), IM_ARRAYSIZE(requestText), ImVec2(600, 100), ImGuiInputTextFlags_AllowTabInput);
2637

38+
S.customTab.method = method;
39+
S.customTab.urlText = urlText;
40+
S.customTab.requestText = requestText;
41+
2742
static std::string customHeader = auth->leagueHeader;
2843
static int customPort = auth->leaguePort;
2944

KBotExt/GameTab.h

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <utility>
4+
35
#include "Definitions.h"
46
#include "Includes.h"
57
#include "HTTP.h"
@@ -14,6 +16,7 @@ inline char instantMessage[50];
1416
class GameTab
1517
{
1618
public:
19+
1720
static void Render()
1821
{
1922
if (ImGui::BeginTabItem("Game"))
@@ -232,7 +235,7 @@ class GameTab
232235
else
233236
result = "Champion select not found";
234237
}
235-
238+
236239
ImGui::Columns(1);
237240

238241
// TODO
@@ -244,16 +247,14 @@ class GameTab
244247
ImGui::Checkbox("Instalock", &bInstalock);
245248
if (ImGui::CollapsingHeader("Instalock champ"))
246249
{
247-
for (auto min : champsMinimal)
250+
std::vector<std::pair<int, std::string>>instalockChamps = GetInstalockChamps();
251+
for (auto champ : instalockChamps)
248252
{
249-
if (!min.owned)
250-
continue;
251-
252253
char bufchamp[128];
253-
sprintf_s(bufchamp, "##Select %s", min.alias.c_str());
254-
ImGui::Text("%s", min.alias.c_str());
254+
sprintf_s(bufchamp, "##Select %s", champ.second.c_str());
255+
ImGui::Text("%s", champ.second.c_str());
255256
ImGui::SameLine();
256-
ImGui::RadioButton(bufchamp, &instalockID, min.id);
257+
ImGui::RadioButton(bufchamp, &instalockID, champ.first);
257258
}
258259
}
259260

@@ -327,4 +328,31 @@ class GameTab
327328
ImGui::EndTabItem();
328329
}
329330
}
331+
332+
static std::vector<std::pair<int, std::string>> GetInstalockChamps()
333+
{
334+
std::vector<std::pair<int, std::string>>temp;
335+
336+
std::string result = http->Request("GET", "https://127.0.0.1/lol-champions/v1/owned-champions-minimal", "", auth->leagueHeader, "", "", auth->leaguePort);
337+
Json::CharReaderBuilder builder;
338+
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
339+
JSONCPP_STRING err;
340+
Json::Value root;
341+
if (reader->parse(result.c_str(), result.c_str() + static_cast<int>(result.length()), &root, &err))
342+
{
343+
if (root.isArray())
344+
{
345+
for (Json::Value::ArrayIndex i = 0; i < root.size(); i++)
346+
{
347+
if (root[i]["freeToPlay"].asBool() == true || root[i]["ownership"]["owned"].asBool() == true)
348+
{
349+
std::pair<int, std::string > champ = { root[i]["id"].asInt() , root[i]["alias"].asString() };
350+
temp.emplace_back(champ);
351+
}
352+
}
353+
}
354+
}
355+
356+
return temp;
357+
}
330358
};

KBotExt/InfoTab.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "HTTP.h"
66
#include "Utils.h"
77
#include "Auth.h"
8+
#include "Settings.h"
89

910
class InfoTab
1011
{
@@ -13,6 +14,7 @@ class InfoTab
1314
{
1415
if (ImGui::BeginTabItem("Info"))
1516
{
17+
static bool once = true;
1618
static std::string result;
1719
static bool bPressed = false;
1820

@@ -21,8 +23,15 @@ class InfoTab
2123
static std::string summName;
2224

2325
static char playerName[50];
26+
if (once)
27+
{
28+
once = false;
29+
std::copy(S.infoTab.playerName.begin(), S.infoTab.playerName.end(), playerName);
30+
}
31+
2432
ImGui::Text("Input player name:");
2533
ImGui::InputText("##inputPlayerName", playerName, IM_ARRAYSIZE(playerName));
34+
S.infoTab.playerName = playerName;
2635
ImGui::SameLine();
2736

2837
if (ImGui::Button("Submit##playerName") || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter), false))

KBotExt/InvokeTab.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,33 @@ class InvokeTab
88
{
99
if (ImGui::BeginTabItem("Invoke"))
1010
{
11+
static bool once = true;
12+
1113
static char destination[1024 * 16];
14+
static char method[1024 * 16];
15+
static char args[1024 * 16];
16+
17+
if (once)
18+
{
19+
once = false;
20+
std::copy(S.invokeTab.destination.begin(), S.invokeTab.destination.end(), destination);
21+
std::copy(S.invokeTab.method.begin(), S.invokeTab.method.end(), method);
22+
std::copy(S.invokeTab.args.begin(), S.invokeTab.args.end(), args);
23+
}
24+
1225
ImGui::Text("Destination:");
1326
ImGui::InputTextMultiline("##inputDestination", destination, IM_ARRAYSIZE(destination), ImVec2(600, 20));
1427

15-
static char method[1024 * 16];
1628
ImGui::Text("Method:");
1729
ImGui::InputTextMultiline("##inputMethod", method, IM_ARRAYSIZE(method), ImVec2(600, 20));
1830

19-
static char args[1024 * 16];
2031
ImGui::Text("Args:");
2132
ImGui::InputTextMultiline("##inputArgs", args, IM_ARRAYSIZE(args), ImVec2(600, 50));
2233

34+
S.invokeTab.destination = destination;
35+
S.invokeTab.method = method;
36+
S.invokeTab.args = args;
37+
2338
static std::string result;
2439
if (ImGui::Button("Submit##submitInvoke"))
2540
{

KBotExt/KBotExt.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
2727
//Randomize using current time, todo swap with recent c++ random
2828
srand(time(0));
2929

30+
bool oldStreamProof = S.streamProof;
31+
3032
CSettings::Load();
3133

3234
std::string sClassName = utils->RandomString(RandomInt(5, 10));
@@ -104,6 +106,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
104106
::SetWindowPos(hwnd, 0, 0, 0, S.Window.width, S.Window.height, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
105107
}
106108

109+
if (oldStreamProof != S.streamProof)
110+
{
111+
oldStreamProof = S.streamProof;
112+
if (oldStreamProof)
113+
SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE);
114+
else
115+
SetWindowDisplayAffinity(hwnd, WDA_NONE);
116+
}
117+
107118
//Start rendering
108119
Direct3D9.StartFrame();
109120

@@ -142,6 +153,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
142153
std::this_thread::sleep_for(std::chrono::milliseconds(1));
143154
}
144155

156+
CSettings::Save();
157+
145158
// Cleanup
146159
ImGui_ImplDX11_Shutdown();
147160
ImGui_ImplWin32_Shutdown();

KBotExt/LoginTab.h

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ class LoginTab
2828
if (ImGui::BeginTabItem("Login"))
2929
{
3030
static std::string result;
31+
static bool once = true;
32+
static char leagueArgs[1024 * 16];
33+
static std::string sArgs;
34+
35+
if (once)
36+
{
37+
once = false;
38+
std::copy(S.loginTab.leagueArgs.begin(), S.loginTab.leagueArgs.end(), leagueArgs);
39+
}
40+
3141
ImGui::Columns(2, 0, false);
3242

3343
static std::vector<std::pair<std::string, std::string>>langs = {
@@ -40,7 +50,7 @@ class LoginTab
4050
{"Vietnamese","vn_VN"},{"Indonesian","id_ID"},{"Chinese (Malaysia)","zh_MY"},{"Chinese (Taiwan)","zh_TW"}
4151
};
4252
// find saved lang from cfg file
43-
auto findLang = std::find_if(langs.begin(), langs.end(), [](std::pair<std::string, std::string>k) { return k.second == S.language; });
53+
auto findLang = std::find_if(langs.begin(), langs.end(), [](std::pair<std::string, std::string>k) { return k.second == S.loginTab.language; });
4454

4555
static std::pair<std::string, std::string>selectedLang = { findLang[0].first,findLang[0].second };
4656

@@ -52,8 +62,8 @@ class LoginTab
5262
}
5363
else
5464
{
55-
ShellExecuteA(NULL, NULL, std::format("{}LeagueClient.exe", S.leaguePath).c_str(), std::format("--locale={}", selectedLang.second).c_str(), NULL, SW_SHOWNORMAL);
56-
result = S.leaguePath + "LeagueClient.exe --locale=" + selectedLang.second; // todo custom arguments
65+
ShellExecuteA(NULL, NULL, std::format("{}LeagueClient.exe", S.leaguePath).c_str(), sArgs.c_str(), NULL, SW_SHOWNORMAL);
66+
result = S.leaguePath + "LeagueClient.exe " + sArgs;
5767
}
5868
}
5969
ImGui::SameLine();
@@ -65,8 +75,17 @@ class LoginTab
6575
if (ImGui::Selectable(lang.first.c_str(), lang.first == selectedLang.first))
6676
{
6777
selectedLang = { lang.first,lang.second };
68-
S.language = lang.second;
78+
S.loginTab.language = lang.second;
6979
CSettings::Save();
80+
81+
std::string localeArg = std::format("--locale={} ", selectedLang.second);
82+
size_t localePos = sArgs.find("--locale=");
83+
if (localePos != std::string::npos)
84+
{
85+
sArgs.replace(localePos, localeArg.size(), localeArg);
86+
}
87+
else
88+
sArgs += localeArg;
7089
}
7190
}
7291
ImGui::EndCombo();
@@ -87,6 +106,14 @@ class LoginTab
87106
}
88107
ImGui::Columns(1);
89108

109+
std::copy(sArgs.begin(), sArgs.end(), leagueArgs);
110+
ImGui::Text(" Args: ");
111+
ImGui::SameLine();
112+
ImGui::InputText("##inputLeagueArgs", leagueArgs, IM_ARRAYSIZE(leagueArgs));
113+
114+
sArgs = leagueArgs;
115+
S.loginTab.leagueArgs = sArgs;
116+
90117
ImGui::Separator();
91118

92119
static char username[50];
@@ -139,7 +166,7 @@ class LoginTab
139166
}
140167

141168
ImGui::SameLine();
142-
Misc::HelpMarker("This part is only, if you want to save your login and pass to .txt file and login with 1 click. You don't have to do that, you can just log in the usual way in client and launch the tool anytime you want");
169+
Misc::HelpMarker("This part is only, if you want to save your login and pass to config file and login with 1 click. You don't have to do that, you can just log in the usual way in client and launch the tool anytime you want");
143170

144171
ImGui::Separator();
145172

KBotExt/Misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Misc
6161
if (reader->parse(getLatest.c_str(), getLatest.c_str() + static_cast<int>(getLatest.length()), &root, &err))
6262
{
6363
std::string latestName = root["tag_name"].asString();
64-
if (latestName != "1.3.0")
64+
if (latestName != "1.3.1")
6565
{
6666
if (MessageBoxA(0, "Open download website?", "New version available", MB_YESNO | MB_SETFOREGROUND) == IDYES)
6767
{

KBotExt/Settings.h

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,44 @@ struct Settings
2020
std::vector<std::string>vFonts;
2121
int selectedFont = 0;
2222
bool bAddFont = false;
23-
std::string language = "en_US";
23+
bool streamProof = false;
2424

2525
struct
2626
{
2727
int width = 700;
2828
int height = 500;
2929
bool resize = false;
3030
}Window;
31+
32+
struct
33+
{
34+
std::string playerName;
35+
}infoTab;
36+
37+
struct
38+
{
39+
std::string method;
40+
std::string urlText;
41+
std::string requestText;
42+
}customTab;
43+
44+
struct
45+
{
46+
std::string destination;
47+
std::string method;
48+
std::string args;
49+
}invokeTab;
50+
51+
struct
52+
{
53+
std::string language = "en_US";
54+
std::string leagueArgs = "--locale=en_US";
55+
}loginTab;
56+
57+
//struct
58+
//{
59+
//
60+
//}profileTab;
3161
};
3262
extern Settings S;
3363

@@ -59,7 +89,16 @@ class CSettings
5989
root["window"]["width"] = S.Window.width;
6090
root["window"]["height"] = S.Window.height;
6191
root["selectedFont"] = S.selectedFont;
62-
root["language"] = S.language;
92+
root["loginTab"]["language"] = S.loginTab.language;
93+
root["loginTab"]["leagueArgs"] = S.loginTab.leagueArgs;
94+
root["streamProof"] = S.streamProof;
95+
root["infoTab"]["playerName"] = S.infoTab.playerName;
96+
root["customTab"]["method"] = S.customTab.method;
97+
root["customTab"]["urlText"] = S.customTab.urlText;
98+
root["customTab"]["requestText"] = S.customTab.requestText;
99+
root["invokeTab"]["destination"] = S.invokeTab.destination;
100+
root["invokeTab"]["method"] = S.invokeTab.method;
101+
root["invokeTab"]["args"] = S.invokeTab.args;
63102

64103
if (S.bAddFont)
65104
{
@@ -110,7 +149,16 @@ class CSettings
110149
if (auto t = root["window"]["width"]; !t.empty()) S.Window.width = t.asInt();
111150
if (auto t = root["window"]["height"]; !t.empty()) S.Window.height = t.asInt();
112151
if (auto t = root["selectedFont"]; !t.empty()) S.selectedFont = t.asInt();
113-
if (auto t = root["language"]; !t.empty()) S.language = t.asString();
152+
if (auto t = root["loginTab"]["language"]; !t.empty()) S.loginTab.language = t.asString();
153+
if (auto t = root["loginTab"]["leagueArgs"]; !t.empty()) S.loginTab.leagueArgs = t.asString();
154+
if (auto t = root["streamProof"]; !t.empty()) S.streamProof = t.asBool();
155+
if (auto t = root["infoTab"]["playerName"]; !t.empty()) S.infoTab.playerName = t.asString();
156+
if (auto t = root["customTab"]["method"]; !t.empty()) S.customTab.method = t.asString();
157+
if (auto t = root["customTab"]["urlText"]; !t.empty()) S.customTab.urlText = t.asString();
158+
if (auto t = root["customTab"]["requestText"]; !t.empty()) S.customTab.requestText = t.asString();
159+
if (auto t = root["invokeTab"]["destination"]; !t.empty()) S.invokeTab.destination = t.asString();
160+
if (auto t = root["invokeTab"]["method"]; !t.empty()) S.invokeTab.method = t.asString();
161+
if (auto t = root["invokeTab"]["args"]; !t.empty()) S.invokeTab.args = t.asString();
114162

115163
if (root["fonts"].isArray() && !root["fonts"].empty())
116164
{

0 commit comments

Comments
 (0)