mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-19 01:47:50 +08:00
222 lines
14 KiB
C++
222 lines
14 KiB
C++
#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);
|
|
static constexpr ImVec2 defMaxChangelogWndSize = ImVec2(400.0f, 700.0f);
|
|
static constexpr ImVec2 minWelcomeWndSize = ImVec2(700.0f, 0.0f);
|
|
static constexpr ImVec2 defMaxWelcomeWndSize = ImVec2(700.0f, 700.0f);
|
|
|
|
static constexpr ImVec2 minWndSize = ImVec2(0.0f, 0.0f);
|
|
static constexpr ImVec2 defMaxWndSize = ImVec2(900.0f, 675.0f);
|
|
static ImVec2 maxWndSize = defMaxWndSize;
|
|
|
|
KeyBindOption menuToggle = KeyBindOption(VK_F5);
|
|
float transparency = 99.0f;
|
|
float scale = 1.0f;
|
|
|
|
static Utils::Time::Timer timePassedFromWelcomeScreen{};
|
|
Option firstTimeRunning{};
|
|
Option hasSeenChangelog{};
|
|
|
|
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 (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(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));
|
|
|
|
const std::string thankYou = "Thank you for downloading EGameTools (" + std::string(MOD_VERSION_STR) + ")!";
|
|
ImGui::TextCentered(thankYou.c_str());
|
|
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();
|
|
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() {
|
|
maxWndSize = defMaxWndSize * scale;
|
|
ImGui::SetNextWindowBgAlpha(static_cast<float>(transparency) / 100.0f);
|
|
ImGui::SetNextWindowSizeConstraints(minWndSize, maxWndSize);
|
|
ImGui::Begin(title.c_str(), &menuToggle.value, windowFlags); {
|
|
if (ImGui::BeginTabBar("##MainTabBar")) {
|
|
for (auto& tab : *MenuTab::GetInstances()) {
|
|
if (ImGui::BeginTabItem(tab.second->tabName.data())) {
|
|
tab.second->Render();
|
|
ImGui::EndTabItem();
|
|
}
|
|
}
|
|
ImGui::EndTabBar();
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
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(&ImGui::GetStyle(), scale);
|
|
ImGui::GetIO().FontGlobalScale = scale;
|
|
}
|
|
ImGui::End();
|
|
}
|
|
}
|
|
} |