Adonthell  0.4
dialog Class Reference

The lowlevel dialog class. More...

#include <dialog.h>

Public Member Functions

 dialog (character_base *npc)
 Default constructor. More...
 
 ~dialog ()
 Destructor. More...
 
bool init (string fpath, string name, PyObject *args)
 Load and instanciate the dialog object. More...
 
bool reload (string fpath, string name, PyObject *args)
 This method is similar to init. More...
 
void run (u_int32 index)
 Run the dialogue. More...
 
PyObject * get_instance ()
 Returns the Python dialog instance. More...
 
u_int32 npc_color ()
 Returns the color to be used for displaying the NPC's speech. More...
 
const string & npc_portrait ()
 Returns the image to be displayed next to the NPC's speech. More...
 
const string & npc_name ()
 Returns the name to be displayed under the NPC's portrait. More...
 
u_int32 text_size ()
 Returns the number of text lines available at this point of the dialoge. More...
 
string text ()
 Iterates over the dialogue's text. More...
 

Detailed Description

The lowlevel dialog class.

It is the link between Python dialogue scripts and the dialogue GUI . As such it is responsible for loading dialogue scripts and for stepping through the dialogue according to the player's input and the current state of the game. After each step, the resulting dialogue text is available for display through the GUI.

Definition at line 44 of file dialog.h.

Constructor & Destructor Documentation

dialog::dialog ( character_base npc)

Default constructor.

Parameters
npcThe npc this dialogue is assigned to.

Definition at line 34 of file dialog.cc.

dialog::~dialog ( )

Destructor.

Definition at line 42 of file dialog.cc.

Member Function Documentation

bool dialog::init ( string  fpath,
string  name,
PyObject *  args 
)

Load and instanciate the dialog object.

Parameters
fpathfull path to the dialogue.
namename of the dialogue class.
argsarguments to pass to the dialogue class
Returns
true in case of success, false otherwise.
See Also
reload()

Definition at line 48 of file dialog.cc.

bool dialog::reload ( string  fpath,
string  name,
PyObject *  args 
)

This method is similar to init.

But unlike init, it will correctly handle dialogues that have changed on disk since they were first imported. This function can safely be called several times, although the dialogue will be reset each time.

Parameters
fpathfull path to the dialogue.
namename of the dialogue class.
argsarguments to pass to the dialogue class
Returns
true in case of success, false otherwise.
See Also
init()

Definition at line 107 of file dialog.cc.

void dialog::run ( u_int32  index)

Run the dialogue.

Executes one step of the conversation. Afterwards the NPC's speech and possible reactions of the player can be retrieved via the text() method.

Parameters
indexthe index of the chosen alternative from the previous list of text.

Definition at line 139 of file dialog.cc.

PyObject* dialog::get_instance ( )
inline

Returns the Python dialog instance.

Returns
the Python dialog instance.

Definition at line 103 of file dialog.h.

u_int32 dialog::npc_color ( )
inline

Returns the color to be used for displaying the NPC's speech.

Returns
the NPC's color.

Definition at line 114 of file dialog.h.

const string& dialog::npc_portrait ( )
inline

Returns the image to be displayed next to the NPC's speech.

Returns
name of the image.

Definition at line 122 of file dialog.h.

const string& dialog::npc_name ( )
inline

Returns the name to be displayed under the NPC's portrait.

Returns
name of the NPC.

Definition at line 130 of file dialog.h.

u_int32 dialog::text_size ( )
inline

Returns the number of text lines available at this point of the dialoge.

Returns
the number of available dialogue texts. 0 if the dialogue is finished.
See Also
text()

Definition at line 141 of file dialog.h.

string dialog::text ( )

Iterates over the dialogue's text.

Depending on the current state of the dialogue, there can be multiple alternatives. The first string is always the NPC's speech. Any following strings are the player's possible reactions. The value passed to the run () method is the (zero-based) index of the alternative chosen by the player.

Returns
the next string in the list of text, or the empty string "" when the end of the array of strings has been reached.
See Also
text_size()

Definition at line 127 of file dialog.cc.


The documentation for this class was generated from the following files: