X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fglobals.cpp;h=e8419f5b9fec4ba461b5559c4c3d67c65a33781c;hb=e147eea9f117721dbcf79d1465452b6ae91fe33c;hp=3b64443f2e53e3d870e4c8e02380a9c14fb80781;hpb=36ce687cfd225430e9e814ff71e1d206774ce9b9;p=supertux.git diff --git a/src/globals.cpp b/src/globals.cpp index 3b64443f2..e8419f5b9 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -18,9 +18,15 @@ std::string datadir; SDL_Surface * screen; text_type black_text, gold_text, blue_text, red_text, yellow_nums, white_text, white_small_text, white_big_text; -int use_gl, use_joystick, use_fullscreen, debug_mode, show_fps; +MouseCursor * mouse_cursor; -int joystick_num = 0; +bool use_gl; +bool use_joystick; +bool use_fullscreen; +bool debug_mode; +bool show_fps; + +int joystick_num = 0; char* level_startup_file = 0; bool launch_worldmap_mode = false; @@ -29,4 +35,60 @@ char *st_dir, *st_save_dir; SDL_Joystick * js; +/* Returns 1 for every button event, 2 for a quit event and 0 for no event. */ +int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_delay, bool empty_events) +{ + int i; + timer_type maxdelay; + timer_type mindelay; + + maxdelay.init(false); + mindelay.init(false); + + if(max_delay < min_delay) + max_delay = min_delay; + + maxdelay.start(max_delay); + mindelay.start(min_delay); + + if(empty_events) + while (SDL_PollEvent(&event)) + {} + + /* Handle events: */ + + for(i = 0; maxdelay.check() || !i; ++i) + { + while (SDL_PollEvent(&event)) + { + if(!mindelay.check()) + { + if (event.type == SDL_QUIT) + { + /* Quit event - quit: */ + return 2; + } + else if (event.type == SDL_KEYDOWN) + { + /* Keypress - skip intro: */ + + return 1; + } + else if (event.type == SDL_JOYBUTTONDOWN) + { + /* Fire button - skip intro: */ + + return 1; + } + else if (event.type == SDL_MOUSEBUTTONDOWN) + { + /* Mouse button - skip intro: */ + return 1; + } + } + } + SDL_Delay(10); + } + return 0; +}