Skip to content

Commit 3fb4229

Browse files
committed
Added All Gamemodes ComboBox
1 parent 2156b52 commit 3fb4229

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

KBotExt/GameTab.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,42 @@ class GameTab
1919
static std::string result;
2020
static std::string custom;
2121

22+
static std::vector < std::pair<long, std::string>>gamemodes;
23+
24+
if (onOpen)
25+
{
26+
if (gamemodes.empty())
27+
{
28+
std::string getQueues = LCU::Request("GET", "/lol-game-queues/v1/queues");
29+
Json::CharReaderBuilder builder;
30+
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
31+
JSONCPP_STRING err;
32+
Json::Value root;
33+
if (reader->parse(getQueues.c_str(), getQueues.c_str() + static_cast<int>(getQueues.length()), &root, &err))
34+
{
35+
if (root.isArray())
36+
{
37+
for (Json::Value::ArrayIndex i = 0; i < root.size(); i++)
38+
{
39+
if (root[i]["queueAvailability"].asString() != "Available")
40+
continue;
41+
42+
long id = root[i]["id"].asInt64();
43+
std::string name = root[i]["name"].asString();
44+
name += " " + std::to_string(id);
45+
//std::cout << id << " " << name << std::endl;
46+
std::pair<long, std::string>temp = { id, name };
47+
gamemodes.emplace_back(temp);
48+
}
49+
50+
std::sort(gamemodes.begin(), gamemodes.end(), [](auto& left, auto& right) {
51+
return left.first < right.first;
52+
});
53+
}
54+
}
55+
}
56+
}
57+
2258
static std::vector<std::string>firstPosition = { "UNSELECTED", "TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY", "FILL" };
2359
static std::vector<std::string>secondPosition = { "UNSELECTED", "TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY", "FILL" };
2460

@@ -123,6 +159,31 @@ class GameTab
123159

124160
//"id" 1- blind 2- draft -4 all random 6- tournament draft
125161

162+
static int indexGamemodes = -1;
163+
const char* labelGamemodes = "All Gamemodes";
164+
if (indexGamemodes != -1)
165+
labelGamemodes = gamemodes[indexGamemodes].second.c_str();
166+
167+
if (ImGui::BeginCombo("##combolGamemodes", labelGamemodes, 0))
168+
{
169+
for (size_t n = 0; n < gamemodes.size(); n++)
170+
{
171+
const bool is_selected = (indexGamemodes == n);
172+
if (ImGui::Selectable(gamemodes[n].second.c_str(), is_selected))
173+
indexGamemodes = n;
174+
175+
if (is_selected)
176+
ImGui::SetItemDefaultFocus();
177+
}
178+
ImGui::EndCombo();
179+
}
180+
ImGui::SameLine();
181+
182+
if (ImGui::Button("Create##gamemode"))
183+
{
184+
gameID = gamemodes[indexGamemodes].first;
185+
}
186+
126187
ImGui::NextColumn();
127188

128189
static std::vector<std::pair<int, std::string>>botChamps;

0 commit comments

Comments
 (0)