2022-01-18 00:10:10 +01:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
|
|
|
|
#include <imgui.h>
|
|
|
|
#include <implot.h>
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <hex/ui/view.hpp>
|
2022-01-18 00:10:10 +01:00
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
static bool g_demoWindowOpen = false;
|
|
|
|
|
|
|
|
void registerMainMenuEntries() {
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.file", 1000);
|
|
|
|
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.edit", 2000);
|
|
|
|
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.view", 3000);
|
2022-01-23 20:45:51 +01:00
|
|
|
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.layout", 4000);
|
2022-01-24 20:53:17 +01:00
|
|
|
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.help", 5000);
|
2022-01-18 00:10:10 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.view", 1000, [] {
|
2022-01-18 00:10:10 +01:00
|
|
|
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
|
|
|
|
if (view->hasViewMenuItemEntry())
|
|
|
|
ImGui::MenuItem(LangEntry(view->getUnlocalizedName()), "", &view->getWindowOpenState());
|
|
|
|
}
|
2022-01-23 20:45:51 +01:00
|
|
|
});
|
2022-01-18 00:10:10 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
#if defined(DEBUG)
|
|
|
|
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.view", 2000, [] {
|
|
|
|
ImGui::MenuItem("hex.builtin.menu.view.demo"_lang, "", &g_demoWindowOpen);
|
|
|
|
});
|
|
|
|
#endif
|
2022-01-18 00:10:10 +01:00
|
|
|
|
2022-01-23 20:45:51 +01:00
|
|
|
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.layout", 1000, [] {
|
2022-01-18 00:10:10 +01:00
|
|
|
for (auto &[layoutName, func] : ContentRegistry::Interface::getLayouts()) {
|
|
|
|
if (ImGui::MenuItem(LangEntry(layoutName), "", false, ImHexApi::Provider::isValid())) {
|
2022-02-01 18:09:40 +01:00
|
|
|
auto dock = ImHexApi::System::getMainDockSpaceId();
|
2022-01-18 00:10:10 +01:00
|
|
|
|
|
|
|
for (auto &[viewName, view] : ContentRegistry::Views::getEntries()) {
|
|
|
|
view->getWindowOpenState() = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::DockBuilderRemoveNode(dock);
|
|
|
|
ImGui::DockBuilderAddNode(dock);
|
|
|
|
func(dock);
|
|
|
|
ImGui::DockBuilderFinish(dock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-01-23 20:45:51 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
(void)EventManager::subscribe<EventFrameEnd>([] {
|
2022-01-18 00:10:10 +01:00
|
|
|
if (g_demoWindowOpen) {
|
|
|
|
ImGui::ShowDemoWindow(&g_demoWindowOpen);
|
|
|
|
ImPlot::ShowDemoWindow(&g_demoWindowOpen);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|