[Super-tux-commit] supertux/lib/app globals.cpp,1.3,1.4 globals.h,1.3,1.4 setup.cpp,1.3,1.4 setup.h,
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-24 11:50:21
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15197/lib/app Modified Files: globals.cpp globals.h setup.cpp setup.h Log Message: SuperTux lib became a bit more independend of SupeTux. Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/setup.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- setup.cpp 22 Jul 2004 19:07:49 -0000 1.3 +++ setup.cpp 24 Jul 2004 11:50:09 -0000 1.4 @@ -60,11 +60,6 @@ #define DATA_PREFIX "./data/" #endif -/* Screen proprities: */ -/* Don't use this to test for the actual screen sizes. Use screen->w/h instead! */ -#define SCREEN_W 800 -#define SCREEN_H 600 - /* Local function prototypes: */ void seticon(void); @@ -297,6 +292,13 @@ free(strings[i]); } +void SuperTux::st_info_setup(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version) +{ +package_name = _package_name; +package_symbol_name = _package_symbol_name; +package_version = _package_version; +} + /* --- SETUP --- */ /* Set SuperTux configuration and save directories */ void SuperTux::st_directory_setup(void) @@ -310,10 +312,11 @@ else home = "."; + std::string st_dir_tmp = "/." + package_symbol_name; st_dir = (char *) malloc(sizeof(char) * (strlen(home) + - strlen("/.supertux") + 1)); + strlen(st_dir_tmp.c_str()) + 1)); strcpy(st_dir, home); - strcat(st_dir, "/.supertux"); + strcat(st_dir,st_dir_tmp.c_str()); /* Remove .supertux config-file from old SuperTux versions */ if(faccessible(st_dir)) @@ -352,7 +355,7 @@ datadir = exedir + "../data"; // SuperTux run from source dir if (access(datadir.c_str(), F_OK) != 0) { - datadir = exedir + "../share/supertux"; // SuperTux run from PATH + datadir = exedir + "../share/" + package_symbol_name; // SuperTux run from PATH if (access(datadir.c_str(), F_OK) != 0) { // If all fails, fall back to compiled path datadir = DATA_PREFIX; @@ -431,7 +434,7 @@ } -void SuperTux::st_video_setup(void) +void SuperTux::st_video_setup(unsigned int screen_w, unsigned int screen_h) { /* Init SDL Video: */ if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -445,21 +448,21 @@ /* Open display: */ if(use_gl) - st_video_setup_gl(); + st_video_setup_gl(screen_w, screen_h); else - st_video_setup_sdl(); + st_video_setup_sdl(screen_w, screen_h); Surface::reload_all(); /* Set window manager stuff: */ - SDL_WM_SetCaption("SuperTux " VERSION, "SuperTux"); + SDL_WM_SetCaption((package_name + " " + package_version).c_str(), package_name.c_str()); } -void SuperTux::st_video_setup_sdl(void) +void SuperTux::st_video_setup_sdl(unsigned int screen_w, unsigned int screen_h) { if (use_fullscreen) { - screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */ + screen = SDL_SetVideoMode(screen_w, screen_h, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */ if (screen == NULL) { fprintf(stderr, @@ -472,7 +475,7 @@ } else { - screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_HWSURFACE | SDL_DOUBLEBUF ); + screen = SDL_SetVideoMode(screen_w, screen_h, 0, SDL_HWSURFACE | SDL_DOUBLEBUF ); if (screen == NULL) { @@ -485,7 +488,7 @@ } } -void SuperTux::st_video_setup_gl(void) +void SuperTux::st_video_setup_gl(unsigned int screen_w, unsigned int screen_h) { #ifndef NOOPENGL @@ -497,7 +500,7 @@ if (use_fullscreen) { - screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_FULLSCREEN | SDL_OPENGL) ; /* | SDL_HWSURFACE); */ + screen = SDL_SetVideoMode(screen_w, screen_h, 0, SDL_FULLSCREEN | SDL_OPENGL) ; /* | SDL_HWSURFACE); */ if (screen == NULL) { fprintf(stderr, @@ -510,7 +513,7 @@ } else { - screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_OPENGL); + screen = SDL_SetVideoMode(screen_w, screen_h, 0, SDL_OPENGL); if (screen == NULL) { @@ -687,13 +690,13 @@ /* Load icon into a surface: */ - icon = IMG_Load((datadir + "/images/supertux.xpm").c_str()); + icon = IMG_Load((datadir + "/images/" + package_symbol_name + ".xpm").c_str()); if (icon == NULL) { fprintf(stderr, "\nError: I could not load the icon image: %s%s\n" "The Simple DirectMedia error that occured was:\n" - "%s\n\n", datadir.c_str(), "/images/supertux.xpm", SDL_GetError()); + "%s\n\n", datadir.c_str(), ("/images/" + package_symbol_name + ".xpm").c_str(), SDL_GetError()); exit(1); } @@ -809,7 +812,7 @@ else if (strcmp(argv[i], "--version") == 0) { /* Show version: */ - printf("SuperTux " VERSION "\n"); + printf((package_name + package_version + "\n").c_str() ); exit(0); } else if (strcmp(argv[i], "--disable-sound") == 0) Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/globals.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- globals.cpp 22 Jul 2004 19:07:49 -0000 1.3 +++ globals.cpp 24 Jul 2004 11:50:09 -0000 1.4 @@ -24,7 +24,10 @@ /** The datadir prefix prepended when loading game data file */ std::string datadir; - +std::string package_symbol_name; +std::string package_name; +std::string package_version; + JoystickKeymap::JoystickKeymap() { a_button = 0; Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/setup.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- setup.h 22 Jul 2004 19:07:49 -0000 1.3 +++ setup.h 24 Jul 2004 11:50:09 -0000 1.4 @@ -37,12 +37,13 @@ string_list_type dsubdirs(const char *rel_path, const char* expected_file); string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str); void free_strings(char **strings, int num); +void st_info_setup(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version); void st_directory_setup(void); void st_general_setup(void); void st_general_free(); -void st_video_setup_sdl(void); -void st_video_setup_gl(void); -void st_video_setup(void); +void st_video_setup_sdl(unsigned int screen_w, unsigned int screen_h); +void st_video_setup_gl(unsigned int screen_w, unsigned int screen_h); +void st_video_setup(unsigned int screen_w, unsigned int screen_h); void st_audio_setup(void); void st_joystick_setup(void); void st_shutdown(void); Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/globals.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- globals.h 22 Jul 2004 19:07:49 -0000 1.3 +++ globals.h 24 Jul 2004 11:50:09 -0000 1.4 @@ -34,6 +34,9 @@ { extern std::string datadir; + extern std::string package_symbol_name; + extern std::string package_name; + extern std::string package_version; struct JoystickKeymap { @@ -77,7 +80,7 @@ /* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */ extern char* st_dir; extern char* st_save_dir; - + extern float game_speed; extern SDL_Joystick * js; |