Skip to content

Commit

Permalink
Added All Gamemodes ComboBox
Browse files Browse the repository at this point in the history
  • Loading branch information
KebsCS committed Aug 21, 2023
1 parent 2156b52 commit 3fb4229
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions KBotExt/GameTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,42 @@ class GameTab
static std::string result;
static std::string custom;

static std::vector < std::pair<long, std::string>>gamemodes;

if (onOpen)
{
if (gamemodes.empty())
{
std::string getQueues = LCU::Request("GET", "/lol-game-queues/v1/queues");
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
JSONCPP_STRING err;
Json::Value root;
if (reader->parse(getQueues.c_str(), getQueues.c_str() + static_cast<int>(getQueues.length()), &root, &err))
{
if (root.isArray())
{
for (Json::Value::ArrayIndex i = 0; i < root.size(); i++)
{
if (root[i]["queueAvailability"].asString() != "Available")
continue;

long id = root[i]["id"].asInt64();
std::string name = root[i]["name"].asString();
name += " " + std::to_string(id);
//std::cout << id << " " << name << std::endl;
std::pair<long, std::string>temp = { id, name };
gamemodes.emplace_back(temp);
}

std::sort(gamemodes.begin(), gamemodes.end(), [](auto& left, auto& right) {
return left.first < right.first;
});
}
}
}
}

static std::vector<std::string>firstPosition = { "UNSELECTED", "TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY", "FILL" };
static std::vector<std::string>secondPosition = { "UNSELECTED", "TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY", "FILL" };

Expand Down Expand Up @@ -123,6 +159,31 @@ class GameTab

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

static int indexGamemodes = -1;
const char* labelGamemodes = "All Gamemodes";
if (indexGamemodes != -1)
labelGamemodes = gamemodes[indexGamemodes].second.c_str();

if (ImGui::BeginCombo("##combolGamemodes", labelGamemodes, 0))
{
for (size_t n = 0; n < gamemodes.size(); n++)
{
const bool is_selected = (indexGamemodes == n);
if (ImGui::Selectable(gamemodes[n].second.c_str(), is_selected))
indexGamemodes = n;

if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::SameLine();

if (ImGui::Button("Create##gamemode"))
{
gameID = gamemodes[indexGamemodes].first;
}

ImGui::NextColumn();

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

0 comments on commit 3fb4229

Please sign in to comment.