openMSX
ImGuiSymbols.hh
Go to the documentation of this file.
1#ifndef IMGUI_SYMBOLS_HH
2#define IMGUI_SYMBOLS_HH
3
4#include "ImGuiPart.hh"
5
6#include "SymbolManager.hh"
7
8#include "hash_map.hh"
9
10#include <cstdint>
11#include <optional>
12#include <vector>
13
14namespace openmsx {
15
16struct SymbolRef {
17 unsigned fileIdx;
18 unsigned symbolIdx;
19
20 [[nodiscard]] std::string_view file(const SymbolManager& m) const { return m.getFiles()[fileIdx].filename; }
21 [[nodiscard]] std::string_view name(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].name; }
22 [[nodiscard]] uint16_t value(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].value; }
23 [[nodiscard]] std::optional<uint8_t> slot(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].slot; }
24 [[nodiscard]] std::optional<uint16_t> segment(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].segment; }
25};
26
27class ImGuiSymbols final : public ImGuiPart, private SymbolObserver
28{
29public:
30 struct FileInfo {
31 FileInfo(std::string f, std::string e, SymbolFile::Type t, std::optional<int> s)
32 : filename(std::move(f)), error(std::move(e)), type(t), slot(s) {} // clang-15 workaround
33
34 std::string filename;
35 std::string error;
37 std::optional<int> slot;
38 };
39
42
43 [[nodiscard]] zstring_view iniName() const override { return "symbols"; }
44 void save(ImGuiTextBuffer& buf) override;
45 void loadStart() override;
46 void loadLine(std::string_view name, zstring_view value) override;
47 void loadEnd() override;
48 void paint(MSXMotherBoard* motherBoard) override;
49
50public:
51 bool show = false;
52
53private:
54 void loadFile(const std::string& filename, SymbolManager::LoadEmpty loadEmpty, SymbolFile::Type type, std::optional<uint8_t> slot = {});
55
56 template<bool FILTER_FILE>
57 void drawTable(MSXMotherBoard* motherBoard, const std::string& file = {});
58
59 void drawContext(MSXMotherBoard* motherBoard, const SymbolRef& sym);
60
61 // SymbolObserver
62 void notifySymbolsChanged() override;
63
64private:
65 SymbolManager& symbolManager;
66 std::vector<SymbolRef> symbols;
67
68 std::vector<FileInfo> fileError;
69
70 static constexpr auto persistentElements = std::tuple{
71 PersistentElement{"show", &ImGuiSymbols::show}
72 };
73};
74
75} // namespace openmsx
76
77#endif
TclObject t
ImGuiManager & manager
Definition ImGuiPart.hh:30
void loadLine(std::string_view name, zstring_view value) override
zstring_view iniName() const override
void save(ImGuiTextBuffer &buf) override
void loadStart() override
void loadEnd() override
void paint(MSXMotherBoard *motherBoard) override
const auto & getFiles() const
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
Definition Autofire.cc:11
STL namespace.
FileInfo(std::string f, std::string e, SymbolFile::Type t, std::optional< int > s)
std::optional< uint8_t > slot(const SymbolManager &m) const
std::optional< uint16_t > segment(const SymbolManager &m) const
std::string_view name(const SymbolManager &m) const
uint16_t value(const SymbolManager &m) const
std::string_view file(const SymbolManager &m) const