2 #include "display_effect.hpp"
5 #include "video/drawing_context.hpp"
8 DisplayEffect::DisplayEffect()
9 : type(NO_FADE), fadetime(0), fading(0), black(false)
11 cutscene_borders = false;
14 DisplayEffect::~DisplayEffect()
19 DisplayEffect::update(float elapsed_time)
25 fading -= elapsed_time;
31 fading -= elapsed_time;
43 DisplayEffect::draw(DrawingContext& context)
45 context.push_transform();
46 context.set_translation(Vector(0, 0));
48 if(black || type != NO_FADE) {
55 alpha = static_cast<uint8_t>
56 (fading * 255.0 / fadetime);
59 alpha = static_cast<uint8_t>
60 ((fadetime-fading) * 255.0 / fadetime);
67 context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
68 Color(0, 0, 0, alpha), LAYER_GUI-10);
71 if (cutscene_borders) {
72 context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, 75),
73 Color(0, 0, 0, 255), LAYER_GUI-10);
74 context.draw_filled_rect(Vector(0, SCREEN_HEIGHT - 75), Vector(SCREEN_WIDTH, 75),
75 Color(0, 0, 0, 255), LAYER_GUI-10);
78 context.pop_transform();
82 DisplayEffect::fade_out(float fadetime)
85 this->fadetime = fadetime;
91 DisplayEffect::fade_in(float fadetime)
94 this->fadetime = fadetime;
100 DisplayEffect::set_black(bool enabled)
106 DisplayEffect::is_black()
112 DisplayEffect::sixteen_to_nine()
114 cutscene_borders = true;
118 DisplayEffect::four_to_three()
120 cutscene_borders = false;