pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3170 - in trunk/pingus: . data/data src src/editor


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3170 - in trunk/pingus: . data/data src src/editor
Date: Mon, 17 Sep 2007 21:49:09 +0200

Author: grumbel
Date: 2007-09-17 21:49:08 +0200 (Mon, 17 Sep 2007)
New Revision: 3170

Modified:
   trunk/pingus/INSTALL.unix
   trunk/pingus/TODO
   trunk/pingus/data/data/entrances.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_selector.cpp
   trunk/pingus/src/editor/object_selector_list.cpp
   trunk/pingus/src/editor/object_selector_list.hpp
   trunk/pingus/src/sprite.cpp
   trunk/pingus/src/sprite.hpp
Log:
- fixed offset errors for entrance and exit in editor

Modified: trunk/pingus/INSTALL.unix
===================================================================
--- trunk/pingus/INSTALL.unix   2007-09-17 16:05:41 UTC (rev 3169)
+++ trunk/pingus/INSTALL.unix   2007-09-17 19:49:08 UTC (rev 3170)
@@ -5,6 +5,7 @@
 -------------
 To compile Pingus you need:
 
+ g++           - http://gcc.gnu.org/
  SDL           - http://libsdl.org/
  SDL_mixer
  SDL_image
@@ -13,7 +14,8 @@
  libpng        - http://libpng.org/
  scons         - http://scons.org/
 
-In most cases you will find those in your distribution.
+In most cases you will find those in your distribution and there
+shouln't be a need to compile them manually.
 
 
 Compilation:

Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO   2007-09-17 16:05:41 UTC (rev 3169)
+++ trunk/pingus/TODO   2007-09-17 19:49:08 UTC (rev 3170)
@@ -1,3 +1,14 @@
+Release Checklist:
+~~~~~~~~~~~~~~~~~~
+
+- turn on fullscreen at default (do we really want this with
+  fullscreen key documented?)
+
+- make sure all important strings are translatable
+
+- run ./extract-po.sh && ./update-po.sh
+
+
 Stuff to do at all times:
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -168,6 +179,8 @@
 
 - add color prop for surface-background
 
+- add position prop for all LevelObjs
+
 - make GPType prop
 
 - ObjectSelector need to support more object types: Starbackground, 
SolidColorBackground
@@ -191,8 +204,6 @@
 
 - make combo box open to the top or bottom depending on variable
 
-- fix align of exits
-
 - add options to show/hide hidden files and filter stuff
 
 - add new level and save level dialogs

Modified: trunk/pingus/data/data/entrances.res
===================================================================
--- trunk/pingus/data/data/entrances.res        2007-09-17 16:05:41 UTC (rev 
3169)
+++ trunk/pingus/data/data/entrances.res        2007-09-17 19:49:08 UTC (rev 
3170)
@@ -9,7 +9,7 @@
 
     (sprite
       (name "generic")
-;;      (origin "bottom_center")
+      (origin "bottom_center")
       (offset 0 0)
       (image-file "../images/entrances/generic.png"))
 

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2007-09-17 16:05:41 UTC (rev 
3169)
+++ trunk/pingus/src/editor/editor_level.cpp    2007-09-17 19:49:08 UTC (rev 
3170)
@@ -38,8 +38,8 @@
 
 // Default constructor
 EditorLevel::EditorLevel(EditorScreen* editor_) 
- : editor(editor_),
-   impl(new LevelImpl())
+  : editor(editor_),
+    impl(new LevelImpl())
 {
   impl->levelname   = "none";
   impl->description = "none";

Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp      2007-09-17 16:05:41 UTC (rev 
3169)
+++ trunk/pingus/src/editor/level_objs.cpp      2007-09-17 19:49:08 UTC (rev 
3170)
@@ -34,7 +34,6 @@
 LevelObj::LevelObj(std::string obj_name, LevelImpl* level_)
   : level(level_),
     pos(Vector3f(0,0,0)),
-    translated_pos(Vector3f(0,0,0)),
     section_name(obj_name),
     speed(0),
     parallax(0.0),
@@ -115,10 +114,8 @@
       // If selected, draw a highlighted box around it
       if (selected)
         {
-          Rect r((int)translated_pos.x, 
-                 (int)translated_pos.y, 
-                 (int)translated_pos.x + sprite.get_width(), 
-                 (int)translated_pos.y + sprite.get_height()); 
+          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));
           gc.draw_rect(r, Color(255,0,0));
