2024-02-11 06:11:25 +02:00
|
|
|
#include <pch.h>
|
2024-01-27 19:59:26 +02:00
|
|
|
#include "menu.h"
|
2023-07-30 06:14:30 +03:00
|
|
|
|
|
|
|
namespace Menu {
|
2024-02-17 21:45:24 +02:00
|
|
|
const std::string title = "EGameTools (" + std::string(MOD_VERSION_STR) + ")";
|
|
|
|
ImGuiStyle defStyle{};
|
|
|
|
ImTextureID EGTLogoTexture{};
|
2024-02-18 02:33:13 +02:00
|
|
|
static constexpr ImVec2 defEGTLogoSize = ImVec2(278.0f, 100.0f);
|
|
|
|
static ImVec2 EGTLogoSize = defEGTLogoSize;
|
2024-02-13 03:39:56 +02:00
|
|
|
|
2024-02-17 18:52:16 +02:00
|
|
|
static constexpr ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar;
|
2024-02-18 02:33:13 +02:00
|
|
|
static constexpr ImVec2 defMinWndSize = ImVec2(425.0f, 725.0f);
|
|
|
|
static ImVec2 minWndSize = defMinWndSize;
|
2024-02-17 21:45:24 +02:00
|
|
|
static constexpr ImVec2 defMaxWndSize = ImVec2(900.0f, 725.0f);
|
2024-02-17 02:45:17 +02:00
|
|
|
static ImVec2 maxWndSize = defMaxWndSize;
|
|
|
|
|
2024-01-25 00:58:38 +02:00
|
|
|
KeyBindOption menuToggle = KeyBindOption(VK_F5);
|
2024-02-15 04:07:58 +02:00
|
|
|
float opacity = 99.0f;
|
2024-02-03 20:40:17 +02:00
|
|
|
float scale = 1.0f;
|
2023-07-30 06:14:30 +03:00
|
|
|
|
2024-02-05 03:23:00 +02:00
|
|
|
Option firstTimeRunning{};
|
2024-02-12 03:51:26 +02:00
|
|
|
Option hasSeenChangelog{};
|
2024-02-05 03:23:00 +02:00
|
|
|
|
2023-07-30 06:14:30 +03:00
|
|
|
void Render() {
|
2024-02-18 02:33:13 +02:00
|
|
|
ImGui::StyleScaleAllSizes(&ImGui::GetStyle(), scale, &defStyle);
|
|
|
|
ImGui::GetIO().FontGlobalScale = scale;
|
|
|
|
minWndSize = defMinWndSize * scale;
|
2024-02-03 20:40:17 +02:00
|
|
|
maxWndSize = defMaxWndSize * scale;
|
2024-02-18 02:33:13 +02:00
|
|
|
EGTLogoSize = defEGTLogoSize * scale;
|
|
|
|
|
2024-02-15 04:07:58 +02:00
|
|
|
ImGui::SetNextWindowBgAlpha(static_cast<float>(opacity) / 100.0f);
|
2023-08-05 05:22:20 +03:00
|
|
|
ImGui::SetNextWindowSizeConstraints(minWndSize, maxWndSize);
|
2024-02-13 03:39:56 +02:00
|
|
|
ImGui::Begin(title.c_str(), &menuToggle.value, windowFlags); {
|
2024-02-18 02:33:13 +02:00
|
|
|
ImGui::SetCursorPosX((ImGui::GetWindowWidth() / 2.0f) - (EGTLogoSize.x / 2.0f));
|
|
|
|
ImGui::Image(EGTLogoTexture, EGTLogoSize);
|
2024-02-17 18:52:16 +02:00
|
|
|
|
|
|
|
const float footerHeight = ImGui::GetFrameHeightWithSpacing() * 3.0f + GImGui->Style.WindowPadding.y * 2.0f + GImGui->Style.FramePadding.y * 2.0f;
|
|
|
|
const float remainingHeight = ImGui::GetContentRegionAvail().y - footerHeight;
|
2024-02-17 02:45:17 +02:00
|
|
|
|
2023-07-30 06:14:30 +03:00
|
|
|
if (ImGui::BeginTabBar("##MainTabBar")) {
|
2024-01-29 01:52:08 +02:00
|
|
|
for (auto& tab : *MenuTab::GetInstances()) {
|
2024-02-17 18:52:16 +02:00
|
|
|
static float childWidth = 0.0f;
|
|
|
|
|
2024-02-17 21:45:24 +02:00
|
|
|
ImGui::SpanNextTabAcrossWidth(childWidth, MenuTab::GetInstances()->size());
|
2024-01-29 01:52:08 +02:00
|
|
|
if (ImGui::BeginTabItem(tab.second->tabName.data())) {
|
2024-02-17 18:52:16 +02:00
|
|
|
ImGui::SetNextWindowBgAlpha(static_cast<float>(opacity) / 100.0f);
|
|
|
|
ImGui::SetNextWindowSizeConstraints(ImVec2(minWndSize.x - GImGui->Style.WindowPadding.x * 2.0f, remainingHeight), ImVec2(maxWndSize.x - GImGui->Style.WindowPadding.x * 2.0f, remainingHeight));
|
|
|
|
if (ImGui::BeginChild("##TabChild", ImVec2(0.0f, 0.0f), ImGuiChildFlags_AlwaysAutoResize | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_Border)) {
|
|
|
|
childWidth = ImGui::GetItemRectSize().x;
|
|
|
|
tab.second->Render();
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2024-01-29 01:52:08 +02:00
|
|
|
ImGui::EndTabItem();
|
|
|
|
}
|
2023-07-30 06:14:30 +03:00
|
|
|
}
|
2024-02-17 21:45:24 +02:00
|
|
|
ImGui::EndTabBarEx();
|
2023-07-30 06:14:30 +03:00
|
|
|
}
|
2024-01-08 06:08:20 +02:00
|
|
|
|
2024-02-08 22:21:11 +02:00
|
|
|
ImGui::Hotkey("Menu Toggle Key", &menuToggle);
|
2024-02-15 04:07:58 +02:00
|
|
|
ImGui::SliderFloat("Menu Opacity", &opacity, 0.0f, 100.0f, "%.1f%%", ImGuiSliderFlags_AlwaysClamp);
|
2024-02-18 02:33:13 +02:00
|
|
|
ImGui::SliderFloat("Menu Scale", &scale, 1.0f, 2.5f, "%.1f%%", ImGuiSliderFlags_AlwaysClamp);
|
2024-01-08 06:08:20 +02:00
|
|
|
ImGui::End();
|
|
|
|
}
|
2023-07-30 06:14:30 +03:00
|
|
|
}
|
|
|
|
}
|