Added hotkeys! Code is very unorganiezd, will clean in later updates

This commit is contained in:
EricPlayZ
2024-01-22 01:04:19 +02:00
parent d7a0275c39
commit 6d21f11c49
18 changed files with 294 additions and 267 deletions

View File

@ -146,7 +146,7 @@
</Optimization>
<IntrinsicFunctions>
</IntrinsicFunctions>
<AdditionalIncludeDirectories>source\ImGui;source\ImGuiFileDialog;source\MinHook\include;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>source\ImGuiHotkeys;source\ImGui;source\ImGuiFileDialog;source\MinHook\include;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -175,7 +175,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>source\ImGui;source\ImGuiFileDialog;source\MinHook\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>source\ImGuiHotkeys;source\ImGui;source\ImGuiFileDialog;source\MinHook\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile>

View File

@ -28,7 +28,7 @@
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
//---- Disable all of Dear ImGui or don't implement standard windows/tools.
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.

View File

@ -1,6 +1,7 @@
#include <Windows.h>
#include <imgui.h>
#include <backends\imgui_impl_win32.h>
#include <Hotkey.h>
#include "..\..\menu\menu.h"
#include "..\..\sigscan\offsets.h"
#include "..\..\game_classes.h"
@ -9,22 +10,57 @@
static WNDPROC oWndProc = NULL;
static bool toggledMenu = false;
static bool menuMsgSent = false;
static bool wasMenuKeyPressed = false;
static bool wasAnyKeyPressed = false;
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT __stdcall hkWindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) {
switch (uMsg) {
case WM_KEYDOWN:
if (wParam == Menu::toggleKey && !wasMenuKeyPressed) {
wasMenuKeyPressed = true;
if (ImGui::isAnyHotkeyBtnPressed || !ImGui::timeSinceHotkeyBtnPressed.GetTimePassed() || wasAnyKeyPressed)
break;
if (wParam == Menu::toggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::isOpen = !Menu::isOpen;
}
else if (wParam == Menu::Player::godModeToggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::Player::godModeEnabled.value = !Menu::Player::godModeEnabled.value;
}
else if (wParam == Menu::Player::freezePlayerToggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::Player::freezePlayerEnabled.value = !Menu::Player::freezePlayerEnabled.value;
}
else if (wParam == Menu::Camera::freeCamToggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::Camera::freeCamEnabled.value = !Menu::Camera::freeCamEnabled.value;
}
else if (wParam == Menu::Camera::teleportPlayerToCameraToggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::Camera::teleportPlayerToCameraEnabled = !Menu::Camera::teleportPlayerToCameraEnabled;
}
else if (wParam == Menu::Camera::thirdPersonCameraToggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::Camera::thirdPersonCameraEnabled.value = !Menu::Camera::thirdPersonCameraEnabled.value;
}
else if (wParam == Menu::Camera::tpUseTPPModelToggleKey.toInt()) {
wasAnyKeyPressed = true;
Menu::Camera::tpUseTPPModelEnabled.value = !Menu::Camera::tpUseTPPModelEnabled.value;
}
break;
case WM_KEYUP:
if (wParam == Menu::toggleKey && wasMenuKeyPressed)
wasMenuKeyPressed = false;
if (!wasAnyKeyPressed)
break;
if (wParam == Menu::toggleKey.toInt() ||
wParam == Menu::Player::godModeToggleKey.toInt() ||
wParam == Menu::Player::freezePlayerToggleKey.toInt() ||
wParam == Menu::Camera::freeCamToggleKey.toInt() ||
wParam == Menu::Camera::teleportPlayerToCameraToggleKey.toInt() ||
wParam == Menu::Camera::thirdPersonCameraToggleKey.toInt() ||
wParam == Menu::Camera::tpUseTPPModelToggleKey.toInt())
wasAnyKeyPressed = false;
break;
}

View File

@ -1,16 +1,18 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui.h"
#include "imgui_internal.h"
#include <imgui.h>
#include <imgui_internal.h>
#include "Hotkey.h"
#include "InputUtil.h"
void ImGuiCustom::hotkey(const char* label, KeyBind& key, float samelineOffset, const ImVec2& size) noexcept
bool ImGui::isAnyHotkeyBtnPressed = false;
Utils::Timer ImGui::timeSinceHotkeyBtnPressed{ 250 };
void ImGui::Hotkey(std::string_view label, KeyBind& key, float samelineOffset, const ImVec2& size) noexcept
{
const auto id = ImGui::GetID(label);
ImGui::PushID(label);
const auto id = ImGui::GetID(label.data());
ImGui::PushID(label.data());
ImGui::TextUnformatted(label);
if (!label.contains("##"))
ImGui::TextUnformatted(label.data());
ImGui::SameLine(samelineOffset);
if (ImGui::GetActiveID() == id) {
@ -19,10 +21,16 @@ void ImGuiCustom::hotkey(const char* label, KeyBind& key, float samelineOffset,
ImGui::PopStyleColor();
ImGui::GetCurrentContext()->ActiveIdAllowOverlap = true;
if ((!ImGui::IsItemHovered() && ImGui::GetIO().MouseClicked[0]) || key.setToPressedKey())
if ((!ImGui::IsItemHovered() && ImGui::GetIO().MouseClicked[0]) || key.setToPressedKey()) {
timeSinceHotkeyBtnPressed = Utils::Timer(250);
isAnyHotkeyBtnPressed = false;
ImGui::ClearActiveID();
}
else
ImGui::SetActiveID(id, ImGui::GetCurrentWindow());
}
else if (ImGui::Button(key.toString(), size)) {
isAnyHotkeyBtnPressed = true;
ImGui::SetActiveID(id, ImGui::GetCurrentWindow());
}

View File

@ -1,10 +1,12 @@
#pragma once
#include <imgui.h>
#include <InputUtil.h>
#include "../utils.h"
#include "imgui.h"
class KeyBind;
namespace ImGuiCustom
namespace ImGui
{
void hotkey(const char* label, KeyBind& key, float samelineOffset = 0.0f, const ImVec2& size = { 100.0f, 0.0f }) noexcept;
extern bool isAnyHotkeyBtnPressed;
extern Utils::Timer timeSinceHotkeyBtnPressed;
void Hotkey(std::string_view label, KeyBind& key, float samelineOffset = 0.0f, const ImVec2& size = {0.0f, 0.0f}) noexcept;
}

View File

@ -3,7 +3,7 @@
#include <string_view>
#include <Windows.h>
#include "imgui.h"
#include <imgui.h>
#include "InputUtil.h"
@ -220,7 +220,7 @@ bool KeyBind::setToPressedKey() noexcept
}
}
for (int i = 0; i < ImGuiKey_COUNT; ++i) {
for (int i = 0; i < ImGuiKey_NamedKey_BEGIN; ++i) {
if (!ImGui::IsKeyPressed(static_cast<ImGuiKey>(i)))
continue;

View File

@ -1,13 +1,11 @@
#pragma once
#include <string>
using namespace std;
class KeyBind {
public:
KeyBind() : keybind{ "" } {};
KeyBind(string _keybind) : keybind{ _keybind } {};
string keybind;
KeyBind(std::string _keybind) : keybind{ _keybind } {};
std::string keybind;
enum KeyCode : unsigned char {
APOSTROPHE = 0,

View File

@ -1,225 +1,161 @@
#include <filesystem>
#include <any>
#include <functional>
#include <Hotkey.h>
#include "..\menu\menu.h"
#include "..\menu\player.h"
#include "..\menu\camera.h"
#include "..\utils.h"
#include "..\print.h"
#include "ini.h"
namespace Config {
static const std::vector<std::pair<std::string_view, int>> virtualKeyCodes = {
static const std::vector<std::pair<std::string_view, KeyBind::KeyCode>> virtualKeyCodes = {
// Function keys
{ "VK_F1", VK_F1 },
{ "VK_F2", VK_F2 },
{ "VK_F3", VK_F3 },
{ "VK_F4", VK_F4 },
{ "VK_F5", VK_F5 },
{ "VK_F6", VK_F6 },
{ "VK_F7", VK_F7 },
{ "VK_F8", VK_F8 },
{ "VK_F9", VK_F9 },
{ "VK_F10", VK_F10 },
{ "VK_F11", VK_F11 },
{ "VK_F12", VK_F12 },
{ "VK_F13", VK_F13 },
{ "VK_F14", VK_F14 },
{ "VK_F15", VK_F15 },
{ "VK_F16", VK_F16 },
{ "VK_F17", VK_F17 },
{ "VK_F18", VK_F18 },
{ "VK_F19", VK_F19 },
{ "VK_F20", VK_F20 },
{ "VK_F21", VK_F21 },
{ "VK_F22", VK_F22 },
{ "VK_F23", VK_F23 },
{ "VK_F24", VK_F24 },
{ "VK_F1", KeyBind::F1 },
{ "VK_F2", KeyBind::F2 },
{ "VK_F3", KeyBind::F3 },
{ "VK_F4", KeyBind::F4 },
{ "VK_F5", KeyBind::F5 },
{ "VK_F6", KeyBind::F6 },
{ "VK_F7", KeyBind::F7 },
{ "VK_F8", KeyBind::F8 },
{ "VK_F9", KeyBind::F9 },
{ "VK_F10", KeyBind::F10 },
{ "VK_F11", KeyBind::F11 },
{ "VK_F12", KeyBind::F12 },
// Number keys
{ "VK_0", 0x30 },
{ "VK_1", 0x31 },
{ "VK_2", 0x32 },
{ "VK_3", 0x33 },
{ "VK_4", 0x34 },
{ "VK_5", 0x35 },
{ "VK_6", 0x36 },
{ "VK_7", 0x37 },
{ "VK_8", 0x38 },
{ "VK_9", 0x39 },
{ "0", 0x30 },
{ "1", 0x31 },
{ "2", 0x32 },
{ "3", 0x33 },
{ "4", 0x34 },
{ "5", 0x35 },
{ "6", 0x36 },
{ "7", 0x37 },
{ "8", 0x38 },
{ "9", 0x39 },
{ "VK_0", KeyBind::KEY_0 },
{ "VK_1", KeyBind::KEY_1 },
{ "VK_2", KeyBind::KEY_2 },
{ "VK_3", KeyBind::KEY_3 },
{ "VK_4", KeyBind::KEY_4 },
{ "VK_5", KeyBind::KEY_5 },
{ "VK_6", KeyBind::KEY_6 },
{ "VK_7", KeyBind::KEY_7 },
{ "VK_8", KeyBind::KEY_8 },
{ "VK_9", KeyBind::KEY_9 },
{ "0", KeyBind::KEY_0 },
{ "1", KeyBind::KEY_1 },
{ "2", KeyBind::KEY_2 },
{ "3", KeyBind::KEY_3 },
{ "4", KeyBind::KEY_4 },
{ "5", KeyBind::KEY_5 },
{ "6", KeyBind::KEY_6 },
{ "7", KeyBind::KEY_7 },
{ "8", KeyBind::KEY_8 },
{ "9", KeyBind::KEY_9 },
// Alphabetic keys
{ "VK_A", 0x41 },
{ "VK_B", 0x42 },
{ "VK_C", 0x43 },
{ "VK_D", 0x44 },
{ "VK_E", 0x45 },
{ "VK_F", 0x46 },
{ "VK_G", 0x47 },
{ "VK_H", 0x48 },
{ "VK_I", 0x49 },
{ "VK_J", 0x4A },
{ "VK_K", 0x4B },
{ "VK_L", 0x4C },
{ "VK_M", 0x4D },
{ "VK_N", 0x4E },
{ "VK_O", 0x4F },
{ "VK_P", 0x50 },
{ "VK_Q", 0x51 },
{ "VK_R", 0x52 },
{ "VK_S", 0x53 },
{ "VK_T", 0x54 },
{ "VK_U", 0x55 },
{ "VK_V", 0x56 },
{ "VK_W", 0x57 },
{ "VK_X", 0x58 },
{ "VK_Y", 0x59 },
{ "VK_Z", 0x5A },
{ "A", 0x41 },
{ "B", 0x42 },
{ "C", 0x43 },
{ "D", 0x44 },
{ "E", 0x45 },
{ "F", 0x46 },
{ "G", 0x47 },
{ "H", 0x48 },
{ "I", 0x49 },
{ "J", 0x4A },
{ "K", 0x4B },
{ "L", 0x4C },
{ "M", 0x4D },
{ "N", 0x4E },
{ "O", 0x4F },
{ "P", 0x50 },
{ "Q", 0x51 },
{ "R", 0x52 },
{ "S", 0x53 },
{ "T", 0x54 },
{ "U", 0x55 },
{ "V", 0x56 },
{ "W", 0x57 },
{ "X", 0x58 },
{ "Y", 0x59 },
{ "Z", 0x5A },
{ "VK_A", KeyBind::A },
{ "VK_B", KeyBind::B },
{ "VK_C", KeyBind::C },
{ "VK_D", KeyBind::D },
{ "VK_E", KeyBind::E },
{ "VK_F", KeyBind::F },
{ "VK_G", KeyBind::G },
{ "VK_H", KeyBind::H },
{ "VK_I", KeyBind::I },
{ "VK_J", KeyBind::J },
{ "VK_K", KeyBind::K },
{ "VK_L", KeyBind::L },
{ "VK_M", KeyBind::M },
{ "VK_N", KeyBind::N },
{ "VK_O", KeyBind::O },
{ "VK_P", KeyBind::P },
{ "VK_Q", KeyBind::Q },
{ "VK_R", KeyBind::R },
{ "VK_S", KeyBind::S },
{ "VK_T", KeyBind::T },
{ "VK_U", KeyBind::U },
{ "VK_V", KeyBind::V },
{ "VK_W", KeyBind::W },
{ "VK_X", KeyBind::X },
{ "VK_Y", KeyBind::Y },
{ "VK_Z", KeyBind::Z },
{ "A", KeyBind::A },
{ "B", KeyBind::B },
{ "C", KeyBind::C },
{ "D", KeyBind::D },
{ "E", KeyBind::E },
{ "F", KeyBind::F },
{ "G", KeyBind::G },
{ "H", KeyBind::H },
{ "I", KeyBind::I },
{ "J", KeyBind::J },
{ "K", KeyBind::K },
{ "L", KeyBind::L },
{ "M", KeyBind::M },
{ "N", KeyBind::N },
{ "O", KeyBind::O },
{ "P", KeyBind::P },
{ "Q", KeyBind::Q },
{ "R", KeyBind::R },
{ "S", KeyBind::S },
{ "T", KeyBind::T },
{ "U", KeyBind::U },
{ "V", KeyBind::V },
{ "W", KeyBind::W },
{ "X", KeyBind::X },
{ "Y", KeyBind::Y },
{ "Z", KeyBind::Z },
// Special keys
{"VK_BACK", VK_BACK },
{"VK_TAB", VK_TAB },
{"VK_CLEAR", VK_CLEAR },
{"VK_RETURN", VK_RETURN },
{"VK_SHIFT", VK_SHIFT },
{"VK_CONTROL", VK_CONTROL },
{"VK_MENU", VK_MENU },
{"VK_PAUSE", VK_PAUSE },
{"VK_CAPITAL", VK_CAPITAL },
{"VK_ESCAPE", VK_ESCAPE },
{"VK_SPACE", VK_SPACE },
{"VK_PRIOR", VK_PRIOR },
{"VK_NEXT", VK_NEXT },
{"VK_END", VK_END },
{"VK_HOME", VK_HOME },
{"VK_LEFT", VK_LEFT },
{"VK_UP", VK_UP },
{"VK_RIGHT", VK_RIGHT },
{"VK_DOWN", VK_DOWN },
{"VK_SELECT", VK_SELECT },
{"VK_PRINT", VK_PRINT },
{"VK_EXECUTE", VK_EXECUTE },
{"VK_SNAPSHOT", VK_SNAPSHOT },
{"VK_INSERT", VK_INSERT },
{"VK_DELETE", VK_DELETE },
{"VK_HELP", VK_HELP },
{"VK_BACK", KeyBind::BACKSPACE },
{"VK_TAB", KeyBind::TAB },
{"VK_RETURN", KeyBind::ENTER },
{"VK_CAPITAL", KeyBind::CAPSLOCK },
{"VK_SPACE", KeyBind::SPACE },
{"VK_PRIOR", KeyBind::PAGE_UP },
{"VK_NEXT", KeyBind::PAGE_DOWN },
{"VK_END", KeyBind::END },
{"VK_HOME", KeyBind::HOME },
{"VK_LEFT", KeyBind::LEFT },
{"VK_UP", KeyBind::UP },
{"VK_RIGHT", KeyBind::RIGHT },
{"VK_DOWN", KeyBind::DOWN },
{"VK_INSERT", KeyBind::INSERT },
{"VK_DELETE", KeyBind::DEL },
// Numpad keys
{ "VK_NUMPAD0", VK_NUMPAD0 },
{ "VK_NUMPAD1", VK_NUMPAD1 },
{ "VK_NUMPAD2", VK_NUMPAD2 },
{ "VK_NUMPAD3", VK_NUMPAD3 },
{ "VK_NUMPAD4", VK_NUMPAD4 },
{ "VK_NUMPAD5", VK_NUMPAD5 },
{ "VK_NUMPAD6", VK_NUMPAD6 },
{ "VK_NUMPAD7", VK_NUMPAD7 },
{ "VK_NUMPAD8", VK_NUMPAD8 },
{ "VK_NUMPAD9", VK_NUMPAD9 },
{ "VK_MULTIPLY", VK_MULTIPLY },
{ "VK_ADD", VK_ADD },
{ "VK_SEPARATOR", VK_SEPARATOR },
{ "VK_SUBTRACT", VK_SUBTRACT },
{ "VK_DECIMAL", VK_DECIMAL },
{ "VK_DIVIDE", VK_DIVIDE },
{ "VK_NUMPAD0", KeyBind::NUMPAD_0 },
{ "VK_NUMPAD1", KeyBind::NUMPAD_1 },
{ "VK_NUMPAD2", KeyBind::NUMPAD_2 },
{ "VK_NUMPAD3", KeyBind::NUMPAD_3 },
{ "VK_NUMPAD4", KeyBind::NUMPAD_4 },
{ "VK_NUMPAD5", KeyBind::NUMPAD_5 },
{ "VK_NUMPAD6", KeyBind::NUMPAD_6 },
{ "VK_NUMPAD7", KeyBind::NUMPAD_7 },
{ "VK_NUMPAD8", KeyBind::NUMPAD_8 },
{ "VK_NUMPAD9", KeyBind::NUMPAD_9 },
{ "VK_MULTIPLY", KeyBind::MULTIPLY },
{ "VK_ADD", KeyBind::ADD },
{ "VK_SUBTRACT", KeyBind::SUBTRACT },
{ "VK_DECIMAL", KeyBind::DECIMAL },
{ "VK_DIVIDE", KeyBind::DIVIDE },
// Modifier keys
{ "VK_SHIFT", VK_SHIFT },
{ "VK_LSHIFT", VK_LSHIFT },
{ "VK_RSHIFT", VK_RSHIFT },
{ "VK_CONTROL", VK_CONTROL },
{ "VK_LCONTROL", VK_LCONTROL },
{ "VK_RCONTROL", VK_RCONTROL },
{ "VK_MENU", VK_MENU },
{ "VK_LMENU", VK_LMENU },
{ "VK_RMENU", VK_RMENU },
// Browser keys
{ "VK_BROWSER_BACK", VK_BROWSER_BACK },
{ "VK_BROWSER_FORWARD", VK_BROWSER_FORWARD },
{ "VK_BROWSER_REFRESH", VK_BROWSER_REFRESH },
{ "VK_BROWSER_STOP", VK_BROWSER_STOP },
{ "VK_BROWSER_SEARCH", VK_BROWSER_SEARCH },
{ "VK_BROWSER_FAVORITES", VK_BROWSER_FAVORITES },
{ "VK_BROWSER_HOME", VK_BROWSER_HOME },
// Volume keys
{ "VK_VOLUME_MUTE", VK_VOLUME_MUTE },
{ "VK_VOLUME_DOWN", VK_VOLUME_DOWN },
{ "VK_VOLUME_UP", VK_VOLUME_UP },
// Media keys
{ "VK_MEDIA_NEXT_TRACK", VK_MEDIA_NEXT_TRACK },
{ "VK_MEDIA_PREV_TRACK", VK_MEDIA_PREV_TRACK },
{ "VK_MEDIA_STOP", VK_MEDIA_STOP },
{ "VK_MEDIA_PLAY_PAUSE", VK_MEDIA_PLAY_PAUSE },
// Application keys
{ "VK_LAUNCH_MAIL", VK_LAUNCH_MAIL },
{ "VK_LAUNCH_MEDIA_SELECT", VK_LAUNCH_MEDIA_SELECT },
{ "VK_LAUNCH_APP1", VK_LAUNCH_APP1 },
{ "VK_LAUNCH_APP2", VK_LAUNCH_APP2 },
{ "VK_SHIFT", KeyBind::LSHIFT },
{ "VK_LSHIFT", KeyBind::LSHIFT },
{ "VK_RSHIFT", KeyBind::RSHIFT },
{ "VK_CONTROL", KeyBind::LCTRL },
{ "VK_LCONTROL", KeyBind::LCTRL },
{ "VK_RCONTROL", KeyBind::RCTRL },
{ "VK_MENU", KeyBind::LALT },
{ "VK_LMENU", KeyBind::LALT },
{ "VK_RMENU", KeyBind::RALT },
// Other keys
{ "VK_OEM_1", VK_OEM_1 },
{ "VK_OEM_PLUS", VK_OEM_PLUS },
{ "VK_OEM_COMMA", VK_OEM_COMMA },
{ "VK_OEM_MINUS", VK_OEM_MINUS },
{ "VK_OEM_PERIOD", VK_OEM_PERIOD },
{ "VK_OEM_2", VK_OEM_2 },
{ "VK_OEM_3", VK_OEM_3 },
{ "VK_OEM_4", VK_OEM_4 },
{ "VK_OEM_5", VK_OEM_5 },
{ "VK_OEM_6", VK_OEM_6 },
{ "VK_OEM_7", VK_OEM_7 },
{ "VK_OEM_8", VK_OEM_8 },
{ "VK_OEM_102", VK_OEM_102 },
{ "VK_PROCESSKEY", VK_PROCESSKEY },
{ "VK_PACKET", VK_PACKET },
{ "VK_ATTN", VK_ATTN },
{ "VK_CRSEL", VK_CRSEL },
{ "VK_EXSEL", VK_EXSEL },
{ "VK_EREOF", VK_EREOF },
{ "VK_PLAY", VK_PLAY },
{ "VK_ZOOM", VK_ZOOM },
{ "VK_NONAME", VK_NONAME },
{ "VK_PA1", VK_PA1 },
{ "VK_OEM_CLEAR", VK_OEM_CLEAR }
{ "VK_OEM_1", KeyBind::SEMICOLON },
{ "VK_OEM_PLUS", KeyBind::EQUALS },
{ "VK_OEM_COMMA", KeyBind::COMMA },
{ "VK_OEM_MINUS", KeyBind::MINUS },
{ "VK_OEM_PERIOD", KeyBind::PERIOD },
{ "VK_OEM_2", KeyBind::SLASH },
{ "VK_OEM_3", KeyBind::BACKTICK },
{ "VK_OEM_4", KeyBind::LEFTBRACKET },
{ "VK_OEM_5", KeyBind::BACKSLASH },
{ "VK_OEM_6", KeyBind::RIGHTBRACKET },
{ "VK_OEM_7", KeyBind::APOSTROPHE }
};
extern const char playerVars[];
@ -4080,7 +4016,13 @@ namespace Config {
static const std::vector<ConfigEntry> configVariablesDefault = {
{ "Menu", "Transparency", 99.0f, &Menu::transparency, Float },
{ "Menu:Keybinds", "MenuToggleKey", std::string("VK_F5"), &Menu::toggleKey, String },
{ "Menu:Keybinds", "MenuToggleKey", std::string("VK_F5"), &Menu::toggleKey, String},
{ "Menu:Keybinds", "GodModeToggleKey", std::string("VK_F6"), &Menu::Player::godModeToggleKey, String},
{ "Menu:Keybinds", "FreezePlayerToggleKey", std::string("VK_F7"), &Menu::Player::freezePlayerToggleKey, String},
{ "Menu:Keybinds", "FreeCamToggleKey", std::string("VK_F3"), &Menu::Camera::freeCamToggleKey, String},
{ "Menu:Keybinds", "TeleportPlayerToCameraToggleKey", std::string("VK_F4"), &Menu::Camera::teleportPlayerToCameraToggleKey, String},
{ "Menu:Keybinds", "ThirdPersonToggleKey", std::string("VK_F1"), &Menu::Camera::thirdPersonCameraToggleKey, String},
{ "Menu:Keybinds", "UseTPPModelToggleKey", std::string("VK_F2"), &Menu::Camera::tpUseTPPModelToggleKey, String},
{ "Player:Misc", "GodMode", false, &Menu::Player::godModeEnabled.value, Bool },
{ "Player:PlayerVariables", "Enabled", false, &Menu::Player::playerVariablesEnabled, Bool },
{ "Player:PlayerVariables", "LastSaveSCRPath", std::string(), &Menu::Player::saveSCRPath, String },
@ -4088,7 +4030,7 @@ namespace Config {
{ "Camera:FreeCam", "Speed", 2.0f, &Menu::Camera::freeCamSpeed, Float },
{ "Camera:FreeCam", "TeleportPlayerToCamera", false, &Menu::Camera::teleportPlayerToCameraEnabled, Bool },
{ "Camera:ThirdPerson", "Enabled", false, &Menu::Camera::thirdPersonCameraEnabled.value, Bool },
{ "Camera:ThirdPerson", "UseTPPModel", true, &Menu::Camera::tpUseTPPModel.value, Bool },
{ "Camera:ThirdPerson", "UseTPPModel", true, &Menu::Camera::tpUseTPPModelEnabled.value, Bool },
{ "Camera:ThirdPerson", "DistanceBehindPlayer", 2.0f, &Menu::Camera::tpDistanceBehindPlayer, Float },
{ "Camera:ThirdPerson", "HeightAbovePlayer", 1.35f, &Menu::Camera::tpHeightAbovePlayer, Float },
{ "Camera:Misc", "DisablePhotoModeLimits", true, &Menu::Camera::disablePhotoModeLimitsEnabled.value, Bool },
@ -4138,11 +4080,11 @@ namespace Config {
entry.value = loadSCRFilePath;
Menu::Player::loadSCRFilePath = loadSCRFilePath;
}
else if (entry.key == "MenuToggleKey") {
else if (entry.section == "Menu:Keybinds") {
const std::string toggleKey = std::any_cast<std::string>(entry.value);
auto it = std::find_if(virtualKeyCodes.begin(), virtualKeyCodes.end(), [&toggleKey](const auto& pair) { return pair.first == toggleKey; });
if (it != virtualKeyCodes.end())
Menu::toggleKey = it->second;
*reinterpret_cast<KeyBindToggle*>(entry.valuePtr) = KeyBindToggle(it->second);
}
switch (entry.type) {
@ -4198,12 +4140,9 @@ namespace Config {
case String:
strValue = reader.Get(entry.section.data(), entry.key.data(), std::any_cast<std::string>(entry.value));
if (entry.section == "Menu:Keybinds") {
if (entry.key == "MenuToggleKey") {
const std::string toggleKey = strValue;
auto it = std::find_if(virtualKeyCodes.begin(), virtualKeyCodes.end(), [&toggleKey](const auto& pair) { return pair.first == toggleKey; });
if (it != virtualKeyCodes.end())
Menu::toggleKey = it->second;
}
auto it = std::find_if(virtualKeyCodes.begin(), virtualKeyCodes.end(), [&strValue](const auto& pair) { return pair.first == strValue; });
if (it != virtualKeyCodes.end())
*reinterpret_cast<KeyBindToggle*>(entry.valuePtr) = KeyBindToggle(it->second);
break;
}
else if (entry.key == "LastSaveSCRPath") {
@ -4250,7 +4189,7 @@ namespace Config {
entry.value = *reinterpret_cast<bool*>(entry.valuePtr);
break;
case String:
if (entry.key == "MenuToggleKey") {
if (entry.section == "Menu:Keybinds") {
auto it = std::find_if(virtualKeyCodes.begin(), virtualKeyCodes.end(), [&entry](const auto& pair) { return pair.second == *reinterpret_cast<int*>(entry.valuePtr); });
if (it != virtualKeyCodes.end())
entry.value = std::string(it->first);

View File

@ -6,8 +6,6 @@
#include "ImGui\impl\d3d11_impl.h"
#include "ImGui\impl\d3d12_impl.h"
#include "menu\menu.h"
#include "menu\player.h"
#include "menu\camera.h"
#include "game_classes.h"
#include "sigscan\offsets.h"
#include "config\config.h"
@ -115,16 +113,6 @@ namespace Core {
Menu::Player::Update();
Menu::Camera::Update();
GamePH::LevelDI* iLevel = GamePH::LevelDI::Get();
if (!iLevel)
return;
GamePH::GameDI_PH* pGameDI_PH = GamePH::GameDI_PH::Get();
if (!pGameDI_PH)
return;
iLevel->GetTimeDelta();
pGameDI_PH->GetGameTimeDelta();
/*Engine::CRTTI* g_BackgroundModuleScreenController = GamePH::BackgroundModuleScreenController::Get();
if (!g_BackgroundModuleScreenController)
return;

View File

@ -163,22 +163,22 @@ namespace GamePH {
gen_TPPModel* pgen_TPPModel = gen_TPPModel::Get();
if (pgen_TPPModel) {
if (Menu::Camera::photoModeEnabled.previousValue != Menu::Camera::photoModeEnabled.value && !Menu::Camera::photoModeEnabled.value) {
Menu::Camera::tpUseTPPModel.previousValue = !Menu::Camera::tpUseTPPModel.value;
Menu::Camera::tpUseTPPModelEnabled.previousValue = !Menu::Camera::tpUseTPPModelEnabled.value;
Menu::Camera::thirdPersonCameraEnabled.previousValue = Menu::Camera::thirdPersonCameraEnabled.value;
}
if (!Menu::Camera::photoModeEnabled.value && !Menu::Camera::freeCamEnabled.value) {
if ((Menu::Camera::tpUseTPPModel.previousValue != Menu::Camera::tpUseTPPModel.value && !Menu::Camera::tpUseTPPModel.value && Menu::Camera::thirdPersonCameraEnabled.value) || (Menu::Camera::thirdPersonCameraEnabled.previousValue != Menu::Camera::thirdPersonCameraEnabled.value && !Menu::Camera::thirdPersonCameraEnabled.value)) {
if ((Menu::Camera::tpUseTPPModelEnabled.previousValue != Menu::Camera::tpUseTPPModelEnabled.value && !Menu::Camera::tpUseTPPModelEnabled.value && Menu::Camera::thirdPersonCameraEnabled.value) || (Menu::Camera::thirdPersonCameraEnabled.previousValue != Menu::Camera::thirdPersonCameraEnabled.value && !Menu::Camera::thirdPersonCameraEnabled.value)) {
pgen_TPPModel->enableTPPModel2 = true;
pgen_TPPModel->enableTPPModel1 = true;
}
ShowTPPModel(Menu::Camera::tpUseTPPModel.value && Menu::Camera::thirdPersonCameraEnabled.value);
if (Menu::Camera::tpUseTPPModel.previousValue == Menu::Camera::tpUseTPPModel.value && Menu::Camera::thirdPersonCameraEnabled.previousValue == Menu::Camera::thirdPersonCameraEnabled.value && (Menu::Camera::tpUseTPPModel.value && Menu::Camera::thirdPersonCameraEnabled.value)) {
ShowTPPModel(Menu::Camera::tpUseTPPModelEnabled.value && Menu::Camera::thirdPersonCameraEnabled.value);
if (Menu::Camera::tpUseTPPModelEnabled.previousValue == Menu::Camera::tpUseTPPModelEnabled.value && Menu::Camera::thirdPersonCameraEnabled.previousValue == Menu::Camera::thirdPersonCameraEnabled.value && (Menu::Camera::tpUseTPPModelEnabled.value && Menu::Camera::thirdPersonCameraEnabled.value)) {
pgen_TPPModel->enableTPPModel2 = false;
pgen_TPPModel->enableTPPModel1 = false;
}
Menu::Camera::tpUseTPPModel.previousValue = Menu::Camera::tpUseTPPModel.value;
Menu::Camera::tpUseTPPModelEnabled.previousValue = Menu::Camera::tpUseTPPModelEnabled.value;
Menu::Camera::thirdPersonCameraEnabled.previousValue = Menu::Camera::thirdPersonCameraEnabled.value;
}
if (Menu::Camera::photoModeEnabled.previousValue != Menu::Camera::photoModeEnabled.value && Menu::Camera::photoModeEnabled.value) {

View File

@ -11,16 +11,19 @@ namespace Menu {
SMART_BOOL photoModeEnabled;
SMART_BOOL freeCamEnabled{};
KeyBindToggle freeCamToggleKey = KeyBindToggle(KeyBind::F3);
float freeCamSpeed = 2.0f;
bool teleportPlayerToCameraEnabled = false;
KeyBindToggle teleportPlayerToCameraToggleKey = KeyBindToggle(KeyBind::F4);
SMART_BOOL thirdPersonCameraEnabled;
SMART_BOOL tpUseTPPModel;
KeyBindToggle thirdPersonCameraToggleKey = KeyBindToggle(KeyBind::F1);
SMART_BOOL tpUseTPPModelEnabled;
KeyBindToggle tpUseTPPModelToggleKey = KeyBindToggle(KeyBind::F2);
float tpDistanceBehindPlayer = 2.0f;
float tpHeightAbovePlayer = 1.35f;
SMART_BOOL disablePhotoModeLimitsEnabled{};
bool teleportPlayerToCameraEnabled = false;
SMART_BOOL disableSafezoneFOVReductionEnabled{};
static const int baseFOV = 57;
@ -119,15 +122,22 @@ namespace Menu {
ImGui::Checkbox("Enabled##FreeCam", &freeCamEnabled.value);
ImGui::EndDisabled();
}
ImGui::Hotkey("##FreeCamToggleKey", freeCamToggleKey);
ImGui::SliderFloat("Speed##FreeCam", &freeCamSpeed, 0.0f, 100.0f);
ImGui::Checkbox("Teleport Player to Camera", &teleportPlayerToCameraEnabled);
ImGui::Hotkey("##TeleportPlayerToCamToggleKey", teleportPlayerToCameraToggleKey);
ImGui::SeparatorText("Third Person Camera");
ImGui::BeginDisabled(freeCamEnabled.value || photoModeEnabled.value); {
ImGui::Checkbox("Enabled##ThirdPerson", &thirdPersonCameraEnabled.value);
ImGui::Checkbox("Use Third Person Player (TPP) Model", &tpUseTPPModel.value);
ImGui::EndDisabled();
}
ImGui::Hotkey("##ThirdPersonToggleKey", thirdPersonCameraToggleKey);
ImGui::BeginDisabled(freeCamEnabled.value || photoModeEnabled.value); {
ImGui::Checkbox("Use Third Person Player (TPP) Model", &tpUseTPPModelEnabled.value);
ImGui::EndDisabled();
}
ImGui::Hotkey("##TPPModelToggleKey", tpUseTPPModelToggleKey);
ImGui::SliderFloat("Distance behind player", &tpDistanceBehindPlayer, 1.0f, 10.0f);
ImGui::SliderFloat("Height above player", &tpHeightAbovePlayer, 1.0f, 3.0f);

View File

@ -1,4 +1,5 @@
#pragma once
#include <Hotkey.h>
#include "..\core.h"
namespace Menu {
@ -8,16 +9,19 @@ namespace Menu {
extern SMART_BOOL photoModeEnabled;
extern SMART_BOOL freeCamEnabled;
extern KeyBindToggle freeCamToggleKey;
extern float freeCamSpeed;
extern bool teleportPlayerToCameraEnabled;
extern KeyBindToggle teleportPlayerToCameraToggleKey;
extern SMART_BOOL thirdPersonCameraEnabled;
extern SMART_BOOL tpUseTPPModel;
extern KeyBindToggle thirdPersonCameraToggleKey;
extern SMART_BOOL tpUseTPPModelEnabled;
extern KeyBindToggle tpUseTPPModelToggleKey;
extern float tpDistanceBehindPlayer;
extern float tpHeightAbovePlayer;
extern SMART_BOOL disablePhotoModeLimitsEnabled;
extern bool teleportPlayerToCameraEnabled;
extern SMART_BOOL disableSafezoneFOVReductionEnabled;
extern void Update();

View File

@ -1,4 +1,5 @@
#include <imgui.h>
#include <Hotkey.h>
#include "camera.h"
#include "player.h"
#include "world.h"
@ -8,7 +9,7 @@ namespace Menu {
static const ImVec2 minWndSize = ImVec2(0.0f, 0.0f);
static const ImVec2 maxWndSize = ImVec2(900.0f, 675.0f);
int toggleKey = VK_F5;
KeyBindToggle toggleKey = KeyBindToggle(KeyBind::F5);
bool isOpen = false;
float transparency = 99.0f;
@ -36,6 +37,7 @@ namespace Menu {
ImGui::Separator();
ImGui::Hotkey("Menu Toggle Key", toggleKey);
ImGui::SliderFloat("Menu Transparency", &transparency, 0.0f, 100.0f, "%.1f%%", ImGuiSliderFlags_AlwaysClamp);
ImGui::End();
}

View File

@ -1,8 +1,11 @@
#pragma once
#include <InputUtil.h>
#include "camera.h"
#include "player.h"
#include "world.h"
namespace Menu {
extern int toggleKey;
extern KeyBindToggle toggleKey;
extern bool isOpen;
extern float transparency;

View File

@ -4,6 +4,7 @@
#include <filesystem>
#include <imgui.h>
#include <ImGuiFileDialog.h>
#include <Hotkey.h>
#include "..\game_classes.h"
#include "..\core.h"
#include "..\utils.h"
@ -5995,7 +5996,9 @@ namespace Menu {
0x63, 0x65, 0x22, 0x2C, 0x20, 0x22, 0x38, 0x22, 0x29, 0x3B, 0x0D, 0x0A, 0x7D, 0x0D, 0x0A };
SMART_BOOL godModeEnabled{};
KeyBindToggle godModeToggleKey = KeyBindToggle(KeyBind::F6);
SMART_BOOL freezePlayerEnabled{};
KeyBindToggle freezePlayerToggleKey = KeyBindToggle(KeyBind::F7);
bool playerVariablesEnabled = false;
std::string saveSCRPath{};
@ -6236,11 +6239,13 @@ namespace Menu {
ImGui::Checkbox("God Mode", &godModeEnabled.value);
ImGui::EndDisabled();
}
ImGui::Hotkey("##GodModeToggleKey", godModeToggleKey);
ImGui::SameLine();
ImGui::BeginDisabled(!Engine::CBulletPhysicsCharacter::Get() || Menu::Camera::freeCamEnabled.value); {
ImGui::Checkbox("Freeze Player", &freezePlayerEnabled.value);
ImGui::EndDisabled();
}
ImGui::Hotkey("##FreezePlayerToggleKey", freezePlayerToggleKey);
ImGui::SeparatorText("Player Variables");
ImGui::Checkbox("Enabled##PlayerVars", &playerVariablesEnabled);

View File

@ -1,11 +1,14 @@
#pragma once
#include <string>
#include <Hotkey.h>
#include "..\core.h"
namespace Menu {
namespace Player {
extern SMART_BOOL godModeEnabled;
extern KeyBindToggle godModeToggleKey;
extern SMART_BOOL freezePlayerEnabled;
extern KeyBindToggle freezePlayerToggleKey;
extern bool playerVariablesEnabled;
extern std::string saveSCRPath;

View File

@ -3,6 +3,21 @@
#include "utils.h"
namespace Utils {
Timer::Timer(long timeMs) : timeToPass(timeMs), timePassed(false) {
start = std::chrono::time_point_cast<std::chrono::milliseconds>(clock::now());
}
bool Timer::GetTimePassed() {
if (timePassed)
return timePassed;
auto end = clock::now();
long timePassedMs = static_cast<long>((end - start).count());
if (timePassedMs >= timeToPass)
timePassed = true;
return timePassed;
}
bool are_same(float a, float b) {
return abs(a - b) < 0.0001f;
}

View File

@ -1,5 +1,6 @@
#pragma once
#include <string>
#include <chrono>
enum class WindowsVersion {
Unknown,
@ -8,6 +9,19 @@ enum class WindowsVersion {
};
namespace Utils {
class Timer {
using clock = std::chrono::system_clock;
using time_point_type = std::chrono::time_point<clock, std::chrono::milliseconds>;
public:
long timeToPass;
Timer(long timeMs);
bool GetTimePassed();
private:
time_point_type start;
bool timePassed;
};
extern bool are_same(float a, float b);
extern bool str_replace(std::string& str, const std::string& from, const std::string& to);