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 auto docDir = FileOperations::getSystemDocDir();
23 im::Menu("Help", [&]{
24 im::Menu("Manual", [&]{
25 drawURL("FAQ", strCat("file://", docDir, "/manual/faq.html"));
26 drawURL("Setup Guide", strCat("file://", docDir, "/manual/setup.html"));
27 drawURL("User Manual", strCat("file://", docDir, "/manual/user.html"));
28 });
29 ImGui::MenuItem("Dear ImGui user guide", nullptr, &showImGuiUserGuide);
30 ImGui::Separator();
31 ImGui::MenuItem("About openMSX", nullptr, &showAboutOpenMSX);
32 ImGui::MenuItem("About Dear ImGui", nullptr, &showAboutImGui);
33 });
34}
35
36void ImGuiHelp::paint(MSXMotherBoard* /*motherBoard*/)
37{
38 if (showAboutOpenMSX) paintAbout();
39 if (showAboutImGui) ImGui::ShowAboutWindow(&showAboutImGui);
40 if (showImGuiUserGuide) {
41 im::Window("Dear ImGui User Guide", &showImGuiUserGuide, [&]{
42 ImGui::ShowUserGuide();
43 });
44 }
45}
46
47void ImGuiHelp::paintAbout()
48{
49 im::Window("About openMSX", &showAboutOpenMSX, [&]{
50 if (!logo) {
51 logo.emplace(); // initialize with null-image
52 try {
54 auto r = context.resolve("icons/openMSX-logo-256.png");
55 gl::ivec2 isize;
56 logo->texture = loadTexture(r, isize);
57 logo->size = gl::vec2(isize);
58 } catch (...) {
59 // ignore, don't try again
60 }
61 }
62 assert(logo);
63 if (logo->texture.get()) {
64 ImGui::Image(logo->texture.getImGui(), logo->size);
65 ImGui::SameLine();
66 }
67 im::Group([&]{
69 ImGui::Spacing();
70 im::Table("##table", 2, ImGuiTableFlags_SizingFixedFit, [&]{
71 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("platform:"sv);
72 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(TARGET_PLATFORM);
73
74 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("target CPU:"sv);
75 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(TARGET_CPU);
76
77 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("flavour:"sv);
78 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(BUILD_FLAVOUR);
79
80 if (ImGui::TableNextColumn()) ImGui::TextUnformatted("components:"sv);
81 if (ImGui::TableNextColumn()) ImGui::TextUnformatted(BUILD_COMPONENTS);
82 });
83 ImGui::Spacing();
84 ImGui::TextUnformatted("license: GPL2"sv);
85 ImGui::Text("%s The openMSX Team", Version::COPYRIGHT);
86
87 ImGui::TextUnformatted("Visit our website:"sv);
88 ImGui::SameLine();
89 drawURL("openMSX.org", "https://openmsx.org");
90 });
91 });
92}
93
94} // namespace openmsx
void paint(MSXMotherBoard *motherBoard) override
Definition ImGuiHelp.cc:36
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:24
vecN< 2, float > vec2
Definition gl_vec.hh:178
void Table(const char *str_id, int column, ImGuiTableFlags flags, const ImVec2 &outer_size, float inner_width, std::invocable<> auto next)
Definition ImGuiCpp.hh:459
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:363
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()
void drawURL(std::string_view text, zstring_view url)
Definition ImGuiUtils.cc:30
gl::Texture loadTexture(const std::string &filename, ivec2 &size)
Definition GLImage.cc:63
std::string strCat()
Definition strCat.hh:703