pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2696 - in branches/pingus_sdl: data/images/fonts src src/w


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2696 - in branches/pingus_sdl: data/images/fonts src src/worldobjs
Date: Fri, 19 Jan 2007 11:56:02 +0100

Author: grumbel
Date: 2007-01-19 11:56:00 +0100 (Fri, 19 Jan 2007)
New Revision: 2696

Modified:
   branches/pingus_sdl/data/images/fonts/chalk_normal-iso-8859-1.font
   branches/pingus_sdl/data/images/fonts/courier_small-iso-8859-1.font
   branches/pingus_sdl/data/images/fonts/pingus_small-iso-8859-1.font
   branches/pingus_sdl/data/images/fonts/pingus_small_fix_num-iso-8859-1.font
   branches/pingus_sdl/src/SConscript
   branches/pingus_sdl/src/blitter.cpp
   branches/pingus_sdl/src/blitter.hpp
   branches/pingus_sdl/src/blitter_impl.hpp
   branches/pingus_sdl/src/font.cpp
   branches/pingus_sdl/src/resource.cpp
   branches/pingus_sdl/src/resource.hpp
   branches/pingus_sdl/src/worldobjs/groundpiece.cpp
Log:
- some more work on font stuff

Modified: branches/pingus_sdl/data/images/fonts/chalk_normal-iso-8859-1.font
===================================================================
--- branches/pingus_sdl/data/images/fonts/chalk_normal-iso-8859-1.font  
2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/data/images/fonts/chalk_normal-iso-8859-1.font  
2007-01-19 10:56:00 UTC (rev 2696)
@@ -2,7 +2,7 @@
 (pingus-font
  (name "Chalk Normal")
  (space-length    8)
- (alpha-threshold  64)
+ (alpha-threshold  0)
  (characters "!\"#$%&'()*+,-./0123456789:;<=>?@"
              "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
              
"���������������������������������������������������������������������������������������������")

Modified: branches/pingus_sdl/data/images/fonts/courier_small-iso-8859-1.font
===================================================================
--- branches/pingus_sdl/data/images/fonts/courier_small-iso-8859-1.font 
2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/data/images/fonts/courier_small-iso-8859-1.font 
2007-01-19 10:56:00 UTC (rev 2696)
@@ -1,7 +1,7 @@
 ;; -*- scheme -*-
 (pingus-font
  (name "Pingus Small")
- (space-length    20)
+ (space-length    8)
  (alpha-threshold  0)
  (characters "!\"#$%&'()*+,-./0123456789:;<=>?@"
              "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"

Modified: branches/pingus_sdl/data/images/fonts/pingus_small-iso-8859-1.font
===================================================================
--- branches/pingus_sdl/data/images/fonts/pingus_small-iso-8859-1.font  
2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/data/images/fonts/pingus_small-iso-8859-1.font  
2007-01-19 10:56:00 UTC (rev 2696)
@@ -1,7 +1,7 @@
 ;; -*- scheme -*-
 (pingus-font
  (name "Pingus Small")
- (space-length    20)
+ (space-length    8)
  (alpha-threshold  0)
  (characters "!\"#$%&'()*+,-./0123456789:;<=>?@"
              "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"

Modified: 
branches/pingus_sdl/data/images/fonts/pingus_small_fix_num-iso-8859-1.font
===================================================================
--- branches/pingus_sdl/data/images/fonts/pingus_small_fix_num-iso-8859-1.font  
2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/data/images/fonts/pingus_small_fix_num-iso-8859-1.font  
2007-01-19 10:56:00 UTC (rev 2696)
@@ -1,7 +1,7 @@
 ;; -*- scheme -*-
 (pingus-font
  (name "Pingus Small")
- (space-length    20)
+ (space-length    8)
  (alpha-threshold  0)
  (characters "!\"#$%&'()*+,-./0123456789:;<=>?@"
              "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"

Modified: branches/pingus_sdl/src/SConscript
===================================================================
--- branches/pingus_sdl/src/SConscript  2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/src/SConscript  2007-01-19 10:56:00 UTC (rev 2696)
@@ -91,7 +91,7 @@
 'actions/teleported.cpp', 
 'actions/waiter.cpp', 
 'actions/walker.cpp', 
-# 'blitter.cpp',
+'blitter.cpp',
 # 'blitter_test.cpp', 
 'capture_rectangle.cpp', 
 'cheat.cpp', 

Modified: branches/pingus_sdl/src/blitter.cpp
===================================================================
--- branches/pingus_sdl/src/blitter.cpp 2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/src/blitter.cpp 2007-01-19 10:56:00 UTC (rev 2696)
@@ -20,12 +20,6 @@
 #include <config.h>
 #include <stdio.h>
 #include <assert.h>
-#include <ClanLib/Core/System/clanstring.h>
-#include <ClanLib/Core/IOData/cl_endian.h>
-#include <ClanLib/Core/IOData/datatypes.h>
-#include <ClanLib/Display/palette.h>
-#include <ClanLib/Display/pixel_buffer.h>
-#include <ClanLib/Display/pixel_format.h>
 
 #include "string_util.hpp"
 #include "pingus_error.hpp"
@@ -38,14 +32,8 @@
 /* Headers needed for i18n / gettext */
 #include "gettext.h"
 
+#if 0
 void
-Blitter::put_surface(PixelBuffer canvas, const CL_Surface& sur,
-                    int x, int y)
-{
-  Blitter::put_surface(canvas, sur.get_pixeldata(), x, y);
-}
-
-void
 Blitter::put_surface(PixelBuffer canvas, PixelBuffer provider,
                     int x, int y)
 {
@@ -418,12 +406,6 @@
 }
 
 PixelBuffer
-Blitter::create_canvas(const CL_Surface& sur)
-{
-  return create_canvas(sur.get_pixeldata());
-}
-
-PixelBuffer
 Blitter::create_canvas(PixelBuffer prov)
 {
   PixelBuffer canvas(prov.get_width(), prov.get_height(), prov.get_width()*4, 
CL_PixelFormat::rgba8888);
@@ -621,6 +603,7 @@
 {
   return Blitter::scale_surface_to_canvas(sur.get_pixeldata(), width, height);
 }
+#endif
 
 /** Flip a surface horizontal */
 PixelBuffer

Modified: branches/pingus_sdl/src/blitter.hpp
===================================================================
--- branches/pingus_sdl/src/blitter.hpp 2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/src/blitter.hpp 2007-01-19 10:56:00 UTC (rev 2696)
@@ -23,9 +23,7 @@
 #include "pingus.hpp"
 #include "math/color.hpp"
 #include "math/rect.hpp"
-////#include <ClanLib/Display/color.h>
 
-////class CL_Surface;
 class PixelBuffer;
 
 /** A bunch of blitting and creation functions to operate on
@@ -50,10 +48,6 @@
                          int x, int y);
 
   /** Returns a newly allocated canvas. The canvas contains the same
-      image as the given surface. */
-  ////static PixelBuffer create_canvas(const CL_Surface&);
-
-  /** Returns a newly allocated canvas. The canvas contains the same
       image as the given surface provider */
   static PixelBuffer create_canvas(PixelBuffer );
 

Modified: branches/pingus_sdl/src/blitter_impl.hpp
===================================================================
--- branches/pingus_sdl/src/blitter_impl.hpp    2007-01-19 06:34:44 UTC (rev 
2695)
+++ branches/pingus_sdl/src/blitter_impl.hpp    2007-01-19 10:56:00 UTC (rev 
2696)
@@ -21,11 +21,9 @@
 #define HEADER_PINGUS_BLITTER_IMPL_HXX
 
 #include <iostream>
-#include <ClanLib/Display/pixel_buffer.h>
-#include <ClanLib/Display/surface.h>
+#include "pixel_buffer.hpp"
 #include "pingus.hpp"
 
-
 /** A collection of helper functions for the blitter class */
 namespace BlitterImpl
 {
@@ -181,6 +179,9 @@
 inline
 PixelBuffer modify(PixelBuffer prov, const TransF&)
 {
+  std::cout << "Blitter::modify: " << 
prov.get_surface()->format->BytesPerPixel << std::endl;
+  return prov;
+#if 0
   if (prov.get_format().get_type() ==  pixelformat_index)
     {
       CL_PixelFormat format(8, 0, 0, 0, 0, 
@@ -188,9 +189,9 @@
                             pixelformat_index);
       
       PixelBuffer canvas(TransF::get_width (prov.get_width(), 
prov.get_height()), 
-                            TransF::get_height(prov.get_width(), 
prov.get_height()),
-                            TransF::get_width (prov.get_width(), 
prov.get_height()),
-                            format, prov.get_palette());
+                         TransF::get_height(prov.get_width(), 
prov.get_height()),
+                         TransF::get_width (prov.get_width(), 
prov.get_height()),
+                         format, prov.get_palette());
 
       prov.lock ();
       canvas.lock ();
@@ -217,7 +218,7 @@
       int pwidth  = prov.get_width();
       int pheight = prov.get_height();
                        
-                       PixelBuffer canvas(prov.get_height(), pwidth, 
pheight*4, CL_PixelFormat::rgba8888);
+      PixelBuffer canvas(prov.get_height(), pwidth, pheight*4, 
CL_PixelFormat::rgba8888);
 
       prov.lock();
       canvas.lock();
@@ -236,6 +237,7 @@
 
       return canvas;
     }
+#endif
 }
 
 } // namespace BlitterImpl

Modified: branches/pingus_sdl/src/font.cpp
===================================================================
--- branches/pingus_sdl/src/font.cpp    2007-01-19 06:34:44 UTC (rev 2695)
+++ branches/pingus_sdl/src/font.cpp    2007-01-19 10:56:00 UTC (rev 2696)
@@ -93,7 +93,6 @@
                   std::cout << "Error: Found more desc.characters then are 
mapped" << std::endl;
 
                 idx += 1;
-                
                 first = -1;
               }
           }
@@ -104,10 +103,10 @@
           }
       }
     
-    if (idx != int(desc.characters.size()))
+    if (idx-1 != int(desc.characters.size())) // FIXME: is that -1 correct?!
       {
         std::cout << "Font: " << desc.image << "\n"
-                  << "  Error:  " << idx << " expected "  << 
desc.characters.size() << "\n"
+                  << "  Error: " << idx-1 << " expected "  << 
desc.characters.size() << "\n"
                   << "  Format: bpp: " << int(surface->format->BitsPerPixel) 
<< "\n"
                   << "  Size: " << surface->w << "x" << surface->h
           //      << "  RMask: " << hex << surface->format->Rmask << "\n"
@@ -152,7 +151,7 @@
             if (srcrect.w != 0 && srcrect.h != 0)
               {
                 SDL_BlitSurface(surface, &srcrect, target, &dstrect);
-                dstrect.x += srcrect.w + 1;
+                dstrect.x += srcrect.w+1;
               }
             else
               {
@@ -174,16 +173,25 @@
 
   int  get_width(const std::string& text) const
   {
-    // FIXME: Line breaks aren't handled
     int width = 0;
+    int last_width = 0;
     for(std::string::size_type i = 0; i < text.size(); ++i)
       {
         if (text[i] == ' ')
-          width += space_length;
+          {
+            width += space_length;
+          }
+        else if (text[i] == '\n')
+          {
+            last_width = std::max(last_width, width);
+            width = 0;
+          }
         else
-          width += chrs[static_cast<unsigned char>(text[i])].w;
+          {
+            width += chrs[static_cast<unsigned char>(text[i])].w+1;
+          }
       }
-    return width;
+    return std::max(width, last_width);
   }
 
   Size get_size(const std::string& text) const

Modified: branches/pingus_sdl/src/resource.cpp
===================================================================
--- branches/pingus_sdl/src/resource.cpp        2007-01-19 06:34:44 UTC (rev 
2695)
+++ branches/pingus_sdl/src/resource.cpp        2007-01-19 10:56:00 UTC (rev 
2696)
@@ -30,6 +30,7 @@
 #include "globals.hpp"
 #include "font_description.hpp"
 #include "resource.hpp"
+#include "res_descriptor.hpp"
 #include "blitter.hpp"
 #include "debug.hpp"
 
@@ -113,6 +114,41 @@
   return load_sprite(desc.res_name);
 }
 
+PixelBuffer
+Resource::apply_modifier_to_pixelbuffer(PixelBuffer prov, const ResDescriptor& 
desc)
+{
+  switch (desc.modifier)
+    {
+    case ResourceModifierNS::ROT0:
+      return prov;
+
+    case ResourceModifierNS::ROT90:
+      return Blitter::rotate_90(prov);
+
+    case ResourceModifierNS::ROT180:
+      return Blitter::rotate_180(prov);
+
+    case ResourceModifierNS::ROT270:
+      return Blitter::rotate_270(prov);
+
+    case ResourceModifierNS::ROT0FLIP:
+      return Blitter::flip_horizontal(prov);
+
+    case ResourceModifierNS::ROT90FLIP:
+      return Blitter::rotate_90_flip(prov);
+
+    case ResourceModifierNS::ROT180FLIP:
+      return Blitter::rotate_180_flip(prov);
+
+    case ResourceModifierNS::ROT270FLIP:
+      return Blitter::rotate_270_flip(prov);
+
+    default:
+      perr << "Resource: Unhandled modifier: " << desc.modifier << std::endl;
+      return prov;
+    }
+}
+
 Sprite
 Resource::load_sprite(const std::string& res_name)
 {
@@ -142,18 +178,7 @@
 PixelBuffer
 Resource::load_pixelbuffer(const ResDescriptor& desc_)
 {
-  return PixelBuffer(desc_.res_name);
-#if 0
-  CL_SpriteDescription desc = load_sprite_desc(desc_.res_name);
-
-  if (desc.get_frames().size() == 0)
-    {
-      std::cout << "Error: load_pixelbuffer: " << desc_.res_name << std::endl;
-      assert(0);
-    }
-
-  return apply_modifier_to_pixelbuffer(desc.get_frames().begin()->first, 
desc_);
-#endif
+  return apply_modifier_to_pixelbuffer(PixelBuffer(desc_.res_name), desc_);
 }
 
 PixelBuffer
@@ -218,42 +243,9 @@
       return i->second;
     }
 }
+#endif 
 
-PixelBuffer
-Resource::apply_modifier_to_pixelbuffer(PixelBuffer prov, const ResDescriptor& 
res_desc)
-{
-  switch (res_desc.modifier)
-    {
-    case ResourceModifierNS::ROT0:
-      return prov;
-
-    case ResourceModifierNS::ROT90:
-      return Blitter::rotate_90(prov);
-
-    case ResourceModifierNS::ROT180:
-      return Blitter::rotate_180(prov);
-
-    case ResourceModifierNS::ROT270:
-      return Blitter::rotate_270(prov);
-
-    case ResourceModifierNS::ROT0FLIP:
-      return Blitter::flip_horizontal(prov);
-
-    case ResourceModifierNS::ROT90FLIP:
-      return Blitter::rotate_90_flip(prov);
-
-    case ResourceModifierNS::ROT180FLIP:
-      return Blitter::rotate_180_flip(prov);
-
-    case ResourceModifierNS::ROT270FLIP:
-      return Blitter::rotate_270_flip(prov);
-
-    default:
-      perr << "Resource: Unhandled modifier: " << res_desc.modifier << 
std::endl;
-      return prov;
-    }
-}
-
+#if 0 
 CL_Surface
 Resource::apply_modifier (const CL_Surface& surf, const ResDescriptor& 
res_desc)
 {

Modified: branches/pingus_sdl/src/resource.hpp
===================================================================
--- branches/pingus_sdl/src/resource.hpp        2007-01-19 06:34:44 UTC (rev 
2695)
+++ branches/pingus_sdl/src/resource.hpp        2007-01-19 10:56:00 UTC (rev 
2696)
@@ -44,7 +44,6 @@
   static CL_Surface load_from_source (const ResDescriptor& res_desc);
   static CL_Surface load_from_cache (const ResDescriptor& res_desc);
   static CL_Surface apply_modifier (const CL_Surface&, const ResDescriptor& 
res_desc);
-  static PixelBuffer apply_modifier_to_pixelbuffer(PixelBuffer, const 
ResDescriptor& res_desc);
 
   /** Returns a list of resources for the given section.
       Returns all if blank */
@@ -55,6 +54,7 @@
       Returns all sections if blank */
   static std::vector<std::string> get_sections(const std::string &section = 
std::string());
 #endif
+  static PixelBuffer apply_modifier_to_pixelbuffer(PixelBuffer, const 
ResDescriptor& res_desc);
 
 public:
   static void init();

Modified: branches/pingus_sdl/src/worldobjs/groundpiece.cpp
===================================================================
--- branches/pingus_sdl/src/worldobjs/groundpiece.cpp   2007-01-19 06:34:44 UTC 
(rev 2695)
+++ branches/pingus_sdl/src/worldobjs/groundpiece.cpp   2007-01-19 10:56:00 UTC 
(rev 2696)
@@ -33,11 +33,6 @@
   
   gptype = Groundtype::GP_GROUND;
   reader.read_enum("type", gptype, &Groundtype::string_to_type);
-
-  std::cout << "Groundpiece: " << desc.res_name << std::endl;
-
-  // FIXME: we don't need to load surfaces here, providers would be
-  // FIXME: enough and should be faster
 }
 
 void





reply via email to

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