Skip to content

Commit f98fec8

Browse files
authored
New Kick, Features, and More (#210)
New Kick - ICE Kick Logger Improvements Color Commands Node and Vtable Hooks Improved Protections Enhancements, Improvements, and Various Refactors
1 parent f33722e commit f98fec8

File tree

118 files changed

+4055
-1100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+4055
-1100
lines changed

.clang-format

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ AlignConsecutiveAssignments: 'true'
55
AlignEscapedNewlines: Left
66
AlignOperands: 'false'
77
AlignTrailingComments: 'true'
8-
AllowAllArgumentsOnNextLine: 'false'
8+
AllowAllArgumentsOnNextLine: 'true'
99
AllowAllConstructorInitializersOnNextLine: 'false'
1010
AllowAllParametersOfDeclarationOnNextLine: 'false'
11-
AllowShortBlocksOnASingleLine: 'false'
11+
AllowShortBlocksOnASingleLine: 'true'
1212
AllowShortCaseLabelsOnASingleLine: 'true'
13-
AllowShortFunctionsOnASingleLine: None
13+
AllowShortFunctionsOnASingleLine: 'true'
1414
AllowShortIfStatementsOnASingleLine: Never
1515
AllowShortLambdasOnASingleLine: None
1616
AlwaysBreakAfterReturnType: None

cmake/rdr-classes.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ message(STATUS "RDR-Classes")
55
FetchContent_Declare(
66
RDR-Classes
77
GIT_REPOSITORY https://github.com/YimMenu/RDR-Classes.git
8-
GIT_TAG fe55483ceaaae7b14fad984a495b07272679bd5d
8+
GIT_TAG a61459d3b100408f736f32046ed2545dc729e617
99
GIT_PROGRESS TRUE
1010
)
1111
FetchContent_MakeAvailable(RDR-Classes)

src/common.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ using namespace al;
3030

3131
namespace YimMenu
3232
{
33+
const inline auto SYNC = std::make_shared<al::LogStream>("SYNC");
34+
const inline auto NET_EVENT = std::make_shared<al::LogStream>("NET_EVENT");
35+
const inline auto NETWORK = std::make_shared<al::LogStream>("NETWORK");
36+
const inline auto GAME = std::make_shared<al::LogStream>("GAME");
37+
const inline auto MENU = std::make_shared<al::LogStream>("MENU");
38+
3339
using namespace std::chrono_literals;
3440
using namespace std::string_literals;
3541

src/core/commands/BoolCommand.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include "BoolCommand.hpp"
22
#include "game/backend/FiberPool.hpp" // TODO: game import in core
3+
#include "Commands.hpp"
34

45
namespace YimMenu
56
{
67
BoolCommand::BoolCommand(std::string name, std::string label, std::string description, bool def_value) :
78
Command(name, label, description, 0),
89
m_State(def_value)
910
{
11+
Commands::AddBoolCommand(this);
1012
}
1113

1214
void BoolCommand::OnCall()

src/core/commands/BoolCommand.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace YimMenu
66
class BoolCommand : public Command
77
{
88
protected:
9-
virtual void OnEnable(){};
10-
virtual void OnDisable(){};
9+
virtual void OnEnable() {};
10+
virtual void OnDisable() {};
1111
virtual void OnCall() override;
1212
virtual void SaveState(nlohmann::json& value) override;
1313
virtual void LoadState(nlohmann::json& value) override;

src/core/commands/ColorCommand.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "ColorCommand.hpp"
2+
#include "game/backend/FiberPool.hpp" // TODO: game import in core
3+
4+
namespace YimMenu
5+
{
6+
void ColorCommand::OnCall()
7+
{
8+
}
9+
10+
void ColorCommand::SaveState(nlohmann::json& value)
11+
{
12+
value = {m_ColorState.x, m_ColorState.y, m_ColorState.z, m_ColorState.w};
13+
}
14+
15+
void ColorCommand::LoadState(nlohmann::json& value)
16+
{
17+
if (value.is_array() && value.size() == 4)
18+
{
19+
m_ColorState = ImVec4(value[0], value[1], value[2], value[3]);
20+
}
21+
else
22+
{
23+
m_ColorState = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
24+
}
25+
}
26+
27+
ColorCommand::ColorCommand(std::string name, std::string label, std::string description, ImVec4 color) :
28+
Command(name, label, description, 0),
29+
m_ColorState(color)
30+
{
31+
}
32+
33+
ImVec4 ColorCommand::GetState()
34+
{
35+
return m_ColorState;
36+
}
37+
38+
void ColorCommand::SetColorState(ImVec4 state)
39+
{
40+
FiberPool::Push([this] {
41+
OnChange();
42+
});
43+
m_ColorState = state;
44+
MarkDirty();
45+
}
46+
}

src/core/commands/ColorCommand.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
#include "Command.hpp"
3+
#include "imgui.h"
4+
5+
namespace YimMenu
6+
{
7+
class ColorCommand : public Command
8+
{
9+
protected:
10+
virtual void OnChange(){};
11+
virtual void OnCall() override;
12+
virtual void SaveState(nlohmann::json& value) override;
13+
virtual void LoadState(nlohmann::json& value) override;
14+
15+
ImVec4 m_ColorState = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
16+
17+
public:
18+
ColorCommand(std::string name, std::string label, std::string description, ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
19+
ImVec4 GetState();
20+
void SetColorState(ImVec4 state);
21+
};
22+
}

src/core/commands/Commands.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ namespace YimMenu
1414
m_Commands.insert({command->GetHash(), command});
1515
}
1616

17+
void Commands::AddBoolCommandImpl(BoolCommand* command)
18+
{
19+
m_BoolCommands.push_back(command);
20+
}
21+
1722
void Commands::AddLoopedCommandImpl(LoopedCommand* command)
1823
{
1924
m_LoopedCommands.push_back(command);
2025
}
2126

22-
void Commands::EnableLoopedCommandsImpl()
27+
void Commands::EnableBoolCommandsImpl()
2328
{
24-
for (auto& command : m_LoopedCommands)
29+
for (auto& command : m_BoolCommands)
2530
if (command->GetState())
2631
command->Initialize();
2732
}

src/core/commands/Commands.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ namespace YimMenu
66
{
77
class Command;
88
class LoopedCommand;
9+
class BoolCommand;
910

1011
class Commands :
1112
private IStateSerializer
1213
{
1314
private:
1415
std::unordered_map<joaat_t, Command*> m_Commands;
1516
std::vector<LoopedCommand*> m_LoopedCommands;
17+
std::vector<BoolCommand*> m_BoolCommands;
1618
Commands();
1719

1820
public:
@@ -21,6 +23,11 @@ namespace YimMenu
2123
GetInstance().AddCommandImpl(command);
2224
}
2325

26+
static void AddBoolCommand(BoolCommand* command)
27+
{
28+
GetInstance().AddBoolCommandImpl(command);
29+
}
30+
2431
static void AddLoopedCommand(LoopedCommand* command)
2532
{
2633
GetInstance().AddLoopedCommandImpl(command);
@@ -31,10 +38,9 @@ namespace YimMenu
3138
GetInstance().RunLoopedCommandsImpl();
3239
}
3340

34-
// TODO: what about bool commands?
35-
static void EnableLoopedCommands()
41+
static void EnableBoolCommands()
3642
{
37-
GetInstance().EnableLoopedCommandsImpl();
43+
GetInstance().EnableBoolCommandsImpl();
3844
}
3945

4046
template<typename T = Command>
@@ -65,8 +71,9 @@ namespace YimMenu
6571

6672
private:
6773
void AddCommandImpl(Command* command);
74+
void AddBoolCommandImpl(BoolCommand* command);
6875
void AddLoopedCommandImpl(LoopedCommand* command);
69-
void EnableLoopedCommandsImpl();
76+
void EnableBoolCommandsImpl();
7077
void RunLoopedCommandsImpl();
7178
Command* GetCommandImpl(joaat_t hash);
7279
virtual void SaveStateImpl(nlohmann::json& state) override;

src/core/commands/HotkeySystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace YimMenu
106106
}
107107
}
108108

109-
if (AllKeysPressed && GetForegroundWindow() == Pointers.Hwnd && std::chrono::system_clock::now() - m_LastHotkeyTriggerTime > 100ms)
109+
if (AllKeysPressed && GetForegroundWindow() == *Pointers.Hwnd && std::chrono::system_clock::now() - m_LastHotkeyTriggerTime > 100ms)
110110
{
111111
auto Command = Commands::GetCommand(Hash);
112112
if (Command)

src/core/frontend/Notifications.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "core/logger/LogHelper.hpp"
44
#include "game/backend/FiberPool.hpp" // TODO: game import in core
5+
#include "util/Joaat.hpp"
56

67
#include <mutex>
78

@@ -13,24 +14,30 @@ namespace YimMenu
1314
if (title.empty() || message.empty())
1415
return {};
1516

17+
auto message_id = Joaat(title + message);
18+
1619
auto exists = std::find_if(m_Notifications.begin(), m_Notifications.end(), [&](auto& notification) {
17-
return notification.second.GetIdentifier() == std::string(title + message);
20+
return notification.second.m_Identifier == message_id;
1821
});
1922

2023
if (exists != m_Notifications.end())
24+
{
25+
exists->second.m_CreatedOn = std::chrono::system_clock::now();
2126
return {};
27+
}
2228

2329
Notification notification{};
2430
notification.m_Title = title;
2531
notification.m_Message = message;
2632
notification.m_Type = type;
27-
notification.m_created_on = std::chrono::system_clock::now();
33+
notification.m_CreatedOn = std::chrono::system_clock::now();
2834
notification.m_Duration = duration;
35+
notification.m_Identifier = message_id;
2936

3037
if (context_function)
3138
{
32-
notification.m_context_function = context_function;
33-
notification.m_context_function_name = context_function_name.empty() ? "Context Function" : context_function_name;
39+
notification.m_ContextFunc = context_function;
40+
notification.m_ContextFuncName = context_function_name.empty() ? "Context Function" : context_function_name;
3441
}
3542

3643
std::lock_guard<std::mutex> lock(m_mutex);
@@ -44,9 +51,9 @@ namespace YimMenu
4451
std::lock_guard<std::mutex> lock(m_mutex);
4552
for (auto& [id, n] : m_Notifications)
4653
{
47-
if (id == notification.GetIdentifier())
54+
if (n.m_Identifier == notification.m_Identifier)
4855
{
49-
n.erasing = true;
56+
n.m_Erasing = true;
5057
return true;
5158
}
5259
}
@@ -63,18 +70,15 @@ namespace YimMenu
6370
ImGui::SetNextWindowSize(cardSize, ImGuiCond_Always);
6471
ImGui::SetNextWindowPos(ImVec2(x_pos + notification.m_AnimationOffset, y_pos + 10), ImGuiCond_Always);
6572

66-
std::string windowTitle = "Notification " + std::to_string(position + 1);
67-
ImGui::Begin(windowTitle.c_str(), nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
73+
std::string windowTitle = std::to_string(position);
74+
ImGui::Begin(windowTitle.c_str(), nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoFocusOnAppearing);
6875

69-
auto timeElapsed =
70-
(float)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - notification.m_created_on)
71-
.count();
76+
auto timeElapsed = (float)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - notification.m_CreatedOn).count();
7277

7378
auto depletionProgress = 1.0f - (timeElapsed / (float)notification.m_Duration);
7479

7580
ImGui::ProgressBar(depletionProgress, ImVec2(-1, 3.5f), "");
7681

77-
auto style = ImGui::GetStyle();
7882
// TODO: Add icon for type instead of colored text
7983
if (notification.m_Type == NotificationType::Info)
8084
{
@@ -103,12 +107,12 @@ namespace YimMenu
103107

104108
ImGui::TextWrapped("%s", notification.m_Message.c_str());
105109

106-
if (notification.m_context_function)
110+
if (notification.m_ContextFunc)
107111
{
108112
ImGui::Spacing();
109-
if (ImGui::Selectable(notification.m_context_function_name.c_str()))
113+
if (ImGui::Selectable(notification.m_ContextFuncName.c_str()))
110114
FiberPool::Push([notification] {
111-
notification.m_context_function();
115+
notification.m_ContextFunc();
112116
});
113117
}
114118

@@ -126,7 +130,7 @@ namespace YimMenu
126130
{
127131
DrawNotification(notification, position);
128132

129-
if (!notification.erasing)
133+
if (!notification.m_Erasing)
130134
{
131135
if (notification.m_AnimationOffset < 0)
132136
notification.m_AnimationOffset += m_CardAnimationSpeed;
@@ -143,10 +147,7 @@ namespace YimMenu
143147
}
144148

145149

146-
if ((float)std::chrono::duration_cast<std::chrono::milliseconds>(
147-
std::chrono::system_clock::now() - notification.m_created_on)
148-
.count()
149-
>= notification.m_Duration)
150+
if ((float)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - notification.m_CreatedOn).count() >= notification.m_Duration)
150151
keys_to_erase.push_back(id);
151152

152153
position++;
@@ -158,4 +159,4 @@ namespace YimMenu
158159
m_Notifications.erase(key);
159160
}
160161
}
161-
}
162+
}

