openMSX
ImGuiHelp.cc
Go to the documentation of this file.
1#include "ImGuiHelp.hh"
2
3#include "ImGuiCpp.hh"
4#include "ImGuiUtils.hh"
5
6#include "FileContext.hh"
7#include "FileOperations.hh"
8#include "GLImage.hh"
9
10#include "Version.hh"
11#include "build-info.hh"
12#include "components.hh"
13
14#include <cassert>
15
16namespace openmsx {
17
18using namespace std::literals;
19
20void ImGuiHelp::showMenu(MSXMotherBoard* /*motherBoard*/)
21{
22 im::Menu("Help", [&]{
23 auto docDir = FileOperations::getSystemDocDir();
24 im::Menu("Manual", [&]{
25 ImGui::TextLinkOpenURL("FAQ", strCat("file://", docDir, "/manual/faq.html").c_str());
26 ImGui::TextLinkOpenURL("Setup Guide", strCat("file://", docDir, "/manual/setup.html").c_str());
27 ImGui::TextLinkOpenURL("User Manual", strCat("file://", docDir, "/manual/user.html").c_str());
28 });
29 ImGui::MenuItem("Dear ImGui user guide", nullptr, &showImGuiUserGuide);
30 ImGui::Separator();
31 ImGui::Checkbox("ImGui Demo Window", &showDemoWindow);
32 HelpMarker("Show the ImGui demo window.\n"
33 "This is purely to demonstrate the ImGui capabilities\n"
34 "and can sometimes help to diagnose problems.\n"
35 "There is no connection with any openMSX functionality.");
36 ImGui::Separator();
37 ImGui::MenuItem("About openMSX", nullptr, &showAboutOpenMSX);
38 ImGui::MenuItem("About Dear ImGui", nullptr, &showAboutImGui);
39 });
40}
41
42void ImGuiHelp::paint(MSXMotherBoard* /*motherBoard*/)
43{
44 if (showAboutOpenMSX) paintAbout();
45 if (showAboutImGui) ImGui::ShowAboutWindow(&showAboutImGui);
46 if (showImGuiUserGuide) {
47 im::Window("Dear ImGui User Guide", &showImGuiUserGuide, [&]{
48 ImGui::ShowUserGuide();
49 });
50 }
51 if (showDemoWindow) {
52 ImGui::ShowDemoWindow(&showDemoWindow);
53 }
54}
55
56void ImGuiHelp::paintAbout()
57{
58 im::Window("About openMSX", &showAboutOpenMSX, [&]{
59 if (!logo) {
60 logo.emplace(); // initialize with null-image
61 try {
63 auto r = context.resolve("icons/openMSX-logo-256.png");
64 gl::ivec2 isize;
65 logo->texture = loadTexture(r, isize);
66 logo->size = gl::vec2(isize);
67 } catch (...) {
68 // ignore, don't try again
69 }
70 }
71 assert(logo);
72 if (logo->texture.get()) {
73 ImGui::Image(logo->texture.getImGui(), logo->size);
74 ImGui::SameLine();
75 }
76 im::Group([&]{
78 ImGui::Spacing();
79 im::Table("##table", 2, ImGuiTableFlags_SizingFixedFit, [&]{
80 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("platform:"sv);
81 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(TARGET_PLATFORM);
82
83 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("target CPU:"sv);
84 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(TARGET_CPU);
85
86 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("flavour:"sv);
87 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(BUILD_FLAVOUR);
88
89 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("components:"sv);
90 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(BUILD_COMPONENTS);
91 });
92 ImGui::Spacing();
93 ImGui::TextUnformatted("license: GPL2"sv);
94 ImGui::Text("%s The openMSX Team", Version::COPYRIGHT);
95
96 ImGui::TextUnformatted("Visit our website:"sv);
97 ImGui::SameLine();
98 ImGui::TextLinkOpenURL("openMSX.org", "https://openmsx.org");
99 });
100 });
101}
102
103} // namespace openmsx
void paint(MSXMotherBoard *motherBoard) override
Definition ImGuiHelp.cc:42
void showMenu(MSXMotherBoard *motherBoard) override
Definition ImGuiHelp.cc:20
static std::string full()
Definition Version.cc:8
static const char *const COPYRIGHT
Definition Version.hh:20
void TextUnformatted(const std::string &str)
Definition ImGuiUtils.hh:25
vecN< 2, float > vec2
Definition gl_vec.hh:382
void Table(const char *str_id, int column, ImGuiTableFlags flags, const ImVec2 &outer_size, float inner_width, std::invocable<> auto next)
Definition ImGuiCpp.hh:455
void Window(const char *name, bool *p_open, ImGuiWindowFlags flags, std::invocable<> auto next)
Definition ImGuiCpp.hh:63
bool Menu(const char *label, bool enabled, std::invocable<> auto next)
Definition ImGuiCpp.hh:359
void Group(std::invocable<> auto next)
Definition ImGuiCpp.hh:236
const string & getSystemDocDir()
Get system doc directory.
This file implemented 3 utility functions:
Definition Autofire.cc:11
const FileContext & systemFileContext()
gl::Texture loadTexture(const std::string &filename, ivec2 &size)
Definition GLImage.cc:63
void HelpMarker(std::string_view desc)
Definition ImGuiUtils.cc:23
std::string strCat()
Definition strCat.hh:703