| 1 |
#ifndef IMGUI_SYMBOLS_HH |
| 2 |
#define IMGUI_SYMBOLS_HH |
| 3 |
|
| 4 |
#include "ImGuiPart.hh" |
| 5 |
|
| 6 |
#include "SymbolManager.hh" |
| 7 |
|
| 8 |
#include <cstdint> |
| 9 |
#include <optional> |
| 10 |
#include <vector> |
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
struct SymbolRef { |
| 15 |
unsigned fileIdx; |
| 16 |
unsigned symbolIdx; |
| 17 |
|
| 18 |
[[nodiscard]] std::string_view file(const SymbolManager& m) const { return m.getFiles()[fileIdx].filename; } |
| 19 |
[[nodiscard]] const std::string& name(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].name; } |
| 20 |
[[nodiscard]] uint16_t value(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].value; } |
| 21 |
[[nodiscard]] std::optional<uint8_t> slot(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].slot; } |
| 22 |
[[nodiscard]] std::optional<uint16_t> segment(const SymbolManager& m) const { return m.getFiles()[fileIdx].symbols[symbolIdx].segment; } |
| 23 |
}; |
| 24 |
|
| 25 |
class ImGuiSymbols final : public ImGuiPart, private SymbolObserver |
| 26 |
{ |
| 27 |
public: |
| 28 |
struct FileInfo { |
| 29 |
std::string filename; |
| 30 |
std::string error; |
| 31 |
SymbolFile::Type type; |
| 32 |
std::optional<uint8_t> slot; |
| 33 |
std::optional<uint16_t> segment; |
| 34 |
}; |
| 35 |
|
| 36 |
explicit ImGuiSymbols(ImGuiManager& manager); |
| 37 |
~ImGuiSymbols(); |
| 38 |
|
| 39 |
[[nodiscard]] zstring_view iniName() const override { return "symbols"; } |
| 40 |
void save(ImGuiTextBuffer& buf) override; |
| 41 |
void loadStart() override; |
| 42 |
void loadLine(std::string_view name, zstring_view value) override; |
| 43 |
void loadEnd() override; |
| 44 |
void paint(MSXMotherBoard* motherBoard) override; |
| 45 |
|
| 46 |
public: |
| 47 |
bool show = false; |
| 48 |
|
| 49 |
private: |
| 50 |
void loadFile(const std::string& filename, SymbolManager::LoadEmpty loadEmpty, SymbolFile::Type type, |
| 51 |
std::optional<uint8_t> slot, std::optional<uint16_t> segment); |
| 52 |
|
| 53 |
template<bool FILTER_FILE> |
| 54 |
void drawTable(MSXMotherBoard* motherBoard, const std::string& file = {}); |
| 55 |
void checkSort(); |
| 56 |
|
| 57 |
void drawContext(MSXMotherBoard* motherBoard, const SymbolRef& sym); |
| 58 |
|
| 59 |
|
| 60 |
void notifySymbolsChanged() override; |
| 61 |
|
| 62 |
private: |
| 63 |
SymbolManager& symbolManager; |
| 64 |
std::vector<SymbolRef> symbols; |
| 65 |
|
| 66 |
std::vector<FileInfo> fileError; |
| 67 |
|
| 68 |
struct SortState { |
| 69 |
int columnIndex = -1; |
| 70 |
ImGuiSortDirection direction = ImGuiSortDirection_None; |
| 71 |
} sortState; |
| 72 |
|
| 73 |
static constexpr auto persistentElements = std::tuple{ |
| 74 |
PersistentElement{"show", &ImGuiSymbols::show} |
| 75 |
}; |
| 76 |
}; |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
#endif |