src/core/frontend/Notifications.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ namespace YimMenu
1919
NotificationType m_Type;
2020
std::string m_Title;
2121
std::string m_Message;
22-
std::chrono::time_point<std::chrono::system_clock> m_created_on;
22+
std::chrono::time_point<std::chrono::system_clock> m_CreatedOn;
2323
int m_Duration;
24-
std::function<void()> m_context_function;
25-
std::string m_context_function_name;
24+
std::function<void()> m_ContextFunc;
25+
std::string m_ContextFuncName;
2626
float m_AnimationOffset = -m_CardSizeX;
27-
bool erasing = false;
28-
29-
std::string GetIdentifier()
30-
{
31-
return std::string(m_Title).append(m_Message);
32-
}
27+
bool m_Erasing = false;
28+
std::uint32_t m_Identifier;
3329
};
3430

3531
class Notifications

src/core/frontend/manager/Category.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ namespace YimMenu
1616
m_Items.push_back(std::move(item));
1717
}
1818

19+
void PrependItem(std::shared_ptr<UIItem>&& item)
20+
{
21+
m_Items.insert(m_Items.begin(), std::move(item));
22+
}
23+
1924
void Draw();
2025
int GetLength();
2126

src/core/hooking/DetourHook.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace YimMenu
4242

4343
if (const auto result = MH_CreateHook(m_TargetFunc, m_DetourFunc, &m_OriginalFunc); result != MH_OK)
4444
{
45-
throw std::runtime_error("Failed to create hook!");
45+
throw std::runtime_error(std::format("Failed to create hook '{}' at 0x{:X} (error: {})", name, uintptr_t(m_TargetFunc), MH_StatusToString(result)));
4646
}
4747
}
4848

0 commit comments

Comments
 (0)