intro.cpp

Go to the documentation of this file.
00001 /* $Id: intro.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 /**
00017  * @file
00018  * Introduction sequence at start of a scenario, End-screen after end of
00019  * campaign.
00020  */
00021 
00022 #include "global.hpp"
00023 
00024 #include "intro.hpp"
00025 
00026 #include "display.hpp"
00027 #include "gettext.hpp"
00028 #include "log.hpp"
00029 #include "marked-up_text.hpp"
00030 #include "storyscreen/interface.hpp"
00031 
00032 static lg::log_domain log_engine("engine");
00033 #define ERR_NG LOG_STREAM(err, log_engine)
00034 #define LOG_NG LOG_STREAM(info, log_engine)
00035 
00036 static bool use_shadowm_storyscreen = false;
00037 
00038 static void the_end_old(display &disp, std::string text, unsigned int duration)
00039 {
00040     //
00041     // Some sane defaults.
00042     //
00043     if(text.empty())
00044         text = _("The End");
00045     if(!duration)
00046         duration = 3500;
00047 
00048     SDL_Rect area = screen_area();
00049     CVideo &video = disp.video();
00050     sdl_fill_rect(video.getSurface(),&area,0);
00051 
00052     update_whole_screen();
00053     disp.flip();
00054 
00055     const size_t font_size = font::SIZE_XLARGE;
00056 
00057     area = font::text_area(text,font_size);
00058     area.x = screen_area().w/2 - area.w/2;
00059     area.y = screen_area().h/2 - area.h/2;
00060 
00061     for(size_t n = 0; n < 255; n += 5) {
00062         if(n)
00063             sdl_fill_rect(video.getSurface(),&area,0);
00064 
00065         const SDL_Color col = create_color(n, n, n, n);
00066         font::draw_text(&video,area,font_size,col,text,area.x,area.y);
00067         update_rect(area);
00068 
00069         events::pump();
00070         events::raise_process_event();
00071         events::raise_draw_event();
00072         disp.flip();
00073         disp.delay(10);
00074     }
00075 
00076     //
00077     // Delay after the end of fading.
00078     // Rounded to multiples of 10.
00079     //
00080     unsigned int count = duration/10;
00081     while(count) {
00082         events::pump();
00083         events::raise_process_event();
00084         events::raise_draw_event();
00085         disp.flip();
00086         disp.delay(10);
00087         --count;
00088     }
00089 }
00090 
00091 void set_new_storyscreen(bool enabled)
00092 {
00093     use_shadowm_storyscreen = enabled;
00094     LOG_NG << "enabled experimental story/endscreen code\n";
00095 }
00096 
00097 void the_end(display &disp, std::string text, unsigned int duration)
00098 {
00099     if(use_shadowm_storyscreen) {
00100         show_endscreen(disp, t_string(text) /* dumb! */, duration);
00101     }
00102     else {
00103         the_end_old(disp,text,duration);
00104     }
00105 }
00106 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:02 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs