openMSX
ImGuiSpriteViewer.hh
Go to the documentation of this file.
1#ifndef IMGUI_SPRITE_VIEWER_HH
2#define IMGUI_SPRITE_VIEWER_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 ImGuiSpriteViewer final : public ImGuiPart
14{
15public:
16 ImGuiSpriteViewer(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
23public:
24 bool show = true;
25
26private:
27 std::string title;
28
29 bool overrideAll = false;
30 bool overrideMode = false;
31 bool overrideSize = false;
32 bool overrideMag = false;
33 bool overrideTrans = false;
34 bool overridePat = false;
35 bool overrideAtt = false;
36 bool overrideScroll = false;
37 bool overrideLines = false;
38 int manualMode = 1;
39 int manualSize = 8;
40 int manualMag = 0;
41 int manualTransparent = 0;
42 int manualPatBase = 0;
43 int manualAttBase = 0;
44 int manualVerticalScroll = 0;
45 int manualLines = 0; // 0->192, 1->212, 2->256
46 int zoom = 0; // 0->1x, 1->2x, ..., 7->8x
47 int checkerBoardSize = 4;
48 int boundingBoxOnAll = 0;
49 gl::vec4 gridColor{0.5f, 0.5f, 0.5f, 0.5f}; // RGBA
50 gl::vec4 checkerBoardColor1{0.2f, 0.2f, 0.2f, 0.8f}; // RGBA
51 gl::vec4 checkerBoardColor2{0.4f, 0.4f, 0.4f, 0.8f}; // RGBA
52 gl::vec4 boundingBoxColor {1.0f, 0.0f, 0.0f, 0.8f}; // RGBA
53 bool grid = true;
54 bool drawBoundingBox = true;
55 bool enableLimitPerLine = true;
56 bool enableStopY = true;
57
58 gl::Texture patternTex {gl::Null{}}; // TODO also deallocate when needed
59 gl::Texture gridTex {gl::Null{}};
60 gl::Texture zoomGridTex{gl::Null{}};
61 gl::Texture checkerTex {gl::Null{}};
62 gl::Texture renderTex {gl::Null{}};
63
64 static constexpr auto validSizes = {8, 16};
65 static constexpr auto persistentElements = std::tuple{
67 PersistentElement{"overrideAll", &ImGuiSpriteViewer::overrideAll},
68 PersistentElement{"overrideMode", &ImGuiSpriteViewer::overrideMode},
69 PersistentElement{"overrideSize", &ImGuiSpriteViewer::overrideSize},
70 PersistentElement{"overrideMag", &ImGuiSpriteViewer::overrideMag},
71 PersistentElement{"overrideTrans", &ImGuiSpriteViewer::overrideTrans},
72 PersistentElement{"overridePat", &ImGuiSpriteViewer::overridePat},
73 PersistentElement{"overrideAtt", &ImGuiSpriteViewer::overrideAtt},
74 PersistentElement{"overrideScroll", &ImGuiSpriteViewer::overrideScroll},
75 PersistentElement{"overrideLines", &ImGuiSpriteViewer::overrideLines},
76 PersistentElementMinMax{"mode", &ImGuiSpriteViewer::manualMode, 1, 3}, // 1 or 2
77 PersistentElementEnum{"size", &ImGuiSpriteViewer::manualSize, validSizes},
78 PersistentElementMax{"mag", &ImGuiSpriteViewer::manualMag, 2},
79 PersistentElementMax{"transparent", &ImGuiSpriteViewer::manualTransparent, 2},
80 PersistentElementMax{"patBase", &ImGuiSpriteViewer::manualPatBase, 0x20000},
81 PersistentElementMax{"attBase", &ImGuiSpriteViewer::manualAttBase, 0x20000},
82 PersistentElementMax{"verticalScroll", &ImGuiSpriteViewer::manualVerticalScroll, 256},
83 PersistentElementMax{"lines", &ImGuiSpriteViewer::manualLines, 3},
84 PersistentElementMax{"zoom", &ImGuiSpriteViewer::zoom, 8},
85 PersistentElement{"showGrid", &ImGuiSpriteViewer::grid},
86 PersistentElementMax{"checkerBoardSize", &ImGuiSpriteViewer::checkerBoardSize, 256},
87 PersistentElementMax{"boundingBoxOnAll", &ImGuiSpriteViewer::boundingBoxOnAll, 2},
88 PersistentElement{"gridColor", &ImGuiSpriteViewer::gridColor},
89 PersistentElement{"checkerBoardColor1", &ImGuiSpriteViewer::checkerBoardColor1},
90 PersistentElement{"checkerBoardColor2", &ImGuiSpriteViewer::checkerBoardColor2},
91 PersistentElement{"boundingBox", &ImGuiSpriteViewer::drawBoundingBox},
92 PersistentElement{"boundingBoxColor", &ImGuiSpriteViewer::boundingBoxColor},
93 PersistentElement{"spritesPerLineLimit", &ImGuiSpriteViewer::enableLimitPerLine},
94 PersistentElement{"stopY", &ImGuiSpriteViewer::enableStopY}
95 };
96};
97
98} // namespace openmsx
99
100#endif
Most basic/generic texture: only contains a texture ID.
Definition GLUtil.hh:40
void save(ImGuiTextBuffer &buf) override
void paint(MSXMotherBoard *motherBoard) override
void loadLine(std::string_view name, zstring_view value) override
zstring_view iniName() const 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 >