Add current level to another debug message
[supertux.git] / src / math / sizef.hpp
index e9580f6..02866d4 100644 (file)
@@ -1,5 +1,5 @@
 //  SuperTux
-//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
 //
 //  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
@@ -31,9 +31,14 @@ public:
     height(0.0f)
   {}
 
+  explicit Sizef(const Vector& v) :
+    width(v.x),
+    height(v.y)
+  {}
+
   Sizef(float width_, float height_) :
-    width(width_), 
-    height(height_) 
+    width(width_),
+    height(height_)
   {}
 
   Sizef(const Sizef& rhs) :
@@ -58,17 +63,22 @@ public:
   }
 
   Sizef& operator+=(const Sizef& rhs)
-  { 
-    width  += rhs.width; 
-    height += rhs.height; 
-    return *this; 
+  {
+    width  += rhs.width;
+    height += rhs.height;
+    return *this;
   }
 
   Sizef& operator-=(const Sizef& rhs)
-  { 
-    width  -= rhs.width; 
-    height -= rhs.height; 
-    return *this; 
+  {
+    width  -= rhs.width;
+    height -= rhs.height;
+    return *this;
+  }
+
+  Vector as_vector() const
+  {
+    return Vector(width, height);
   }
 
 public:
@@ -77,61 +87,43 @@ public:
 };
 
 inline Sizef operator*(const Sizef& lhs, float factor)
-{ 
-  return Sizef(lhs.width  * factor, 
-               lhs.height * factor); 
+{
+  return Sizef(lhs.width  * factor,
+               lhs.height * factor);
 }
 
 inline Sizef operator*(float factor, const Sizef& rhs)
-{ 
-  return Sizef(rhs.width  * factor, 
-               rhs.height * factor); 
+{
+  return Sizef(rhs.width  * factor,
+               rhs.height * factor);
 }
 
 inline Sizef operator/(const Sizef& lhs, float divisor)
-{ 
-  return Sizef(lhs.width  / divisor, 
-               lhs.height / divisor); 
+{
+  return Sizef(lhs.width  / divisor,
+               lhs.height / divisor);
 }
 
 inline Sizef operator+(const Sizef& lhs, const Sizef& rhs)
-{ 
-  return Sizef(lhs.width  + rhs.width, 
-               lhs.height + rhs.height); 
-}
-
-inline Vector operator+(const Vector& lhs, const Sizef& rhs) const
-{ 
-  return Vector(lhs.x + rhs.width, 
-                lhs.y + rhs.height); 
-}
-
-inline Vector operator*(const Vector& lhs, const Sizef& rhs) const
-{ 
-  return Vector(lhs.x * rhs.width, 
-                lhs.y * rhs.height); 
-}
-
-inline Vector operator*(const Sizefr& lhs, const Vector& rhs) const
-{ 
-  return Vector(lhs.width  * rhs.x, 
-                lhs.height * rhs.y); 
+{
+  return Sizef(lhs.width  + rhs.width,
+               lhs.height + rhs.height);
 }
 
 inline Sizef operator-(const Sizef& lhs, const Sizef& rhs)
 {
-  return Sizef(lhs.width  - rhs.width, 
-               lhs.height - rhs.height); 
+  return Sizef(lhs.width  - rhs.width,
+               lhs.height - rhs.height);
 }
 
 inline bool operator==(const Sizef& lhs, const Sizef& rhs)
 {
-  return (lhs.width == rhs.width) && (rhs.height == rhs.height); 
+  return (lhs.width == rhs.width) && (rhs.height == rhs.height);
 }
 
 inline bool operator!=(const Sizef& lhs, const Sizef& rhs)
-{ 
-  return (lhs.width != rhs.width) || (lhs.height != rhs.height); 
+{
+  return (lhs.width != rhs.width) || (lhs.height != rhs.height);
 }
 
 std::ostream& operator<<(std::ostream& s, const Sizef& size);