D:/Zythum/DinoKod/Common/Game.cpp

00001 //---------------------------------------------------------------------------------------------
00002 //      This file is a part of "DinoKod".
00003 //      Copyright © 2003 Dino Productions. All Rights Reserved.
00004 //      
00005 //      File                    : Game.cpp
00006 //      Author                  : Sebastien LEIX        sebastien.leix@wanadoo.fr
00007 //      Date                    : 
00008 //      Modification    :
00009 //
00010 //---------------------------------------------------------------------------------------------
00011 #include "Common/Types.h"
00012 #include "Common/Console.h"
00013 #include "Common/Variable.h"
00014 #include "Common/Command.h"
00015 #include "Common/Time.h"
00016 
00017 #include "Common/Game.h"
00018 
00019 KGame   *g_pGame;
00020 
00021 //---------------------------------------------------------------------------------------------------------------------
00022 KGame::KGame( HINSTANCE hInstance )
00023 {
00024         g_pGame                 = this;
00025         m_hInstance             = hInstance;
00026         m_bQuit                 = false;
00027         m_pIniFile              = NULL;
00028         m_StartTime             = 0;
00029         m_Version               = KMAKE_VERSION( 0, 0 );
00030 
00031         // Variable
00032         m_pVariable             = new KVariableList();
00033 
00034         // Command
00035         m_pCommand              = new KCommandList();
00036 }
00037 
00038 //---------------------------------------------------------------------------------------------------------------------
00039 KGame::~KGame()
00040 {
00041         if( m_pVariable )
00042                 Deletep( m_pVariable );
00043 
00044         if( m_pCommand )
00045                 Deletep( m_pCommand );
00046 }
00047 
00048 //---------------------------------------------------------------------------------------------------------------------
00049 void KGame::CommandEcho( KStr sArgument, void* pContext )
00050 {
00051         g_Console << sArgument << KENDL;
00052 }
00053 
00054 //---------------------------------------------------------------------------------------------------------------------
00055 void KGame::CommandExit( KStr sArgument, void* pContext )
00056 {
00057         g_pGame->Quit();
00058 }
00059 
00060 //---------------------------------------------------------------------------------------------------------------------
00061 void KGame::CommandHelp( KStr sArgument, void* pContext )
00062 {
00063         KCommand*       pCommand = g_pGame->GetpCommand()->GetpFirst();
00064 
00065         g_Console << "Command list :" << KENDL;
00066         while( pCommand )
00067         {
00068                 g_Console << " " << pCommand->GetsName() << " : " << pCommand->GetsDescription() << KENDL;
00069 
00070                 pCommand = g_pGame->GetpCommand()->GetpNext( pCommand );
00071         }
00072                 
00073 }
00074 
00075 //---------------------------------------------------------------------------------------------------------------------
00076 bool KGame::Init()
00077 {
00078         m_StartTime = g_Time.GetTime();
00079 
00080         GetpCommand()->RegisterCommand( "echo", CommandEcho, "Display a text",this );
00081         GetpCommand()->RegisterCommand( "exit", CommandExit, "Exit the game", this );
00082         GetpCommand()->RegisterCommand( "help", CommandHelp, "Display this help", this );
00083         
00084         return true;
00085 }
00086 
00087 //---------------------------------------------------------------------------------------------------------------------
00088 void KGame::End()
00089 {
00090 }

Generated on Sun Mar 25 20:02:10 2007 for Zythum Project by  doxygen 1.5.1-p1