Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
dialog.h
Go to the documentation of this file.
1
/*
2
$Id: dialog.h,v 1.55 2007/10/13 19:47:25 ksterker Exp $
3
4
(C) Copyright 2000/2001/2002 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
#ifndef DIALOG_H__
16
#define DIALOG_H__
17
18
19
/**
20
* @file dialog.h
21
* @author Kai Sterker <kaisterker@linuxgames.com>
22
*
23
* @brief Defines the dialog class.
24
*
25
*
26
*/
27
28
#include "
character_base.h
"
29
#include "
py_object.h
"
30
31
32
using namespace
std;
33
34
35
/**
36
* The lowlevel dialog class. It is the link between Python dialogue
37
* scripts and the \link dialog_screen dialogue GUI \endlink . As such
38
* it is responsible for loading dialogue scripts and for stepping through
39
* the dialogue according to the player's %input and the current state
40
* of the %game. After each step, the resulting dialogue %text is available
41
* for display through the GUI.
42
*
43
*/
44
class
dialog
45
{
46
public
:
47
48
/**
49
* Default constructor.
50
* @param npc The npc this dialogue is assigned to.
51
*/
52
dialog
(
character_base
*npc);
53
54
/**
55
* Destructor.
56
*
57
*/
58
~
dialog
();
59
60
/**
61
* Load and instanciate the dialog object.
62
*
63
* @param fpath full path to the dialogue.
64
* @param name name of the dialogue class.
65
* @param args arguments to pass to the dialogue class
66
*
67
* @return \e true in case of success, \e false otherwise.
68
* @sa reload()
69
*/
70
bool
init (
string
fpath,
string
name, PyObject *args);
71
72
/**
73
* This method is similar to init. But unlike init, it will
74
* correctly handle dialogues that have changed on disk since
75
* they were first imported. This function can safely be called
76
* several times, although the dialogue will be reset each time.
77
*
78
* @param fpath full path to the dialogue.
79
* @param name name of the dialogue class.
80
* @param args arguments to pass to the dialogue class
81
*
82
* @return \e true in case of success, \e false otherwise.
83
* @sa init()
84
*/
85
bool
reload (
string
fpath,
string
name, PyObject *args);
86
87
/**
88
* Run the dialogue. Executes one step of the conversation.
89
* Afterwards the NPC's speech and possible reactions of the
90
* player can be retrieved via the text() method.
91
*
92
* @param index the index of the chosen alternative from the
93
* previous list of %text.
94
*/
95
void
run (
u_int32
index);
96
97
/**
98
* Returns the Python dialog instance.
99
*
100
*
101
* @return the Python dialog instance.
102
*/
103
PyObject *
get_instance
()
104
{
105
return
dialogue.get_instance ();
106
}
107
108
/**
109
* Returns the color to be used for displaying the NPC's speech.
110
*
111
*
112
* @return the NPC's color.
113
*/
114
u_int32
npc_color
() {
return
npc_color_; }
115
116
/**
117
* Returns the image to be displayed next to the NPC's speech.
118
*
119
*
120
* @return name of the image.
121
*/
122
const
string
&
npc_portrait
() {
return
npc_portrait_; }
123
124
/**
125
* Returns the name to be displayed under the NPC's portrait.
126
*
127
*
128
* @return name of the NPC.
129
*/
130
const
string
&
npc_name
() {
return
npc_name_; }
131
132
/**
133
* Returns the number of %text lines available at this point of
134
* the dialoge.
135
*
136
* @return the number of available dialogue texts. 0 if the
137
* dialogue is finished.
138
*
139
* @sa text()
140
*/
141
u_int32
text_size
() {
return
text_.size (); }
142
143
/**
144
* Iterates over the dialogue's %text. Depending on the current state
145
* of the dialogue, there can be multiple alternatives. The first
146
* string is always the NPC's speech. Any following strings are
147
* the player's possible reactions. The value passed to the run ()
148
* method is the (zero-based) index of the alternative chosen by
149
* the player.
150
*
151
* @return the next string in the list of text, or the empty string ""
152
* when the end of the array of strings has been reached.
153
* @sa text_size()
154
*/
155
string
text ();
156
157
private
:
158
py_object
dialogue;
// Points to the instantiated dialogue class
159
const
char
**strings;
// The dialogue text
160
vector<string> text_;
// NPC's speech and according Player responses
161
vector<string>::iterator i_text;
// Iterator for the text_ vector
162
163
u_int32
npc_color_;
// Current NPCs text color
164
string
npc_portrait_;
// Current NPCs portrait
165
string
npc_name_;
// Current NPCs name
166
167
vector<s_int32> answers;
// The indices to pass to dialogue.run ()
168
vector<s_int32> choices;
// Strings player can chose from
169
vector<s_int32> used;
// Dialogue parts that are already spoken
170
vector<s_int32> loop;
// Dialogue parts that can be looped
171
172
void
clear ();
// Cleanup
173
bool
setup ();
// Further dialogue initialisation
174
string
scan_string (
const
char
*);
// Look for enclosed code and execute it
175
char
* get_substr (
const
char
*,
const
char
*,
const
char
*);
176
};
177
178
#endif // DIALOG_H__
179
src
dialog.h
Generated by
1.8.4