45 init (mynpc, dlg_file, size);
50 string path = dlg_file;
51 string file = strrchr (dlg_file,
'.') ? strrchr (dlg_file,
'.') + 1 : dlg_file;
53 audio::play_wave (-1, 0);
72 set_background (*theme);
73 set_trans_background (
true);
89 ((
image*)face)->resize (64, 64);
95 name->set_font (*(fonts[0]));
97 ((
label*)name)->resize (64, 0);
98 name->set_form (label::AUTO_HEIGHT);
103 sel->set_scrollbar (*theme);
106 sel->set_mode (win_select::MODE_BRIGHTNESS);
107 sel->set_layout (win_container::LIST_LAYOUT);
108 sel->set_space_with_border (5);
109 sel->set_space_with_object (5);
110 sel->set_circle (
true);
111 sel->set_visible_scrollbar (
true);
120 sel->set_signal_connect (makeFunctor (*
this, &dialog_screen::on_select),
121 win_event::ACTIVATE_KEY);
127 set_focus_object (sel);
129 set_visible_border (
true);
130 set_visible_background (
true);
136 PyObject *args = PyTuple_New (2);
141 if (!dlg->
init (path, file, args))
143 cout <<
"\n*** Error loading dialogue script " << file <<
"\n";
193 for (
string txt = dlg->
text (); txt !=
""; txt = dlg->
text (), i++)
196 l->set_font (i == 0 ? *fonts[dlg->
npc_color ()] : *fonts[1]);
198 ((
label*)l)->resize(190,0);
199 l->set_form(label::AUTO_HEIGHT);
203 cur_answers.push_back (l);
209 sel->set_default_object (cur_answers.front ());
214 cur_answers[0]->set_can_be_selected (
false);
215 sel->set_default_object (cur_answers[1]);
227 void dialog_screen::on_select ()
230 answer = sel->get_selected_position () - 1;
235 cur_answers.clear ();
240 void dialog_screen::insert_plugin ()
247 if (new_portrait == portrait)
return;
248 portrait = new_portrait;
250 if (new_portrait ==
"")
252 face->image::resize (64, 64);
253 face->fillrect (0, 0, 64, 64, 0x00ff00ff);
256 face->load_pnm(
string (
"gfx/portraits/") + new_portrait);
257 face->set_mask(
true);
264 if (new_name == name->text_string())
return;
266 name->set_text (new_name);
u_int16 height() const
Returns the height of the drawing_area.
static win_font * get_font(string name)
Returns a pointer to a font.
const string & npc_name()
Returns the name to be displayed under the NPC's portrait.
virtual void move(s_int16 tx, s_int16 ty)
Move the win_*.
void run(u_int32 index)
Run the dialogue.
void set_portrait(const string &new_portrait)
Changes the displayed NPC portrait.
string text()
Iterates over the dialogue's text.
static win_theme * get_theme(string name)
Returns a pointer to a theme.
void set_visible(const bool b)
Set the visible parameter.
Image manipulation class.
void resize(u_int16, u_int16)
Rezise the win_*.
#define u_int32
32 bits long unsigned integer
void move(s_int16, s_int16)
Move the win_*.
The lowlevel dialog class.
#define u_int8
8 bits long unsigned integer
string get_portrait() const
Returns the current portrait of the character.
static void show_traceback(void)
Dumps any error information to stderr.
Base character class containing attributes and dialog stuff.
Declares the image class.
Declares the gamedata and data classes.
Declares the dialog_screen class.
~dialog_screen()
Destructor.
void run()
Execute one step of the dialogue.
u_int32 text_size()
Returns the number of text lines available at this point of the dialoge.
static PyObject * pass_instance(void *instance, const char *class_name)
Magic function that makes any C object available to Python!
void set_focus(const bool b)
Set the focus parameter.
bool update()
React to (keyboard) input.
dialog_screen(character_base *mynpc, char *dlg_file, u_int8 size=1)
Constructor.
Defines the python class. This file is named this way so it doesn't conflicts with Python...
void set_npc(const string &new_npc)
Changes the whole NPC.
const string & npc_portrait()
Returns the image to be displayed next to the NPC's speech.
A* pathfinding algorithm implementation class.
u_int32 npc_color()
Returns the color to be used for displaying the NPC's speech.
void init(character_base *mynpc, char *dlg_file, u_int8 size=1)
Inits the dialogue engine (similar to a constructor call).
string get_name() const
Returns the name of the character.
Declares the win_manager class.
virtual bool update()
Update process.
void set_name(const string &new_name)
Changes the displayed NPC name.
void set_activate(const bool b)
Set the activate parameter When a win_* is setup on, the keys queue is cleared.
bool init(string fpath, string name, PyObject *args)
Load and instanciate the dialog object.