38 #if defined (WIN32) || defined (__APPLE__)
57 #ifndef SINGLE_DIR_INST
58 adonthellrc = string (getenv (
"HOME")) +
"/.adonthell";
60 adonthellrc = string (
".");
70 cout <<
"Usage: " << argv[0] <<
" [OPTIONS] GAME" << endl;
72 cout <<
"Where [OPTIONS] can be:\n";
73 cout <<
"-h print this help message" << endl;
74 cout <<
"-d print the data directory and exit" << endl;
75 cout <<
"-v print version and exit" << endl;
76 cout <<
"-l list installed games and exit" << endl;
77 cout <<
"-g dir play the game contained in dir (for development only)" << endl;
78 cout <<
"-c byte-compile all Python scripts in this directory (for " << endl;
79 cout <<
" development only)" << endl;
98 while ((d = readdir (mydir)) != NULL)
100 string s (d->d_name);
101 if (s !=
"." && s !=
"..")
106 cout <<
"Installed games (Suitable for the GAME parameter):\n";
108 cout <<
" - " << d->d_name << endl;
112 if (nogames) cout <<
"No games available.\n";
124 c = getopt (argc, argv,
"lcdhvg:");
141 cout << VERSION << endl;
161 DIR * mydir = opendir (
gamedir.c_str ());
165 cerr <<
"Cannot open directory " <<
gamedir <<
"!" << endl;
185 if (argc - optind != 1)
202 while ((d = readdir (mydir)) != NULL)
204 if (
string (d->d_name) == argv[optind]) found =
true;
211 cerr <<
"Game '" << argv[optind] <<
"' can't be found.\n"
212 <<
"Run '" << argv[0] <<
" -l' for a list of available games.\n";
222 string tfile =
gamedir +
"/gamename.txt";
223 ifstream f (tfile.c_str ());
226 cerr <<
"Directory " <<
gamedir <<
" is not a valid game directory.\n";
245 adonthellrc = c->adonthellrc;
253 return (
char *) adonthellrc.c_str ();
262 fname = adonthellrc +
"/adonthellrc";
264 fname = adonthellrc +
"/adonthell.ini";
267 ofstream rc (fname.c_str ());
269 rc <<
"# Sample Adonthell configuration file;\n"
270 <<
"# edit to your needs!\n\n"
271 <<
"# Screen-mode num\n# 0 Windowed mode\n"
272 <<
"# 1 Fullscreen mode\n Screen-mode " << (int)
screen_mode
273 <<
"\n\n" <<
"# Double-size num\n# 0 320x240 mode\n"
274 <<
"# 1 640x480 (double) mode\n Double-size "
275 << (
int) double_screen <<
"\n\n"
276 <<
"# Language [locale]\n# Where locale has the form fr_FR or de_DE, etc.\n"
277 <<
" Language [" <<
language <<
"]\n\n"
278 <<
"# Font [font.ttf]\n# Path to a true type font to use. Leave empty for default\n"
279 <<
" Font [" << font <<
"]\n\n"
280 <<
"# Quick-load num\n# 0 off\n# 1 on\n Quick-load "
282 <<
"# Audio-channels num\n# 0 Mono\n# 1 Stereo\n"
284 <<
"# Audio-resolution num\n# 0 8 bit\n# 1 16 bit\n"
286 <<
"# Audio-sample-rate num\n# 0 11025 Hz\n# 1 22050 Hz\n# 2 44100 Hz\n"
288 <<
"# Audio-volume num\n# 0 - 100 %\n"
290 <<
"# Version number of this file. Please don't edit\n Version [" << VERSION <<
"]\n";
298 u_int32 major = 0, minor = 0, micro = 0, MAJOR, MINOR, MICRO;
299 char suffix[16] =
"\0", SUFFIX[16] =
"\0";
303 fname = adonthellrc +
"/adonthellrc";
305 fname = adonthellrc +
"/adonthell.ini";
310 mkdir (adonthellrc.c_str ());
312 mkdir (adonthellrc.c_str (), 0700);
316 prefsin = fopen (fname.c_str (),
"r");
324 if (!(prefsin = fopen (fname.c_str (),
"r")))
326 fprintf (stderr,
"*** warning: prefs::read_adonthellrc: creating config file failed\n");
346 case PREFS_SCREEN_MODE:
352 case PREFS_DOUBLE_SCREEN:
358 case PREFS_QUICK_LOAD:
364 case PREFS_AUDIO_RESOLUTION:
370 case PREFS_AUDIO_CHANNELS:
376 case PREFS_AUDIO_SAMPLE_RATE:
382 case PREFS_AUDIO_VOLUME:
392 sscanf (s.c_str (),
"%d.%d.%d%15s", &major, &minor, µ, suffix);
402 sscanf (VERSION,
"%d.%d.%d%15s", &MAJOR, &MINOR, &MICRO, SUFFIX);
406 (major == MAJOR && minor < MINOR) ||
407 (major == MAJOR && minor == MINOR && micro < MICRO) ||
408 strcmp (suffix, SUFFIX) != 0)
bool read_adonthellrc()
Reads the configuration file.
char * get_adonthellrc()
Returns the path to the user's private Adonthell directory.
FILE * prefsin
The config file opened by the lexical scanner.
string gamedir
Path of the directory that contains the game running at present.
Adonthell's configuration.
u_int8 audio_sample_rate
The sample rate: 11025 Hz (0), 22050 Hz (1) or 44100 Hz (2)
#define u_int32
32 bits long unsigned integer
void print_help_message(char *argv[])
Displays the help message - for internal use only.
string language
Language to use if NLS was compiled in.
static string global_data_dir()
Returns the absolute path to the global data directory.
int parse_adonthellrc(int &, string &)
Start the lexical scanner to parse the config file, usually fount at ~/.adonthell/adonthellrc.
u_int8 quick_load
Whether the quick-load feature is enabled (1) or not (0)
Defines the python class. This file is named this way so it doesn't conflicts with Python...
u_int8 audio_volume
The volume: a value betwen 0 and 100.
static void exec_string(char *s)
Execute Python statements contained in a string.
void parse_arguments(int argc, char *argv[])
See whether any options have been specified on the command line.
void write_adonthellrc()
Writes a default configuration file with the values set in the constructor.
string game_name
Name of the game that is running at present.
u_int8 audio_resolution
The resolution: 8 bit (0) or 16 bit (1)
void print_available_games()
Displays the available games - for internal use only.
u_int8 audio_channels
The number of channels: mono (0) or stereo (1).
This class contains the engine's configuration read either from the config file or from the command l...
static void cleanup()
Cleanup Python.
u_int8 screen_mode
Whether the engine shall run in window (0) or fullscreen (1) mode.
static void init()
Initialise Python and insert the Adonthell include paths.