steed/src/sdl-instead/main.c

118 lines
2.1 KiB
C
Raw Normal View History

#include "externals.h"
#include "internals.h"
2009-08-26 08:25:53 +03:00
extern int debug_init(void);
extern void debug_done(void);
int debug_sw = 0;
int noauto_sw = 0;
2009-08-31 22:50:29 +03:00
char *game_sw = NULL;
2009-09-03 13:34:53 +03:00
char *games_sw = NULL;
2009-09-07 09:14:26 +03:00
char *theme_sw = NULL;
2009-09-03 13:34:53 +03:00
char *themes_sw = NULL;
2009-02-21 12:52:44 +02:00
int main(int argc, char **argv)
{
2009-08-26 08:25:53 +03:00
int i;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i],"-alsa"))
alsa_sw = 1;
else if (!strcmp(argv[i], "-nosound"))
nosound_sw = 1;
else if (!strcmp(argv[i], "-fullscreen"))
fullscreen_sw = 1;
else if (!strcmp(argv[i], "-window"))
window_sw = 1;
else if (!strcmp(argv[i], "-debug"))
debug_sw = 1;
else if (!strcmp(argv[i], "-noautosave"))
noauto_sw = 1;
2009-08-31 22:50:29 +03:00
else if (!strcmp(argv[i], "-game")) {
if ((i + 1) < argc)
game_sw = argv[++i];
else
game_sw = "";
2009-09-07 09:14:26 +03:00
} else if (!strcmp(argv[i], "-theme")) {
if ((i + 1) < argc)
theme_sw = argv[++i];
else
theme_sw = "";
2009-09-03 13:34:53 +03:00
} else if (!strcmp(argv[i], "-gamespath")) {
if ((i + 1) < argc)
games_sw = argv[++i];
else
games_sw = "";
} else if (!strcmp(argv[i], "-themespath")) {
if ((i + 1) < argc)
themes_sw = argv[++i];
else
themes_sw = "";
2009-08-31 22:50:29 +03:00
}
2009-09-03 13:34:53 +03:00
2009-08-26 08:25:53 +03:00
}
if (debug_sw) {
debug_init();
}
menu_langs_lookup(LANG_PATH);
if (!langs_nr) {
fprintf(stderr, "No languages found in: %s.\n", LANG_PATH);
exit(1);
}
2009-09-03 13:34:53 +03:00
if (games_sw)
games_lookup(games_sw);
if (games_lookup(GAMES_PATH))
fprintf(stderr, "No games found in: %s.\n", GAMES_PATH);
if (themes_sw)
themes_lookup(themes_sw);
2009-08-26 08:25:53 +03:00
themes_lookup(THEMES_PATH);
2009-09-03 13:34:53 +03:00
themes_lookup(game_local_themes_path());
2009-08-26 08:25:53 +03:00
games_lookup(game_local_games_path());
2009-09-03 13:34:53 +03:00
2009-08-26 08:25:53 +03:00
cfg_load();
if (noauto_sw)
opt_autosave = 0;
2009-09-15 12:47:23 +03:00
if (window_sw)
opt_fs = 0;
if (fullscreen_sw)
opt_fs = 1;
2009-09-01 20:42:05 +03:00
if (game_sw) {
2009-09-07 09:14:26 +03:00
FREE(opt_game);
2009-08-31 22:50:29 +03:00
opt_game = game_sw;
2009-09-01 20:42:05 +03:00
}
2009-09-07 09:14:26 +03:00
if (theme_sw) {
FREE(opt_theme);
opt_theme = theme_sw;
}
2009-09-01 20:42:05 +03:00
2009-08-26 08:25:53 +03:00
if (opt_theme)
game_theme_select(opt_theme);
if (!curtheme_dir)
2009-08-26 08:25:53 +03:00
game_theme_select(DEFAULT_THEME);
// Initialize SDL
2009-09-10 20:07:32 +03:00
if (gfx_init() < 0)
return -1;
2009-02-21 12:52:44 +02:00
2009-08-26 08:25:53 +03:00
if (game_init(opt_game)) {
game_error(opt_game);
2009-02-21 12:52:44 +02:00
}
game_loop();
2009-08-26 08:25:53 +03:00
cfg_save();
2009-02-21 12:52:44 +02:00
game_done();
2009-08-26 08:25:53 +03:00
if (debug_sw)
debug_done();
2009-09-10 20:07:32 +03:00
gfx_done();
2009-02-21 12:52:44 +02:00
return 0;
}
2009-08-26 08:25:53 +03:00