mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
- Added changelog screen
- Fixed console printing thread safety
This commit is contained in:
@ -89,9 +89,9 @@ namespace ImGui {
|
||||
const float indentation = (window_width - text_width) * 0.5f;
|
||||
return indentation > min_indentation ? indentation : min_indentation;
|
||||
}
|
||||
void TextCentered(const char* text) {
|
||||
void TextCentered(const char* text, const bool calculateWithScrollbar) {
|
||||
const float min_indentation = 20.0f;
|
||||
const float window_width = ImGui::GetWindowSize().x - ImGui::GetStyle().ScrollbarSize - min_indentation;
|
||||
const float window_width = ImGui::GetWindowSize().x - (calculateWithScrollbar ? ImGui::GetStyle().ScrollbarSize : 0.0f);
|
||||
const float wrap_pos = window_width - min_indentation;
|
||||
|
||||
std::istringstream iss(text);
|
||||
@ -117,9 +117,9 @@ namespace ImGui {
|
||||
ImGui::NewLine();
|
||||
}
|
||||
}
|
||||
void TextCenteredColored(const char* text, const ImU32 col) {
|
||||
void TextCenteredColored(const char* text, const ImU32 col, const bool calculateWithScrollbar) {
|
||||
const float min_indentation = 20.0f;
|
||||
const float window_width = ImGui::GetWindowSize().x - ImGui::GetStyle().ScrollbarSize - min_indentation;
|
||||
const float window_width = ImGui::GetWindowSize().x - (calculateWithScrollbar ? ImGui::GetStyle().ScrollbarSize : 0.0f);
|
||||
const float wrap_pos = window_width - min_indentation;
|
||||
|
||||
std::istringstream iss(text);
|
||||
|
@ -5,8 +5,8 @@ namespace ImGui {
|
||||
extern void StyleScaleAllSizes(ImGuiStyle* style, const float scale_factor);
|
||||
extern bool Checkbox(const char* label, Option* v);
|
||||
extern bool CheckboxHotkey(const char* label, KeyBindOption* v);
|
||||
extern void TextCentered(const char* text);
|
||||
extern void TextCenteredColored(const char* text, const ImU32 col);
|
||||
extern void TextCentered(const char* text, const bool calculateWithScrollbar = true);
|
||||
extern void TextCenteredColored(const char* text, const ImU32 col, const bool calculateWithScrollbar = true);
|
||||
extern bool ButtonCentered(const char* label, const ImVec2 size = ImVec2(0.0f, 0.0f));
|
||||
extern void SeparatorTextColored(const char* text, const ImU32 col);
|
||||
extern void Spacing(const ImVec2 size, const bool customPosOffset = false);
|
||||
|
@ -46,16 +46,18 @@ namespace impl {
|
||||
if (!pCInput)
|
||||
return CallWindowProc(oWndProc, hwnd, uMsg, wParam, lParam);
|
||||
|
||||
ImGui::GetIO().MouseDrawCursor = Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue();
|
||||
ImGui::GetIO().MouseDrawCursor = !Menu::hasSeenChangelog.GetValue() || Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue();
|
||||
ImGui_ImplWin32_WndProcHandler(hwnd, uMsg, wParam, lParam);
|
||||
|
||||
if (Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue()) {
|
||||
if (!Menu::hasSeenChangelog.GetValue() || Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue()) {
|
||||
pCInput->BlockGameInput();
|
||||
|
||||
if (Menu::menuToggle.GetValue())
|
||||
Menu::menuToggle.SetPrevValue(true);
|
||||
} else if (Menu::firstTimeRunning.GetPrevValue() || Menu::menuToggle.GetPrevValue()) {
|
||||
if (Menu::firstTimeRunning.GetPrevValue())
|
||||
} else if (!Menu::hasSeenChangelog.GetPrevValue() || Menu::firstTimeRunning.GetPrevValue() || Menu::menuToggle.GetPrevValue()) {
|
||||
if (!Menu::hasSeenChangelog.GetPrevValue())
|
||||
Menu::hasSeenChangelog.SetPrevValue(true);
|
||||
else if (Menu::firstTimeRunning.GetPrevValue())
|
||||
Menu::firstTimeRunning.SetPrevValue(false);
|
||||
else if (Menu::menuToggle.GetPrevValue())
|
||||
Menu::menuToggle.SetPrevValue(false);
|
||||
|
@ -7,6 +7,7 @@ namespace Changelog {
|
||||
{ "v1.1.0",
|
||||
R"(- You can now load custom mod files from "EGameTools\UserModFiles"! Please read the new "Welcome" screen which explains how to use this feature and how to use the rest of the mod menu
|
||||
- By using the directory mentioned earlier for mod files, you can reload most of them by just reloading the savegame!
|
||||
|
||||
- Added "Reload Jump Params", using the directory mentioned earlier (Player)
|
||||
- Added "One-handed Mode" (Player)
|
||||
- Added "Nightrunner Mode" (Player)
|
||||
@ -14,6 +15,7 @@ R"(- You can now load custom mod files from "EGameTools\UserModFiles"! Please re
|
||||
- Added "Freeze Time" (World)
|
||||
- Added "Game Speed" slider (World)
|
||||
- Added "Slow Motion" (World)
|
||||
|
||||
- Fixed having FreeCam enabled while in the Map view would cause a weird offset of the entire Map view)" }
|
||||
};
|
||||
}
|
@ -114,7 +114,10 @@ namespace Core {
|
||||
|
||||
for (auto& hook : *Utils::Hook::HookBase::GetInstances()) {
|
||||
Utils::PrintInfo("Hooking %s", hook->name.data());
|
||||
std::thread([hook]() { hook->HookLoop(); }).detach();
|
||||
std::thread([&hook]() {
|
||||
hook->HookLoop();
|
||||
Utils::PrintSuccess("Hooked %s!", hook->name.data());
|
||||
}).detach();
|
||||
}
|
||||
|
||||
const HANDLE proc = GetCurrentProcess();
|
||||
|
@ -20,7 +20,7 @@ namespace GamePH {
|
||||
}
|
||||
const std::string GetCurrentGameVersionStr() {
|
||||
if (!GetCurrentGameVersion())
|
||||
return {};
|
||||
return "UNKNOWN";
|
||||
|
||||
DWORD64 version = GetCurrentGameVersion();
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include <pch.h>
|
||||
#include "..\changelog.h"
|
||||
#include "..\game\GamePH\Other.h"
|
||||
#include "menu.h"
|
||||
|
||||
namespace Menu {
|
||||
static const std::string title = "EGameTools (" + std::string(MOD_VERSION_STR) + ")";
|
||||
|
||||
static constexpr ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_HorizontalScrollbar;
|
||||
static constexpr ImGuiWindowFlags welcomeWindowFlags = (windowFlags | ImGuiWindowFlags_NoMove) & ~ImGuiWindowFlags_HorizontalScrollbar;
|
||||
static constexpr ImVec2 minChangelogWndSize = ImVec2(400.0f, 0.0f);
|
||||
@ -19,110 +22,57 @@ namespace Menu {
|
||||
float scale = 1.0f;
|
||||
|
||||
static Utils::Time::Timer timePassedFromWelcomeScreen{};
|
||||
static bool firstTimeRunningFunc = true;
|
||||
Option firstTimeRunning{};
|
||||
Option hasSeenChangelog{};
|
||||
|
||||
void FirstTimeRunning() {
|
||||
if (!firstTimeRunning.GetValue())
|
||||
static void CreateChangelogFile() {
|
||||
const std::string localAppDataDir = Utils::Files::GetLocalAppDataDir();
|
||||
if (localAppDataDir.empty())
|
||||
return;
|
||||
const std::string dirPath = std::string(localAppDataDir) + "\\EGameTools\\";
|
||||
std::filesystem::create_directories(dirPath);
|
||||
|
||||
const std::string finalPath = dirPath + MOD_VERSION_STR + ".changelog";
|
||||
if (!std::filesystem::exists(finalPath)) {
|
||||
std::ofstream outFile(finalPath.c_str(), std::ios::binary);
|
||||
if (!outFile.is_open())
|
||||
return;
|
||||
outFile.close();
|
||||
}
|
||||
}
|
||||
static bool DoesChangelogFileExist() {
|
||||
const std::string localAppDataDir = Utils::Files::GetLocalAppDataDir();
|
||||
if (localAppDataDir.empty())
|
||||
return false;
|
||||
return std::filesystem::exists(std::string(localAppDataDir) + "\\EGameTools\\" + MOD_VERSION_STR + ".changelog");
|
||||
}
|
||||
void FirstTimeRunning() {
|
||||
static bool firstTimeRunningFunc = true;
|
||||
if (firstTimeRunningFunc)
|
||||
hasSeenChangelog.SetBothValues(hasSeenChangelog.GetValue() && DoesChangelogFileExist());
|
||||
|
||||
if (hasSeenChangelog.GetValue() && !firstTimeRunning.GetValue()) {
|
||||
firstTimeRunningFunc = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string changelogTitle = std::string(title + " - Update Changelog");
|
||||
const std::string welcomeTitle = std::string(title + " - Welcome!");
|
||||
|
||||
if (firstTimeRunningFunc) {
|
||||
firstTimeRunningFunc = false;
|
||||
timePassedFromWelcomeScreen = Utils::Time::Timer(10000);
|
||||
menuToggle.SetChangesAreDisabled(true);
|
||||
if (!hasSeenChangelog.GetValue())
|
||||
ImGui::OpenPopup("EGameTools - Update Changelog");
|
||||
ImGui::OpenPopup("EGameTools - Welcome!");
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowSizeConstraints(minChangelogWndSize, defMaxChangelogWndSize);
|
||||
if (ImGui::BeginPopupModal("EGameTools - Update Changelog", nullptr, welcomeWindowFlags)) {
|
||||
const std::string title = "EGameTools (" + std::string(MOD_VERSION_STR) + ") - Update Changelog";
|
||||
ImGui::TextCenteredColored(title.c_str(), IM_COL32(230, 0, 0, 255));
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
|
||||
const std::string gameCompat = "This version of the mod is compatible with game version " + std::string(GAME_VER_COMPAT_STR) + ".";
|
||||
ImGui::TextCentered(gameCompat.c_str());
|
||||
const std::string gameVer = "The game version you are currently running is v" + GamePH::GetCurrentGameVersionStr() + ".";
|
||||
ImGui::TextCentered(gameVer.c_str());
|
||||
const std::string gameTestedVer = "This mod has last been tested with version v" + GamePH::GameVerToStr(GAME_VER_COMPAT) + ".";
|
||||
ImGui::TextCentered(gameTestedVer.c_str());
|
||||
if (GamePH::GetCurrentGameVersion() < 11400 || GamePH::GetCurrentGameVersion() > GAME_VER_COMPAT) {
|
||||
const std::string gameNotCompat = "Please note that your game version has not been officially tested with this mod, therefore expect bugs, glitches or the mod to completely stop working. If so, please " + std::string(GamePH::GetCurrentGameVersion() > GAME_VER_COMPAT ? "wait for a new patch." : "upgrade your game version to one that the mod supports.");
|
||||
ImGui::TextCenteredColored(gameNotCompat.c_str(), IM_COL32(200, 0, 0, 255));
|
||||
}
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
ImGui::TextCentered("I will not bore you with what this mod is about, so let's get right to teaching you how to use it!");
|
||||
|
||||
ImGui::SeparatorTextColored("Menu Toggle", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("The default key for opening/closing the menu is F5. You can use your mouse to navigate the menu.");
|
||||
ImGui::TextCentered("To change it, you can open up the menu and change the hotkey by clicking the hotkey button for \"Menu Toggle Key\" and then pressing a key on your keyboard.");
|
||||
|
||||
ImGui::SeparatorTextColored("FreeCam", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("While using FreeCam, you can press Shift or Alt to boost your speed or slow you down respectively.");
|
||||
ImGui::TextCentered("You can also use the scroll wheel to change FreeCam speed while FreeCam is enabled.");
|
||||
|
||||
ImGui::SeparatorTextColored("Menu Sliders", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("To manually change the value of a slider option, hold \"CTRL\" while clicking the slider.");
|
||||
ImGui::TextCentered("This will let you input a value manually into the slider, which can even surpass the option's slider limit, given I allowed the option to do so.");
|
||||
|
||||
ImGui::SeparatorTextColored("Custom File Loading", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("The mod always creates a folder \"EGameTools\\UserModFiles\" inside the same folder as the game executable (exe) or in the same folder as the mod file.");
|
||||
ImGui::TextCentered("This folder is used for custom file loading. This has only been tested with a few mods that change some .scr files, gpufx files, and other files included inside .pak game archives, or files like .rpack files.");
|
||||
ImGui::TextCentered("Files in this folder must have the same names as the ones from the game files, otherwise the game won't know it should load those files. Files in subfolders of the \"EGameTools\\UserModFiles\" folder will automatically be detected, so you can sort all your mods in different folders!");
|
||||
ImGui::TextCentered("The game will reload a lot of the files upon a load of your savegame, so if you want to edit those files and reload them without having to restart the game, just reload your savegame and the game should automatically reload most of those files!");
|
||||
ImGui::TextCentered("Just make sure that if you add new, additional files while you're in-game, please wait AT LEAST 5 seconds before reloading your savegame, otherwise additional files will not get detected.");
|
||||
ImGui::TextCentered("Also, if there are multiple files of the same exact name, the game will pick the first instance of that file it finds in the folder.");
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
ImGui::TextCentered("The gist of it is, you now don't have to use dataX.pak mods anymore! You can open the pak files, extract their files in the \"EGameTools\\UserModFiles\" folder and start the game!");
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
ImGui::TextCentered("Please try not to touch \"EGameTools\\DefaultModFiles\"! Those are mods that come with EGameTools by default, and you should only ever touch those if I can't update them in time to make them work with the latest game version.");
|
||||
|
||||
ImGui::SeparatorTextColored("Game Variables Reloading", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("You can also reload Player Variables from a file specified by you, or reload Jump Parameters from \"EGameTools\\UserModFiles\".");
|
||||
|
||||
ImGui::SeparatorTextColored("Hotkeys", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("Most mod menu options are toggleable by a hotkey that you can change by clicking the hotkey button for the respective option and then pressing a key on your keyboard.");
|
||||
ImGui::TextCentered("To change those hotkeys through the config file, visit the \"Virtual-Key Codes\" page from Microsoft which contains a list of all virtual key codes. Simply write the name of the keycode you want to use for each hotkey and save the config file.");
|
||||
|
||||
ImGui::SeparatorTextColored("Config", IM_COL32(200, 0, 0, 255));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("A config file \"EGameTools.ini\" is stored in the same folder as the game executable (exe) or in the same folder as the mod file.");
|
||||
ImGui::TextCentered("The config file stores the mod menu's options and hotkeys.");
|
||||
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
|
||||
ImGui::TextCentered("Changes to the mod menu or to the config file are always automatically saved or refreshed respectively.");
|
||||
ImGui::TextCentered("You DO NOT NEED to restart the game for the changes in the config to be applied!");
|
||||
ImGui::TextCentered("If you want to regenerate the config file, delete it and it will automatically be regenerated.");
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::NewLine();
|
||||
ImGui::TextCentered("Finally, if you've got any issue, no matter how small, please make sure to report it! I will try my best to fix it. I want this mod to be polished and enjoyable to use!");
|
||||
ImGui::TextCentered("If you've got any suggestions for how I could improve the mod, in terms of UI, features, among other things, please let me know!");
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
|
||||
ImGui::BeginDisabled(!timePassedFromWelcomeScreen.DidTimePass());
|
||||
{
|
||||
const std::string btnText = "Let me play!" + (!timePassedFromWelcomeScreen.DidTimePass() ? (std::to_string(10 - (timePassedFromWelcomeScreen.GetTimePassed() / 1000)) + ")") : "");
|
||||
if (ImGui::ButtonCentered(btnText.c_str(), ImVec2(0.0f, 30.0f))) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
menuToggle.SetChangesAreDisabled(false);
|
||||
firstTimeRunning.Set(false);
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
||||
if (firstTimeRunning.GetValue())
|
||||
ImGui::OpenPopup(welcomeTitle.c_str());
|
||||
else if (!hasSeenChangelog.GetValue())
|
||||
ImGui::OpenPopup(changelogTitle.c_str());
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowBgAlpha(1.0f);
|
||||
ImGui::SetNextWindowSizeConstraints(minWelcomeWndSize, defMaxWelcomeWndSize);
|
||||
if (ImGui::BeginPopupModal("EGameTools - Welcome!", nullptr, welcomeWindowFlags)) {
|
||||
if (ImGui::BeginPopupModal(welcomeTitle.c_str(), nullptr, welcomeWindowFlags)) {
|
||||
ImGui::TextCenteredColored("PLEASE read the following text!", IM_COL32(230, 0, 0, 255));
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
|
||||
@ -198,24 +148,56 @@ namespace Menu {
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
|
||||
ImGui::BeginDisabled(!timePassedFromWelcomeScreen.DidTimePass()); {
|
||||
const std::string btnText = "Let me play!" + (!timePassedFromWelcomeScreen.DidTimePass() ? (std::to_string(10 - (timePassedFromWelcomeScreen.GetTimePassed() / 1000)) + ")") : "");
|
||||
const std::string btnText = "Let me play!" + (!timePassedFromWelcomeScreen.DidTimePass() ? (" (" + std::to_string(10 - (timePassedFromWelcomeScreen.GetTimePassed() / 1000)) + ")") : "");
|
||||
if (ImGui::ButtonCentered(btnText.c_str(), ImVec2(0.0f, 30.0f))) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
menuToggle.SetChangesAreDisabled(false);
|
||||
firstTimeRunning.Set(false);
|
||||
if (hasSeenChangelog.GetValue())
|
||||
menuToggle.SetChangesAreDisabled(false);
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
static bool changelogPopupOpened = false;
|
||||
if (!hasSeenChangelog.GetValue() && !firstTimeRunning.GetValue() && !changelogPopupOpened) {
|
||||
changelogPopupOpened = true;
|
||||
ImGui::OpenPopup(changelogTitle.c_str());
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowBgAlpha(1.0f);
|
||||
ImGui::SetNextWindowSizeConstraints(minChangelogWndSize, defMaxChangelogWndSize);
|
||||
if (ImGui::BeginPopupModal(changelogTitle.c_str(), nullptr, welcomeWindowFlags)) {
|
||||
const std::string subTitle = "This is what the " + std::string(MOD_VERSION_STR) + " update brings:";
|
||||
ImGui::TextCenteredColored(subTitle.c_str(), IM_COL32(230, 0, 0, 255), false);
|
||||
ImGui::Spacing(ImVec2(0.0f, 5.0f));
|
||||
|
||||
std::istringstream iss(Changelog::changelogs[MOD_VERSION_STR]);
|
||||
std::string line{};
|
||||
while (std::getline(iss, line)) {
|
||||
if (line.empty()) {
|
||||
ImGui::NewLine();
|
||||
continue;
|
||||
}
|
||||
ImGui::TextCentered(line.c_str(), false);
|
||||
}
|
||||
|
||||
if (ImGui::ButtonCentered("Close", ImVec2(0.0f, 30.0f))) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
menuToggle.SetChangesAreDisabled(false);
|
||||
hasSeenChangelog.Set(true);
|
||||
firstTimeRunning.Set(false);
|
||||
CreateChangelogFile();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
void Render() {
|
||||
ImGuiStyle* style = &ImGui::GetStyle();
|
||||
style->Colors[ImGuiCol_WindowBg] = ImVec4(style->Colors[ImGuiCol_WindowBg].x, style->Colors[ImGuiCol_WindowBg].y, style->Colors[ImGuiCol_WindowBg].z, static_cast<float>(transparency) / 100.0f);
|
||||
|
||||
maxWndSize = defMaxWndSize * scale;
|
||||
ImGui::SetNextWindowBgAlpha(static_cast<float>(transparency) / 100.0f);
|
||||
ImGui::SetNextWindowSizeConstraints(minWndSize, maxWndSize);
|
||||
ImGui::Begin(std::string("EGameTools " + std::string(MOD_VERSION_STR)).c_str(), &menuToggle.value, windowFlags); {
|
||||
ImGui::Begin(title.c_str(), &menuToggle.value, windowFlags); {
|
||||
if (ImGui::BeginTabBar("##MainTabBar")) {
|
||||
for (auto& tab : *MenuTab::GetInstances()) {
|
||||
if (ImGui::BeginTabItem(tab.second->tabName.data())) {
|
||||
@ -231,7 +213,7 @@ namespace Menu {
|
||||
ImGui::Hotkey("Menu Toggle Key", &menuToggle);
|
||||
ImGui::SliderFloat("Menu Transparency", &transparency, 0.0f, 100.0f, "%.1f%%", ImGuiSliderFlags_AlwaysClamp);
|
||||
if (ImGui::SliderFloat("Menu Scale", &scale, 1.0f, 2.5f, "%.1f%%", ImGuiSliderFlags_AlwaysClamp)) {
|
||||
ImGui::StyleScaleAllSizes(style, scale);
|
||||
ImGui::StyleScaleAllSizes(&ImGui::GetStyle(), scale);
|
||||
ImGui::GetIO().FontGlobalScale = scale;
|
||||
}
|
||||
ImGui::End();
|
||||
|
@ -2,20 +2,27 @@
|
||||
|
||||
namespace Utils {
|
||||
namespace Files {
|
||||
const std::string_view GetDesktopDir() {
|
||||
const std::string GetDesktopDir() {
|
||||
char path[MAX_PATH + 1]{};
|
||||
if (!SHGetSpecialFolderPathA(HWND_DESKTOP, path, CSIDL_DESKTOP, FALSE))
|
||||
return {};
|
||||
|
||||
return path;
|
||||
}
|
||||
const std::string_view GetDocumentsDir() {
|
||||
const std::string GetDocumentsDir() {
|
||||
char path[MAX_PATH + 1]{};
|
||||
if (SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, path) != S_OK)
|
||||
return {};
|
||||
|
||||
return path;
|
||||
}
|
||||
const std::string GetLocalAppDataDir() {
|
||||
char path[MAX_PATH + 1]{};
|
||||
if (SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, path) != S_OK)
|
||||
return {};
|
||||
|
||||
return path;
|
||||
}
|
||||
const std::filesystem::path GetCurrentProcDirectoryFS() {
|
||||
char buffer[MAX_PATH];
|
||||
GetModuleFileNameA(nullptr, buffer, sizeof(buffer));
|
||||
|
@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
|
||||
namespace Utils {
|
||||
namespace Files {
|
||||
extern const std::string_view GetDesktopDir();
|
||||
extern const std::string_view GetDocumentsDir();
|
||||
extern const std::string GetDesktopDir();
|
||||
extern const std::string GetDocumentsDir();
|
||||
extern const std::string GetLocalAppDataDir();
|
||||
extern const std::filesystem::path GetCurrentProcDirectoryFS();
|
||||
extern const std::string GetCurrentProcDirectory();
|
||||
extern const bool FileExistsInDir(const char* fileName, const char* dir);
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include "..\MinHook\MinHook.h"
|
||||
#include "print.h"
|
||||
|
||||
namespace Utils {
|
||||
namespace Hook {
|
||||
@ -49,11 +48,7 @@ namespace Utils {
|
||||
MH_EnableHook(pTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(250);
|
||||
}
|
||||
|
||||
PrintSuccess("Hooked %s!", name.data());
|
||||
}
|
||||
|
||||
OrigType pOriginal = nullptr;
|
||||
@ -78,11 +73,7 @@ namespace Utils {
|
||||
HookVT(pInstance, pDetour, reinterpret_cast<LPVOID*>(&pOriginal), offset);
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(250);
|
||||
}
|
||||
|
||||
PrintSuccess("Hooked %s!", name.data());
|
||||
}
|
||||
|
||||
OrigType pOriginal = nullptr;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include <mutex>
|
||||
#include "time.h"
|
||||
|
||||
namespace Utils {
|
||||
@ -22,16 +23,20 @@ namespace Utils {
|
||||
c_brightwhite
|
||||
};
|
||||
|
||||
static std::mutex printMutex{};
|
||||
|
||||
template<typename... Args> const std::string PrintError(std::string f, Args... args) {
|
||||
f.append("\n");
|
||||
std::ostringstream oss = Utils::Time::GetTimestamp();
|
||||
oss << f;
|
||||
const std::string ossStr = oss.str();
|
||||
|
||||
printMutex.lock();
|
||||
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, c_red);
|
||||
printf(ossStr.c_str(), args...);
|
||||
SetConsoleTextAttribute(hConsole, c_white);
|
||||
printMutex.unlock();
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@ -41,10 +46,12 @@ namespace Utils {
|
||||
oss << f;
|
||||
const std::string ossStr = oss.str();
|
||||
|
||||
printMutex.lock();
|
||||
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, c_yellow);
|
||||
printf(ossStr.c_str(), args...);
|
||||
SetConsoleTextAttribute(hConsole, c_white);
|
||||
printMutex.unlock();
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@ -54,10 +61,12 @@ namespace Utils {
|
||||
oss << f;
|
||||
const std::string ossStr = oss.str();
|
||||
|
||||
printMutex.lock();
|
||||
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, c_green);
|
||||
printf(ossStr.c_str(), args...);
|
||||
SetConsoleTextAttribute(hConsole, c_white);
|
||||
printMutex.unlock();
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@ -67,10 +76,12 @@ namespace Utils {
|
||||
oss << f;
|
||||
const std::string ossStr = oss.str();
|
||||
|
||||
printMutex.lock();
|
||||
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, c_brightwhite);
|
||||
printf(ossStr.c_str(), args...);
|
||||
SetConsoleTextAttribute(hConsole, c_white);
|
||||
printMutex.unlock();
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@ -80,10 +91,12 @@ namespace Utils {
|
||||
oss << f;
|
||||
const std::string ossStr = oss.str();
|
||||
|
||||
printMutex.lock();
|
||||
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, c_gray);
|
||||
printf(ossStr.c_str(), args...);
|
||||
SetConsoleTextAttribute(hConsole, c_white);
|
||||
printMutex.unlock();
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@ -93,10 +106,12 @@ namespace Utils {
|
||||
oss << f;
|
||||
const std::string ossStr = oss.str();
|
||||
|
||||
printMutex.lock();
|
||||
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, color);
|
||||
printf(ossStr.c_str(), args...);
|
||||
SetConsoleTextAttribute(hConsole, c_white);
|
||||
printMutex.unlock();
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
Reference in New Issue
Block a user