Skip to content

Commit

Permalink
update log cleaner and invite to lobby by folder
Browse files Browse the repository at this point in the history
  • Loading branch information
KebsCS committed Nov 25, 2023
1 parent 866c0bc commit e533dbb
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 18 deletions.
2 changes: 0 additions & 2 deletions KBotExt/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <vector>
#include <string>

//#define RandomInt(min, max) (rand() % (max - min + 1) + min)

struct ChampMinimal
{
bool active;
Expand Down
49 changes: 47 additions & 2 deletions KBotExt/GameTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,12 @@ class GameTab
ImGui::Checkbox("Auto accept", &S.gameTab.autoAcceptEnabled);

ImGui::NextColumn();
if (ImGui::Button("Invite everyone to lobby"))

static std::vector<std::pair<std::string, int>> itemsInvite = { {"**Default", 0} };
static size_t itemIdxInvite = 0;
auto labelInvite = itemsInvite[itemIdxInvite].first.c_str();

if (ImGui::Button("Invite to lobby"))
{
std::string getFriends = LCU::Request("GET", "https://127.0.0.1/lol-chat/v1/friends");

Expand All @@ -443,17 +448,57 @@ class GameTab
{
if (root.isArray())
{
unsigned invitedCount = 0;
for (auto& i : root)
{
if (i["groupId"].asUInt() != itemsInvite[itemIdxInvite].second)
continue;

std::string friendSummId = i["summonerId"].asString();
std::string inviteBody = "[{\"toSummonerId\":" + friendSummId + "}]";
LCU::Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby/invitations", inviteBody);
invitedCount++;
}
result = "Invited friends to lobby";
result = "Invited " + std::to_string(invitedCount) + " friends to lobby";
}
}
}

ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::CalcTextSize(std::string(15, 'W').c_str(), nullptr, true).x);
if (ImGui::BeginCombo("##comboInvite", labelInvite, 0))
{
std::string getGroups = LCU::Request("GET", "https://127.0.0.1/lol-chat/v1/friend-groups");
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
JSONCPP_STRING err;
Json::Value root;
if (reader->parse(getGroups.c_str(), getGroups.c_str() + static_cast<int>(getGroups.length()), &root, &err))
{
if (root.isArray())
{
itemsInvite.clear();
for (auto& i : root)
{
std::pair temp = { i["name"].asString(), i["id"].asInt() };
itemsInvite.emplace_back(temp);
}
std::ranges::sort(itemsInvite, [](std::pair<std::string, int> a, std::pair<std::string, int> b) { return a.second < b.second; });
}
}

for (size_t n = 0; n < itemsInvite.size(); n++)
{
const bool is_selected = (itemIdxInvite == n);
if (ImGui::Selectable(itemsInvite[n].first.c_str(), is_selected))
itemIdxInvite = n;

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

ImGui::NextColumn();

ImGui::Text("Nexus Blitz Force");
Expand Down
3 changes: 0 additions & 3 deletions KBotExt/LCU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ std::string LCU::Request(const std::string& method, const std::string& endpoint,
sURL.insert(strlen("https://127.0.0.1"), ":" + std::to_string(league.port));
}

/*wrap::Response r = wrap::HttpsRequest(wrap::Method{ method }, wrap::Url{ sURL }, wrap::Body{ body }, wrap::Header{ league.header }, wrap::Port{ league.port },
wrap::Timeout{1000});*/

cpr::Response r = {};

session.SetUrl(sURL);
Expand Down
8 changes: 7 additions & 1 deletion KBotExt/Misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,21 @@ class Misc
_dupenv_s(&pLocal, &localLen, "LOCALAPPDATA");
const auto localAppData = std::filesystem::path(pLocal);

_dupenv_s(&pLocal, &localLen, "PROGRAMDATA");
const auto programData = std::filesystem::path(pLocal);

for (const std::vector leagueFiles = {
leaguePath / "Logs",
leaguePath / "Config",
leaguePath / "debug.log",
leaguePath / "Game" / "Logs",
riotClientPath / "UX" / "natives_blob.bin",
riotClientPath / "UX" / "snapshot_blob.bin",
riotClientPath / "UX" / "v8_context_snapshot.bin",
riotClientPath / "UX" / "icudtl.dat",
localAppData / "Riot Games"
riotClientPath / "UX" / "GPUCache",
localAppData / "Riot Games",
programData / "Riot Games"
}; const auto & file : leagueFiles)
{
if (exists(file))
Expand Down
8 changes: 3 additions & 5 deletions KBotExt/MiscTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ class MiscTab

ImGui::Columns(1);

static std::vector<std::pair<std::string, int>> items;
static std::vector<std::pair<std::string, int>> items = { {"**Default", 0} };
static size_t item_current_idx = 0; // Here we store our selection data as an index.
auto combo_label = "**Default";
if (!items.empty())
combo_label = items[item_current_idx].first.c_str();
auto combo_label = items[item_current_idx].first.c_str();

if (ImGui::Button("Remove all friends"))
{
Expand All @@ -252,7 +250,7 @@ class MiscTab
int iDeleted = 0;
for (auto& i : root)
{
if (i["groupId"].asUInt() == item_current_idx)
if (i["groupId"].asUInt() == items[item_current_idx].second)
{
std::string req = "https://127.0.0.1/lol-chat/v1/friends/" + i["pid"].asString();
LCU::Request("DELETE", req, "");
Expand Down
10 changes: 5 additions & 5 deletions KBotExt/imgui/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ void ImGuiIO::ClearEventsQueue()
IM_ASSERT(Ctx != NULL);
ImGuiContext& g = *Ctx;
g.InputEventsQueue.clear();
}
}

// Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
void ImGuiIO::ClearInputKeys()
Expand Down Expand Up @@ -1412,7 +1412,7 @@ static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventT
if (type == ImGuiInputEventType_MouseButton && e->MouseButton.Button != arg)
continue;
return e;
}
}
return NULL;
}

Expand Down Expand Up @@ -1934,7 +1934,7 @@ void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end,
*out_buf = g.TempBuffer.Data;
if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
}
}
}

// CRC32 needs a 1KB lookup table (not cache friendly)
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
Expand Down Expand Up @@ -2504,7 +2504,7 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) //-V1077
{
ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf));
Build();
}
}
}

bool ImGuiTextFilter::Draw(const char* label, float width)
Expand Down Expand Up @@ -4460,7 +4460,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
if (io.MouseDown[i])
if (mouse_earliest_down == -1 || io.MouseClickedTime[i] < io.MouseClickedTime[mouse_earliest_down])
mouse_earliest_down = i;
}
}
const bool mouse_avail = (mouse_earliest_down == -1) || io.MouseDownOwned[mouse_earliest_down];
const bool mouse_avail_unless_popup_close = (mouse_earliest_down == -1) || io.MouseDownOwnedUnlessPopupClose[mouse_earliest_down];

Expand Down

0 comments on commit e533dbb

Please sign in to comment.