1 // $Id$
2 
3 // Fish Supper
4 // Copyright 2006, 2007, 2009, 2010 Matthew Clarke <mafferyew@googlemail.com>
5 //
6 // This file is part of Fish Supper.
7 //
8 // Fish Supper is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // Fish Supper is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Fish Supper.  If not, see <http://www.gnu.org/licenses/>.
20 
21 
22 
23 
24 #ifndef Tutorial_h
25 #define Tutorial_h
26 
27 
28 
29 
30 #include "enums.h"
31 #include <vector>
32 #include <iostream>
33 #include <fstream>
34 #include <string>
35 #include <cstdlib>
36 #include <cassert>
37 #include "constants.h"
38 #include "Crystal.h"
39 #include "FS_gfx.h"
40 #include <memory>
41 
42 
43 
44 
45 extern std::shared_ptr<FS::FS_gfx> gfx_ptr;
46 
47 
48 
49 
50 namespace FS
51 {
52 
53 class Tutorial
54 {
55     public:
56 
57         enum TaskType { READ_TASK, PLAY_TASK };
58         static const int MAX_CRYSTALS = 5;
59         static const int MAX_MSG_LINES = 3;
60 
61         static const int MSG_BOARD_WIDTH = 700;
62         static const int MSG_BOARD_HEIGHT = 30;
63         static const int MSG_BOARD_X = 100;
64         static const int MSG_BOARD_Y = 560;
65         static const int MSG_TEXT_Y_OFFSET = 4;
66 
67         struct Task
68         {
69             TaskType type;
70 
71             // PLAY_TASK
72             RowDescription row_desc;
73             LogColor lc;
74             int num_required_crystals;
75             Crystal::Color required_crystals[MAX_CRYSTALS];
76 
77             // READ_TASK
78             bool do_once_only;
79             bool done_once_already;
80 
81             // READ_ and PLAY_TASKs
82             std::string msg;
83         }; // struct Task
84 
85         Tutorial();
86         ~Tutorial();
87 
88         void load_task_list(int level);
89 
90         // Sets 'current_task' to 0 and clears all 'done_once_already'
91         // flags. No need to call this immediately after load_task_list
92         // (- it's called for you).
93         void reset_task_list();
94 
95         // If we're at the end of the 'task_list', this function returns
96         // the null pointer, 0; else a pointer to 'current_task'.
97         const Task* get_current_task() const;
98         // Inform Tutorial class that current task has been completed and
99         // that we're ready to move to the next one. As a convenience, it'll
100         // also return pointer to new task.
101         const Task* next_task();
102 
103         // Call this after level-restart while in TUTORIAL mode. It sets
104         // current_task back to the start (i.e. 0) while leaving undisturbed
105         // 'done_once_already' flags in task_list.
106         void restart();
107 
108         void print_task_list();
109 
110     private:
111 
112         // FIXME: if find we need to remove tasks during tutorial, maybe
113         // switch to using a std::list instead.
114         std::vector<Task*> task_list;
115         unsigned int current_task;
116 
117         void delete_tasks();
118 
119 }; // class Tutorial
120 
121 // Non-member, non-friend functions related to Tutorial class.
122 void draw_task_message(const std::string& msg);
123 
124 } // namespace FS
125 
126 
127 
128 
129 #endif
130