Update CMake to 3.2.1 in .travis.yml
[supertux.git] / src / object / gradient.cpp
index 4295073..ef86b11 100644 (file)
@@ -1,12 +1,10 @@
-//  $Id: background.cpp 3144 2006-03-31 10:31:03Z matzebraun $
+//  SuperTux
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
-//  SuperTux -  A Jump'n Run
-//  Copyright (C) 2004 Matthias Braun <matze@braunis.de
-//
-//  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
 //  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.
-#include <config.h>
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "object/gradient.hpp"
+#include "supertux/object_factory.hpp"
+#include "util/reader.hpp"
 
 #include <stdexcept>
-#include "gradient.hpp"
-#include "camera.hpp"
-#include "video/drawing_context.hpp"
-#include "lisp/lisp.hpp"
-#include "lisp/writer.hpp"
-#include "object_factory.hpp"
-#include "resources.hpp"
-#include "main.hpp"
-#include "msg.hpp"
 
-Gradient::Gradient()
-  : layer(LAYER_BACKGROUND0)
+Gradient::Gradient() :
+  layer(LAYER_BACKGROUND0),
+  gradient_top(),
+  gradient_bottom()
 {
 }
 
-Gradient::Gradient(const lisp::Lisp& reader)
-  : layer(LAYER_BACKGROUND0)
+Gradient::Gradient(const Reader& reader) :
+  layer(LAYER_BACKGROUND0),
+  gradient_top(),
+  gradient_bottom()
 {
-  reader.get("layer", layer);
+  layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND0);
   std::vector<float> bkgd_top_color, bkgd_bottom_color;
-  if(!reader.get_vector("top_color", bkgd_top_color) ||
-     !reader.get_vector("bottom_color", bkgd_bottom_color))
+  if(!reader.get("top_color", bkgd_top_color) ||
+     !reader.get("bottom_color", bkgd_bottom_color))
     throw std::runtime_error("Must specify top_color and bottom_color in gradient");
 
   gradient_top = Color(bkgd_top_color);
@@ -52,26 +47,6 @@ Gradient::~Gradient()
 }
 
 void
-Gradient::write(lisp::Writer& writer)
-{
-  writer.start_list("gradient");
-
-  std::vector<float> bkgd_top_color, bkgd_bottom_color;
-  bkgd_top_color.push_back(gradient_top.red);
-  bkgd_top_color.push_back(gradient_top.green);
-  bkgd_top_color.push_back(gradient_top.blue);
-  bkgd_bottom_color.push_back(gradient_bottom.red);
-  bkgd_bottom_color.push_back(gradient_bottom.green);
-  bkgd_bottom_color.push_back(gradient_bottom.blue);
-  writer.write_float_vector("top_color", bkgd_top_color);
-  writer.write_float_vector("bottom_color", bkgd_bottom_color);
-
-  writer.write_int("layer", layer);
-  
-  writer.end_list("gradient");
-}
-
-void
 Gradient::update(float)
 {
 }
@@ -81,13 +56,18 @@ Gradient::set_gradient(Color top, Color bottom)
 {
   gradient_top = top;
   gradient_bottom = bottom;
-  
-  if (gradient_top.red > 1.0 || gradient_top.green > 1.0
-   || gradient_top.blue > 1.0 || gradient_top.alpha > 1.0)
-    msg_warning << "top gradient color has values above 1.0" << std::endl;
-  if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0
-   || gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0)
-    msg_warning << "bottom gradient color has values above 1.0" << std::endl;
+
+  if (gradient_top.red > 1.0 || gradient_top.green > 1.0 ||
+      gradient_top.blue > 1.0 || gradient_top.alpha > 1.0)
+  {
+    log_warning << "top gradient color has values above 1.0" << std::endl;
+  }
+
+  if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0 ||
+       gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0)
+  {
+    log_warning << "bottom gradient color has values above 1.0" << std::endl;
+  }
 }
 
 void
@@ -99,4 +79,4 @@ Gradient::draw(DrawingContext& context)
   context.pop_transform();
 }
 
-IMPLEMENT_FACTORY(Gradient, "gradient");
+/* EOF */