K3dOptions.cpp

Go to the documentation of this file.
00001 
00012 /***************************************************************************
00013  *   Copyright (C) 2007 by Jan Koci   *
00014  *   honza.koci@email.cz   *
00015  *   http://kengine.sourceforge.net/tutorial/
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  *   This program is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00025  *   GNU General Public License for more details.                          *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU General Public License     *
00028  *   along with this program; if not, write to the                         *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00031  ***************************************************************************/
00032 
00033 #include "K3dOptions.h"
00034 
00038 K3dOptions::K3dOptions ( K3dGameData *_pGameData )
00039 {
00040         m_pGameData = _pGameData;
00041         m_pStream = m_pGameData->GetStream();
00042 }
00043 
00044 K3dOptions::~K3dOptions ( void )
00045 {
00046 }
00047 
00049 bool K3dOptions::LoadOptions()
00050 {
00051         // Load default ini file K3dEngineIni.lua
00052         cout << "bool K3dOptions::LoadOptions()" << endl;
00053         //K3dString strIni = K_STR_INI;
00054         //strIni = m_pGameData->GetPath(K_PATH_APP) + strIni;
00055         //cout << "strIni = " << strIni.GetString() << endl;
00056         //cout << "strIni = " << K3D_STR_INI << endl;
00057         K3dString strIni = m_pGameData->GetSysHome() + K3D_STR_SHARE_PATH + K3D_STR_INI;
00058         if ( m_pStream->LoadIni ( strIni ) )
00059         {
00060                 // Load graphic option from ini file
00061                 LoadGraphics();
00062                 // Load texture option from ini file
00063                 LoadTexture();
00064                 // Load bitmap font options from ini file
00065                 LoadFontBmp();
00066                 // Load script
00067                 LoadScript();
00068         }
00069         else
00070         {
00071                 cerr << "Error -- K3dOptions::LoadOptions() -- Error file " << strIni.GetString() << " doesn`t loaded" << endl;
00072                 return false;
00073         }
00074 
00075         return true;
00076 }
00077 
00079 void K3dOptions::LoadFontBmp()
00080 {
00081         cout << "void K3dOptions::LoadFontBmp()" << endl;
00082         TFontBmpOption *ptOption = new TFontBmpOption;
00083 
00084         K3dString strFc = "void K3dOptions::LoadFontBmp() -- ";
00085         K3dString strOut;
00086 
00087         // Get lua from global data
00088         K3dLua *pLua = m_pGameData->GetLua();
00089         pLua->LuaGetGlobal ( K_STR_FONTBMP );
00090         if ( !pLua->LuaIsTable ( -1 ) )
00091         {
00092                 strOut = strFc + K_STR_FONTBMP;
00093                 strOut += " is not a valid bmp font table";
00094                 pLua->LuaError ( strOut.GetString().c_str() );
00095         }
00096         ptOption->bItalic = pLua->LuaGetFieldBool ( K_STR_ITALIC );
00097         cout << "bItalic = " << ptOption->bItalic << endl;
00098         ptOption->bDrawFps = pLua->LuaGetFieldBool ( K_STR_DRAWFPS );
00099         cout << "bDrawFps = " << ptOption->bDrawFps << endl;
00100         ptOption->bDrawCamPos = pLua->LuaGetFieldBool ( K_STR_DRAW_CAM_POS );
00101         cout << "bDrawCamPos = " << ptOption->bDrawCamPos << endl;
00102         ptOption->bDrawNumFaces = pLua->LuaGetFieldBool ( K_STR_DRAW_NUM_FACES );
00103         cout << "bDrawNumFaces = " << ptOption->bDrawNumFaces << endl;
00104 
00105         m_pGameData->SetFontBmpOption ( ptOption );
00106 }
00107 

Generated on Thu Aug 16 23:53:28 2007 for K3dEngine by  doxygen 1.5.0