Go to the documentation of this file.
59 cout <<
"Usage: " << argv[0] <<
" [OPTIONS] GAME" << endl;
61 cout <<
"Where [OPTIONS] can be:\n";
62 cout <<
"-h print this help message" << endl;
63 cout <<
"-d print the data directory and exit" << endl;
64 cout <<
"-v print version and exit" << endl;
65 cout <<
"-l list installed games and exit" << endl;
66 cout <<
"-g dir play the game contained in dir (for development only)" << endl;
67 cout <<
"-c byte-compile all Python scripts in this directory (for " << endl;
68 cout <<
" development only)" << endl;
87 while ((d = readdir (mydir)) != NULL)
90 if (s !=
"." && s !=
"..")
95 cout <<
"Installed games (Suitable for the GAME parameter):\n";
97 cout <<
" - " << d->d_name << endl;
101 if (nogames) cout <<
"No games available.\n";
113 c = getopt (argc, argv,
"lcdhvg:");
130 cout << VERSION << endl;
137 #if PY_VERSION_HEX < 0x03020000
142 python::exec_string (
"import compileall; compileall.compile_dir (\".\", maxlevels=0, legacy=True);");
156 DIR * mydir = opendir (
gamedir.c_str ());
160 cerr <<
"Cannot open directory " <<
gamedir <<
"!" << endl;
180 if (argc - optind != 1)
197 while ((d = readdir (mydir)) != NULL)
199 if (
string (d->d_name) == argv[optind]) found =
true;
206 cerr <<
"Game '" << argv[optind] <<
"' can't be found.\n"
207 <<
"Run '" << argv[0] <<
" -l' for a list of available games.\n";
217 string tfile =
gamedir +
"/gamename.txt";
218 ifstream f (tfile.c_str ());
221 cerr <<
"Directory " <<
gamedir <<
" is not a valid game directory.\n";
241 adonthellrc = c->adonthellrc;
249 return (
char *) adonthellrc.c_str ();
258 fname = adonthellrc +
"/adonthellrc";
260 fname = adonthellrc +
"/adonthell.ini";
263 ofstream rc (fname.c_str ());
265 rc <<
"# Sample Adonthell configuration file;\n"
266 <<
"# edit to your needs!\n\n"
267 <<
"# Screen-mode num\n# 0 Windowed mode\n# 1 Letterbox mode\n"
268 <<
"# 2 Fullscreen mode\n Screen-mode " << (int)
screen_mode
269 <<
"\n\n" <<
"# Display num\n# Index of the display to use in fullscreen mode"
270 <<
"\n Display " << (
int)
display <<
"\n\n"
271 <<
"# Language [locale]\n# Where locale has the form fr_FR or de_DE, etc.\n"
272 <<
" Language [" <<
language <<
"]\n\n"
273 <<
"# Font [font.ttf]\n# Path to a true type font to use. Leave empty for default\n"
274 <<
" Font [" << font <<
"]\n\n"
275 <<
"# Quick-load num\n# 0 off\n# 1 on\n Quick-load "
277 <<
"# Audio-channels num\n# 0 Mono\n# 1 Stereo\n"
279 <<
"# Audio-resolution num\n# 0 8 bit\n# 1 16 bit\n"
281 <<
"# Audio-sample-rate num\n# 0 11025 Hz\n# 1 22050 Hz\n# 2 44100 Hz\n"
283 <<
"# Audio-volume num\n# 0 - 100 %\n"
285 <<
"# Version number of this file. Please don't edit\n Version [" << VERSION <<
"]\n";
293 u_int32 major = 0, minor = 0, micro = 0, MAJOR, MINOR, MICRO;
294 char suffix[16] =
"\0", SUFFIX[16] =
"\0";
298 fname = adonthellrc +
"/adonthellrc";
300 fname = adonthellrc +
"/adonthell.ini";
304 prefsin = fopen (fname.c_str (),
"r");
312 if (!(
prefsin = fopen (fname.c_str (),
"r")))
314 fprintf (stderr,
"*** warning: prefs::read_adonthellrc: creating config file failed\n");
334 case PREFS_SCREEN_MODE:
346 case PREFS_QUICK_LOAD:
352 case PREFS_AUDIO_RESOLUTION:
358 case PREFS_AUDIO_CHANNELS:
364 case PREFS_AUDIO_SAMPLE_RATE:
370 case PREFS_AUDIO_VOLUME:
380 sscanf (s.c_str (),
"%u.%u.%u%15s", &major, &minor, µ, suffix);
390 sscanf (VERSION,
"%u.%u.%u%15s", &MAJOR, &MINOR, &MICRO, SUFFIX);
394 (major == MAJOR && minor < MINOR) ||
395 (major == MAJOR && minor == MINOR && micro < MICRO) ||
396 strcmp (suffix, SUFFIX) != 0)
u_int8 audio_channels
The number of channels: mono (0) or stereo (1).
u_int8 display
Index of the display to use for fullscreen mode.
bool read_adonthellrc()
Reads the configuration file.
#define u_int32
32 bits long unsigned integer
string game_name
Name of the game that is running at present.
Defines the python class. This file is named this way so it doesn't conflicts with Python....
void print_available_games()
Displays the available games - for internal use only.
Adonthell's configuration.
char * get_adonthellrc()
Returns the path to the user's private Adonthell directory.
FILE * prefsin
The config file opened by the lexical scanner.
string language
Language to use if NLS was compiled in.
u_int8 audio_volume
The volume: a value betwen 0 and 100.
int parse_adonthellrc(int &, string &)
Start the lexical scanner to parse the config file, usually fount at ~/.adonthell/adonthellrc.
static void cleanup()
Cleanup Python.
This class contains the engine's configuration read either from the config file or from the command l...
u_int8 screen_mode
Whether the engine shall run in window (0) or fullscreen (1) mode.
string gamedir
Path of the directory that contains the game running at present.
static void exec_string(const 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.
u_int8 audio_resolution
The resolution: 8 bit (0) or 16 bit (1)
u_int8 audio_sample_rate
The sample rate: 11025 Hz (0), 22050 Hz (1) or 44100 Hz (2)
void write_adonthellrc()
Writes a default configuration file with the values set in the constructor.
static string get_system_dir(const sys_dir_type &type)
Return the OS-specific directory of the given type.
u_int8 quick_load
Whether the quick-load feature is enabled (1) or not (0)
void print_help_message(char *argv[])
Displays the help message - for internal use only.
static void init()
Initialise Python and insert the Adonthell include paths.
static string global_data_dir()
Returns the absolute path to the global data directory.