Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ExCOptions Class Reference

#include <ExCOptions.h>


Public Methods

 ExCOptions ()
bool init (void)
bool load (void)
bool reload (void)
int getWindowResolutionX (void)
int getWindowResolutionY (void)
int getWindowDepth (void)
int getWindowRate (void)
bool getWindowFullscreen (void)
bool getWindowShowfps (void)
bool getDebugStyle (void)

Private Methods

bool load (int)
bool create_options_file (void)

Private Attributes

int type_of_debug
ExCFileoptions_file
int resolution_x
int resolution_y
int rate
int depth
std::string fullscreen
std::string fps
int debug_style


Constructor & Destructor Documentation

ExCOptions  
 

Definition at line 26 of file ExCOptions.cpp.

References debug_style, depth, EXC_NORMAL, EXNIHILO_REP_NAME, fps, fullscreen, options_file, rate, resolution_x, resolution_y, and type_of_debug.

00026                         {
00027         type_of_debug = EXC_NORMAL;
00028 #ifdef UNIX_SRC
00029         std::string where = getenv ("HOME");
00030         where += EXNIHILO_REP_NAME;
00031         where += "/options";
00032         options_file = new ExCFile (where);
00033 #endif
00034         
00035         // for the resolution
00036         resolution_x = 800;
00037         resolution_y = 600;
00038         depth = 16;
00039         rate = 75;
00040         
00041         fullscreen = "yes";
00042         fps = "yes";
00043         
00044         debug_style = EXC_NORMAL;
00045 }


Member Function Documentation

bool create_options_file void    [private]
 

Definition at line 47 of file ExCOptions.cpp.

References ExCFile::add(), ExCFile::addLine(), EXNIHILO_REP_NAME, and options_file.

Referenced by init().

00047                                           {
00048 #ifdef UNIX_SRC
00049         std::string where = getenv ("HOME");
00050         where += EXNIHILO_REP_NAME;
00051 
00052         // checking for the directory
00053         struct stat stbuf;
00054         if (stat (where.data (), &stbuf) == 0) {
00055                 if (! S_ISDIR (stbuf.st_mode)) {
00056                         std::cout << where << " is not a directory, please remove it !!!" 
00057                                                         << std::endl;
00058                         return false;
00059                 } else {
00060                         std::cout << where << " created" << std::endl;
00061                 }
00062         } else {
00063                 if (mkdir (where.data (), 0755) != 0) {
00064                         std::cout << "Can not create " << where << std::endl;
00065                         return false;
00066                 } else {
00067                         std::cout << where << " created" << std::endl;
00068                 }
00069         }
00070         // ok, now, we create the options file
00071         options_file->add ("# ExNihilo Options file");
00072         options_file->add ("# you can comment a line with '#'");
00073         options_file->addLine ();
00074 
00075         // DEBUG
00076         options_file->add ("# type of debug : NORMAL, DEBUG, TRACE, LOG");
00077         options_file->add ("# you need to compile ExNihilo with debug enabled to use this option");
00078         options_file->add ("debug.type: NORMAL");
00079         options_file->addLine ();
00080 
00081         // SCREEN
00082         options_file->add ("# resolution of the screen : format WidthxHeigth:bpp@frequency");
00083         options_file->add ("# WARNING: a too big frequency may damage your screen and/or video card");
00084         options_file->add ("screen.resolution: 800x600:16@75");
00085         options_file->addLine ();
00086         options_file->add ("# start in fullscreen ? [true|false]");
00087         options_file->add ("screen.fullscreen: yes");
00088         options_file->addLine ();
00089         options_file->add ("# show fps ? [true|false]");
00090         options_file->add ("screen.fps: yes");
00091         options_file->addLine ();
00092 
00093 #endif // UNIX_SRC
00094 
00095         return true;
00096 }

bool getDebugStyle void    [inline]
 

Definition at line 82 of file ExCOptions.h.

References debug_style.

00082 { return debug_style; }

int getWindowDepth void    [inline]
 

Definition at line 78 of file ExCOptions.h.

References depth.

Referenced by ExManagerWindow::ExManagerWindow().

00078 { return depth; }

bool getWindowFullscreen void   
 

Definition at line 171 of file ExCOptions.cpp.

References fullscreen.

Referenced by ExManagerWindow::Apply(), and ExManagerWindow::ExManagerWindow().

00171                                           { 
00172         return (fullscreen == "yes") ? true : false; 
00173 }

int getWindowRate void    [inline]
 

Definition at line 79 of file ExCOptions.h.

References rate.

Referenced by ExManagerWindow::ExManagerWindow().

00079 { return rate; }

int getWindowResolutionX void    [inline]
 

Definition at line 76 of file ExCOptions.h.

References resolution_x.

Referenced by ExManagerWindow::ExManagerWindow(), and main().

00076 { return resolution_x; }

int getWindowResolutionY void    [inline]
 

Definition at line 77 of file ExCOptions.h.

References resolution_y.

Referenced by ExManagerWindow::ExManagerWindow(), and main().

00077 { return resolution_y; }

bool getWindowShowfps void   
 

Definition at line 175 of file ExCOptions.cpp.

References fps.

Referenced by ExManagerWindow::ExManagerWindow(), and main().

