Adonthell
0.4
|
00001 /* 00002 $Id: prefs.h,v 1.17 2004/10/25 06:55:01 ksterker Exp $ 00003 00004 Copyright (C) 2000/2002/2004 Kai Sterker <kaisterker@linuxgames.com> 00005 Part of the Adonthell Project http://adonthell.linuxgames.com 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details. 00013 */ 00014 00015 /** 00016 * @file prefs.h 00017 * 00018 * @author Kai Sterker 00019 * @brief Adonthell's configuration 00020 */ 00021 00022 #ifndef __PREFS_H__ 00023 #define __PREFS_H__ 00024 00025 #include <string> 00026 #include <fstream> 00027 #include "types.h" 00028 00029 #ifndef SWIG 00030 using namespace std; 00031 #endif 00032 00033 /** 00034 * The config file opened by the lexical scanner 00035 */ 00036 extern FILE* prefsin; 00037 00038 /** 00039 * Start the lexical scanner to parse the config file, 00040 * usually fount at ~/.adonthell/adonthellrc 00041 */ 00042 extern int parse_adonthellrc (int&, string&); 00043 00044 /** 00045 * Returncodes of the scanner for the different entries 00046 * of the configuration file. 00047 */ 00048 enum 00049 { 00050 PREFS_UNKNOWN = 0, 00051 PREFS_SCREEN_MODE = 1, 00052 PREFS_LANGUAGE = 2, 00053 PREFS_FONT = 3, 00054 PREFS_QUICK_LOAD = 4, 00055 PREFS_AUDIO_CHANNELS = 5, 00056 PREFS_AUDIO_RESOLUTION = 6, 00057 PREFS_AUDIO_SAMPLE_RATE = 7, 00058 PREFS_AUDIO_VOLUME = 8, 00059 PREFS_VERSION = 9, 00060 PREFS_NUM = 10, 00061 PREFS_STR = 11, 00062 PREFS_DOUBLE_SCREEN = 12, 00063 }; 00064 00065 00066 /** 00067 * This class contains the engine's configuration read either from the 00068 * %config file or from the command line. 00069 */ 00070 class config 00071 { 00072 public: 00073 /** 00074 * Constructor. Initializes all configuration options with default 00075 * values. 00076 * - Language: English 00077 * - Screen mode: windowed 00078 * - Quick load: enabled 00079 * - Audio: High quality (44.1kHz, 16 bit, stereo) 00080 * - Volume: 100% 00081 * - Config file: $HOME/.adonthell/adonthellrc 00082 */ 00083 config (); 00084 00085 /** 00086 * See whether any options have been specified on the command line. 00087 * Possible command line options are 00088 * - <b>\-h</b> Print help message 00089 * - <b>\-d</b> Print the data directory 00090 * - <b>\-v</b> Print the version number 00091 * - <b>\-l</b> List games found in the gamedir 00092 * - <b>\-g dir</b> Play %game contained in dir 00093 * - <b>\-c</b> Byte-compile all Python scripts in the current directory 00094 * 00095 * @param argc argument count 00096 * @param argv argument vector 00097 */ 00098 void parse_arguments (int argc, char * argv[]); 00099 00100 /** 00101 * Writes a default configuration file with the values set in the 00102 * constructor 00103 * @sa config::config () 00104 */ 00105 void write_adonthellrc (); 00106 /** 00107 * Reads the configuration file. If it cannot find the file, it 00108 * tries to write a default one. 00109 * @return <b>true</b> on success, <b>false</b> otherwise. 00110 */ 00111 bool read_adonthellrc (); 00112 /** 00113 * Returns the path to the user's private Adonthell directory. 00114 * Usually this is $HOME/.adonthell/ and will contain his personal 00115 * configuration as well as all saved games. 00116 */ 00117 char *get_adonthellrc (); 00118 00119 /** 00120 * @name Configuration options 00121 */ 00122 //@{ 00123 /** 00124 * Language to use if NLS was compiled in. 00125 */ 00126 string language; 00127 string font; 00128 /** 00129 * Name of the %game that is running at present. 00130 */ 00131 string game_name; 00132 /** 00133 * Path of the directory that contains the %game running at present. 00134 */ 00135 string gamedir; 00136 /** 00137 * Whether the engine shall run in window (0) or fullscreen (1) mode. 00138 */ 00139 u_int8 screen_mode; 00140 u_int8 double_screen; 00141 /** 00142 * Whether the quick-load feature is enabled (1) or not (0) 00143 */ 00144 u_int8 quick_load; 00145 /** 00146 * The number of channels: mono (0) or stereo (1). 00147 */ 00148 u_int8 audio_channels; 00149 /** 00150 * The resolution: 8 bit (0) or 16 bit (1) 00151 */ 00152 u_int8 audio_resolution; 00153 /** 00154 * The sample rate: 11025 Hz (0), 22050 Hz (1) or 44100 Hz (2) 00155 */ 00156 u_int8 audio_sample_rate; 00157 /** 00158 * The volume: a value betwen 0 and 100. 0 means that audio 00159 * is completely off. 00160 */ 00161 u_int8 audio_volume; 00162 //@} 00163 00164 private: 00165 config & operator = (const config*); 00166 00167 string adonthellrc; // Path to the adonthellrc file: $HOME/.adonthell/ 00168 }; 00169 00170 #endif // __PREFS_H__