Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

console.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                 console.h  -  Drop-down console with built-in font
00003                              -------------------
00004     begin                : Thu Feb 21 2002
00005     copyright            : (C) 2002 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, console.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
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 }; // namespace NeoEngine
00275 
00276 
00277 #endif

Generated on Wed Jan 21 14:21:06 2004 for NeoEngine by doxygen 1.3.5