pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3197 - in trunk/pingus: data/data data/images/core/editor


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3197 - in trunk/pingus: data/data data/images/core/editor src/editor
Date: Fri, 21 Sep 2007 15:28:46 +0200

Author: grumbel
Date: 2007-09-21 15:28:45 +0200 (Fri, 21 Sep 2007)
New Revision: 3197

Added:
   trunk/pingus/data/images/core/editor/solidcolorbackground.png
   trunk/pingus/data/images/core/editor/starfield.png
Modified:
   trunk/pingus/data/data/core.res
   trunk/pingus/src/editor/editor_level.cpp
   trunk/pingus/src/editor/level_objs.cpp
   trunk/pingus/src/editor/level_objs.hpp
   trunk/pingus/src/editor/object_properties.cpp
   trunk/pingus/src/editor/object_properties.hpp
   trunk/pingus/src/editor/object_selector.cpp
Log:
- implemented liquids

Modified: trunk/pingus/data/data/core.res
===================================================================
--- trunk/pingus/data/data/core.res     2007-09-21 13:09:07 UTC (rev 3196)
+++ trunk/pingus/data/data/core.res     2007-09-21 13:28:45 UTC (rev 3197)
@@ -58,6 +58,10 @@
                     (image-file "../images/core/editor/starfield_thumb.png"))
 
                    (sprite
+                    (name "starfield")
+                    (image-file "../images/core/editor/starfield.png"))
+
+                   (sprite
                     (name "combobox")
                     (image-file "../images/core/editor/combobox.png"))
 

Added: trunk/pingus/data/images/core/editor/solidcolorbackground.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/pingus/data/images/core/editor/solidcolorbackground.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: trunk/pingus/data/images/core/editor/starfield.png
===================================================================
(Binary files differ)


Property changes on: trunk/pingus/data/images/core/editor/starfield.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2007-09-21 13:09:07 UTC (rev 
3196)
+++ trunk/pingus/src/editor/editor_level.cpp    2007-09-21 13:28:45 UTC (rev 
3197)
@@ -241,10 +241,10 @@
           i->read_int("speed", tmp_int);
           obj->set_speed(tmp_int);
         }
-      if (attribs & HAS_WIDTH)
+      if (attribs & HAS_REPEAT)
         {
-          i->read_int("width", tmp_int);
-          obj->set_width(tmp_int);
+          i->read_int("repeat", tmp_int);
+          obj->set_repeat(tmp_int);
         }
       if (attribs & HAS_PARALLAX)
         {

Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp      2007-09-21 13:09:07 UTC (rev 
3196)
+++ trunk/pingus/src/editor/level_objs.cpp      2007-09-21 13:28:45 UTC (rev 
3197)
@@ -37,7 +37,7 @@
     section_name(obj_name),
     speed(0),
     parallax(0.0),
-    width(0),
+    repeat(0),
     owner_id(0),
     release_rate(0),
     scroll_x(0),
@@ -64,7 +64,7 @@
   else if (obj_type == "hotspot")
     return HAS_SPEED | HAS_PARALLAX | HAS_SURFACE | CAN_ROTATE;
   else if (obj_type == "liquid")
-    return HAS_SPEED | HAS_WIDTH | HAS_SURFACE;
+    return HAS_SPEED | HAS_REPEAT | HAS_SURFACE;
   else if (obj_type == "surface-background")
     return HAS_COLOR | HAS_STRETCH | HAS_PARA | HAS_SCROLL | HAS_SURFACE;
   else if (obj_type == "solidcolor-background")
@@ -96,9 +96,9 @@
 {
   if (attribs & HAS_SURFACE || attribs & HAS_SURFACE_FAKE)
     {
-      if (attribs & HAS_WIDTH)
+      if (attribs & HAS_REPEAT)
         {
-          for(int x = int(pos.x); x < pos.x + width; x += sprite.get_width())
+          for(int x = int(pos.x); x < pos.x + sprite.get_width()*repeat; x += 
sprite.get_width())
             gc.draw(sprite, Vector3f(static_cast<float>(x), pos.y, pos.z));
         }
 #if 0
@@ -123,11 +123,8 @@
       // If selected, draw a highlighted box around it
       if (selected)
         {
-          Rect r(Vector2i((int)pos.x, (int)pos.y) - sprite.get_offset(),
-                 Size(sprite.get_width(), sprite.get_height())); 
-
-          gc.draw_fillrect(r, Color(255,0,0,50), pos.z);
-          gc.draw_rect(r, Color(255,0,0), pos.z);
+          gc.draw_fillrect(get_rect(), Color(255,0,0,50), pos.z);
+          gc.draw_rect(get_rect(), Color(255,0,0), pos.z);
         }
     }
 }
@@ -135,6 +132,9 @@
 bool
 LevelObj::is_at(int x, int y)
 {
+  return get_rect().is_inside(Vector2i(x,y));
+#if 0  
+  // old code
   if (attribs & HAS_SURFACE || attribs & HAS_SURFACE_FAKE)
     {
       Vector2i offset = sprite.get_offset();
@@ -147,10 +147,11 @@
     {
       return false;
     }
+#endif 
 }
 
-  void
-  LevelObj::set_stretch_x(const bool s)
+void
+LevelObj::set_stretch_x(const bool s)
 { 
   stretch_x = s;
 }
@@ -231,8 +232,8 @@
     fw.write_int("speed", speed);
   if (attribs & HAS_PARALLAX)
     fw.write_float("parallax", parallax);
-  if (attribs & HAS_WIDTH)
-    fw.write_int("width", width);
+  if (attribs & HAS_REPEAT)
+    fw.write_int("repeat", repeat);
   if (attribs & HAS_OWNER)
     fw.write_int("owner-id", owner_id);
   if (attribs & HAS_DIRECTION)
@@ -303,8 +304,16 @@
 Rect
 LevelObj::get_rect() const
 {
-  return Rect(Vector2i((int)pos.x, (int)pos.y) - sprite.get_offset(),
-              Size(sprite.get_width(), sprite.get_height()));
+  if (attribs & HAS_REPEAT)
+    {
+      return Rect(Vector2i((int)pos.x, (int)pos.y) - sprite.get_offset(),
+                  Size(sprite.get_width() * repeat, sprite.get_height()));
+    }
+  else
+    {
+      return Rect(Vector2i((int)pos.x, (int)pos.y) - sprite.get_offset(),
+                  Size(sprite.get_width(), sprite.get_height()));
+    }
 }
 
 } // namespace Editor 

Modified: trunk/pingus/src/editor/level_objs.hpp
===================================================================
--- trunk/pingus/src/editor/level_objs.hpp      2007-09-21 13:09:07 UTC (rev 
3196)
+++ trunk/pingus/src/editor/level_objs.hpp      2007-09-21 13:28:45 UTC (rev 
3197)
@@ -37,7 +37,7 @@
 const unsigned HAS_TYPE =         1 << 0;
 const unsigned HAS_SPEED =        1 << 1;
 const unsigned HAS_PARALLAX =     1 << 2;
-const unsigned HAS_WIDTH =        1 << 3;
+const unsigned HAS_REPEAT =        1 << 3;
 const unsigned HAS_OWNER =        1 << 4;
 const unsigned HAS_COLOR =        1 << 5;
 const unsigned HAS_SCROLL =       1 << 6;
@@ -88,8 +88,8 @@
   /** Optional parallax field for certain objects */
   float parallax;
 
-  /** Optional width field for certain objects */
-  int width;
+  /** Optional repeat field for certain objects */
+  int repeat;
 
   /** Optional owner id field for certain objects */
   int owner_id;
@@ -184,8 +184,8 @@
   /** Retrieve the object's owner */
   int get_owner() const { return owner_id; }
 
-  /** Retrieve the object's width */
-  int get_width() const { return width; }
+  /** Retrieve the object's repeat */
+  int get_repeat() const { return repeat; }
 
   /** Retrieve the object's color */
   Color get_color() const { return color; }
@@ -263,8 +263,8 @@
   /** Set the object's parallax */
   void set_parallax(const float para) { parallax = para; }
 
-  /** Set the object's width */
-  void set_width(const int w) { width = w; }
+  /** Set the object's repeat */
+  void set_repeat(const int w) { repeat = w; }
 
   /** Set the object's owner_id */
   void set_owner(const int id) { owner_id = id; }

Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp       2007-09-21 13:09:07 UTC 
(rev 3196)
+++ trunk/pingus/src/editor/object_properties.cpp       2007-09-21 13:28:45 UTC 
(rev 3197)
@@ -137,6 +137,11 @@
   
small_stars_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_small_stars_change,
 this, _1));
   
middle_stars_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_middle_stars_change,
 this, _1));
   
large_stars_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_large_stars_change,
 this, _1));
+  // ___________________________________________________________________
+  //
+  add(repeat_label    = new Label(label_rect, "Repeat:"), true);
+  add(repeat_inputbox = new Inputbox(box_rect), true);
+  
repeat_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_repeat_change,
 this, _1));
 
   set_object(0);
 }
