1 /////////////////////////////////////////////////////////////////////////////// 2 // Copyright (C) 2004-2011 by The Allacrost Project 3 // Copyright (C) 2012-2016 by Bertram (Valyria Tear) 4 // All Rights Reserved 5 // 6 // This code is licensed under the GNU GPL version 2. It is free software 7 // and you may modify it and/or redistribute it under the terms of this license. 8 // See http://www.gnu.org/copyleft/gpl.html for details. 9 /////////////////////////////////////////////////////////////////////////////// 10 11 /** **************************************************************************** 12 *** \file fade.h 13 *** \author Raj Sharma, roos@allacrost.org 14 *** \author Yohann Ferreira, yohann ferreira orange fr 15 *** \brief Header file for ScreenFader class. 16 *** ***************************************************************************/ 17 18 #ifndef __FADE_HEADER__ 19 #define __FADE_HEADER__ 20 21 #include "color.h" 22 #include "image.h" 23 24 namespace vt_video 25 { 26 27 namespace private_video 28 { 29 30 /** **************************************************************************** 31 *** \brief Used to monitor progress for a fading screen. 32 *** 33 *** This class is used internally by the video engine to calculate how much to 34 *** fade the screen by. It keeps track of the current color and figures out whether 35 *** it should implement the fade using modulation or an overlay. 36 *** 37 *** \note Fades are either implemented with overlays or with modulation, depending 38 *** on whether it's a simple fade to black or a fade to a different color. 39 *** ***************************************************************************/ 40 class ScreenFader 41 { 42 public: 43 ScreenFader(); 44 45 /** \brief Begins a new screen fading process 46 *** \param final The color to fade the screen to. 47 *** \param time The number of milliseconds that the fade should last for. 48 *** \param transitional whether the fading is done between two game modes. 49 **/ 50 void BeginFade(const Color &final, uint32_t time, bool transitional = false); 51 52 /** \brief Updates the amount of fading for the screen 53 *** \param time The number of milliseconds that have passed since last update. 54 **/ 55 void Update(uint32_t time); 56 IsFading()57 bool IsFading() const { 58 return _is_fading; 59 } 60 61 /** \brief start a fade used as a transition between two game modes. 62 *** It's a simple fade but flagged as special to let the mode manager handle it. 63 **/ StartTransitionFadeOut(const Color & final,uint32_t time)64 void StartTransitionFadeOut(const Color &final, uint32_t time) { 65 BeginFade(final, time, true); 66 } 67 68 //! \brief A shortcut function used to make a fade in more explicitely. TransitionalFadeIn(uint32_t time)69 void TransitionalFadeIn(uint32_t time) { 70 BeginFade(Color::clear, time, true); 71 } 72 73 //! \brief A shortcut function used to make a fade in more explicitely. FadeIn(uint32_t time)74 void FadeIn(uint32_t time) { 75 BeginFade(Color::clear, time); 76 } 77 78 //! \brief tells whether the last fade effect was transitional. IsLastFadeTransitional()79 bool IsLastFadeTransitional() const { 80 return _transitional_fading; 81 } 82 83 //! \brief Draw the fading overlay 84 void Draw(); 85 86 private: 87 //! \brief The current overlay color. 88 Color _current_color; 89 90 //! \brief The initial color of the screen before the fade started. 91 Color _initial_color; 92 93 //! \brief The destination color that the screen is being fade to. 94 Color _final_color; 95 96 //! \brief The number of milliseconds that have passed since the fading began. 97 uint32_t _current_time; 98 99 //! \brief The number of milliseconds that this fade was set to last for. 100 uint32_t _end_time; 101 102 //! \brief True if the class is currently in the process of fading 103 bool _is_fading; 104 105 //! Image used as a fading overlay 106 StillImage _fade_overlay_img; 107 108 //! \brief Set to true if the fading process requires interpolation of RGB values between colors 109 bool _interpolate_rgb_values; 110 111 //! \brief Tells whether the current fading is used to make a transition between two game mode. 112 bool _transitional_fading; 113 //@} 114 }; // class ScreenFader 115 116 } // namespace private_video 117 118 } // namespace vt_video 119 120 #endif // __FADE_HEADER__ 121