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)