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 zoom = 0; // 0->1x, 1->2x, ..., 7->8x
32 bool overrideAll = false;
33 bool overrideMode = false;
34 bool overrideFgCol = false;
35 bool overrideBgCol = false;
36 bool overrideFgBlink = false;
37 bool overrideBgBlink = false;
38 bool overrideBlink = false;
39 bool overridePat = false;
40 bool overrideCol = false;
41 bool overrideNam = false;
42 bool overrideRows = false;
43 bool overrideColor0 = false;
44 bool grid = true;
45 bool nameTableOverlay = false;
46 gl::vec4 gridColor{0.0f, 0.0f, 0.0f, 0.5f}; // RGBA
47
48 enum CharScrnMode : int { TEXT40, TEXT80, SCR1, SCR2, SCR3, SCR4, OTHER };
49 int manualMode = 0;
50 int manualFgCol = 15;
51 int manualBgCol = 4;
52 int manualFgBlink = 14;
53 int manualBgBlink = 1;
54 int manualBlink = 1;
55 int manualPatBase = 0;
56 int manualColBase = 0;
57 int manualNamBase = 0;
58 int manualRows = 0;
59 int manualColor0 = 16;
60
61 gl::Texture patternTex{gl::Null{}}; // TODO also deallocate when needed
62 gl::Texture gridTex {gl::Null{}};
63 gl::Texture smallHexDigits{gl::Null{}};
64
65 static constexpr auto persistentElements = std::tuple{
67 PersistentElement {"overrideAll", &ImGuiCharacter::overrideAll},
68 PersistentElement {"overrideMode", &ImGuiCharacter::overrideMode},
69 PersistentElement {"overrideFgCol", &ImGuiCharacter::overrideFgCol},
70 PersistentElement {"overrideBgCol", &ImGuiCharacter::overrideBgCol},
71 PersistentElement {"overrideFgBlink", &ImGuiCharacter::overrideFgBlink},
72 PersistentElement {"overrideBgBlink", &ImGuiCharacter::overrideBgBlink},
73 PersistentElement {"overrideBlink", &ImGuiCharacter::overrideBlink},
74 PersistentElement {"overridePat", &ImGuiCharacter::overridePat},
75 PersistentElement {"overrideCol", &ImGuiCharacter::overrideCol},
76 PersistentElement {"overrideNam", &ImGuiCharacter::overrideNam},
77 PersistentElement {"overrideRows", &ImGuiCharacter::overrideRows},
78 PersistentElement {"overrideColor0", &ImGuiCharacter::overrideColor0},
79 PersistentElementMax{"zoom", &ImGuiCharacter::zoom, 8},
80 PersistentElement {"showGrid", &ImGuiCharacter::grid},
81 PersistentElement {"overlay", &ImGuiCharacter::nameTableOverlay},
82 PersistentElement {"gridColor", &ImGuiCharacter::gridColor},
83 PersistentElementMax{"mode", &ImGuiCharacter::manualMode, OTHER}, // TEXT40..SCR4
84 PersistentElementMax{"fgCol", &ImGuiCharacter::manualFgCol, 16},
85 PersistentElementMax{"bgCol", &ImGuiCharacter::manualBgCol, 16},
86 PersistentElementMax{"fgBlink", &ImGuiCharacter::manualFgBlink, 16},
87 PersistentElementMax{"bgBlink", &ImGuiCharacter::manualBgBlink, 16},
88 PersistentElement {"blink", &ImGuiCharacter::manualBlink},
89 PersistentElementMax{"patBase", &ImGuiCharacter::manualPatBase, 0x20000},
90 PersistentElementMax{"colBase", &ImGuiCharacter::manualColBase, 0x20000},
91 PersistentElementMax{"namBase", &ImGuiCharacter::manualNamBase, 0x20000},
92 PersistentElementMax{"rows", &ImGuiCharacter::manualRows, 3},
93 PersistentElementMax{"color0", &ImGuiCharacter::manualColor0, 16 + 1}
94 };
95};
96
97} // namespace openmsx
98
99#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 >