feat(chat): make chat disappear after a while

This commit is contained in:
maybegreat48
2025-06-04 00:14:55 -04:00
parent 0842941f96
commit 66d0277db7
7 changed files with 66 additions and 22 deletions
+13 -4
View File
@@ -1,28 +1,37 @@
#include "core/commands/BoolCommand.hpp"
#include "core/commands/LoopedCommand.hpp"
#include "core/hooking/DetourHook.hpp"
#include "game/hooks/Hooks.hpp"
#include "game/pointers/Pointers.hpp"
namespace YimMenu::Features
{
class CheaterPool : public BoolCommand
class CheaterPool : public LoopedCommand
{
using BoolCommand::BoolCommand;
using LoopedCommand::LoopedCommand;
int m_OldRegion;
virtual void OnEnable() override
{
Pointers.SetJoinRequestPoolTypePatch->Apply();
Pointers.HandleJoinRequestIgnorePoolPatch->Apply();
m_OldRegion = *Pointers.RegionCode;
}
virtual void OnTick() override
{
*Pointers.RegionCode = 0; // put everyone in the same region for easier matchmaking
}
virtual void OnDisable() override
{
Pointers.SetJoinRequestPoolTypePatch->Restore();
Pointers.HandleJoinRequestIgnorePoolPatch->Restore();
*Pointers.RegionCode = m_OldRegion;
}
};
static CheaterPool _CheaterPool{"cheaterpool", "Join YimMenu-only Sessions", "Matchmaking will put you into sessions with other YimMenu users.", true};
static CheaterPool _CheaterPool{"cheaterpool", "Join YimMenu-only Sessions", "Matchmaking will put you into sessions with other YimMenu users."};
}
namespace YimMenu::Hooks
+1
View File
@@ -23,6 +23,7 @@ namespace
while (true)
{
YimMenu::ChatDisplay::MarkAccessed();
YimMenu::ScriptMgr::Yield();
int update_res = MISC::UPDATE_ONSCREEN_KEYBOARD();
+36 -14
View File
@@ -30,6 +30,7 @@ namespace YimMenu
}
m_Messages.push_back(notification);
MarkAccessed();
}
void ChatDisplay::DrawImpl()
@@ -40,32 +41,53 @@ namespace YimMenu
static const float y_pos = position * 100 + 200;
static const float x_pos = *Pointers.ScreenResX - 470;
ImGui::SetNextWindowSize(ImVec2(*Pointers.ScreenResX - x_pos - 10, *Pointers.ScreenResY - y_pos), ImGuiCond_Always);
ImGui::SetNextWindowPos(ImVec2(x_pos, y_pos), ImGuiCond_Always);
if (ImGui::Begin("##chatwin", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs))
if (m_Messages.size() && m_Opacity >= 0.011f)
{
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PushFont(Menu::Font::g_ChatFont);
ImGui::SetNextWindowSize(ImVec2(*Pointers.ScreenResX - x_pos - 10, *Pointers.ScreenResY - y_pos), ImGuiCond_Always);
ImGui::SetNextWindowPos(ImVec2(x_pos, y_pos), ImGuiCond_Always);
for (auto& message : m_Messages)
if (ImGui::Begin("##chatwin", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs))
{
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(message.m_Color));
ImGui::TextWrapped("%s:", message.m_Sender.data());
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PushFont(Menu::Font::g_ChatFont);
for (auto& message : m_Messages)
{
auto color = message.m_Color;
color.Value.w = m_Opacity;
ImGui::PushStyleColor(ImGuiCol_Text, color.Value);
ImGui::TextWrapped("%s:", message.m_Sender.data());
ImGui::PopStyleColor();
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, m_Opacity));
ImGui::TextWrapped("%s", message.m_Message.data());
ImGui::PopStyleColor();
}
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::SameLine();
ImGui::TextWrapped("%s", message.m_Message.data());
}
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::End();
}
ImGui::End();
// TODO: unlink fade speed with FPS
if (std::chrono::system_clock::now() - m_LastAccessTime > 15s && m_Opacity != 0.0f)
{
m_Opacity -= 0.01f;
if (m_Opacity <= 0.011f)
m_Opacity = 0.0f;
}
}
void ChatDisplay::ClearImpl()
{
m_Messages.clear();
}
void ChatDisplay::MarkAccessedImpl()
{
m_Opacity = 1.0f;
m_LastAccessTime = std::chrono::system_clock::now();
}
}
+8
View File
@@ -16,12 +16,15 @@ namespace YimMenu
class ChatDisplay
{
private:
std::chrono::system_clock::time_point m_LastAccessTime;
float m_Opacity = 1.0f;
std::vector<Message> m_Messages = {};
std::mutex m_Mutex;
void ShowImpl(std::string sender, std::string message, ImColor color);
void DrawImpl();
void ClearImpl();
void MarkAccessedImpl();
static ChatDisplay& GetInstance()
{
@@ -44,6 +47,11 @@ namespace YimMenu
{
GetInstance().ClearImpl();
}
static void MarkAccessed()
{
GetInstance().MarkAccessedImpl();
}
};
}
+2 -2
View File
@@ -38,9 +38,9 @@ namespace YimMenu
static int value = 0;
ImGui::RadioButton("Play with YimMenu users", &value, 0);
ImGui::SameLine();
ImGui::RadioButton("Play with everyone", &value, 1);
ImGui::RadioButton("Play with everyone (Broken!)", &value, 1);
ImGui::TextWrapped("%s",
"You can always change your choice by going to Network > Spoofing > Join YimMenu-only Sessions. Our official repository is at "
"You can always change your choice by toggling Network > Spoofing > Join YimMenu-only Sessions. Our official repository is at "
"https://github.com/YimMenu/YimMenuV2. Make sure to only download the menu from GitHub to avoid malware. "
"You can use the repository to report bugs, suggest features, and contribute by making pull requests. We also have a "
"Matrix server that can be found at https://matrix.to/#/#yimmenu:matrix.org for faster communication with developers "
+2 -2
View File
@@ -90,11 +90,11 @@ namespace YimMenu::Submenus
auto spoofing = std::make_shared<Category>("Spoofing");
auto matchmakingGroup = std::make_shared<Group>("Matchmaking");
matchmakingGroup->AddItem(std::make_shared<BoolCommandItem>("cheaterpool"_J));
auto spoofMMRegion = std::make_shared<Group>("", 1);
spoofMMRegion->AddItem(std::make_shared<BoolCommandItem>("spoofmmregion"_J, "Spoof Region"));
spoofMMRegion->AddItem(std::make_shared<ConditionalItem>("spoofmmregion"_J, std::make_shared<ListCommandItem>("mmregion"_J, "##mmregion")));
matchmakingGroup->AddItem(spoofMMRegion);
matchmakingGroup->AddItem(std::make_shared<BoolCommandItem>("cheaterpool"_J));
matchmakingGroup->AddItem(std::make_shared<ConditionalItem>("cheaterpool"_J, spoofMMRegion, true));
spoofing->AddItem(matchmakingGroup);
AddCategory(std::move(session));
+4
View File
@@ -39,6 +39,7 @@ namespace YimMenu::Submenus
auto playerEsp = std::make_shared<Group>("Player ESP", 10);
auto pedEsp = std::make_shared<Group>("Ped ESP", 10);
auto overlay = std::make_shared<Group>("Overlay");
auto chat = std::make_shared<Group>("Chat");
hotkeys->AddItem(std::make_shared<ImGuiItem>(Hotkeys));
@@ -74,9 +75,12 @@ namespace YimMenu::Submenus
overlay->AddItem(std::make_shared<BoolCommandItem>("overlay"_J));
overlay->AddItem(std::make_shared<ConditionalItem>("overlay"_J, std::make_shared<BoolCommandItem>("overlayfps"_J)));
chat->AddItem(std::make_shared<BoolCommandItem>("clearchat"_J));
gui->AddItem(playerEsp);
gui->AddItem(pedEsp);
gui->AddItem(overlay);
gui->AddItem(chat);
AddCategory(std::move(hotkeys));
AddCategory(std::move(gui));