@@ -129,13 +126,18 @@
 bool
 LevelObj::is_at(int x, int y)
 {
-  if (!removed && attribs & (HAS_SURFACE | HAS_SURFACE_FAKE))
+  if (attribs & (HAS_SURFACE | HAS_SURFACE_FAKE))
     {
-      return (x > translated_pos.x && x < translated_pos.x + sprite.get_width()
-              && y > translated_pos.y && y < translated_pos.y + 
sprite.get_height());
-}
+      Vector2i offset = sprite.get_offset();
+      return (x > pos.x - offset.x &&
+              x < pos.x - offset.x + sprite.get_width() && 
+              y > pos.y - offset.y && 
+              y < pos.y - offset.y + sprite.get_height());
+    }
   else
-    return false;
+    {
+      return false;
+    }
 }
 
   void
@@ -163,47 +165,6 @@
     {
       sprite = Resource::load_sprite(desc);
     }
-  set_translated_pos();
-
-#if 0                          
-      Surface pb;
-
-      // Apply modifier, then change the sprite loaded for this object in 
memory.
-      if (stretch_x || stretch_y)
-        {
-          float w = (float)sprite.get_width();
-          float h = (float)sprite.get_height();
-                       
-          // Determine the new dimensions for the sprite
-          if (stretch_x && !stretch_y)
-            {
-              if (keep_aspect)
-                h = h * Display::get_width() / w;
-              w = (float)Display::get_width();
-            }
-          else if (stretch_y && !stretch_x)
-            {
-              if (keep_aspect)
-                w = w * Display::get_height() / h;
-              h = (float)Display::get_height();
-            }
-          else
-            {
-              w = (float)Display::get_width();
-              h = (float)Display::get_height();
-            }
-
-          //FIXME: Sat Jan 13 10:26:15 2007
-          assert(0);
-          // pb = Blitter::scale_surface_to_canvas(
-          // sprite.get_frame_pixeldata(0), (int)w, (int)h);
-                        
-        }
-      else             // No stretch involved
-        pb = Resource::load_surface(desc);
-
-      sprite = Sprite(pb);
-#endif
 }
 
 // Set the modifier and actually modify the sprite loaded in memory
@@ -287,8 +248,7 @@
 
       // Writes any extra properties that may be necessary (virtual function)
       write_extra_properties(fw);
-
-      // Write the Vector3f position - all objects have this
+      
       fw.write_vector("position", pos);
 
       fw.end_section();        // object's section_name
@@ -306,61 +266,10 @@
     }
 }
 
-// The translated pos is where the object appears to be "at" instead
-// of using it's "translation origin" specified in the sprite resource files
 void
-LevelObj::set_translated_pos()
-{
-  if (!sprite)
-    return;
-       
-  translated_pos = pos;
-       
-  Origin orig = origin_top_left;
-  ////int x, y;
-  float w = (float)sprite.get_width();
-  float h = (float)sprite.get_height();
-       
-  ////sprite.get_alignment(orig, x, y);
-  switch (orig)
-    {
-      case origin_top_left :
-        break;
-      case origin_top_center :
-        translated_pos.x -= w / 2;
-        break;
-      case origin_top_right :
-        translated_pos.x -= w;
-        break;
-      case origin_center_left :
-        translated_pos.y -= w / 2;
-        break;
-      case origin_center :
-        translated_pos.x -= w / 2;
-        translated_pos.y -= h / 2;
-        break;
-      case origin_center_right :
-        translated_pos.x -= w; 
-        translated_pos.y -= h / 2;
-        break;
-      case origin_bottom_left :
-        translated_pos.y -= h;
-        break;
-      case origin_bottom_center :
-        translated_pos.x -= w / 2;
-        translated_pos.y -= h;
-        break;
-      case origin_bottom_right :
-        translated_pos.x -= w;
-        translated_pos.y -= h;
-    }
-}
-
-void
 LevelObj::set_pos(Vector3f p)
 {
   pos = p;
-  set_translated_pos();
 }
 
 void

