1//
2// KBlackBox
3//
4// A simple game inspired by an emacs module
5//
6/***************************************************************************
7 * Copyright (c) 2007, Nicolas Roffet *
8 * nicolas-kde@roffet.com *
9 * *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
25 ***************************************************************************/
26
27#ifndef KBBTUTORIAL_H
28#define KBBTUTORIAL_H
29
30
31
32#include <QGroupBox>
33class QHideEvent;
34class QLabel;
35class QProgressBar;
36class QWidget;
37
38
39class KPushButton;
40class KTextEdit;
41
42
43class KBBGraphicsItemTutorialMarker;
44class KBBScalableGraphicWidget;
45
46
47
48/**
49 * @brief Tutorial widget
50 */
51class KBBTutorial : public QGroupBox
52{
53 Q_OBJECT
54
55 public:
56 /**
57 * @brief Number of balls in the tutorial
58 */
59 static int const BALLS = 3;
60
61 /**
62 * @brief Number of columns in the tutorial
63 */
64 static int const COLUMNS = 6;
65
66 /**
67 * @brief Number of rows in the tutorial
68 */
69 static int const ROWS = 6;
70
71
72 /**
73 * @brief Constructor
74 */
75 explicit KBBTutorial(QWidget* parent);
76
77
78 /**
79 * @brief Event: Leaving the tutorial
80 *
81 * Called by exiting the tutorial
82 */
83 void hideEvent(QHideEvent*);
84
85 /**
86 * @brief May the player solve the running game?
87 *
88 * The player may solve the game only at the end of the tutorial during the last step.
89 */
90 bool maySolve();
91
92 /**
93 * @brief May the player shoot the ray?
94 *
95 * The player may only shoot given rays during the tutorial (except during the last step).
96 */
97 bool mayShootRay(const int incomingPosition);
98
99 /**
100 * @brief Define the scalable graphic widget
101 */
102 void setGameWidget(KBBScalableGraphicWidget* gameWidget, KBBGraphicsItemTutorialMarker* marker);
103
104 /**
105 * @brief Go to the given tutorial step
106 */
107 void setStep(const int step);
108
109 /**
110 * @brief Start the tutorial
111 * Start or restart the tutorial at the 1st step.
112 */
113 void start();
114
115
116 private slots:
117 /**
118 * @brief Go to the next tutorial step
119 */
120 void nextStep();
121
122 /**
123 * @brief Go to the previous tutorial step
124 */
125 void previousStep();
126
127 /**
128 * @brief Restore the default style of the label m_playerAction
129 *
130 * This slot is called by the timer.
131 */
132 void restoreStyle();
133
134
135 private:
136 /**
137 * @brief First tutorial step
138 */
139 static int const FIRST_STEP = 1;
140
141 /**
142 * @brief Time to highlight the label m_playerAction
143 *
144 * If the player clicks on a disabled laser, the label m_playerAction is highlighted during this time (in ms).
145 */
146 static int const HIGHLIGHT_TIME = 600;
147
148 /**
149 * @brief Last tutorial step
150 */
151 static int const LAST_STEP = 11;
152
153 /**
154 * @brief Position of laser, if laser may not be used
155 */
156 static int const MAY_NOT_USE = -1;
157
158 /**
159 * @brief Fixed width and minimum height
160 *
161 * This is the fixed width and the minimum height of the widget. The widget needs a minimal size: it is ugly if it is too small.
162 */
163 static int const WIDTH = 275;
164
165
166 /**
167 * @brief define the maximal step
168 *
169 * The player may just navigate between the steps he already read.
170 */
171 void setNewStepMaxAllowed(const int newStepMax);
172
173 /**
174 * @brief Set the title and the main text
175 */
176 void setTexts(const QString &title, const QString &text, const QString &action);
177
178 /**
179 * @brief Show tutorial marker on the board
180 */
181 void showMarker(const int laserPosition) const;
182
183
184 KPushButton* m_buttonNext;
185 KPushButton* m_buttonPrevious;
186 KTextEdit* m_explanation;
187 KBBScalableGraphicWidget* m_gameWidget;
188 int m_laserToUse;
189 KBBGraphicsItemTutorialMarker* m_marker;
190 QLabel* m_playerAction;
191 QProgressBar* m_progression;
192
193 /**
194 * @brief Tutorial step number
195 */
196 int m_step;
197
198 int m_stepMaxAllowed;
199 QLabel* m_title;
200};
201
202#endif //KBBTUTORIAL_H
203