Adonthell 0.4
dialog_screen.h
Go to the documentation of this file.
00001 /*
00002    $Id: dialog_screen.h,v 1.3 2003/02/23 23:14:34 ksterker Exp $
00003 
00004    (C) Copyright 2000/2001 Kai Sterker <kaisterker@linuxgames.com>
00005    Part of the Adonthell Project http://adonthell.linuxgames.com
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details
00013 */
00014 
00015 
00016 /**
00017  * @file   dialog_screen.h
00018  * @author Kai Sterker <kaisterker@linuxgames.com>
00019  *
00020  * @brief  Declares the dialog_screen class.
00021  *
00022  *
00023  */
00024 
00025 
00026 #ifndef DLG_ENGINE_H__
00027 #define DLG_ENGINE_H__
00028 
00029 #include "dialog.h"
00030 #include "window.h"
00031 #include "win_select.h"
00032 #include "win_theme.h"
00033 
00034 /**
00035  * Maximum number of colors used during a dialog.
00036  *
00037  */
00038 #define MAX_COLOR 6
00039 
00040 /**
00041  * Allows the running of dialogues through a nice interface.
00042  *
00043  */
00044 class dialog_screen : public win_container
00045 {
00046 public:
00047 
00048     /**
00049      * Constructor.
00050      *
00051      * @param mynpc npc the player is talking with.
00052      * @param dlg_file dialogue file to use.
00053      * @param size if 1, use a large window, else a small one.
00054      *
00055      */
00056     dialog_screen (character_base * mynpc, char * dlg_file, u_int8 size=1);
00057 
00058     /**
00059      * Destructor.
00060      *
00061      */
00062     ~dialog_screen ();
00063 
00064     /** 
00065      * Inits the dialogue engine (similar to a constructor call).
00066      * 
00067      * @param mynpc npc the player is talking with.
00068      * @param dlg_file dialogue file to use.
00069      * @param size if 1, use a large window, else a small one.
00070      * 
00071      */
00072     void init(character_base *mynpc, char * dlg_file, u_int8 size=1);
00073 
00074     /** 
00075      * Changes the displayed NPC portrait.
00076      * 
00077      * @param new_portrait file name of the new portrait image to set.
00078      */
00079     void set_portrait (const string & new_portrait);
00080 
00081     /** 
00082      * Changes the displayed NPC name.
00083      * 
00084      * @param char* new name of the npc.
00085      */
00086     void set_name (const string & new_name);
00087 
00088     /** 
00089      * Changes the whole NPC.
00090      * 
00091      * @param char* the name of the new npc to use.
00092      */
00093     void set_npc (const string & new_npc);
00094 
00095     /** 
00096      * React to (keyboard) input.
00097      *
00098      * @return true if the dialog is still running, false otherwise.
00099      */
00100     bool update ();
00101 
00102     /**
00103      * Execute one step of the dialogue. 
00104      * 
00105      */
00106     void run ();
00107 
00108 #ifndef SWIG
00109 private:
00110     /** 
00111      * 'Merges' a dialogue with the loaded one.
00112      * 
00113      */
00114     void insert_plugin ();
00115 
00116     /** 
00117      * Callback when item is "activated".
00118      * 
00119      */
00120     void on_select ();
00121     
00122     /**
00123      * Widget holding NPC portrait.
00124      * 
00125      */ 
00126     win_image *face;
00127 
00128     /**
00129      * Widget holding NPC name.
00130      * 
00131      */ 
00132     win_label *name;
00133 
00134     /**
00135      * Window theme.
00136      * 
00137      */ 
00138     win_theme *theme;
00139     
00140     /**
00141      * Selection of possible answers.
00142      * 
00143      */
00144     win_select *sel;
00145     
00146     /**
00147      * As long as realtime coloring does not work.
00148      * 
00149      */
00150 
00151     win_font *fonts[MAX_COLOR];
00152     
00153     /**
00154      * Answers currently available for selection.
00155      * 
00156      */
00157     vector <win_label*> cur_answers;
00158 
00159     /**
00160      * The Python/C interface for the dialogue.
00161      * 
00162      */ 
00163     dialog *dlg;
00164 
00165     /**
00166      * The selected dialogue option.
00167      * 
00168      */
00169     s_int32 answer; 
00170 
00171     /**
00172      * Index of first selectible dialogue item.
00173      * 
00174      */
00175     u_int32 sel_start;
00176     
00177     /**
00178      * True as long as we don't want to quit.
00179      * 
00180      */
00181     bool is_running;
00182 
00183     /**
00184      * Image to display next to the NPC text
00185      *
00186      */
00187     string portrait;
00188 #endif // SWIG
00189 };
00190 
00191 #endif // DLG_ENGINE_H__