@@ -236,6 +241,9 @@
   small_stars_inputbox->hide();
   middle_stars_inputbox->hide();
   large_stars_inputbox->hide();
+
+  repeat_label->hide();
+  repeat_inputbox->hide();
 }
 
 void
@@ -274,8 +282,10 @@
         { // used for hotspot
         }
         
-      if (attr & HAS_WIDTH)
-        { // used by liquid and some obscure ones
+      if (attr & HAS_REPEAT)
+        { 
+          repeat_inputbox->set_text(StringUtil::to_string(obj->get_repeat()));
+          place(repeat_label, repeat_inputbox);
         }
         
       if (attr & HAS_OWNER)
@@ -551,6 +561,15 @@
       (*i)->set_large_stars(StringUtil::to<int>(str));
     }  
 }
+
+void
+ObjectProperties::on_repeat_change(const std::string& str)
+{
+  for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+    {
+      (*i)->set_repeat(StringUtil::to<int>(str));
+    }   
+}
 
 } // namespace Editor
 

Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp       2007-09-21 13:09:07 UTC 
(rev 3196)
+++ trunk/pingus/src/editor/object_properties.hpp       2007-09-21 13:28:45 UTC 
(rev 3197)
@@ -89,6 +89,9 @@
   Label*    large_stars_label;
   Inputbox* large_stars_inputbox;
 
+  Label*    repeat_label;
+  Inputbox* repeat_inputbox;
+
   int y_pos;
 
 public:
@@ -127,6 +130,8 @@
   void on_small_stars_change(const std::string& str);
   void on_middle_stars_change(const std::string& str);
   void on_large_stars_change(const std::string& str);
+
+  void on_repeat_change(const std::string& str);
 
 };
 

Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-09-21 13:09:07 UTC (rev 
3196)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-09-21 13:28:45 UTC (rev 
3197)
@@ -159,14 +159,14 @@
 struct StarfieldBackground : public ObjectSelectorList::Object
 {
   StarfieldBackground() 
-    : Object(Resource::load_sprite("core/editor/starfield_thumb"),
+    : Object(Resource::load_sprite("core/editor/starfield"),
              Resource::load_thumb_sprite("core/editor/starfield_thumb"))
   {}
   
   LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
     LevelObj* obj = new LevelObj("starfield-background", impl);
     obj->set_pos(Vector3f((float)pos.x, (float)pos.y, -1000.0f)); // FIXME: 
Hack, z-pos handling is messed up
-    obj->set_res_desc(ResDescriptor("core/editor/starfield_thumb"));
+    obj->set_res_desc(ResDescriptor("core/editor/starfield"));
     obj->set_small_stars(500);
     obj->set_middle_stars(250);
     obj->set_large_stars(125);
@@ -174,22 +174,24 @@
   }
 };
 
-#if 0
 struct Liquid : public ObjectSelectorList::Object
 {
   ResDescriptor desc;
 
   Liquid(const std::string& name) 
-    : Object(Resource::load_sprite("core/editor/starfield_thumb"),
-             Resource::load_thumb_sprite("core/editor/starfield_thumb")),
+    : Object(Resource::load_sprite(name),
+             Resource::load_thumb_sprite(name)),
       desc(name)
   {}
   
   LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
-    return 0;
+    LevelObj* obj = new LevelObj("liquid", impl);
+    obj->set_pos(Vector3f((float)pos.x, (float)pos.y));
+    obj->set_res_desc(desc);
+    obj->set_repeat(1);
+    return obj;     
   }
 };
-#endif
 
 class ObjectSelectorButton : public GUI::RectComponent
 {
@@ -474,7 +476,6 @@
  std::vector<std::string> lst = Resource::resmgr.get_section("exit");
  for(std::vector<std::string>::const_iterator i = lst.begin(); i != lst.end(); 
++i)
     {
-      //sprite.scale(48, 48);
       set->add(new Exit(*i));
     }
  
@@ -484,7 +485,15 @@
 ObjectSelectorSet*
 ObjectSelector::create_liquid()
 {
-  return create_objects("liquids");
+ ObjectSelectorSet* set = new ObjectSelectorSet(object_list, 48, 48);
+
+ std::vector<std::string> lst = Resource::resmgr.get_section("liquids");
+ for(std::vector<std::string>::const_iterator i = lst.begin(); i != lst.end(); 
++i)
+    {
+      set->add(new Liquid(*i));
+    }
+
+ return set;
 }
 
 ObjectSelectorSet*





reply via email to

[Prev in Thread] Current Thread [Next in Thread]