more work on the camera
[supertux.git] / src / object / text_object.cpp
index 19c9416..aa16a29 100644 (file)
 #include "scripting/squirrel_util.hpp"
 #include "log.hpp"
 
-TextObject::TextObject(std::string name) :
-  GameObject(name), fading(0), fadetime(0), visible(false)
+TextObject::TextObject(std::string name)
+  : fading(0), fadetime(0), visible(false)
 {
+  this->name = name;
   font = blue_text;
   centered = false;
 }
@@ -41,14 +42,18 @@ TextObject::~TextObject()
 void
 TextObject::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
-  if (name.empty()) return;
+  if (name.empty())
+    return;
+
   Scripting::expose_object(vm, table_idx, dynamic_cast<Scripting::Text *>(this), name, false);
 }
 
 void
 TextObject::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
 {
-  if (name.empty()) return;
+  if (name.empty())
+    return;
+
   Scripting::unexpose_object(vm, table_idx, name);
 }
 
@@ -120,11 +125,12 @@ TextObject::draw(DrawingContext& context)
   }
 
   context.draw_filled_rect(Vector(125, 50), Vector(550, 120),
-      Color(0.6, 0.7, 0.8, 0.5), LAYER_GUI-50);
+      Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-50);
   if (centered) {
     context.draw_center_text(font, text, Vector(0, 50+35), LAYER_GUI-40);
+  } else {
+    context.draw_text(font, text, Vector(125+35, 50+35), ALIGN_LEFT, LAYER_GUI-40);
   }
-  else context.draw_text(font, text, Vector(125+35, 50+35), LEFT_ALLIGN, LAYER_GUI-40);
 
   context.pop_transform();
 }