OXYGENHUB
◆ main openmsx / src / imgui / ImGuiHelp.cc
3.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 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
16
namespace openmsx {
17
18
using namespace std::literals;
19
20
void 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
42
void 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
56
void ImGuiHelp::paintAbout()
57
{
58
	im::Window("About openMSX", &showAboutOpenMSX, [&]{
59
		if (!logo) {
60
			logo.emplace(); // initialize with null-image
61
			try {
62
				auto r = systemFileContext().resolve("icons/openMSX-logo-256.png");
63
				gl::ivec2 isize;
64
				logo->texture = loadTexture(r, isize);
65
				logo->size = gl::vec2(isize);
66
			} catch (...) {
67
				// ignore, don't try again
68
			}
69
		}
70
		assert(logo);
71
		if (logo->texture.get()) {
72
			ImGui::Image(logo->texture.getImGui(), logo->size);
73
			ImGui::SameLine();
74
		}
75
		im::Group([&]{
76
			ImGui::TextUnformatted(Version::full());
77
			ImGui::Spacing();
78
			im::Table("##table", 2, ImGuiTableFlags_SizingFixedFit, [&]{
79
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted("platform:"sv);
80
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted(TARGET_PLATFORM);
81
82
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted("target CPU:"sv);
83
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted(TARGET_CPU);
84
85
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted("flavour:"sv);
86
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted(BUILD_FLAVOUR);
87
88
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted("components:"sv);
89
				if (ImGui::TableNextColumn()) ImGui::TextUnformatted(BUILD_COMPONENTS);
90
			});
91
			ImGui::Spacing();
92
			ImGui::TextUnformatted("license: GPL2"sv);
93
			ImGui::Text("%s The openMSX Team", Version::COPYRIGHT);
94
95
			ImGui::TextUnformatted("Visit our website:"sv);
96
			ImGui::SameLine();
97
			ImGui::TextLinkOpenURL("openMSX.org", "https://openmsx.org");
98
		});
99
	});
100
}
101
102
} // namespace openmsx