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