- DrawingContext context;
-
- unsigned int frame_count;
- float fps_fps;
- Uint32 fps_ticks = SDL_GetTicks();
- Uint32 fps_nextframe_ticks = SDL_GetTicks();
- Uint32 ticks;
- bool skipdraw = false;
-
- running = true;
- while(running) {
- if(next_screen.get() != NULL) {
- if(nextpush && current_screen.get() != NULL) {
- current_screen->leave();
- screen_stack.push_back(current_screen.release());
- }
-
- next_screen->setup();
- script_manager->fire_wakeup_event(ScriptManager::SCREEN_SWITCHED);
- current_screen.reset(next_screen.release());
- next_screen.reset(NULL);
- nextpush = false;
+ 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), LEFT_ALLIGN, LAYER_HUD);
+ context.draw_text(gold_text, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), RIGHT_ALLIGN, LAYER_HUD);
+}
+
+void
+MainLoop::draw(DrawingContext& context)
+{
+ static Uint32 fps_ticks = SDL_GetTicks();
+ static int frame_count = 0;
+
+ current_screen->draw(context);
+ if(Menu::current() != NULL)
+ Menu::current()->draw(context);
+ if(screen_fade.get() != NULL)
+ screen_fade->draw(context);
+ Console::instance->draw(context);
+
+ if(config->show_fps)
+ draw_fps(context, fps);
+
+ context.do_drawing();
+
+ /* Calculate frames per second */
+ if(config->show_fps)
+ {
+ ++frame_count;
+
+ if(SDL_GetTicks() - fps_ticks >= 500)
+ {
+ fps = (float) frame_count / .5;
+ frame_count = 0;
+ fps_ticks = SDL_GetTicks();