From 26885b778d6d3d2f98326de56b15cbd625febd11 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:29:55 -0400 Subject: [PATCH] feat: add onboarding for new users --- src/game/features/network/CheaterPool.cpp | 2 +- src/game/frontend/GUI.cpp | 17 ++++-- src/game/frontend/GUI.hpp | 12 ++++ src/game/frontend/Menu.cpp | 3 + src/game/frontend/Onboarding.cpp | 70 +++++++++++++++++++++++ src/game/frontend/Onboarding.hpp | 6 ++ src/game/frontend/submenus/Network.cpp | 2 +- 7 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 src/game/frontend/Onboarding.cpp create mode 100644 src/game/frontend/Onboarding.hpp diff --git a/src/game/features/network/CheaterPool.cpp b/src/game/features/network/CheaterPool.cpp index 66df7c5..1d3025b 100644 --- a/src/game/features/network/CheaterPool.cpp +++ b/src/game/features/network/CheaterPool.cpp @@ -22,7 +22,7 @@ namespace YimMenu::Features } }; - static CheaterPool _CheaterPool{"cheaterpool", "Cheater Pool", "Matchmaking will put you into sessions with other YimMenu users."}; + static CheaterPool _CheaterPool{"cheaterpool", "Join YimMenu-only Sessions", "Matchmaking will put you into sessions with other YimMenu users.", true}; } namespace YimMenu::Hooks diff --git a/src/game/frontend/GUI.cpp b/src/game/frontend/GUI.cpp index 2b8ab70..2958a94 100644 --- a/src/game/frontend/GUI.cpp +++ b/src/game/frontend/GUI.cpp @@ -50,9 +50,11 @@ namespace YimMenu void GUI::ToggleMouse() { - auto& io = ImGui::GetIO(); - io.MouseDrawCursor = GUI::IsOpen(); - GUI::IsOpen() ? io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse : io.ConfigFlags |= ImGuiConfigFlags_NoMouse; + auto& io = ImGui::GetIO(); + io.MouseDrawCursor = GUI::IsOpen() || GUI::IsOnboarding(); + GUI::IsOpen() || GUI::IsOnboarding() + ? io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse : + io.ConfigFlags |= ImGuiConfigFlags_NoMouse; } void GUI::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) @@ -69,11 +71,18 @@ namespace YimMenu { SetCursorPos(CursorCoords.x, CursorCoords.y); } - Toggle(); + if (!GUI::IsOnboarding()) + Toggle(); ToggleMouse(); } } + void GUI::SetOnboardingImpl(bool state) + { + m_Onboarding = state; + ToggleMouse(); + } + void GUI::RunScriptImpl() { while (g_Running) diff --git a/src/game/frontend/GUI.hpp b/src/game/frontend/GUI.hpp index 845fdb4..a0e5599 100644 --- a/src/game/frontend/GUI.hpp +++ b/src/game/frontend/GUI.hpp @@ -41,9 +41,20 @@ namespace YimMenu GetInstance().RunScriptImpl(); } + static void SetOnboarding(bool state) + { + GetInstance().SetOnboardingImpl(state); + } + + static bool IsOnboarding() + { + return GetInstance().m_Onboarding; + } + private: void WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); + void SetOnboardingImpl(bool state); void RunScriptImpl(); static void ToggleMouse(); @@ -56,5 +67,6 @@ namespace YimMenu private: bool m_IsOpen; + bool m_Onboarding; }; } \ No newline at end of file diff --git a/src/game/frontend/Menu.cpp b/src/game/frontend/Menu.cpp index 86467b7..d6aa2d9 100644 --- a/src/game/frontend/Menu.cpp +++ b/src/game/frontend/Menu.cpp @@ -19,6 +19,7 @@ #include "submenus/World.hpp" #include "core/filemgr/FileMgr.hpp" #include "core/memory/ModuleMgr.hpp" +#include "Onboarding.hpp" namespace YimMenu { @@ -37,6 +38,8 @@ namespace YimMenu Renderer::AddRendererCallBack( [&] { + ProcessOnboarding(); + if (!GUI::IsOpen()) return; diff --git a/src/game/frontend/Onboarding.cpp b/src/game/frontend/Onboarding.cpp new file mode 100644 index 0000000..78b6fe7 --- /dev/null +++ b/src/game/frontend/Onboarding.cpp @@ -0,0 +1,70 @@ +#include "Onboarding.hpp" +#include "GUI.hpp" +#include "core/commands/Commands.hpp" +#include "core/commands/BoolCommand.hpp" +#include "game/backend/AnticheatBypass.hpp" +#include "game/pointers/Pointers.hpp" +#include + +namespace YimMenu +{ + static BoolCommand _OnboardingComplete{"$onboardingcomplete", "", ""}; + + void ProcessOnboarding() + { + if (_OnboardingComplete.GetState()) + return; + + static bool ensure_popup_open = [] { + ImGui::OpenPopup("IMPORTANT! PLEASE READ!"); + GUI::SetOnboarding(true); + return true; + }(); + + const auto window_size = ImVec2{700, 500}; + const auto window_position = ImVec2{(*Pointers.ScreenResX - window_size.x) / 2, (*Pointers.ScreenResY - window_size.y) / 2}; + + ImGui::SetNextWindowSize(window_size, ImGuiCond_Once); + ImGui::SetNextWindowPos(window_position, ImGuiCond_Once); + + if (ImGui::BeginPopupModal("IMPORTANT! PLEASE READ!", nullptr, ImGuiWindowFlags_NoSavedSettings)) + { + ImGui::TextWrapped("%s", + "Welcome to YimMenuV2! With the introduction of BattlEye, the ability to join and stay in public sessions has been severely limited. " + "You have an option to play only with other YimMenu users, or you can choose to connect to regular BattlEye-protected sessions. " + "You will automatically be kicked out of regular sessions in under three minutes, and you may be temporarily blacklisted from " + "joining for up to two days, even after re-enabling BattlEye" + ); + static int value = 0; + ImGui::RadioButton("Play with YimMenu users", &value, 0); + ImGui::SameLine(); + ImGui::RadioButton("Play with everyone", &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 " + "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 " + "and other users. Matrix is a free and open source alternative to Discord, and creating an account is safe and easy"); + if (ImGui::Button("Open GitHub")) + { + ShellExecuteA(NULL, "open", "https://github.com/YimMenu/YimMenuV2", NULL, NULL, SW_SHOWNORMAL); + } + ImGui::SameLine(); + if (ImGui::Button("Open Matrix server")) + { + ShellExecuteA(NULL, "open", "https://matrix.to/#/#yimmenu:matrix.org", NULL, NULL, SW_SHOWNORMAL); + } + ImGui::TextWrapped("%s", + "Check for updates reguarly; we publish new builds every night. But most importantly, mess around and have fun with YimMenu!" + ); + if (ImGui::Button("Close")) + { + Commands::GetCommand("cheaterpool"_J)->SetState(!value); + _OnboardingComplete.SetState(true); + GUI::SetOnboarding(false); + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + } +} \ No newline at end of file diff --git a/src/game/frontend/Onboarding.hpp b/src/game/frontend/Onboarding.hpp new file mode 100644 index 0000000..4942770 --- /dev/null +++ b/src/game/frontend/Onboarding.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace YimMenu +{ + void ProcessOnboarding(); +} \ No newline at end of file diff --git a/src/game/frontend/submenus/Network.cpp b/src/game/frontend/submenus/Network.cpp index babf5b2..53436d6 100644 --- a/src/game/frontend/submenus/Network.cpp +++ b/src/game/frontend/submenus/Network.cpp @@ -4,7 +4,7 @@ #include "game/frontend/items/Items.hpp" #include "game/frontend/submenus/Network/SavedPlayers.hpp" #include "game/gta/Network.hpp" -#include "game/frontend/submenus/network/RandomEvents.hpp" +#include "game/frontend/submenus/Network/RandomEvents.hpp" namespace YimMenu::Submenus {