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
9#include <string>
10
11namespace openmsx {
12
13class ImGuiCharacter final : public ImGuiPart
14{
15public:
16 ImGuiCharacter(ImGuiManager& manager_, size_t index);
17
18 [[nodiscard]] zstring_view iniName() const override { return title; }
19 void save(ImGuiTextBuffer& buf) override;
20 void loadLine(std::string_view name, zstring_view value) override;
21 void paint(MSXMotherBoard* motherBoard) override;
22
23private:
24 static void renderPatterns(int mode, std::span<const uint32_t, 16> palette,
25 int fgCol, int bgCol, int fgBlink, int bgBlink,
26 VramTable& pat, VramTable& col, int lines, std::span<uint32_t> pixels);
27 void initHexDigits();
28
29public:
30 bool show = true;
31
32private:
33 std::string title;
34
35 int zoom = 0; // 0->1x, 1->2x, ..., 7->8x
36 bool overrideAll = false;
37 bool overrideMode = false;
38 bool overrideFgCol = false;
39 bool overrideBgCol = false;
40 bool overrideFgBlink = false;
41 bool overrideBgBlink = false;
42 bool overrideBlink = false;
43 bool overridePat = false;
44 bool overrideCol = false;
45 bool overrideNam = false;
46 bool overrideRows = false;
47 bool overrideColor0 = false;
48 bool grid = true;
49 bool nameTableOverlay = false;
50 gl::vec4 gridColor{0.0f, 0.0f, 0.0f, 0.5f}; // RGBA
51
52 enum CharScrnMode : int { TEXT40, TEXT80, SCR1, SCR2, SCR3, SCR4, OTHER };
53 int manualMode = 0;
54 int manualFgCol = 15;
55 int manualBgCol = 4;
56 int manualFgBlink = 14;
57 int manualBgBlink = 1;
58 int manualBlink = 1;
59 int manualPatBase = 0;
60 int manualColBase = 0;
61 int manualNamBase = 0;
62 int manualRows = 0;
63 int manualColor0 = 16;
64
65 gl::Texture patternTex{gl::Null{}}; // TODO also deallocate when needed
66 gl::Texture gridTex {gl::Null{}};
67 gl::Texture smallHexDigits{gl::Null{}};
68
69 static constexpr auto persistentElements = std::tuple{
71 PersistentElement {"overrideAll", &ImGuiCharacter::overrideAll},
72 PersistentElement {"overrideMode", &ImGuiCharacter::overrideMode},
73 PersistentElement {"overrideFgCol", &ImGuiCharacter::overrideFgCol},
74 PersistentElement {"overrideBgCol", &ImGuiCharacter::overrideBgCol},
75 PersistentElement {"overrideFgBlink", &ImGuiCharacter::overrideFgBlink},
76 PersistentElement {"overrideBgBlink", &ImGuiCharacter::overrideBgBlink},
77 PersistentElement {"overrideBlink", &ImGuiCharacter::overrideBlink},
78 PersistentElement {"overridePat", &ImGuiCharacter::overridePat},
79 PersistentElement {"overrideCol", &ImGuiCharacter::overrideCol},
80 PersistentElement {"overrideNam", &ImGuiCharacter::overrideNam},
81 PersistentElement {"overrideRows", &ImGuiCharacter::overrideRows},
82 PersistentElement {"overrideColor0", &ImGuiCharacter::overrideColor0},
83 PersistentElementMax{"zoom", &ImGuiCharacter::zoom, 8},
84 PersistentElement {"showGrid", &ImGuiCharacter::grid},
85 PersistentElement {"overlay", &ImGuiCharacter::nameTableOverlay},
86 PersistentElement {"gridColor", &ImGuiCharacter::gridColor},
87 PersistentElementMax{"mode", &ImGuiCharacter::manualMode, OTHER}, // TEXT40..SCR4
88 PersistentElementMax{"fgCol", &ImGuiCharacter::manualFgCol, 16},
89 PersistentElementMax{"bgCol", &ImGuiCharacter::manualBgCol, 16},
90 PersistentElementMax{"fgBlink", &ImGuiCharacter::manualFgBlink, 16},
91 PersistentElementMax{"bgBlink", &ImGuiCharacter::manualBgBlink, 16},
92 PersistentElement {"blink", &ImGuiCharacter::manualBlink},
93 PersistentElementMax{"patBase", &ImGuiCharacter::manualPatBase, 0x20000},
94 PersistentElementMax{"colBase", &ImGuiCharacter::manualColBase, 0x20000},
95 PersistentElementMax{"namBase", &ImGuiCharacter::manualNamBase, 0x20000},
96 PersistentElementMax{"rows", &ImGuiCharacter::manualRows, 3},
97 PersistentElementMax{"color0", &ImGuiCharacter::manualColor0, 16 + 1}
98 };
99};
100
101} // namespace openmsx
102
103#endif
Most basic/generic texture: only contains a texture ID.
Definition GLUtil.hh:40
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
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 >