pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3833 - in trunk/pingus: . src src/worldobjs


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3833 - in trunk/pingus: . src src/worldobjs
Date: Wed, 16 Jul 2008 12:59:36 +0200

Author: grumbel
Date: 2008-07-16 12:59:32 +0200 (Wed, 16 Jul 2008)
New Revision: 3833

Modified:
   trunk/pingus/SConstruct
   trunk/pingus/src/pingus_menu.cpp
   trunk/pingus/src/resource.cpp
   trunk/pingus/src/sprite.cpp
   trunk/pingus/src/worldobjs/surface_background.cpp
   trunk/pingus/src/worldobjs/surface_background.hpp
Log:
Reenabled things, disabled in the last commit

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2008-07-16 10:23:09 UTC (rev 3832)
+++ trunk/pingus/SConstruct     2008-07-16 10:59:32 UTC (rev 3833)
@@ -121,6 +121,8 @@
 'src/gui/checkbox.cpp',
 'src/gui/combobox.cpp', 
 'src/display/display.cpp', 
+'src/display/framebuffer_surface.cpp', 
+'src/display/sdl_framebuffer_surface_impl.cpp', 
 'src/display/sdl_framebuffer.cpp', 
 'src/display/delta_framebuffer.cpp', 
 'src/display/rect_merger.cpp',

Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp    2008-07-16 10:23:09 UTC (rev 3832)
+++ trunk/pingus/src/pingus_menu.cpp    2008-07-16 10:59:32 UTC (rev 3833)
@@ -207,11 +207,11 @@
   // Recreate the layer manager in the new size
   background = std::auto_ptr<LayerManager>(new LayerManager());
 
-  Sprite layer1("core/menu/layer1");
-  Sprite layer2("core/menu/layer2");
-  Sprite layer3("core/menu/layer3");
-  Sprite layer4("core/menu/layer4");
-  Sprite layer5("core/menu/layer5");
+  Surface layer1 = Resource::load_surface("core/menu/layer1");
+  Surface layer2 = Resource::load_surface("core/menu/layer2");
+  Surface layer3 = Resource::load_surface("core/menu/layer3");
+  Surface layer4 = Resource::load_surface("core/menu/layer4");
+  Surface layer5 = Resource::load_surface("core/menu/layer5");
 
   int w = size.width;
   int h = size.height;
@@ -220,28 +220,26 @@
   // resolution is not default
   if (w != default_screen_width && h != default_screen_height)
     {
-#if 0 // FIXME: Wed Jul 16 11:40:53 2008
-      layer1.scale(w, 185 * h / default_screen_height);
-      layer2.scale(w, 362 * h / default_screen_height);
-      layer3.scale(w, 306 * h / default_screen_height);
-      layer4.scale(w, 171 * h / default_screen_height);
-      layer5.scale(302 * w / default_screen_width, 104 * h / 
default_screen_height);
+      layer1 = layer1.scale(w, 185 * h / default_screen_height);
+      layer2 = layer2.scale(w, 362 * h / default_screen_height);
+      layer3 = layer3.scale(w, 306 * h / default_screen_height);
+      layer4 = layer4.scale(w, 171 * h / default_screen_height);
+      layer5 = layer5.scale(302 * w / default_screen_width, 104 * h / 
default_screen_height);
       
-      background->add_layer(layer1, 0, 0, 12, 0);
-      background->add_layer(layer2, 0, 150 * (float)h / default_screen_height, 
25, 0);
-      background->add_layer(layer3, 0, 200 * (float)h / default_screen_height, 
50, 0);
-      background->add_layer(layer4, 0, 429 * (float)h / default_screen_height, 
100, 0);
-      background->add_layer(layer5, 0, 500 * (float)h / default_screen_height, 
200, 0);
-#endif
+      background->add_layer(Sprite(layer1), 0, 0, 12, 0);
+      background->add_layer(Sprite(layer2), 0, 150 * (float)h / 
default_screen_height, 25, 0);
+      background->add_layer(Sprite(layer3), 0, 200 * (float)h / 
default_screen_height, 50, 0);
+      background->add_layer(Sprite(layer4), 0, 429 * (float)h / 
default_screen_height, 100, 0);
+      background->add_layer(Sprite(layer5), 0, 500 * (float)h / 
default_screen_height, 200, 0);
     }
   else
     {
-      background->add_layer(layer1, 0, 0, 12, 0);
-      background->add_layer(layer2, 0, 150, 25, 0);
-      background->add_layer(layer3, 0, 200, 50, 0);
-      background->add_layer(layer4, 0, 429, 100, 0);
-      background->add_layer(layer5, 0, 500, 200, 0);
-    }  
+      background->add_layer(Sprite(layer1), 0, 0, 12, 0);
+      background->add_layer(Sprite(layer2), 0, 150, 25, 0);
+      background->add_layer(Sprite(layer3), 0, 200, 50, 0);
+      background->add_layer(Sprite(layer4), 0, 429, 100, 0);
+      background->add_layer(Sprite(layer5), 0, 500, 200, 0);
+    }
 }
 
 void

