X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmainloop.cpp;h=0add5f9c850f3b07ee7e57e0275670cd66875461;hb=7a0031e8f250c852743709ab06ecafe1896eefbe;hp=1f341508ec6925098e87f7f2bbd2b3443271c7a3;hpb=20b1c27dacf592c4f82fa8772d135ca9b7375d45;p=supertux.git diff --git a/src/mainloop.cpp b/src/mainloop.cpp index 1f341508e..0add5f9c8 100644 --- a/src/mainloop.cpp +++ b/src/mainloop.cpp @@ -38,10 +38,6 @@ #include "video/renderer.hpp" #include "random_generator.hpp" -// the engine will be run with a logical framerate of 64fps. -// We chose 64fps here because it is a power of 2, so 1/64 gives an "even" -// binary fraction... -static const float LOGICAL_FPS = 64.0; /** ticks (as returned from SDL_GetTicks) per frame */ static const Uint32 TICKS_PER_FRAME = (Uint32) (1000.0 / LOGICAL_FPS); /** don't skip more than every 2nd frame */ @@ -124,8 +120,8 @@ MainLoop::draw_fps(DrawingContext& context, float fps_fps) char str[60]; snprintf(str, sizeof(str), "%3.1f", fps_fps); const char* fpstext = "FPS"; - context.draw_text(white_text, fpstext, Vector(SCREEN_WIDTH - white_text->get_text_width(fpstext) - gold_text->get_text_width(" 99999") - BORDER_X, BORDER_Y + 20), ALIGN_LEFT, LAYER_HUD); - context.draw_text(gold_text, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), ALIGN_RIGHT, LAYER_HUD); + context.draw_text(small_font, fpstext, Vector(SCREEN_WIDTH - small_font->get_text_width(fpstext) - small_font->get_text_width(" 99999") - BORDER_X, BORDER_Y + 20), ALIGN_LEFT, LAYER_HUD); + context.draw_text(small_font, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), ALIGN_RIGHT, LAYER_HUD); } void @@ -180,6 +176,7 @@ void MainLoop::process_events() { main_controller->update(); + Uint8* keystate = SDL_GetKeyState(NULL); SDL_Event event; while(SDL_PollEvent(&event)) { @@ -200,15 +197,29 @@ MainLoop::process_events() break; case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_F10) + { + config->show_fps = !config->show_fps; + } if (event.key.keysym.sym == SDLK_F11) { config->use_fullscreen = !config->use_fullscreen; init_video(); + Menu::recalc_pos(); } - else if (event.key.keysym.sym == SDLK_PRINT) + else if (event.key.keysym.sym == SDLK_PRINT || + event.key.keysym.sym == SDLK_F12) { take_screenshot(); } + else if (event.key.keysym.sym == SDLK_F1 && + (keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL]) && + keystate[SDLK_c]) + { + Console::instance->toggle(); + config->console_enabled = true; + config->save(); + } break; } } @@ -238,9 +249,11 @@ MainLoop::handle_screen_switch() nextpush = false; nextpop = false; speed = 1.0; - if(next_screen.get() != NULL) - next_screen->setup(); - current_screen.reset(next_screen.release()); + Screen* next_screen_ptr = next_screen.release(); + next_screen.reset(0); + if(next_screen_ptr) + next_screen_ptr->setup(); + current_screen.reset(next_screen_ptr); screen_fade.reset(NULL); waiting_threads.wakeup(); @@ -268,7 +281,7 @@ MainLoop::run(DrawingContext &context) if (elapsed_ticks > ticks_per_frame*4) { // when the game loads up or levels are switched the - // elapsed_ticks grows extremly large, so we just ignore those + // elapsed_ticks grows extremely large, so we just ignore those // large time jumps elapsed_ticks = 0; }