X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fobject%2Fdisplay_effect.cpp;h=b32e8397654653113f520193b911544cccf92999;hb=cbb015c68e184f5c19d0483a486325c1ee819086;hp=a01e9db502e2f5d6d9682ce276901c0660c0c4d9;hpb=4a486d92343d1824b311c234e9321e08f280fe68;p=supertux.git diff --git a/src/object/display_effect.cpp b/src/object/display_effect.cpp index a01e9db50..b32e83976 100644 --- a/src/object/display_effect.cpp +++ b/src/object/display_effect.cpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,23 +12,26 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// along with this program. If not, see . -#include -#include "display_effect.hpp" +#include "object/display_effect.hpp" -#include -#include "video/drawing_context.hpp" #include "scripting/squirrel_util.hpp" -#include "main.hpp" +#include "supertux/globals.hpp" +#include "video/drawing_context.hpp" static const float BORDER_SIZE = 75; -DisplayEffect::DisplayEffect(std::string name) - : screen_fade(NO_FADE), screen_fadetime(0), screen_fading(0), - border_fade(NO_FADE), border_fadetime(0), border_size(0), black(false), - borders(false) +DisplayEffect::DisplayEffect(std::string name) : + screen_fade(NO_FADE), + screen_fadetime(0), + screen_fading(0), + border_fade(NO_FADE), + border_fadetime(0), + border_fading(), + border_size(0), + black(false), + borders(false) { this->name = name; } @@ -43,60 +44,60 @@ void DisplayEffect::expose(HSQUIRRELVM vm, SQInteger table_idx) { if (name.empty()) return; - expose_object(vm, table_idx, dynamic_cast(this), name, false); + expose_object(vm, table_idx, dynamic_cast(this), name, false); } void DisplayEffect::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { if (name.empty()) return; - Scripting::unexpose_object(vm, table_idx, name); + scripting::unexpose_object(vm, table_idx, name); } void DisplayEffect::update(float elapsed_time) { switch(screen_fade) { - case NO_FADE: - break; - case FADE_IN: - screen_fading -= elapsed_time; - if(screen_fading < 0) { - screen_fade = NO_FADE; - } - break; - case FADE_OUT: - screen_fading -= elapsed_time; - if(screen_fading < 0) { - screen_fade = NO_FADE; - black = true; - } - break; - default: - assert(false); + case NO_FADE: + break; + case FADE_IN: + screen_fading -= elapsed_time; + if(screen_fading < 0) { + screen_fade = NO_FADE; + } + break; + case FADE_OUT: + screen_fading -= elapsed_time; + if(screen_fading < 0) { + screen_fade = NO_FADE; + black = true; + } + break; + default: + assert(false); } switch(border_fade) { - case NO_FADE: - break; - case FADE_IN: - border_fading -= elapsed_time; - if(border_fading < 0) { - border_fade = NO_FADE; - } - border_size = border_fading / border_fading * BORDER_SIZE; - break; - case FADE_OUT: - border_fading -= elapsed_time; - if(border_fading < 0) { - borders = false; - border_fade = NO_FADE; - } - border_size = (border_fadetime - border_fading) - / border_fadetime * BORDER_SIZE; - break; - default: - assert(false); + case NO_FADE: + break; + case FADE_IN: + border_fading -= elapsed_time; + if(border_fading < 0) { + border_fade = NO_FADE; + } + border_size = (border_fadetime - border_fading) + / border_fadetime * BORDER_SIZE; + break; + case FADE_OUT: + border_fading -= elapsed_time; + if(border_fading < 0) { + borders = false; + border_fade = NO_FADE; + } + border_size = border_fading / border_fadetime * BORDER_SIZE; + break; + default: + assert(false); } } @@ -112,26 +113,26 @@ DisplayEffect::draw(DrawingContext& context) alpha = 1.0f; } else { switch(screen_fade) { - case FADE_IN: - alpha = screen_fading / screen_fadetime; - break; - case FADE_OUT: - alpha = (screen_fadetime - screen_fading) / screen_fadetime; - break; - default: - alpha = 0; - assert(false); + case FADE_IN: + alpha = screen_fading / screen_fadetime; + break; + case FADE_OUT: + alpha = (screen_fadetime - screen_fading) / screen_fadetime; + break; + default: + alpha = 0; + assert(false); } } context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT), - Color(0, 0, 0, alpha), LAYER_GUI-10); + Color(0, 0, 0, alpha), LAYER_GUI-10); } if (borders) { context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, border_size), - Color(0, 0, 0, 1.0f), LAYER_GUI-10); + Color(0, 0, 0, 1.0f), LAYER_GUI-10); context.draw_filled_rect(Vector(0, SCREEN_HEIGHT - border_size), Vector(SCREEN_WIDTH, border_size), - Color(0, 0, 0, 1.0f), LAYER_GUI-10); + Color(0, 0, 0, 1.0f), LAYER_GUI-10); } context.pop_transform(); @@ -194,3 +195,5 @@ DisplayEffect::four_to_three(float fadetime) border_fading = border_fadetime; } } + +/* EOF */