00175                                        { 
00176         return (fps == "yes") ? true : false; 
00177 }

bool init void   
 

Definition at line 98 of file ExCOptions.cpp.

References create_options_file(), EXC_OPTIONS_ALL, ExCFile::exist(), load(), options_file, RO, and ExCFile::setOpenMode().

Referenced by main().

00098                            {
00099 #ifdef UNIX_SRC
00100         options_file->setOpenMode (RO);
00101         if (! options_file->exist ()) {
00102                 create_options_file ();
00103         }
00104 #endif
00105         load (EXC_OPTIONS_ALL);
00106 
00107         return true;
00108 }

bool load void   
 

Definition at line 163 of file ExCOptions.cpp.

References EXC_OPTIONS_ALL.

Referenced by init(), and reload().

00163                            {
00164         return load (EXC_OPTIONS_ALL);
00165 }

bool load int    [private]
 

Definition at line 110 of file ExCOptions.cpp.

References debug_style, depth, EXC_DEBUG, EXC_LOG, EXC_NORMAL, EXC_TRACE, fps, fullscreen, ExCFile::getContent(), options_file, rate, resolution_x, resolution_y, RO, and ExCFile::setOpenMode().

00110                                {
00111 #ifdef UNIX_SRC
00112         options_file->setOpenMode (RO);
00113         // we take the content of the options file
00114         std::vector<std::string> v = options_file->getContent ();
00115         // we analyse this content
00116         std::vector<std::string>::iterator i = v.begin ();
00117         std::string analyze;
00118         while (i != v.end ()) {
00119                 analyze = *i++;
00120                 if (analyze[0] == '#') 
00121                         // if line begin by # so it's a comment
00122                         continue;
00123                 else {
00124                         if (analyze.find ('.') < analyze.size ()) {
00125                                 string type = analyze.substr (0, analyze.find ('.'));
00126                                 string under_type = analyze.substr (analyze.find ('.') + 1, analyze.size ());
00127                                 under_type = analyze.substr (analyze.find ('.') + 1, analyze.find (':') - analyze.find ('.') - 1);
00128                                 string value = analyze.substr (analyze.find (':') + 2, analyze.size ());
00129                                 
00130                                 if (type == "debug") {
00131                                         if (under_type == "type") {
00132                                                 if (value == "NORMAL") 
00133                                                         debug_style = EXC_NORMAL;
00134                                                 else if (value == "DEBUG") 
00135                                                         debug_style = EXC_DEBUG;
00136                                                 else if (value == "TRACE") 
00137                                                         debug_style = EXC_TRACE;
00138                                                 else if (value == "LOG") 
00139                                                         debug_style = EXC_LOG;
00140                                         }
00141                                 } else if (type == "screen") {
00142                                         if (under_type == "resolution") {
00143                                                 resolution_x = atoi (value.substr (0, value.find ('x')).data ());
00144                                                 value.erase (0, value.find ('x') + 1);
00145                                                 resolution_y = atoi (value.substr (0, value.find (':')).data ());
00146                                                 value.erase (0, value.find (':') + 1);
00147                                                 depth = atoi (value.substr (0, value.find ('@')).data ());
00148                                                 value.erase (0, value.find ('@') + 1);
00149                                                 rate = atoi (value.data ());
00150                                         } else if (under_type == "fullscreen") {
00151                                                 fullscreen = value;
00152                                         } else if (under_type == "fps") {
00153                                                 fps = value;
00154                                         }
00155                                 }
00156                         }
00157                 }                               
00158         }
00159 #endif  
00160         return true;
00161 }

bool reload void   
 

Definition at line 167 of file ExCOptions.cpp.

References EXC_OPTIONS_RELOAD, and load().

00167                              {
00168         return load (EXC_OPTIONS_RELOAD);
00169 }


Field Documentation

int debug_style [private]
 

Definition at line 67 of file ExCOptions.h.

Referenced by ExCOptions(), getDebugStyle(), and load().

int depth [private]
 

Definition at line 63 of file ExCOptions.h.

Referenced by ExCOptions(), getWindowDepth(), and load().

std::string fps [private]
 

Definition at line 65 of file ExCOptions.h.

Referenced by ExCOptions(), getWindowShowfps(), and load().

std::string fullscreen [private]
 

Definition at line 64 of file ExCOptions.h.

Referenced by ExCOptions(), getWindowFullscreen(), and load().

ExCFile* options_file [private]
 

Definition at line 55 of file ExCOptions.h.

Referenced by create_options_file(), ExCOptions(), init(), and load().

int rate [private]
 

Definition at line 62 of file ExCOptions.h.

Referenced by ExCOptions(), getWindowRate(), and load().

int resolution_x [private]
 

Definition at line 60 of file ExCOptions.h.

Referenced by ExCOptions(), getWindowResolutionX(), and load().

int resolution_y [private]
 

Definition at line 61 of file ExCOptions.h.

Referenced by ExCOptions(), getWindowResolutionY(), and load().

int type_of_debug [private]
 

Definition at line 54 of file ExCOptions.h.

Referenced by ExCOptions().


The documentation for this class was generated from the following files:
Generated on Tue Aug 6 20:27:22 2002 for ExNihilo by doxygen1.2.17