Modified: trunk/pingus/src/resource.cpp
===================================================================
--- trunk/pingus/src/resource.cpp       2008-07-16 10:23:09 UTC (rev 3832)
+++ trunk/pingus/src/resource.cpp       2008-07-16 10:59:32 UTC (rev 3833)
@@ -124,25 +124,21 @@
     }
   else
     {
-      Sprite sprite(name);
+      Surface surface = load_surface(name);
 
       Size thumb_size;
-      if (sprite.get_width() <= 48)
-        thumb_size.width = sprite.get_width();
+      if (surface.get_width() <= 48)
+        thumb_size.width = surface.get_width();
       else
         thumb_size.width = 48;
 
-      if (sprite.get_height() <= 48)
-        thumb_size.height = sprite.get_height();
+      if (surface.get_height() <= 48)
+        thumb_size.height = surface.get_height();
       else
         thumb_size.height = 48;
 
-#if 0 // FIXME: Wed Jul 16 11:40:53 2008
-      sprite.scale(thumb_size.width, thumb_size.height);
-#endif
-
+      Sprite sprite(surface.scale(thumb_size.width, thumb_size.height));
       sprite.set_hotspot(origin_top_left, (48 - sprite.get_width())/2, (48 - 
sprite.get_height())/2);
-
       return sprite;
     }
 }

Modified: trunk/pingus/src/sprite.cpp
===================================================================
--- trunk/pingus/src/sprite.cpp 2008-07-16 10:23:09 UTC (rev 3832)
+++ trunk/pingus/src/sprite.cpp 2008-07-16 10:59:32 UTC (rev 3833)
@@ -186,84 +186,6 @@
     impl->finish();
 }
 
