Changeset View
Changeset View
Standalone View
Standalone View
renderer.h
Show All 27 Lines | |||||
28 | #include <QSize> | 28 | #include <QSize> | ||
29 | #include <QHash> | 29 | #include <QHash> | ||
30 | #include <QPixmap> | 30 | #include <QPixmap> | ||
31 | 31 | | |||
32 | 32 | | |||
33 | /** | 33 | /** | ||
34 | * Class for rendering elements of game SVG to QPixmap | 34 | * Class for rendering elements of game SVG to QPixmap | ||
35 | */ | 35 | */ | ||
36 | | ||||
37 | class KBounceRenderer : public KGameRenderer | 36 | class KBounceRenderer : public KGameRenderer | ||
38 | { | 37 | { | ||
39 | public: | 38 | public: | ||
39 | | ||||
40 | /** | 40 | /** | ||
41 | * Constructor. | 41 | * Constructor. | ||
42 | * @param fileName path to SVG containing game graphics | 42 | * @param fileName path to SVG containing game graphics | ||
43 | */ | 43 | */ | ||
44 | explicit KBounceRenderer(); | 44 | explicit KBounceRenderer(); | ||
45 | | ||||
45 | /** | 46 | /** | ||
46 | * Destructor. | 47 | * Destructor. | ||
47 | */ | 48 | */ | ||
48 | ~KBounceRenderer(); | 49 | ~KBounceRenderer(); | ||
50 | | ||||
49 | /** | 51 | /** | ||
50 | * Sets Background size and invalidates background cache | 52 | * Sets Background size and invalidates background cache | ||
53 | * @param size new size | ||||
54 | * @see render.cpp | ||||
51 | */ | 55 | */ | ||
52 | void setBackgroundSize( const QSize& size); | 56 | void setBackgroundSize( const QSize& size); | ||
57 | | ||||
53 | /** | 58 | /** | ||
54 | * Renders background to QPixmap of size set by setBachgroundSize | 59 | * Renders background to QPixmap of size set by setBachgroundSize | ||
55 | * Background pixmap is cached (setBackgroundSize() invalidates the cache) | 60 | * Background pixmap is cached (setBackgroundSize() invalidates the cache) | ||
61 | * @see render.cpp | ||||
56 | */ | 62 | */ | ||
57 | QPixmap renderBackground(); | 63 | QPixmap renderBackground(); | ||
64 | | ||||
58 | /** | 65 | /** | ||
59 | * Set s the path were custom background pictures are located. | 66 | * Sets the path were custom background pictures are located. | ||
67 | * @see render.cpp | ||||
60 | */ | 68 | */ | ||
61 | void setCustomBackgroundPath(const QString &path); | 69 | void setCustomBackgroundPath(const QString &path); | ||
70 | | ||||
62 | /** | 71 | /** | ||
63 | * Returns a random pixmap from the custom background path. | 72 | * Returns a random pixmap from the custom background path. | ||
64 | * If no picture is located in this path the pixmap is null. | 73 | * If no picture is located in this path the pixmap is null. | ||
74 | * @see render.cpp | ||||
65 | */ | 75 | */ | ||
66 | QPixmap getRandomBackgroundPixmap(const QString& path); | 76 | QPixmap getRandomBackgroundPixmap(const QString& path); | ||
77 | | ||||
78 | /** | ||||
79 | * Load a new background image | ||||
80 | * @see render.cpp | ||||
81 | */ | ||||
67 | bool loadNewBackgroundPixmap(); | 82 | bool loadNewBackgroundPixmap(); | ||
68 | 83 | | |||
69 | private: | 84 | private: | ||
70 | QSvgRenderer m_svgRenderer; | 85 | QSvgRenderer m_svgRenderer; | ||
71 | QSize m_backgroundSize; | 86 | QSize m_backgroundSize; | ||
72 | QPixmap m_cachedBackground; | 87 | QPixmap m_cachedBackground; | ||
73 | QPixmap m_randomBackground; | 88 | QPixmap m_randomBackground; | ||
74 | 89 | | |||
75 | QString m_customBackgroundPath; | 90 | QString m_customBackgroundPath; | ||
76 | bool m_useRandomBackgrounds; | 91 | bool m_useRandomBackgrounds; | ||
77 | }; | 92 | }; | ||
78 | 93 | | |||
79 | #endif //RENDERER_H | 94 | #endif //RENDERER_H | ||
80 | 95 | |