00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __NECONSOLE_H
00029 #define __NECONSOLE_H
00030
00031
00038 #ifndef __NEED_VECTOR_STRING
00039 # define __NEED_VECTOR_STRING
00040 #endif
00041
00042 #include "base.h"
00043 #include "renderentity.h"
00044 #include "inputentity.h"
00045 #include "callback.h"
00046 #include "logstream.h"
00047 #include "font.h"
00048 #include "vertexbuffer.h"
00049 #include "polygonbuffer.h"
00050 #include "material.h"
00051
00052 #include <vector>
00053
00054
00055 namespace NeoEngine
00056 {
00057
00058
00065 class NEOENGINE_API ConsoleCmd
00066 {
00067 public:
00068
00070 HashString m_strCmd;
00071
00073 ConsoleCmdCallback *m_pkCallback;
00074
00079 ConsoleCmd( const HashString &rstrCmd, ConsoleCmdCallback *pkCallback ) : m_strCmd( rstrCmd ), m_pkCallback( pkCallback ) {}
00080 };
00081
00082
00083
00084 #ifdef WIN32
00085 # ifndef __HAVE_VECTOR_CONSOLECMD
00086 UDTVectorEXPIMP( ConsoleCmd* );
00087 # define __HAVE_VECTOR_CONSOLECMD
00088 # endif
00089 #endif
00090
00091
00110 class NEOENGINE_API Console : public RenderEntity, public InputEntity, public LogSink
00111 {
00112 friend class Core;
00113
00114 public:
00115
00119 enum CONSOLEDEFS
00120 {
00122 DEFAULTHISTORY = 200
00123 };
00124
00125
00126 protected:
00127
00129 std::vector< std::string > m_vstrHistory;
00130
00132 FontPtr m_pkFont;
00133
00135 std::string m_strCmd;
00136
00138 std::vector< ConsoleCmd* > m_vpkCommands;
00139
00141 int m_iX;
00142
00144 int m_iY;
00145
00147 int m_iWidth;
00148
00150 int m_iHeight;
00151
00153 ConsoleCmdCallback *m_pkDefaultCallback;
00154
00156 VertexBufferPtr m_pkVertexBuffer;
00157
00159 PolygonBufferPtr m_pkPolygonBuffer;
00160
00162 MaterialPtr m_pkMaterial;
00163
00165 unsigned int m_uiHistory;
00166
00167
00169 static FontPtr s_pkDefaultFont;
00170
00171
00177 virtual bool ProcessCmd( const std::string &rstrCmd );
00178
00179
00180 public:
00181
00185 Console( unsigned int uiHistory = DEFAULTHISTORY );
00186
00190 virtual ~Console();
00191
00198 virtual bool Render( Frustum *pkFrustum = 0, bool bForce = false );
00199
00204 void SetFont( FontPtr pkFont );
00205
00209 const FontPtr &GetFont() const { return m_pkFont; }
00210
00215 virtual void Input( const InputEvent *pkEvent );
00216
00221 virtual void Write( const std::string &rstrMsg );
00222
00229 bool RegisterCommand( const HashString &rstrCmd, ConsoleCmdCallback *pkCallback );
00230
00235 void RegisterDefaultCallback( ConsoleCmdCallback *pkCallback );
00236
00244 void SetDimensions( int iX = 0, int iY = 0, int iWidth = -1, int iHeight = -1 );
00245
00249 void DeleteBuffers();
00250
00254 void Clear();
00255
00259 static void LoadDefaultFont();
00260
00265 static FontPtr GetDefaultFont();
00266
00270 static void UnloadDefaultFont();
00271 };
00272
00273
00274 };
00275
00276
00277 #endif