-#if 0 // FIXME: Wed Jul 16 11:40:53 2008
-void
-Sprite::scale(int w, int h)
-{
-  if (impl.get())
-    {
-      // FIXME: This doesn't work for animated graphics, in which case it will 
only handle the first frame
-      if (impl->frame_size.width != w || impl->frame_size.height != h)
-        {
-          boost::shared_ptr<SpriteImpl> new_impl(new SpriteImpl());
-      
-          if ((impl->frame_size.width  * impl->array.width)  == 
impl->surface.get_width() && 
-              (impl->frame_size.height * impl->array.height) == 
impl->surface.get_height())
-            { // single frame Sprite
-              new_impl->surface = impl->surface.scale(w, h);
-            }
-          else
-            { // multi frame sprite
-              new_impl->surface = 
impl->surface.subsection(Rect(impl->frame_pos, impl->frame_size)).scale(w, h);
-            }
-
-          float scale_x = float(w) / float(impl->frame_size.width);
-          float scale_y = float(h) / float(impl->frame_size.height);
-      
-          new_impl->offset          = Vector2i(int(impl->offset.x * scale_x),
-                                               int(impl->offset.y * scale_y)); 
-          new_impl->frame_pos       = Vector2i(0, 0);
-          new_impl->frame_size      = Size(w, h);
-          new_impl->frame_delay     = impl->frame_delay;
-          new_impl->array           = impl->array;
-          new_impl->loop            = impl->loop;
-          new_impl->loop_last_cycle = impl->loop_last_cycle;
-          new_impl->finished        = impl->finished;
-          new_impl->frame           = impl->frame;
-          new_impl->tick_count      = impl->tick_count;
-
-          impl = new_impl;
-        }
-    }
-}
-
-void
-Sprite::fill(const Color& color)
-{
-  if (impl.get())
-    {
-      if (color.a != 0) 
-        {
-          make_single_user();
-          impl->surface.fill(color);
-        }
-    }
-}
-
-void
-Sprite::make_single_user()
-{
-  if (impl.get())
-    {
-      boost::shared_ptr<SpriteImpl> new_impl(new SpriteImpl());
-  
-      new_impl->surface         = impl->surface.clone();
-      new_impl->offset          = impl->offset;
-      new_impl->frame_pos       = impl->frame_pos;
-      new_impl->frame_size      = impl->frame_size;
-      new_impl->frame_delay     = impl->frame_delay;
-      new_impl->array           = impl->array;
-      new_impl->loop            = impl->loop;
-      new_impl->loop_last_cycle = impl->loop_last_cycle;
-      new_impl->finished        = impl->finished;
-      new_impl->frame           = impl->frame;
-      new_impl->tick_count      = impl->tick_count;
-
-      impl = new_impl;  
-    }
-}
-#endif
-
 Vector2i
 Sprite::get_offset() const
 {
@@ -282,32 +204,5 @@
       impl->offset = calc_origin(origin, impl->frame_size) - Vector2i(x, y);
     }
 }
-
-#if 0 // FIXME
-void
-Sprite::apply_mod(ResourceModifierNS::ResourceModifier mod)
-{
-  if (impl.get())
-    {
-      // FIXME: This isn't all that useful, since Sprites are optimized
-      // per default and thus not modifiable, since the Modifier can only
-      // handle indexed images.
-      if (impl->frame_pos  == Vector2i(0, 0) &&
-          impl->frame_size == Size(impl->surface.get_width(), 
impl->surface.get_height()) &&
-          impl->array      == Size(1, 1))
-        {
-          make_single_user();
-          impl->surface = impl->surface.mod(mod);
-          impl->frame_size.width  = impl->surface.get_width();
-          impl->frame_size.height = impl->surface.get_height();
-        }
-      else
-        {
-          std::cout << "Error: Sprite: apply_mod() only works with single 
frame Sprites" << std::endl;
-        }
-    }
-}
-#endif
-
 
 /* EOF */

Modified: trunk/pingus/src/worldobjs/surface_background.cpp
===================================================================
--- trunk/pingus/src/worldobjs/surface_background.cpp   2008-07-16 10:23:09 UTC 
(rev 3832)
+++ trunk/pingus/src/worldobjs/surface_background.cpp   2008-07-16 10:59:32 UTC 
(rev 3833)
@@ -56,40 +56,41 @@
 
   reader.read_bool("keep-aspect", keep_aspect);
 
-  bg_surface = Sprite(desc);
-#if 0 // FIXME: Wed Jul 16 11:40:53 2008
-  bg_surface.fill(color);
+  Surface surface = Resource::load_surface(desc);
 
+  surface.fill(color);
+
   // Scaling Code
   if (stretch_x && stretch_y)
     {
-      bg_surface.scale(world->get_width(), world->get_height());
+      surface = surface.scale(world->get_width(), world->get_height());
     }
   else if (stretch_x && !stretch_y)
     {
       if (keep_aspect)
         {
-          float aspect = bg_surface.get_height()/float(bg_surface.get_width());
-          bg_surface.scale(world->get_width(), int(world->get_width()*aspect));
+          float aspect = surface.get_height()/float(surface.get_width());
+          surface = surface.scale(world->get_width(), 
int(world->get_width()*aspect));
         }
       else
         {
-          bg_surface.scale(world->get_width(), bg_surface.get_height());
+          surface = surface.scale(world->get_width(), surface.get_height());
         }
     }
   else if (!stretch_x && stretch_y)
     {
       if (keep_aspect)
         {
-          float aspect = float(bg_surface.get_width())/bg_surface.get_height();
-          bg_surface.scale(int(world->get_height() * aspect), 
world->get_height());
+          float aspect = float(surface.get_width())/surface.get_height();
+          surface = surface.scale(int(world->get_height() * aspect), 
world->get_height());
         }
       else
         {
-          bg_surface.scale(bg_surface.get_width(), world->get_height());
+          surface = surface.scale(surface.get_width(), world->get_height());
         }
     }
-#endif
+
+  bg_sprite = Sprite(surface);
 }
 
 float
@@ -101,34 +102,34 @@
 void
 SurfaceBackground::update()
 {
-  if (!bg_surface)
+  if (!bg_sprite)
     return;
 
   if (scroll_x) 
     {
       scroll_ox += scroll_x;
 
-      if (scroll_ox > bg_surface.get_width())
-        scroll_ox -= bg_surface.get_width();
-      else if (-scroll_ox > bg_surface.get_width())
-        scroll_ox += bg_surface.get_width();
+      if (scroll_ox > bg_sprite.get_width())
+        scroll_ox -= bg_sprite.get_width();
+      else if (-scroll_ox > bg_sprite.get_width())
+        scroll_ox += bg_sprite.get_width();
     }
 
   if (scroll_y) 
     {
       scroll_oy += scroll_y;
 
-      if (scroll_oy > bg_surface.get_height())
-        scroll_oy -= bg_surface.get_height();
-      else if (-scroll_oy > bg_surface.get_height())
-        scroll_oy += bg_surface.get_height();
+      if (scroll_oy > bg_sprite.get_height())
+        scroll_oy -= bg_sprite.get_height();
+      else if (-scroll_oy > bg_sprite.get_height())
+        scroll_oy += bg_sprite.get_height();
     }
 }
 
 void
 SurfaceBackground::draw (SceneContext& gc)
 {
-  if (!bg_surface)
+  if (!bg_sprite)
     return;
 
   
@@ -141,21 +142,21 @@
   int start_y = static_cast<int>((offset.y * para_y) + scroll_oy);
 
   if (start_x > 0)
-    start_x = (start_x % bg_surface.get_width()) - bg_surface.get_width();
+    start_x = (start_x % bg_sprite.get_width()) - bg_sprite.get_width();
 
   if (start_y > 0)
-    start_y = (start_y % bg_surface.get_height()) - bg_surface.get_height();
+    start_y = (start_y % bg_sprite.get_height()) - bg_sprite.get_height();
 
   for(int y = start_y;
       y < world->get_height();
-      y += bg_surface.get_height())
+      y += bg_sprite.get_height())
     {
       for(int x = start_x;
           x < world->get_width();
-          x += bg_surface.get_width())
+          x += bg_sprite.get_width())
         {
-          gc.color().draw(bg_surface, Vector3f(x - offset.x, 
-                                               y - offset.y, pos.z));
+          gc.color().draw(bg_sprite, Vector3f(x - offset.x, 
+                                              y - offset.y, pos.z));
         }
     }
 }

Modified: trunk/pingus/src/worldobjs/surface_background.hpp
===================================================================
--- trunk/pingus/src/worldobjs/surface_background.hpp   2008-07-16 10:23:09 UTC 
(rev 3832)
+++ trunk/pingus/src/worldobjs/surface_background.hpp   2008-07-16 10:59:32 UTC 
(rev 3833)
@@ -57,8 +57,8 @@
   /** If streched in x or y direction keep the aspect ratio */
   bool keep_aspect;
 
-       /** Background image */
-       Sprite bg_surface;
+  /** Background image */
+  Sprite bg_sprite;
 
   /** The horizontal scrolling speed in pixels per tick */
   float scroll_ox;





reply via email to

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