OXYGENHUB
◆ main openmsx / src / imgui / ImGuiMachine.hh
3.2 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef IMGUI_MACHINE_HH
2
#define IMGUI_MACHINE_HH
3
4
#include "FileListWidget.hh"
5
#include "ImGuiPart.hh"
6
#include "ImGuiUtils.hh"
7
8
#include "MSXMotherBoard.hh"
9
10
#include "circular_buffer.hh"
11
12
#include <string>
13
#include <vector>
14
15
namespace openmsx {
16
17
class ImGuiMachine final : public ImGuiPart
18
{
19
public:
20
	struct MachineInfo {
21
		std::string configName;
22
		std::string displayName;
23
		std::vector<std::pair<std::string, std::string>> configInfo;
24
		std::optional<std::string> testResult; // lazily initialized
25
	};
26
27
public:
28
	explicit ImGuiMachine(ImGuiManager& manager);
29
30
	[[nodiscard]] zstring_view iniName() const override { return "machine"; }
31
	void save(ImGuiTextBuffer& buf) override;
32
	void loadLine(std::string_view name, zstring_view value) override;
33
	void showMenu(MSXMotherBoard* motherBoard) override;
34
	void paint(MSXMotherBoard* motherBoard) override;
35
36
	void signalQuit();
37
38
private:
39
	void showRecentMachinesMenu();
40
	void paintSelectMachine(const MSXMotherBoard* motherBoard);
41
	void paintTestHardware();
42
	[[nodiscard]] std::vector<MachineInfo>& getAllMachines();
43
	[[nodiscard]] MachineInfo* findMachineInfo(std::string_view config);
44
	[[nodiscard]] const std::string& getTestResult(MachineInfo& info);
45
	bool printConfigInfo(MachineInfo& info);
46
	enum class Mode : uint8_t { VIEW, EDIT };
47
	void showSetupOverviewView(MSXMotherBoard& motherBoard);
48
	void showSetupOverviewSave(MSXMotherBoard& motherBoard);
49
	void showSetupOverviewTooltip(MSXMotherBoard& motherBoard);
50
	void showSetupOverviewEdit(MSXMotherBoard& motherBoard);
51
	void showSetupOverviewMachine(MachineInfo& info);
52
	void showSetupOverviewMachineEdit(MachineInfo& info);
53
	void showSetupOverviewExtensions(MSXMotherBoard& motherBoard, Mode mode, ImGuiTreeNodeFlags flags = 0);
54
	void showSetupOverviewConnectors(MSXMotherBoard& motherBoard, Mode mode, ImGuiTreeNodeFlags flags = 0);
55
	void showSetupOverviewMedia(MSXMotherBoard& motherBoard, Mode mode, ImGuiTreeNodeFlags flags = 0);
56
	void showSetupOverviewState(MSXMotherBoard& motherBoard, ImGuiTreeNodeFlags flags = 0);
57
	void loadPreviewSetup();
58
	void showNonExistingPreview();
59
60
public:
61
	bool showSelectMachine = false;
62
	bool showTestHardware = false;
63
	bool showQuickSetupEditor = true;
64
65
private:
66
	std::vector<MachineInfo> machineInfo; // sorted on displayName
67
	std::string newMachineConfig;
68
	std::string filterType;
69
	std::string filterRegion;
70
	std::string filterString;
71
	bool hideNonWorking = false;
72
73
	static constexpr size_t HISTORY_SIZE = 8;
74
	circular_buffer<std::string> recentMachines{HISTORY_SIZE};
75
76
	struct PreviewSetup {
77
		std::string name;
78
		std::string fullName;
79
		std::string lastExceptionMessage;
80
		std::shared_ptr<MSXMotherBoard> motherBoard;
81
	} previewSetup;
82
	bool saveSetupOpen = false;
83
	bool setSetupAsDefault = false;
84
	std::string saveSetupName;
85
	FileListWidget setupFileList;
86
	ConfirmDialog confirmDialog;
87
	SetupDepth saveSetupDepth = SetupDepth::CONNECTORS;
88
	std::string previousDefaultSetup;
89
	bool setupSettingsOpen = false;
90
	std::vector<std::string> setups;
91
92
	static constexpr auto persistentElements = std::tuple{
93
		PersistentElement{"hideNonWorkingMachines", &ImGuiMachine::hideNonWorking},
94
		PersistentElement{"showQuickSetupEditor", &ImGuiMachine::showQuickSetupEditor},
95
		// manually handle "recentMachines"
96
	};
97
};
98
99
} // namespace openmsx
100
101
#endif