-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sprite-viewer.h
74 lines (58 loc) · 1.59 KB
/
sprite-viewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef SPRITE_VIEWER_H
#define SPRITE_VIEWER_H
#include <optional>
#include <QColor>
#include <QWidget>
#include "signal-wrapper.h"
#include "sprite-mappings.h"
#include "tile-manager.h"
class SpriteViewer : public QWidget
{
Q_OBJECT
public:
SpriteViewer(const TileManager &tile_manager, const SignalWrapper<SpriteMappings> &sprite_mappings);
std::optional<int> selectedSpriteIndex() const
{
return selected_sprite_index;
}
std::optional<int> selectedPieceIndex() const
{
return selected_piece_index;
}
int startingPaletteLine() const
{
return starting_palette_line;
}
public slots:
void setSelectedSprite(std::optional<int> sprite_index);
void setSelectedPiece(std::optional<int> piece_index);
void selectNextPiece();
void selectPreviousPiece();
void setBackgroundColour(const QColor &colour);
void setStartingPaletteLine(const int palette_line)
{
starting_palette_line = palette_line;
update();
}
void setHideDuplicateTiles(const bool enabled)
{
hide_duplicate_tiles = enabled;
update();
}
signals:
void selectedSpriteChanged();
protected:
void paintEvent(QPaintEvent *event) override;
private:
std::optional<int> selected_sprite_index;
std::optional<int> selected_piece_index;
int starting_palette_line = 0;
bool hide_duplicate_tiles = false;
const SpriteMappings &sprite_mappings;
const TileManager &tile_manager;
int totalPiecesInSelectedSprite() const
{
return static_cast<int>(sprite_mappings.frames[selected_sprite_index.value()].pieces.size());
}
};
#endif // SPRITE_VIEWER_H