ctrl: add menu entries to show dear imgui userguide and about window
This commit is contained in:
parent
407dded717
commit
9ef9e71a46
1 changed files with 32 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
#include <nng/nng.h>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <backends/imgui_impl_sdl.h>
|
||||
#include <backends/imgui_impl_sdlrenderer.h>
|
||||
#include <SDL.h>
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include "dp_util.hpp"
|
||||
|
||||
#if DoomBytesPerPixel == 3
|
||||
// FIXME: don't use, it's buggy
|
||||
static const u32 DoomSdlTexturePixelFormat = SDL_PIXELFORMAT_RGB888;
|
||||
#elif DoomBytesPerPixel == 4
|
||||
static const u32 DoomSdlTexturePixelFormat = SDL_PIXELFORMAT_ARGB8888;
|
||||
|
@ -30,7 +32,6 @@ static const u32 DoomSdlTexturePixelFormat = SDL_PIXELFORMAT_ARGB8888;
|
|||
#error Unhandled DoomBytesPerPixel value. Which SDL_PIXELFORMAT to use?
|
||||
#endif
|
||||
|
||||
|
||||
void dp_sdl_fatal(const char *const msg)
|
||||
{
|
||||
log_fatal("%s: %s", msg, SDL_GetError());
|
||||
|
@ -206,14 +207,14 @@ void check_on_dooms(ControllerContext &ctx)
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: We can miss Endoom state updates when nng has to drop message due
|
||||
// FIXME: We can miss Endoom state updates when nng has to drop messages due
|
||||
// to queue size limits. If this happens for an externally started doom it
|
||||
// will never be removed from ctx.dooms (waitpid() does not work because the
|
||||
// doom is not our child). Use DoomState::tLastActive and a fixed timeout
|
||||
// value to timeout dooms and erase them from ctx.dooms.
|
||||
}
|
||||
|
||||
#define DP_DO_DEBUG_DRAWING
|
||||
//#define DP_DO_DEBUG_DRAWING
|
||||
#ifdef DP_DO_DEBUG_DRAWING
|
||||
#include "debug_draw.cc"
|
||||
#endif
|
||||
|
@ -437,12 +438,17 @@ ControllerActions run_ui(ControllerContext &ctx)
|
|||
#endif
|
||||
static bool show_app_metrics = false;
|
||||
static bool show_app_debug_log = false;
|
||||
static bool show_app_about = false;
|
||||
|
||||
static bool show_log_window = true;
|
||||
static bool show_userguide = false;
|
||||
|
||||
if (show_app_metrics)
|
||||
ImGui::ShowMetricsWindow(&show_app_metrics);
|
||||
if (show_app_debug_log)
|
||||
ImGui::ShowDebugLogWindow(&show_app_debug_log);
|
||||
if (show_app_about)
|
||||
ImGui::ShowAboutWindow(&show_app_about);
|
||||
|
||||
const ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
|
||||
|
@ -453,6 +459,17 @@ ControllerActions run_ui(ControllerContext &ctx)
|
|||
ctx.appLog.Draw("log");
|
||||
}
|
||||
|
||||
if (show_userguide)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(main_viewport->WorkPos.x + 666, main_viewport->WorkPos.y + 420), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(500, 360), ImGuiCond_FirstUseEver);
|
||||
if (ImGui::Begin("Dear ImGui User Guide", &show_userguide))
|
||||
{
|
||||
ImGui::ShowUserGuide();
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(main_viewport->WorkPos.x + 20, main_viewport->WorkPos.y + 20), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(420, 340), ImGuiCond_FirstUseEver);
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar;
|
||||
|
@ -476,18 +493,25 @@ ControllerActions run_ui(ControllerContext &ctx)
|
|||
{
|
||||
if (ImGui::BeginMenu("Menu"))
|
||||
{
|
||||
ImGui::MenuItem("Log Window", nullptr, &show_log_window);
|
||||
ImGui::MenuItem("Quit", "Ctrl+Q", &ctx.quit, true);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Tools"))
|
||||
{
|
||||
ImGui::MenuItem("Log Window", nullptr, &show_log_window);
|
||||
ImGui::MenuItem("Dear ImGui Metrics/Debugger", NULL, &show_app_metrics, has_debug_tools);
|
||||
ImGui::MenuItem("Dear ImGui Debug Log", NULL, &show_app_debug_log, has_debug_tools);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Help"))
|
||||
{
|
||||
ImGui::MenuItem("Dear ImGui User Guide", NULL, &show_userguide);
|
||||
ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
|
@ -683,12 +707,15 @@ int main(int argc, char *argv[])
|
|||
dp_sdl_fatal("SDL_CreateRenderer");
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
auto imgui = ImGui::CreateContext();
|
||||
ImGui::GetIO().IniFilename = "doompanning_ui.ini";
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
|
||||
ImGui_ImplSDLRenderer_Init(renderer);
|
||||
|
||||
//ImGuiSettingsHandler dpSettingsHandler;
|
||||
//imgui->SettingsHandlers.push_back(dpSettingsHandler);
|
||||
|
||||
//dp_nng_init_limits(1, 1, 1); // int ncpu_max, int pool_thread_limit_max, int resolv_thread_limit
|
||||
//nng_set_ncpu_max(ncpu_max);
|
||||
//nng_set_pool_thread_limit_max(pool_thread_limit_max);
|
||||
|
|
Loading…
Reference in a new issue