1 /*
2    (C) Copyright 2000/2001 Kai Sterker <kai.sterker@gmail.com>
3    Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5    Adonthell is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9 
10    Adonthell is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with Adonthell.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 /**
21  * @file   dialog_screen.h
22  * @author Kai Sterker <kai.sterker@gmail.com>
23  *
24  * @brief  Declares the dialog_screen class.
25  *
26  *
27  */
28 
29 
30 #ifndef DLG_ENGINE_H__
31 #define DLG_ENGINE_H__
32 
33 #include "dialog.h"
34 #include "window.h"
35 #include "win_select.h"
36 #include "win_theme.h"
37 
38 /**
39  * Maximum number of colors used during a dialog.
40  *
41  */
42 #define MAX_COLOR 6
43 
44 /**
45  * Allows the running of dialogues through a nice interface.
46  *
47  */
48 class dialog_screen : public win_container
49 {
50 public:
51 
52     /**
53      * Constructor.
54      *
55      * @param mynpc npc the player is talking with.
56      * @param dlg_file dialogue file to use.
57      * @param size if 1, use a large window, else a small one.
58      *
59      */
60     dialog_screen (character_base * mynpc, char * dlg_file, u_int8 size=1);
61 
62     /**
63      * Destructor.
64      *
65      */
66     ~dialog_screen ();
67 
68     /**
69      * Inits the dialogue engine (similar to a constructor call).
70      *
71      * @param mynpc npc the player is talking with.
72      * @param dlg_file dialogue file to use.
73      * @param size if 1, use a large window, else a small one.
74      *
75      */
76     void init(character_base *mynpc, char * dlg_file, u_int8 size=1);
77 
78     /**
79      * Changes the displayed NPC portrait.
80      *
81      * @param new_portrait file name of the new portrait image to set.
82      */
83     void set_portrait (const string & new_portrait);
84 
85     /**
86      * Changes the displayed NPC name.
87      *
88      * @param char* new name of the npc.
89      */
90     void set_name (const string & new_name);
91 
92     /**
93      * Changes the whole NPC.
94      *
95      * @param char* the name of the new npc to use.
96      */
97     void set_npc (const string & new_npc);
98 
99     /**
100      * React to (keyboard) input.
101      *
102      * @return true if the dialog is still running, false otherwise.
103      */
104     bool update ();
105 
106     /**
107      * Execute one step of the dialogue.
108      *
109      */
110     void run ();
111 
112 #ifndef SWIG
113 private:
114     /**
115      * 'Merges' a dialogue with the loaded one.
116      *
117      */
118     void insert_plugin ();
119 
120     /**
121      * Callback when item is "activated".
122      *
123      */
124     void on_select ();
125 
126     /**
127      * Widget holding NPC portrait.
128      *
129      */
130     win_image *face;
131 
132     /**
133      * Widget holding NPC name.
134      *
135      */
136     win_label *name;
137 
138     /**
139      * Window theme.
140      *
141      */
142     win_theme *theme;
143 
144     /**
145      * Selection of possible answers.
146      *
147      */
148     win_select *sel;
149 
150     /**
151      * As long as realtime coloring does not work.
152      *
153      */
154 
155     win_font *fonts[MAX_COLOR];
156 
157     /**
158      * Answers currently available for selection.
159      *
160      */
161     vector <win_label*> cur_answers;
162 
163     /**
164      * The Python/C interface for the dialogue.
165      *
166      */
167     dialog *dlg;
168 
169     /**
170      * The selected dialogue option.
171      *
172      */
173     s_int32 answer;
174 
175     /**
176      * Index of first selectible dialogue item.
177      *
178      */
179     u_int32 sel_start;
180 
181     /**
182      * True as long as we don't want to quit.
183      *
184      */
185     bool is_running;
186 
187     /**
188      * Image to display next to the NPC text
189      *
190      */
191     string portrait;
192 #endif // SWIG
193 };
194 
195 #endif // DLG_ENGINE_H__
196