Modified: trunk/pingus/src/editor/level_objs.hpp
===================================================================
--- trunk/pingus/src/editor/level_objs.hpp      2007-09-17 16:05:41 UTC (rev 
3169)
+++ trunk/pingus/src/editor/level_objs.hpp      2007-09-17 19:49:08 UTC (rev 
3170)
@@ -69,10 +69,6 @@
   /** Location of this object in the World */
   Vector3f pos;
 
-  /** Only used for display functions - this is the pos Vector3f adjusted
-      by the translation origin of the sprite */
-  Vector3f translated_pos;
-
   /** Location of this object before moving it around */
   Vector3f orig_pos;
 
@@ -291,10 +287,8 @@
 
   /** Soft delete of the object (needed for Undo action) */
   void remove() { removed = true; }
+  bool is_removed() const { return removed; }
 
-  /** Undelete this object if it's been removed */
-  void unremove() { removed = false; }
-
   /** Select or unselect this object */
   void select() { selected = true; }
   void unselect() { selected = false; }

Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-09-17 16:05:41 UTC (rev 
3169)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-09-17 19:49:08 UTC (rev 
3170)
@@ -319,7 +319,7 @@
     {
       // need to reset the align to top/left
       set->add(new ObjectSelectorList::Object(Resource::load_sprite(*i),
-                          Resource::load_thumb_sprite(*i)));
+                                              
Resource::load_thumb_sprite(*i)));
     }
   
   return set;

Modified: trunk/pingus/src/editor/object_selector_list.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.cpp    2007-09-17 16:05:41 UTC 
(rev 3169)
+++ trunk/pingus/src/editor/object_selector_list.cpp    2007-09-17 19:49:08 UTC 
(rev 3170)
@@ -86,9 +86,11 @@
 
   if (set && mode == OBJECT_DRAG)
     {
-      parent_gc.draw(set->get_objects()[current_object]->sprite, 
-                     real_mouse_pos - 
Vector2i(set->get_objects()[current_object]->sprite.get_width()/2,
-                                               
set->get_objects()[current_object]->sprite.get_height()/2), 
+      Sprite sprite = set->get_objects()[current_object]->sprite;
+      parent_gc.draw(sprite,
+                     real_mouse_pos
+                     - Vector2i(sprite.get_width()/2, sprite.get_height()/2)
+                     + sprite.get_offset(), 
                      2000.0f);
     }
 }
@@ -130,6 +132,8 @@
               p -= 
Vector2i(set->get_objects()[current_object]->sprite.get_width()/2,
                             
set->get_objects()[current_object]->sprite.get_height()/2);
 
+              p += set->get_objects()[current_object]->sprite.get_offset();
+
               LevelObj* obj = set->get_objects()[current_object]->create(p, 
editor->get_level()->get_level_impl());
               if (obj)
                 editor->add_object(obj);

Modified: trunk/pingus/src/editor/object_selector_list.hpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.hpp    2007-09-17 16:05:41 UTC 
(rev 3169)
+++ trunk/pingus/src/editor/object_selector_list.hpp    2007-09-17 19:49:08 UTC 
(rev 3170)
@@ -44,7 +44,8 @@
     Object(const Sprite& sprite_, const Sprite& thumbnail_) 
       : sprite(sprite_),
         thumbnail(thumbnail_)
-    {}      
+    {
+    }
 
     virtual ~Object() {}
 

Modified: trunk/pingus/src/sprite.cpp
===================================================================
--- trunk/pingus/src/sprite.cpp 2007-09-17 16:05:41 UTC (rev 3169)
+++ trunk/pingus/src/sprite.cpp 2007-09-17 19:49:08 UTC (rev 3170)
@@ -385,6 +385,12 @@
   impl = new_impl;  
 }
 
+Vector2i
+Sprite::get_offset() const
+{
+  return impl->offset;
+}
+
 void
 Sprite::set_hotspot(Origin origin, int x, int y)
 {

Modified: trunk/pingus/src/sprite.hpp
===================================================================
--- trunk/pingus/src/sprite.hpp 2007-09-17 16:05:41 UTC (rev 3169)
+++ trunk/pingus/src/sprite.hpp 2007-09-17 19:49:08 UTC (rev 3170)
@@ -49,6 +49,7 @@
 
   void draw(float x, float y, SDL_Surface* target);
   void set_hotspot(Origin origin, int x, int y);
+  Vector2i get_offset() const;
   void set_frame(int i);
   int  get_frame_count() const;
   int  get_current_frame() const;





reply via email to

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