[Super-tux-commit] supertux/lib/app globals.cpp,1.1,1.2 globals.h,1.1,1.2 setup.cpp,1.1,1.2 setup.h,
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-21 16:52:39
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/app Modified Files: globals.cpp globals.h setup.cpp setup.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/setup.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- setup.cpp 20 Jul 2004 17:51:34 -0000 1.1 +++ setup.cpp 21 Jul 2004 16:51:50 -0000 1.2 @@ -51,6 +51,7 @@ #include "audio/sound_manager.h" #include "app/gettext.h" +using namespace SuperTux; #ifdef WIN32 #define mkdir(dir, mode) mkdir(dir) @@ -70,7 +71,7 @@ void usage(char * prog, int ret); /* Does the given file exist and is it accessible? */ -int faccessible(const char *filename) +int SuperTux::faccessible(const char *filename) { struct stat filestat; if (stat(filename, &filestat) == -1) @@ -87,7 +88,7 @@ } /* Can we write to this location? */ -int fwriteable(const char *filename) +int SuperTux::fwriteable(const char *filename) { FILE* fi; fi = fopen(filename, "wa"); @@ -99,7 +100,7 @@ } /* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/ -int fcreatedir(const char* relative_dir) +int SuperTux::fcreatedir(const char* relative_dir) { char path[1024]; snprintf(path, 1024, "%s/%s/", st_dir, relative_dir); @@ -121,7 +122,7 @@ } } -FILE * opendata(const char * rel_filename, const char * mode) +FILE * SuperTux::opendata(const char * rel_filename, const char * mode) { char * filename = NULL; FILE * fi; @@ -154,7 +155,7 @@ /* Get all names of sub-directories in a certain directory. */ /* Returns the number of sub-directories found. */ /* Note: The user has to free the allocated space. */ -string_list_type dsubdirs(const char *rel_path,const char* expected_file) +string_list_type SuperTux::dsubdirs(const char *rel_path,const char* expected_file) { DIR *dirStructP; struct dirent *direntp; @@ -224,7 +225,7 @@ return sdirs; } -string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str) +string_list_type SuperTux::dfiles(const char *rel_path, const char* glob, const char* exception_str) { DIR *dirStructP; struct dirent *direntp; @@ -289,7 +290,7 @@ return sdirs; } -void free_strings(char **strings, int num) +void SuperTux::free_strings(char **strings, int num) { int i; for(i=0; i < num; ++i) @@ -298,7 +299,7 @@ /* --- SETUP --- */ /* Set SuperTux configuration and save directories */ -void st_directory_setup(void) +void SuperTux::st_directory_setup(void) { char *home; char str[1024]; @@ -365,7 +366,7 @@ printf("Datadir: %s\n", datadir.c_str()); } -void st_general_setup(void) +void SuperTux::st_general_setup(void) { /* Seed random number generator: */ @@ -406,7 +407,7 @@ } -void st_general_free(void) +void SuperTux::st_general_free(void) { /* Free global images: */ @@ -428,20 +429,9 @@ /* Free mouse-cursor */ delete mouse_cursor; - /* Free menus */ - delete main_menu; - delete game_menu; - delete options_menu; - delete options_keys_menu; - delete options_joystick_menu; - delete highscore_menu; - delete contrib_menu; - delete contrib_subset_menu; - delete save_game_menu; - delete load_game_menu; } -void st_video_setup(void) +void SuperTux::st_video_setup(void) { /* Init SDL Video: */ if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -465,7 +455,7 @@ SDL_WM_SetCaption("SuperTux " VERSION, "SuperTux"); } -void st_video_setup_sdl(void) +void SuperTux::st_video_setup_sdl(void) { if (use_fullscreen) { @@ -495,7 +485,7 @@ } } -void st_video_setup_gl(void) +void SuperTux::st_video_setup_gl(void) { #ifndef NOOPENGL @@ -551,7 +541,7 @@ } -void st_joystick_setup(void) +void SuperTux::st_joystick_setup(void) { /* Init Joystick: */ @@ -612,7 +602,7 @@ } } -void st_audio_setup(void) +void SuperTux::st_audio_setup(void) { /* Init SDL Audio silently even if --disable-sound : */ @@ -670,7 +660,7 @@ /* --- SHUTDOWN --- */ -void st_shutdown(void) +void SuperTux::st_shutdown(void) { close_audio(); SDL_Quit(); @@ -679,7 +669,7 @@ /* --- ABORT! --- */ -void st_abort(const std::string& reason, const std::string& details) +void SuperTux::st_abort(const std::string& reason, const std::string& details) { fprintf(stderr, "\nError: %s\n%s\n\n", reason.c_str(), details.c_str()); st_shutdown(); @@ -729,7 +719,7 @@ /* Parse command-line arguments: */ -void parseargs(int argc, char * argv[]) +void SuperTux::parseargs(int argc, char * argv[]) { int i; @@ -913,7 +903,7 @@ exit(ret); } -std::vector<std::string> read_directory(const std::string& pathname) +std::vector<std::string> SuperTux::read_directory(const std::string& pathname) { std::vector<std::string> dirnames; Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/globals.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- globals.cpp 20 Jul 2004 17:51:34 -0000 1.1 +++ globals.cpp 21 Jul 2004 16:51:50 -0000 1.2 @@ -20,6 +20,8 @@ #include "app/globals.h" +namespace SuperTux { + /** The datadir prefix prepended when loading game data file */ std::string datadir; @@ -122,3 +124,5 @@ return 0; } + +} //namespace SuperTux Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/setup.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- setup.h 20 Jul 2004 17:51:34 -0000 1.1 +++ setup.h 21 Jul 2004 16:51:50 -0000 1.2 @@ -26,6 +26,8 @@ #include "audio/sound.h" #include "special/base.h" +namespace SuperTux { + int faccessible(const char *filename); int fcreatedir(const char* relative_dir); int fwriteable(const char *filename); @@ -48,5 +50,7 @@ void parseargs(int argc, char * argv[]); +} + #endif /*SUPERTUX_SETUP_H*/ Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/globals.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- globals.h 20 Jul 2004 17:51:34 -0000 1.1 +++ globals.h 21 Jul 2004 16:51:50 -0000 1.2 @@ -30,54 +30,59 @@ #include "gui/menu.h" #include "gui/mousecursor.h" -extern std::string datadir; +namespace SuperTux + { -struct JoystickKeymap -{ - int a_button; - int b_button; - int start_button; + extern std::string datadir; - int x_axis; - int y_axis; - - int dead_zone; + struct JoystickKeymap + { + int a_button; + int b_button; + int start_button; - JoystickKeymap(); -}; + int x_axis; + int y_axis; -extern JoystickKeymap joystick_keymap; + int dead_zone; -extern SDL_Surface* screen; -extern Font* gold_text; -extern Font* white_text; -extern Font* blue_text; -extern Font* gray_text; -extern Font* white_small_text; -extern Font* white_big_text; -extern Font* yellow_nums; + JoystickKeymap(); + }; -extern MouseCursor * mouse_cursor; + extern JoystickKeymap joystick_keymap; -extern bool use_gl; -extern bool use_joystick; -extern bool use_fullscreen; -extern bool debug_mode; -extern bool show_fps; + extern SDL_Surface* screen; + extern Font* gold_text; + extern Font* white_text; + extern Font* blue_text; + extern Font* gray_text; + extern Font* white_small_text; + extern Font* white_big_text; + extern Font* yellow_nums; -/** The number of the joystick that will be use in the game */ -extern int joystick_num; -extern char* level_startup_file; -extern bool launch_leveleditor_mode; -extern bool launch_worldmap_mode; + extern MouseCursor * mouse_cursor; -/* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */ -extern char* st_dir; -extern char* st_save_dir; + extern bool use_gl; + extern bool use_joystick; + extern bool use_fullscreen; + extern bool debug_mode; + extern bool show_fps; -extern float game_speed; -extern SDL_Joystick * js; + /** The number of the joystick that will be use in the game */ + extern int joystick_num; + extern char* level_startup_file; + extern bool launch_leveleditor_mode; + extern bool launch_worldmap_mode; -int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); + /* 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; + + int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); + +} //namespace SuperTux #endif /* SUPERTUX_GLOBALS_H */ |