openMSX
ImGuiCharacter.hh
Go to the documentation of this file.
1#ifndef IMGUI_CHARACTER_HH
2#define IMGUI_CHARACTER_HH
3
4#include "ImGuiPart.hh"
5
6#include "GLUtil.hh"
7#include "gl_vec.hh"
8
9namespace openmsx {
10
11class ImGuiCharacter final : public ImGuiPart
12{
13public:
15
16 [[nodiscard]] zstring_view iniName() const override { return "Tile viewer"; }
17 void save(ImGuiTextBuffer& buf) override;
18 void loadLine(std::string_view name, zstring_view value) override;
19 void paint(MSXMotherBoard* motherBoard) override;
20
21private:
22 static void renderPatterns(int mode, std::span<const uint32_t, 16> palette,
23 int fgCol, int bgCol, int fgBlink, int bgBlink,
24 VramTable& pat, VramTable& col, int lines, std::span<uint32_t> pixels);
25 void initHexDigits();
26
27public:
28 bool show = false;
29
30private:
31 int manual = 0;
32 int zoom = 0; // 0->1x, 1->2x, ..., 7->8x
33 bool grid = true;
34 bool nameTableOverlay = false;
35 gl::vec4 gridColor{0.0f, 0.0f, 0.0f, 0.5f}; // RGBA
36
37 enum CharScrnMode : int { TEXT40, TEXT80, SCR1, SCR2, SCR3, SCR4, OTHER };
38 int manualMode = 0;
39 int manualFgCol = 15;
40 int manualBgCol = 4;
41 int manualFgBlink = 14;
42 int manualBgBlink = 1;
43 int manualBlink = 1;
44 int manualPatBase = 0;
45 int manualColBase = 0;
46 int manualNamBase = 0;
47 int manualRows = 0;
48 int manualColor0 = 16;
49
50 gl::Texture patternTex{gl::Null{}}; // TODO also deallocate when needed
51 gl::Texture gridTex {gl::Null{}};
52 gl::Texture smallHexDigits{gl::Null{}};
53
54 static constexpr auto persistentElements = std::tuple{
56 PersistentElementMax{"override", &ImGuiCharacter::manual, 2},
57 PersistentElementMax{"zoom", &ImGuiCharacter::zoom, 8},
58 PersistentElement {"showGrid", &ImGuiCharacter::grid},
59 PersistentElement {"overlay", &ImGuiCharacter::nameTableOverlay},
60 PersistentElement {"gridColor", &ImGuiCharacter::gridColor},
61 PersistentElementMax{"mode", &ImGuiCharacter::manualMode, OTHER}, // TEXT40..SCR4
62 PersistentElementMax{"fgCol", &ImGuiCharacter::manualFgCol, 16},
63 PersistentElementMax{"bgCol", &ImGuiCharacter::manualBgCol, 16},
64 PersistentElementMax{"fgBlink", &ImGuiCharacter::manualFgBlink, 16},
65 PersistentElementMax{"bgBlink", &ImGuiCharacter::manualBgBlink, 16},
66 PersistentElement {"blink", &ImGuiCharacter::manualBlink},
67 PersistentElementMax{"patBase", &ImGuiCharacter::manualPatBase, 0x20000},
68 PersistentElementMax{"colBase", &ImGuiCharacter::manualColBase, 0x20000},
69 PersistentElementMax{"namBase", &ImGuiCharacter::manualNamBase, 0x20000},
70 PersistentElementMax{"rows", &ImGuiCharacter::manualRows, 3},
71 PersistentElementMax{"color0", &ImGuiCharacter::manualColor0, 16 + 1}
72 };
73};
74
75} // namespace openmsx
76
77#endif
Most basic/generic texture: only contains a texture ID.
Definition GLUtil.hh:39
void paint(MSXMotherBoard *motherBoard) override
zstring_view iniName() const override
void save(ImGuiTextBuffer &buf) override
void loadLine(std::string_view name, zstring_view value) override
ImGuiPart(ImGuiManager &manager_)
Definition ImGuiPart.hh:12
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
PersistentElement(zstring_view, T C::*) -> PersistentElement< C, T >