Add menu bar to ImGui

This commit is contained in:
Llennpie 2021-07-23 23:41:02 -04:00
parent bd20d16d07
commit c7e928f631
1 changed files with 20 additions and 11 deletions

View File

@ -28,8 +28,10 @@
#define GL_GLEXT_PROTOTYPES 1 #define GL_GLEXT_PROTOTYPES 1
#ifdef USE_GLES #ifdef USE_GLES
# include <SDL2/SDL_opengles2.h> # include <SDL2/SDL_opengles2.h>
# define RAPI_NAME "OpenGL ES"
#else #else
# include <SDL2/SDL_opengl.h> # include <SDL2/SDL_opengl.h>
# define RAPI_NAME "OpenGL"
#endif #endif
#endif #endif
@ -49,7 +51,8 @@ extern "C" {
using namespace std; using namespace std;
bool showWindow = true; bool showMenu = true;
bool showWindowMoon = false;
SDL_Window* window = nullptr; SDL_Window* window = nullptr;
ImGuiIO io; ImGuiIO io;
@ -87,7 +90,7 @@ namespace MoonInternal {
switch (ev->type){ switch (ev->type){
case SDL_KEYDOWN: case SDL_KEYDOWN:
if(ev->key.keysym.sym == SDLK_F12) if(ev->key.keysym.sym == SDLK_F12)
showWindow = !showWindow; showMenu = !showMenu;
break; break;
} }
}}); }});
@ -100,15 +103,21 @@ namespace MoonInternal {
MoonInternal::initBindHook(0); MoonInternal::initBindHook(0);
MoonInternal::callBindHook(0); MoonInternal::callBindHook(0);
if(showWindow){ if(showMenu){
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); ImGui::BeginMainMenuBar();
ImGui::Begin("Moon64 Game Stats", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize); ImGui::MenuItem("Moon64", NULL, &showWindowMoon);
ImGui::Text("Framerate: %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); ImGui::EndMainMenuBar();
ImGui::Text("Platform: " PLATFORM);
ImGui::Text("Branch: " GIT_BRANCH); if (showWindowMoon){
ImGui::Text("Commit: " GIT_HASH); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
ImGui::End(); ImGui::Begin("Moon64 Game Stats", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
ImGui::PopStyleColor(); ImGui::SetWindowPos(ImVec2(10, 35));
ImGui::Text("Platform: " PLATFORM " (" RAPI_NAME ")");
ImGui::Text("Status: %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::Text("Version: " GIT_BRANCH " " GIT_HASH);
ImGui::End();
ImGui::PopStyleColor();
}
} }
ImGui::Render(); ImGui::Render();