00001 /* $Id: render.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2009 - 2012 by Ignacio R. Morelle <shadowm2006@gmail.com> 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 * Storyscreen parts rendering interface. 00019 * @todo Translate relevant parts to GUI2. 00020 */ 00021 00022 #ifndef STORYSCREEN_RENDER_HPP_INCLUDED 00023 #define STORYSCREEN_RENDER_HPP_INCLUDED 00024 00025 #include "key.hpp" 00026 #include "storyscreen/part.hpp" 00027 // #include "widgets/button.hpp" 00028 00029 class display; 00030 class CVideo; 00031 00032 namespace gui { class button; } 00033 00034 namespace storyscreen { 00035 00036 /** 00037 * Storyscreen part user interface. 00038 * This works on the assumption, like the old one, that the screen 00039 * cannot be resized while we are at this. More specifically, it is 00040 * assumed that the screen dimensions remain constant between the 00041 * constructor call, and the destruction of the objects. 00042 */ 00043 class part_ui 00044 { 00045 public: 00046 /** Storyscreen result. */ 00047 enum RESULT { 00048 NEXT, /**< The user pressed the go-next button. */ 00049 BACK, /**< The user pressed the go-back button. */ 00050 QUIT /**< The user selected quit. */ 00051 }; 00052 00053 /** 00054 * Constructor. 00055 * @param p A storyscreen::part with the required information and parameters. 00056 * @param disp Display. 00057 * @param next_button Next button. Shouldn't be destroyed before the part_ui object. 00058 * @param skip_button Skip button. Shouldn't be destroyed before the part_ui object. 00059 */ 00060 part_ui(part &p, display &disp, gui::button &next_button, 00061 gui::button &back_button, gui::button& play_button); 00062 00063 /** 00064 * Render and display the storyscreen, process and return user input. 00065 */ 00066 RESULT show(); 00067 00068 private: 00069 part& p_; 00070 display& disp_; 00071 CVideo& video_; // convenience, it's currently obtained from disp_ 00072 CKey keys_; // convenience 00073 00074 gui::button& next_button_; 00075 gui::button& back_button_; 00076 gui::button& play_button_; 00077 00078 RESULT ret_; 00079 bool skip_, last_key_; 00080 00081 double scale_factor_; 00082 00083 // The background is aspect-corrected when scaled, so the image doesn't 00084 // look distorted. base_rect_ has the actual area occupied by the background. 00085 SDL_Rect base_rect_; 00086 00087 surface background_; 00088 std::vector< floating_image::render_input > imgs_; 00089 bool has_background_; 00090 00091 int text_x_, text_y_, buttons_x_, buttons_y_; 00092 00093 /** Constructor implementation details. */ 00094 void prepare_background(); 00095 /** Constructor implementation details. */ 00096 void prepare_geometry(); 00097 /** Constructor implementation details. */ 00098 void prepare_floating_images(); 00099 00100 void render_background(); 00101 void render_title_box(); 00102 void render_story_box(); 00103 void render_story_box_borders(SDL_Rect&); 00104 00105 /** 00106 * Returns true if the user did an action. Modifies #ret_, #skip_, 00107 * and #last_key_ accordingly. 00108 */ 00109 bool handle_interface(); 00110 00111 /** 00112 * Renders all floating images in sequence. 00113 * @return 'true' if the user interrupted the operation; 'false' otherwise. 00114 */ 00115 bool render_floating_images(); 00116 00117 void wait_for_input(); 00118 }; 00119 00120 } // end namespace storyscreen 00121 00122 #endif /* !STORYSCREEN_RENDER_HPP_INCLUDED */
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:10 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |