Skip to content

Commit 1770af7

Browse files
committed
force close client, skins tab improvement
1 parent 0805120 commit 1770af7

6 files changed

Lines changed: 114 additions & 63 deletions

File tree

KBotExt/ChampsTab.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class ChampsTab
2828
ImGui::RadioButton("Purchase date", &iSort, 1);
2929
ImGui::SameLine();
3030
ImGui::RadioButton("Mastery points", &iSort, 2);
31+
ImGui::SameLine();
32+
ImGui::RadioButton("ID", &iSort, 3);
3133

3234
if (bOnOpen)
3335
{
@@ -156,6 +158,12 @@ class ChampsTab
156158
return lhs.mas.championPoints > rhs.mas.championPoints;
157159
});
158160
break;
161+
// id
162+
case 3:
163+
std::sort(champsAll.begin(), champsAll.end(), [](const ChampAll& lhs, const ChampAll& rhs) {
164+
return lhs.min.id < rhs.min.id;
165+
});
166+
break;
159167
}
160168
}
161169

KBotExt/Definitions.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ inline std::vector<ChampMinimal>champsMinimal;
5555
inline std::vector<ChampMastery>champsMastery;
5656
inline std::vector<ChampAll>champsAll;
5757

58+
struct Skin
59+
{
60+
std::string name;
61+
std::string inventoryType;
62+
int itemId;
63+
std::string ownershipType;
64+
bool isVintage;
65+
std::string purchaseDate;
66+
int qunatity;
67+
std::string uuid;
68+
};
69+
70+
inline std::vector<Skin>ownedSkins;
71+
5872
enum QueueID : const int
5973
{
6074
DraftPick = 400,

KBotExt/GameTab.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ class GameTab
317317
ImGui::SliderInt("Delay##sliderInstalockDelay", &S.gameTab.instalockDelay, 0, 10000, "%d ms");
318318

319319
ImGui::NextColumn();
320+
// todo
320321
bool test11;
321322
ImGui::Checkbox("Dodge on champion ban", &test11);
322323

@@ -335,6 +336,7 @@ class GameTab
335336
}
336337
}
337338

339+
// todo
338340
if (ImGui::CollapsingHeader("Backup pick"))
339341
{
340342
ImGui::Text("None");

KBotExt/Misc.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ class Misc
8686
return "0.0.0";
8787
}
8888

89-
static std::string ClearLogs()
89+
static void TaskKillLeague()
9090
{
91-
std::string result = "";
9291
Misc::TerminateProcessByName("RiotClientServices.exe");
9392
Misc::TerminateProcessByName("RiotClientCrashHandler.exe");
9493
Misc::TerminateProcessByName("RiotClientUx.exe");
@@ -98,6 +97,13 @@ class Misc
9897
Misc::TerminateProcessByName("LeagueCrashHandler.exe");
9998
Misc::TerminateProcessByName("LeagueClientUx.exe");
10099
Misc::TerminateProcessByName("LeagueClientUxRender.exe");
100+
}
101+
102+
static std::string ClearLogs()
103+
{
104+
std::string result = "";
105+
106+
TaskKillLeague();
101107

102108
std::this_thread::sleep_for(std::chrono::seconds(2));
103109

KBotExt/MiscTab.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ class MiscTab
121121
if (ImGui::Button("Close client"))
122122
result = http->Request("POST", "https://127.0.0.1/process-control/v1/process/quit", "", auth->leagueHeader, "", "", auth->leaguePort);
123123

124+
ImGui::SameLine();
125+
if (ImGui::Button("Force close client"))
126+
Misc::TaskKillLeague();
127+
124128
ImGui::Columns(1);
125129

126130
ImGui::Separator();

KBotExt/SkinsTab.h

Lines changed: 78 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,88 +10,105 @@ class SkinsTab
1010
public:
1111
static void Render()
1212
{
13-
static bool skinsOpen = true;
13+
//todo add sorting
14+
15+
static bool bOnOpen = true;
1416
if (ImGui::BeginTabItem("Skins"))
1517
{
16-
static std::string result;
17-
static Json::Value root;
18-
19-
// todo improve performance
20-
// and combobox to sort by name, date etc
21-
22-
if (skinsOpen)
18+
if (bOnOpen)
2319
{
24-
skinsOpen = false;
25-
result = http->Request("GET", "https://127.0.0.1/lol-inventory/v2/inventory/CHAMPION_SKIN", "", auth->leagueHeader, "", "", auth->leaguePort);
20+
bOnOpen = false;
21+
ownedSkins.clear();
2622

27-
Json::CharReaderBuilder builder;
28-
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
29-
JSONCPP_STRING err;
23+
static Json::Value root;
24+
static Json::CharReaderBuilder builder;
25+
static const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
26+
static JSONCPP_STRING err;
3027

31-
if (!reader->parse(result.c_str(), result.c_str() + static_cast<int>(result.length()), &root, &err))
32-
result = "Failed to parse JSON";
33-
}
34-
35-
if (root.isArray())
36-
{
37-
ImGui::Text("Skins owned: %d", root.size());
28+
std::string getSkins = http->Request("GET", "https://127.0.0.1/lol-inventory/v2/inventory/CHAMPION_SKIN", "", auth->leagueHeader, "", "", auth->leaguePort);
3829

39-
for (Json::Value::ArrayIndex i = 0; i < root.size(); ++i)
30+
if (reader->parse(getSkins.c_str(), getSkins.c_str() + static_cast<int>(getSkins.length()), &root, &err))
4031
{
41-
ImGui::Separator();
42-
std::string itemId = root[i]["itemId"].asString();
43-
if (!champSkins.empty())
32+
if (root.isArray())
4433
{
45-
bool found = false;
46-
for (auto champ : champSkins)
34+
for (Json::Value::ArrayIndex i = 0; i < root.size(); ++i)
4735
{
48-
if (itemId.substr(0, std::to_string(champ.key).size()) == std::to_string(champ.key))
36+
Skin skin;
37+
38+
skin.inventoryType = root[i]["inventoryType"].asString().c_str();;
39+
skin.itemId = root[i]["itemId"].asInt();
40+
skin.ownershipType = root[i]["ownershipType"].asString().c_str();
41+
skin.isVintage = root[i]["payload"]["isVintage"].asBool();
42+
skin.purchaseDate = root[i]["purchaseDate"].asString().c_str();
43+
skin.qunatity = root[i]["quantity"].asInt();
44+
skin.uuid = root[i]["uuid"].asString().c_str();
45+
46+
if (!champSkins.empty())
4947
{
50-
for (auto skin : champ.skins)
48+
bool found = false;
49+
for (auto champ : champSkins)
5150
{
52-
if (itemId == skin.first)
51+
for (auto s : champ.skins)
5352
{
54-
ImGui::Text("Name: %s", skin.second.c_str());
55-
found = true;
56-
break;
53+
if (skin.itemId == std::stoi(s.first))
54+
{
55+
skin.name = s.second.c_str();
56+
found = true;
57+
break;
58+
}
5759
}
60+
if (found)
61+
break;
5862
}
59-
if (found)
60-
break;
6163
}
64+
ownedSkins.emplace_back(skin);
6265
}
6366
}
67+
}
68+
}
6469

65-
ImGui::Text("inventoryType: %s", root[i]["inventoryType"].asString().c_str());
66-
ImGui::Text("itemId: %s", itemId.c_str());
67-
ImGui::Text("ownershipType: %s", root[i]["ownershipType"].asString().c_str());
68-
auto payloadObj = root[i]["payload"];
69-
ImGui::Text("isVintage: %d", payloadObj["isVintage"].asInt());
70-
std::string purchaseDateFormatted = root[i]["purchaseDate"].asString();
71-
size_t fintTPos = purchaseDateFormatted.find("T");
72-
size_t finddDotPos = purchaseDateFormatted.find(".");
73-
size_t findMinusPos = purchaseDateFormatted.find("-");
74-
if (findMinusPos == std::string::npos)
75-
{
76-
purchaseDateFormatted = purchaseDateFormatted.substr(0, finddDotPos);
77-
purchaseDateFormatted.insert(4, "-");
78-
purchaseDateFormatted.insert(7, "-");
79-
purchaseDateFormatted.replace(fintTPos + 2, 1, " ");
80-
purchaseDateFormatted.insert(fintTPos + 2 + 3, ":");
81-
purchaseDateFormatted.insert(fintTPos + 2 + 3 + 3, ":");
82-
}
83-
else
84-
{
85-
purchaseDateFormatted = purchaseDateFormatted.substr(0, finddDotPos);
86-
purchaseDateFormatted.replace(fintTPos, 1, " ");
87-
}
88-
ImGui::Text("purchaseDate: %s", purchaseDateFormatted.c_str());
89-
ImGui::Text("quantity: %d", root[i]["quantity"].asInt());
90-
ImGui::Text("uuid: %s", root[i]["uuid"].asString().c_str());
70+
ImGui::Text("Skins owned: %d", ownedSkins.size());
71+
72+
for (Skin skin : ownedSkins)
73+
{
74+
ImGui::Separator();
75+
if (!skin.name.empty())
76+
ImGui::Text("name: %s", skin.name.c_str());
77+
//else if (!champSkins.empty())
78+
// ImGui::Text("name: Chroma"); // todo find a way to get chroma's name
79+
ImGui::Text("inventoryType: %s", skin.inventoryType.c_str());
80+
ImGui::Text("itemId: %d", skin.itemId);
81+
ImGui::Text("ownershipType: %s", skin.ownershipType.c_str());
82+
ImGui::Text("isVintage: %d", skin.isVintage);
83+
ImGui::Text("purchaseDate: %s", skin.purchaseDate.c_str());
84+
85+
/*std::string purchaseDateFormatted = root[i]["purchaseDate"].asString();
86+
size_t fintTPos = purchaseDateFormatted.find("T");
87+
size_t finddDotPos = purchaseDateFormatted.find(".");
88+
size_t findMinusPos = purchaseDateFormatted.find("-");
89+
if (findMinusPos == std::string::npos)
90+
{
91+
purchaseDateFormatted = purchaseDateFormatted.substr(0, finddDotPos);
92+
purchaseDateFormatted.insert(4, "-");
93+
purchaseDateFormatted.insert(7, "-");
94+
purchaseDateFormatted.replace(fintTPos + 2, 1, " ");
95+
purchaseDateFormatted.insert(fintTPos + 2 + 3, ":");
96+
purchaseDateFormatted.insert(fintTPos + 2 + 3 + 3, ":");
97+
}
98+
else
99+
{
100+
purchaseDateFormatted = purchaseDateFormatted.substr(0, finddDotPos);
101+
purchaseDateFormatted.replace(fintTPos, 1, " ");
91102
}
103+
ImGui::Text("purchaseDate: %s", purchaseDateFormatted.c_str());*/
104+
105+
ImGui::Text("quantity: %d", skin.qunatity);
106+
ImGui::Text("uuid: %s", skin.uuid.c_str());
92107
}
108+
93109
ImGui::EndTabItem();
94110
}
95-
else skinsOpen = true;
111+
else
112+
bOnOpen = true;
96113
}
97114
};

0 commit comments

Comments
 (0)