pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2520 - in trunk/src: . actions particles tinygettext world


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2520 - in trunk/src: . actions particles tinygettext worldobjs
Date: Thu, 1 Dec 2005 21:55:37 +0100

Author: grumbel
Date: 2005-12-01 21:55:34 +0100 (Thu, 01 Dec 2005)
New Revision: 2520

Added:
   trunk/src/ground_map.cxx
   trunk/src/ground_map.hxx
   trunk/src/tinygettext/
   trunk/src/tinygettext/tinygettext.cxx
   trunk/src/tinygettext/tinygettext.hxx
Removed:
   trunk/src/pingu_map.cxx
   trunk/src/pingu_map.hxx
   trunk/src/spot_map.cxx
   trunk/src/spot_map.hxx
   trunk/src/tinygettext.cxx
   trunk/src/tinygettext.hxx
Modified:
   trunk/src/SConscript
   trunk/src/actions/basher.cxx
   trunk/src/actions/bomber.cxx
   trunk/src/actions/bridger.cxx
   trunk/src/actions/digger.cxx
   trunk/src/actions/miner.cxx
   trunk/src/gettext.h
   trunk/src/particles/snow_particle_holder.cxx
   trunk/src/world.cxx
   trunk/src/world.hxx
   trunk/src/worldobjs/groundpiece.cxx
   trunk/src/worldobjs/ice_block.cxx
   trunk/src/xml_pdf.hxx
Log:
- removed PinguMap, renamed SpotMap to GroundMap

Modified: trunk/src/SConscript
===================================================================
--- trunk/src/SConscript        2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/SConscript        2005-12-01 20:55:34 UTC (rev 2520)
@@ -182,7 +182,6 @@
 'pingu_action_factory.cxx', 
 'pingu_enums.cxx', 
 'pingu_holder.cxx', 
-'pingu_map.cxx', 
 'pingus_counter_bar.cxx', 
 'pingus_error.cxx', 
 'pingus_level.cxx', 
@@ -210,7 +209,7 @@
 'sound/sound_dummy.cxx', 
 'sound/sound_real.cxx', 
 'sound/sound_res_mgr.cxx', 
-'spot_map.cxx', 
+'ground_map.cxx', 
 'start_screen.cxx', 
 'stat_manager.cxx', 
 'state_sprite.cxx', 
@@ -219,7 +218,7 @@
 'string_format.cxx', 
 'system.cxx', 
 'timer.cxx', 
-'tinygettext.cxx', 
+'tinygettext/tinygettext.cxx', 
 'true_server.cxx', 
 'vector.cxx', 
 'world.cxx', 

Modified: trunk/src/actions/basher.cxx
===================================================================
--- trunk/src/actions/basher.cxx        2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/actions/basher.cxx        2005-12-01 20:55:34 UTC (rev 2520)
@@ -21,10 +21,11 @@
 #include "../debug.hxx"
 #include "../globals.hxx"
 #include "../display/scene_context.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../resource.hxx"
 #include "../pingu.hxx"
 #include "../world.hxx"
+#include "../worldobj.hxx"
 #include "basher.hxx"
 
 namespace Pingus {

Modified: trunk/src/actions/bomber.cxx
===================================================================
--- trunk/src/actions/bomber.cxx        2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/actions/bomber.cxx        2005-12-01 20:55:34 UTC (rev 2520)
@@ -24,7 +24,7 @@
 #include "../display/scene_context.hxx"
 #include "../pingu.hxx"
 #include "../pingu_enums.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../world.hxx"
 #include "../resource.hxx"
 #include "../particles/pingu_particle_holder.hxx"

Modified: trunk/src/actions/bridger.cxx
===================================================================
--- trunk/src/actions/bridger.cxx       2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/actions/bridger.cxx       2005-12-01 20:55:34 UTC (rev 2520)
@@ -22,10 +22,11 @@
 #include "../col_map.hxx"
 #include "../display/scene_context.hxx"
 #include "../pingu.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../resource.hxx"
 #include "../sound/sound.hxx"
 #include "../world.hxx"
+#include "../worldobj.hxx"
 #include "../gettext.h"
 #include "bridger.hxx"
 

Modified: trunk/src/actions/digger.cxx
===================================================================
--- trunk/src/actions/digger.cxx        2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/actions/digger.cxx        2005-12-01 20:55:34 UTC (rev 2520)
@@ -20,8 +20,9 @@
 #include <cstdio>
 #include "../col_map.hxx"
 #include "../display/scene_context.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../world.hxx"
+#include "../worldobj.hxx"
 #include "../resource.hxx"
 #include "../sound/sound.hxx"
 #include "../pingu.hxx"

Modified: trunk/src/actions/miner.cxx
===================================================================
--- trunk/src/actions/miner.cxx 2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/actions/miner.cxx 2005-12-01 20:55:34 UTC (rev 2520)
@@ -17,13 +17,14 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../col_map.hxx"
 #include "../display/scene_context.hxx"
 #include "../world.hxx"
 #include "../resource.hxx"
 #include "../sound/sound.hxx"
 #include "../pingu.hxx"
+#include "../worldobj.hxx"
 #include "miner.hxx"
 
 namespace Pingus {

Modified: trunk/src/gettext.h
===================================================================
--- trunk/src/gettext.h 2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/gettext.h 2005-12-01 20:55:34 UTC (rev 2520)
@@ -20,7 +20,7 @@
 #ifndef HEADER_GETTEXT_HXX
 #define HEADER_GETTEXT_HXX
 
-#include "tinygettext.hxx"
+#include "tinygettext/tinygettext.hxx"
 
 namespace Pingus {
 extern TinyGetText::DictionaryManager dictionary_manager;

Copied: trunk/src/ground_map.cxx (from rev 2517, trunk/src/spot_map.cxx)
===================================================================
--- trunk/src/spot_map.cxx      2005-12-01 16:10:05 UTC (rev 2517)
+++ trunk/src/ground_map.cxx    2005-12-01 20:55:34 UTC (rev 2520)
@@ -0,0 +1,301 @@
+//  $Id: spot_map.cxx,v 1.31 2003/10/22 11:11:22 grumbel Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#include <stdio.h>
+#include <iostream>
+#include <ClanLib/Display/pixel_buffer.h>
+#include <ClanLib/Display/pixel_format.h>
+#include <ClanLib/Core/core_iostream.h>
+#include <ClanLib/Core/IOData/cl_endian.h>
+#include "display/scene_context.hxx"
+#include "pingus_error.hxx"
+#include "blitter.hxx"
+#include "ground_map.hxx"
+#include "pingus_level.hxx"
+#include "gettext.h"
+#include "col_map.hxx"
+#include "math.hxx"
+#include <ClanLib/Core/IOData/datatypes.h>
+#include <ClanLib/Display/palette.h>
+
+namespace Pingus {
+
+       MapTile::MapTile () 
+       {
+       }
+
+       MapTile::~MapTile()
+       {
+       }
+
+       void
+       MapTile::prepare()
+       {
+               if (!pixelbuffer)
+               {
+                       pixelbuffer = CL_PixelBuffer(tile_size, tile_size, 
tile_size*4, CL_PixelFormat::rgba8888);
+                       Blitter::clear_canvas(pixelbuffer);
+               }
+       }
+
+       void
+       MapTile::remove(CL_PixelBuffer obj, int x, int y, 
+                                                int real_x, int real_y, 
GroundMap* parent)
+       {
+               if (surface)
+               {
+                       parent->put_alpha_surface(pixelbuffer, obj, x, y, 
real_x, real_y);
+                       surface = CL_Surface(pixelbuffer);
+               }
+       }
+
+       void
+       MapTile::put(CL_PixelBuffer obj, int x, int y)
+       {
+               prepare();
+               Blitter::put_surface(pixelbuffer, obj, x, y);
+               surface = CL_Surface(pixelbuffer);
+       }
+
+       GroundMap::GroundMap(const PingusLevel& plf)
+       {
+               width  = plf.get_size().width;
+               height = plf.get_size().height;
+
+               colmap = new ColMap(width, height);
+
+               // Checking that the map has the correct size, only multiples of
+               // tile_size are allowed, anything else wouldn't fit very well 
on
+               // the colmap
+               if ((width % tile_size) != 0)
+               {
+                       width += (tile_size - (width % tile_size));
+               }
+
+               if ((height % tile_size) != 0)
+               {
+                       height += (tile_size - (height % tile_size));
+               }
+
+               tile_width  = width/tile_size;
+               tile_height = height/tile_size;
+
+               // Allocating tile map
+               tile.resize(tile_width);
+               for(unsigned int i=0; i < tile.size(); ++i)
+                       tile[i].resize(tile_height);
+
+               // fix the height back to the correct values
+               width  = plf.get_size().width;
+               height = plf.get_size().height;
+       }
+
+       GroundMap::~GroundMap(void)
+       {
+               delete colmap;
+       }
+
+       void
+       GroundMap::draw_colmap(SceneContext& gc)
+       {
+               colmap->draw(gc.color());
+       }
+
+// Draws the map with a offset, needed for scrolling
+       void
+       GroundMap::draw(SceneContext& gc)
+       {
+               const CL_Rect& display = gc.color().get_clip_rect();
+
+               // FIXME: delete the next four lines and replace them with 
gc.get_clip_rect()
+               if (draw_collision_map)
+               {
+                       draw_colmap(gc);
+               }
+               else
+               {
+                       // Trying to calc which parts of the tilemap needs to 
be drawn
+                       int start_x = Math::max(0, display.left/tile_size);
+                       int start_y = Math::max(0, display.top/tile_size);
+                       int tilemap_width  = display.get_width()  / tile_size + 
1;
+                       int tilemap_height = display.get_height() / tile_size + 
1;
+
+                       // drawing the stuff
+                       for (int x = start_x; x <= (start_x + tilemap_width) && 
x < int(tile.size()); ++x)
+                               for (int y = start_y; y <= start_y + 
tilemap_height && y < int(tile[x].size()); ++y)
+                               {
+                                       if (tile[x][y].get_surface())
+                                       {
+                                               
gc.color().draw(tile[x][y].get_surface(),
+                                                                               
         Vector(static_cast<float>(x * tile_size),
+                                                                               
                          static_cast<float>(y * tile_size)));
+                                       }
+                                       else
+                                       {
+                                               if (pingus_debug_flags & 
PINGUS_DEBUG_TILES)
+                                                       
gc.color().draw_fillrect(static_cast<float>(x * tile_size),
+                                                                               
                                         static_cast<float>(y * tile_size),
+                                                                               
                                         static_cast<float>(x * tile_size + 
tile_size),
+                                                                               
                                         static_cast<float>(y * tile_size + 
tile_size),
+                                                                               
                                         CL_Color(255, 0, 0, 75));
+                                       }
+                               }
+               }
+       }
+
+// Returns the width of the map, it is read directly from the *.psm file
+       int
+       GroundMap::get_width(void)
+       {
+               return width;
+       }
+
+// Returns the height of the map, it is read directly from the *.psm file
+       int
+       GroundMap::get_height(void)
+       {
+               return height;
+       }
+
+       void
+       GroundMap::remove(CL_PixelBuffer sprovider, int x, int y)
+       {
+               // Get the start tile and end tile
+               int start_x = Math::max(x / tile_size, 0);
+               int start_y = Math::max(y / tile_size, 0);
+               int end_x   = Math::min((x + sprovider.get_width()) / tile_size,
+                                                                               
(width - 1) / tile_size);
+               int end_y   = Math::min((y + sprovider.get_height()) / 
tile_size,
+                                                                               
(height - 1) / tile_size);
+
+               for(int ix = start_x; ix <= end_x; ++ix)
+                       for(int iy = start_y; iy <= end_y; ++iy)
+                       {
+                               tile[ix][iy].remove(sprovider, x - (ix * 
tile_size),
+                                                                               
  y - (iy * tile_size), x, y, this);
+                       }
+       }
+
+       void
+       GroundMap::put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer 
sprovider,
+                                                                               
                int x_pos, int y_pos, int real_x_arg, int real_y_arg)
+       {
+               if (sprovider.get_format().get_depth() != 8)
+               {
+                       
PingusError::raise(std::string("SpotMap::put_alpha_surface: Image has wrong 
color depth: " 
+                                                                               
                         + sprovider.get_format().get_depth()));
+               }
+
+               provider.lock();
+               sprovider.lock();
+
+               int swidth  = sprovider.get_width();
+               int twidth  = provider.get_width();
+
+               int start_x = std::max(0, -x_pos);
+               int start_y = std::max(0, -y_pos);
+
+               int end_x = std::min(swidth,  twidth  - x_pos);
+               int end_y = std::min(sprovider.get_height(), 
provider.get_height() - y_pos);
+
+               if (end_x - start_x <= 0 || end_y - start_y <= 0)
+                       return;
+
+               cl_uint8* target_buf = 
static_cast<cl_uint8*>(provider.get_data());
+               cl_uint8* source_buf = 
static_cast<cl_uint8*>(sprovider.get_data());
+
+               CL_Palette palette = sprovider.get_palette();
+
+               if (sprovider.get_format().has_colorkey())
+               {
+                       unsigned int colorkey = 
sprovider.get_format().get_colorkey();
+
+                       for (int y = start_y; y < end_y; ++y)
+                       {
+                               cl_uint8* tptr = target_buf + 
4*((twidth*(y+y_pos)) + x_pos + start_x);
+                               cl_uint8* sptr = source_buf + swidth*y + 
start_x;
+
+                               for (int x = start_x; x < end_x; ++x)
+            { 
+                                       if (*sptr != colorkey && 
colmap->getpixel(real_x_arg+x, real_y_arg+y) != Groundtype::GP_SOLID)
+                                       { // FIXME: Slow?! if inside a blit 
loop probally not such a good idea
+                  if (!CL_Endian::is_system_big())
+                                                       *tptr = 0;
+                  else
+                                                       tptr[3] = 0;
+                                       }
+
+                                       tptr += 4;
+                                       sptr += 1;
+            }
+                       }
+               }
+               else
+               {
+                       for (int y = start_y; y < end_y; ++y)
+                       {
+                               cl_uint8* tptr = target_buf + 
4*((twidth*(y+y_pos)) + x_pos + start_x);
+                               cl_uint8* sptr = source_buf + swidth*y + 
start_x;
+
+                               for (int x = start_x; x < end_x; ++x)
+            { 
+                                               if 
(colmap->getpixel(real_x_arg+x, real_y_arg+y) != Groundtype::GP_SOLID)
+                                               { // FIXME: if inside blit loop 
might not be such a good idea
+                                                       if 
(!CL_Endian::is_system_big())
+                                                               *tptr = 0;
+                                                       else
+                                                               tptr[3] = 0;
+                                               }
+              
+                                                                               
tptr += 4;
+                                               sptr += 1;
+            }
+                       }
+               }
+  
+               sprovider.unlock();
+               provider.unlock();
+       }
+
+       void
+       GroundMap::put(CL_PixelBuffer sprovider, int x, int y)
+       {
+               // Get the start tile and end tile
+               int start_x = std::max(0, x / tile_size);
+               int start_y = std::max(0, y / tile_size);
+               int end_x   = std::min(tile_width,  (x + sprovider.get_width()) 
 / tile_size + 1);
+               int end_y   = std::min(tile_height, (y + 
sprovider.get_height()) / tile_size + 1);
+
+               for(int ix = start_x; ix < end_x; ++ix)
+                       for(int iy = start_y; iy < end_y; ++iy)
+                       {
+                               tile[ix][iy].put(sprovider,
+                                                                         x - 
(ix * tile_size), y - (iy * tile_size));
+                       }
+       }
+
+       ColMap*
+       GroundMap::get_colmap(void)
+       {
+               return colmap;
+       }
+
+} // namespace Pingus
+
+/* EOF */

Copied: trunk/src/ground_map.hxx (from rev 2516, trunk/src/spot_map.hxx)
===================================================================
--- trunk/src/spot_map.hxx      2005-12-01 15:43:45 UTC (rev 2516)
+++ trunk/src/ground_map.hxx    2005-12-01 20:55:34 UTC (rev 2520)
@@ -0,0 +1,114 @@
+//  $Id: spot_map.hxx,v 1.11 2003/10/22 11:11:22 grumbel Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+//  02111-1307, USA.
+
+#ifndef HEADER_PINGUS_GROUND_MAP_HXX
+#define HEADER_PINGUS_GROUND_MAP_HXX
+
+#include <vector>
+#include <ClanLib/Display/pixel_buffer.h>
+#include <ClanLib/Display/surface.h>
+#include "globals.hxx"
+#include "worldobj.hxx"
+#include "ground_map.hxx"
+
+class CL_PixelBuffer;
+
+namespace Pingus {
+
+class SceneContext;
+class PingusLevel;
+class ColMap;
+class GroundMap;
+
+class MapTile
+{
+private:
+  CL_Surface     surface;
+  CL_PixelBuffer pixelbuffer;
+
+  void prepare();
+public:
+  MapTile();
+  ~MapTile();
+
+       void remove(CL_PixelBuffer, int x, int y, int real_x, int real_y, 
GroundMap*);  
+  void put(CL_PixelBuffer, int x, int y);  
+
+  CL_Surface get_surface() const { return surface; }
+};
+
+/** This map type is the defaulh maptype, it is should be used for the
+    most levels. It allows to construct a map, from a set of simple
+    small images, this allows the generation of large map without
+    using to much diskspace. */
+class GroundMap : public WorldObj
+{
+private:
+  ColMap* colmap;
+
+  /** The tiles out of which the map is constructed */
+  std::vector<std::vector<MapTile> > tile;
+
+  /** Width of the map */
+  int width;
+  /** Height of the map */
+  int height;
+
+  int tile_width;
+  int tile_height;
+public:
+  GroundMap(const PingusLevel& arg_plf);
+  virtual ~GroundMap();
+
+  void draw(SceneContext& gc);
+
+  ColMap* get_colmap();
+
+  int  get_height();
+  int  get_width();
+
+  /** Put the gives surface provider onto the given coordinates */
+  void put(CL_PixelBuffer, int x, int y);
+
+  /** Remove the gives surface provider onto the given coordinates
+      (everything non-transparent that isn't Groundtype::GP_Solid 
+                       is removed from the map) */
+  void remove(CL_PixelBuffer, int x, int y);
+
+  float get_z_pos () const { return 0; }
+
+       /** Low level version of the remove() call, acts on a single tile
+      instead of the complete map-tiles */
+  void put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer sprovider,
+                        int x, int y, int real_x, int real_y);
+
+private:
+  /** Draw the collision map onto the screen */
+  void draw_colmap(SceneContext& gc);
+
+  GroundMap (const GroundMap&);
+  GroundMap& operator= (const GroundMap&);
+};
+
+} // namespace Pingus
+
+#endif
+
+/* EOF */

Modified: trunk/src/particles/snow_particle_holder.cxx
===================================================================
--- trunk/src/particles/snow_particle_holder.cxx        2005-12-01 20:18:15 UTC 
(rev 2519)
+++ trunk/src/particles/snow_particle_holder.cxx        2005-12-01 20:55:34 UTC 
(rev 2520)
@@ -21,7 +21,7 @@
 #include "../math.hxx"
 #include "../col_map.hxx"
 #include "../display/scene_context.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../resource.hxx"
 #include "../world.hxx"
 #include "snow_particle_holder.hxx"

Deleted: trunk/src/pingu_map.cxx
===================================================================
--- trunk/src/pingu_map.cxx     2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/pingu_map.cxx     2005-12-01 20:55:34 UTC (rev 2520)
@@ -1,36 +0,0 @@
-//  $Id: pingu_map.cxx,v 1.10 2003/10/21 11:01:52 grumbel Exp $
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#include <ClanLib/Display/surface.h>
-#include "pingu_map.hxx"
-
-namespace Pingus {
-
-PinguMap::PinguMap()
-{
-}
-
-PinguMap::~PinguMap()
-{
-  //std::cout << "PinguMap:~PinguMap()" << std::endl;
-}
-
-} // namespace Pingus
-
-/* EOF */

Deleted: trunk/src/pingu_map.hxx
===================================================================
--- trunk/src/pingu_map.hxx     2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/pingu_map.hxx     2005-12-01 20:55:34 UTC (rev 2520)
@@ -1,61 +0,0 @@
-//  $Id: pingu_map.hxx,v 1.8 2003/10/21 11:01:52 grumbel Exp $
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#ifndef HEADER_PINGUS_PINGU_MAP_HXX
-#define HEADER_PINGUS_PINGU_MAP_HXX
-
-#include "worldobj.hxx"
-
-class CL_Surface;
-class CL_PixelBuffer;
-
-namespace Pingus {
-
-class ColMap;
-
-/** The type of the map, currently we have a random, a bitmap and a
-    spot map, the only map, which is currently supported is the spot
-    map. */
-enum MapType { BMP, SPOT, RANDOM, UNDEF };
-
-///
-class PinguMap : public WorldObj
-{
-public:
-  PinguMap();
-  virtual ~PinguMap();
-
-  virtual ColMap *get_colmap() =0;
-
-  virtual int  get_width() =0;
-  virtual int  get_height() =0;
-
-  virtual void remove(CL_PixelBuffer obj, int x, int y) =0;
-  virtual void put(CL_PixelBuffer obj, int x, int y) =0;
-
-private:
-  PinguMap (const PinguMap&);
-  PinguMap& operator= (const PinguMap&);
-};
-
-} // namespace Pingus
-
-#endif
-
-/* EOF */

Deleted: trunk/src/spot_map.cxx
===================================================================
--- trunk/src/spot_map.cxx      2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/spot_map.cxx      2005-12-01 20:55:34 UTC (rev 2520)
@@ -1,301 +0,0 @@
-//  $Id: spot_map.cxx,v 1.31 2003/10/22 11:11:22 grumbel Exp $
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#include <stdio.h>
-#include <iostream>
-#include <ClanLib/Display/pixel_buffer.h>
-#include <ClanLib/Display/pixel_format.h>
-#include <ClanLib/Core/core_iostream.h>
-#include <ClanLib/Core/IOData/cl_endian.h>
-#include "display/scene_context.hxx"
-#include "pingus_error.hxx"
-#include "blitter.hxx"
-#include "spot_map.hxx"
-#include "pingus_level.hxx"
-#include "gettext.h"
-#include "col_map.hxx"
-#include "math.hxx"
-#include <ClanLib/Core/IOData/datatypes.h>
-#include <ClanLib/Display/palette.h>
-
-namespace Pingus {
-
-       MapTile::MapTile () 
-       {
-       }
-
-       MapTile::~MapTile()
-       {
-       }
-
-       void
-       MapTile::prepare()
-       {
-               if (!pixelbuffer)
-               {
-                       pixelbuffer = CL_PixelBuffer(tile_size, tile_size, 
tile_size*4, CL_PixelFormat::rgba8888);
-                       Blitter::clear_canvas(pixelbuffer);
-               }
-       }
-
-       void
-       MapTile::remove(CL_PixelBuffer obj, int x, int y, 
-                                                int real_x, int real_y, 
PingusSpotMap* parent)
-       {
-               if (surface)
-               {
-                       parent->put_alpha_surface(pixelbuffer, obj, x, y, 
real_x, real_y);
-                       surface = CL_Surface(pixelbuffer);
-               }
-       }
-
-       void
-       MapTile::put(CL_PixelBuffer obj, int x, int y)
-       {
-               prepare();
-               Blitter::put_surface(pixelbuffer, obj, x, y);
-               surface = CL_Surface(pixelbuffer);
-       }
-
-       PingusSpotMap::PingusSpotMap(const PingusLevel& plf)
-       {
-               width  = plf.get_size().width;
-               height = plf.get_size().height;
-
-               colmap = new ColMap(width, height);
-
-               // Checking that the map has the correct size, only multiples of
-               // tile_size are allowed, anything else wouldn't fit very well 
on
-               // the colmap
-               if ((width % tile_size) != 0)
-               {
-                       width += (tile_size - (width % tile_size));
-               }
-
-               if ((height % tile_size) != 0)
-               {
-                       height += (tile_size - (height % tile_size));
-               }
-
-               tile_width  = width/tile_size;
-               tile_height = height/tile_size;
-
-               // Allocating tile map
-               tile.resize(tile_width);
-               for(unsigned int i=0; i < tile.size(); ++i)
-                       tile[i].resize(tile_height);
-
-               // fix the height back to the correct values
-               width  = plf.get_size().width;
-               height = plf.get_size().height;
-       }
-
-       PingusSpotMap::~PingusSpotMap(void)
-       {
-               delete colmap;
-       }
-
-       void
-       PingusSpotMap::draw_colmap(SceneContext& gc)
-       {
-               colmap->draw(gc.color());
-       }
-
-// Draws the map with a offset, needed for scrolling
-       void
-       PingusSpotMap::draw(SceneContext& gc)
-       {
-               const CL_Rect& display = gc.color().get_clip_rect();
-
-               // FIXME: delete the next four lines and replace them with 
gc.get_clip_rect()
-               if (draw_collision_map)
-               {
-                       draw_colmap(gc);
-               }
-               else
-               {
-                       // Trying to calc which parts of the tilemap needs to 
be drawn
-                       int start_x = Math::max(0, display.left/tile_size);
-                       int start_y = Math::max(0, display.top/tile_size);
-                       int tilemap_width  = display.get_width()  / tile_size + 
1;
-                       int tilemap_height = display.get_height() / tile_size + 
1;
-
-                       // drawing the stuff
-                       for (int x = start_x; x <= (start_x + tilemap_width) && 
x < int(tile.size()); ++x)
-                               for (int y = start_y; y <= start_y + 
tilemap_height && y < int(tile[x].size()); ++y)
-                               {
-                                       if (tile[x][y].get_surface())
-                                       {
-                                               
gc.color().draw(tile[x][y].get_surface(),
-                                                                               
         Vector(static_cast<float>(x * tile_size),
-                                                                               
                          static_cast<float>(y * tile_size)));
-                                       }
-                                       else
-                                       {
-                                               if (pingus_debug_flags & 
PINGUS_DEBUG_TILES)
-                                                       
gc.color().draw_fillrect(static_cast<float>(x * tile_size),
-                                                                               
                                         static_cast<float>(y * tile_size),
-                                                                               
                                         static_cast<float>(x * tile_size + 
tile_size),
-                                                                               
                                         static_cast<float>(y * tile_size + 
tile_size),
-                                                                               
                                         CL_Color(255, 0, 0, 75));
-                                       }
-                               }
-               }
-       }
-
-// Returns the width of the map, it is read directly from the *.psm file
-       int
-       PingusSpotMap::get_width(void)
-       {
-               return width;
-       }
-
-// Returns the height of the map, it is read directly from the *.psm file
-       int
-       PingusSpotMap::get_height(void)
-       {
-               return height;
-       }
-
-       void
-       PingusSpotMap::remove(CL_PixelBuffer sprovider, int x, int y)
-       {
-               // Get the start tile and end tile
-               int start_x = Math::max(x / tile_size, 0);
-               int start_y = Math::max(y / tile_size, 0);
-               int end_x   = Math::min((x + sprovider.get_width()) / tile_size,
-                                                                               
(width - 1) / tile_size);
-               int end_y   = Math::min((y + sprovider.get_height()) / 
tile_size,
-                                                                               
(height - 1) / tile_size);
-
-               for(int ix = start_x; ix <= end_x; ++ix)
-                       for(int iy = start_y; iy <= end_y; ++iy)
-                       {
-                               tile[ix][iy].remove(sprovider, x - (ix * 
tile_size),
-                                                                               
  y - (iy * tile_size), x, y, this);
-                       }
-       }
-
-       void
-       PingusSpotMap::put_alpha_surface(CL_PixelBuffer provider, 
CL_PixelBuffer sprovider,
-                                                                               
                int x_pos, int y_pos, int real_x_arg, int real_y_arg)
-       {
-               if (sprovider.get_format().get_depth() != 8)
-               {
-                       
PingusError::raise(std::string("SpotMap::put_alpha_surface: Image has wrong 
color depth: " 
-                                                                               
                         + sprovider.get_format().get_depth()));
-               }
-
-               provider.lock();
-               sprovider.lock();
-
-               int swidth  = sprovider.get_width();
-               int twidth  = provider.get_width();
-
-               int start_x = std::max(0, -x_pos);
-               int start_y = std::max(0, -y_pos);
-
-               int end_x = std::min(swidth,  twidth  - x_pos);
-               int end_y = std::min(sprovider.get_height(), 
provider.get_height() - y_pos);
-
-               if (end_x - start_x <= 0 || end_y - start_y <= 0)
-                       return;
-
-               cl_uint8* target_buf = 
static_cast<cl_uint8*>(provider.get_data());
-               cl_uint8* source_buf = 
static_cast<cl_uint8*>(sprovider.get_data());
-
-               CL_Palette palette = sprovider.get_palette();
-
-               if (sprovider.get_format().has_colorkey())
-               {
-                       unsigned int colorkey = 
sprovider.get_format().get_colorkey();
-
-                       for (int y = start_y; y < end_y; ++y)
-                       {
-                               cl_uint8* tptr = target_buf + 
4*((twidth*(y+y_pos)) + x_pos + start_x);
-                               cl_uint8* sptr = source_buf + swidth*y + 
start_x;
-
-                               for (int x = start_x; x < end_x; ++x)
-            { 
-                                       if (*sptr != colorkey && 
colmap->getpixel(real_x_arg+x, real_y_arg+y) != Groundtype::GP_SOLID)
-                                       { // FIXME: Slow?! if inside a blit 
loop probally not such a good idea
-                  if (!CL_Endian::is_system_big())
-                                                       *tptr = 0;
-                  else
-                                                       tptr[3] = 0;
-                                       }
-
-                                       tptr += 4;
-                                       sptr += 1;
-            }
-                       }
-               }
-               else
-               {
-                       for (int y = start_y; y < end_y; ++y)
-                       {
-                               cl_uint8* tptr = target_buf + 
4*((twidth*(y+y_pos)) + x_pos + start_x);
-                               cl_uint8* sptr = source_buf + swidth*y + 
start_x;
-
-                               for (int x = start_x; x < end_x; ++x)
-            { 
-                                               if 
(colmap->getpixel(real_x_arg+x, real_y_arg+y) != Groundtype::GP_SOLID)
-                                               { // FIXME: if inside blit loop 
might not be such a good idea
-                                                       if 
(!CL_Endian::is_system_big())
-                                                               *tptr = 0;
-                                                       else
-                                                               tptr[3] = 0;
-                                               }
-              
-                                                                               
tptr += 4;
-                                               sptr += 1;
-            }
-                       }
-               }
-  
-               sprovider.unlock();
-               provider.unlock();
-       }
-
-       void
-       PingusSpotMap::put(CL_PixelBuffer sprovider, int x, int y)
-       {
-               // Get the start tile and end tile
-               int start_x = std::max(0, x / tile_size);
-               int start_y = std::max(0, y / tile_size);
-               int end_x   = std::min(tile_width,  (x + sprovider.get_width()) 
 / tile_size + 1);
-               int end_y   = std::min(tile_height, (y + 
sprovider.get_height()) / tile_size + 1);
-
-               for(int ix = start_x; ix < end_x; ++ix)
-                       for(int iy = start_y; iy < end_y; ++iy)
-                       {
-                               tile[ix][iy].put(sprovider,
-                                                                         x - 
(ix * tile_size), y - (iy * tile_size));
-                       }
-       }
-
-       ColMap*
-       PingusSpotMap::get_colmap(void)
-       {
-               return colmap;
-       }
-
-} // namespace Pingus
-
-/* EOF */

Deleted: trunk/src/spot_map.hxx
===================================================================
--- trunk/src/spot_map.hxx      2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/spot_map.hxx      2005-12-01 20:55:34 UTC (rev 2520)
@@ -1,112 +0,0 @@
-//  $Id: spot_map.hxx,v 1.11 2003/10/22 11:11:22 grumbel Exp $
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-//  02111-1307, USA.
-
-#ifndef HEADER_PINGUS_SPOT_MAP_HXX
-#define HEADER_PINGUS_SPOT_MAP_HXX
-
-#include <vector>
-#include <ClanLib/Display/pixel_buffer.h>
-#include <ClanLib/Display/surface.h>
-#include "globals.hxx"
-#include "pingu_map.hxx"
-
-class CL_PixelBuffer;
-
-namespace Pingus {
-
-class PingusLevel;
-class ColMap;
-class PingusSpotMap;
-
-class MapTile
-{
-private:
-  CL_Surface     surface;
-  CL_PixelBuffer pixelbuffer;
-
-  void prepare();
-public:
-  MapTile();
-  ~MapTile();
-
-       void remove(CL_PixelBuffer, int x, int y, int real_x, int real_y, 
PingusSpotMap*);  
-  void put(CL_PixelBuffer, int x, int y);  
-
-  CL_Surface get_surface() const { return surface; }
-};
-
-/** This map type is the defaulh maptype, it is should be used for the
-    most levels. It allows to construct a map, from a set of simple
-    small images, this allows the generation of large map without
-    using to much diskspace. */
-class PingusSpotMap : public PinguMap
-{
-private:
-  ColMap* colmap;
-
-  /** The tiles out of which the map is constructed */
-  std::vector<std::vector<MapTile> > tile;
-
-  /** Width of the map */
-  int width;
-  /** Height of the map */
-  int height;
-
-  int tile_width;
-  int tile_height;
-public:
-  PingusSpotMap(const PingusLevel& arg_plf);
-  virtual ~PingusSpotMap();
-
-  void draw(SceneContext& gc);
-
-  ColMap* get_colmap();
-
-  int  get_height();
-  int  get_width();
-
-  /** Put the gives surface provider onto the given coordinates */
-  void put(CL_PixelBuffer, int x, int y);
-
-  /** Remove the gives surface provider onto the given coordinates
-      (everything non-transparent that isn't Groundtype::GP_Solid 
-                       is removed from the map) */
-  void remove(CL_PixelBuffer, int x, int y);
-
-  float get_z_pos () const { return 0; }
-
-       /** Low level version of the remove() call, acts on a single tile
-      instead of the complete map-tiles */
-  void put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer sprovider,
-                        int x, int y, int real_x, int real_y);
-
-private:
-  /** Draw the collision map onto the screen */
-  void draw_colmap(SceneContext& gc);
-
-  PingusSpotMap (const PingusSpotMap&);
-  PingusSpotMap& operator= (const PingusSpotMap&);
-};
-
-} // namespace Pingus
-
-#endif
-
-/* EOF */

Copied: trunk/src/tinygettext/tinygettext.cxx (from rev 2518, 
trunk/src/tinygettext.cxx)
===================================================================
--- trunk/src/tinygettext.cxx   2005-12-01 17:47:39 UTC (rev 2518)
+++ trunk/src/tinygettext/tinygettext.cxx       2005-12-01 20:55:34 UTC (rev 
2520)
@@ -0,0 +1,792 @@
+//  $Id: tinygettext.cpp,v 1.4 2004/11/25 13:15:56 matzebraun Exp $
+// 
+//  TinyGetText - A small flexible gettext() replacement
+//  Copyright (C) 2004 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#include <config.h>
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#else
+#include "win32/uce_dirent.h"
+#endif
+
+#include <sys/types.h>
+#include <iconv.h>
+#include <fstream>
+#include <iostream>
+#include <ctype.h>
+#include <errno.h>
+#include "tinygettext.hxx"
+
+//#define TRANSLATION_DEBUG
+
+namespace TinyGetText {
+
+class charconv
+{
+public:
+       charconv() : m_conv(0)
+       {}
+ 
+       charconv(const std::string& incharset, const std::string& outcharset)
+       : m_conv(0)
+       {
+               create(incharset, outcharset);
+       }
+ 
+       ~charconv()
+       {
+               close();
+       }
+ 
+       void create(const std::string& incharset, const std::string& outcharset)
+       {
+               // Create the converter.
+               if(!(m_conv = iconv_open(incharset.c_str(), 
outcharset.c_str())))
+               {
+                       /*if(errno == EINVAL)
+                       {
+                               ostringstream sstr;
+                               sstr << "Unsupported conversion: " << incharset
+                                    << " => " << outcharset << "!";
+                               throw runtime_error(sstr.str());
+                       }
+                       else
+                               throw runtime_error(strerror(errno));
+                       */
+                       exit(1);
+               }
+       }
+ 
+       void close()
+       {
+               // Free, if exists.
+               if(m_conv)
+               {
+                       iconv_close(m_conv);
+                       m_conv = 0;
+               }
+       }
+ 
+       /// Convert a string from encoding to another.
+       std::string convert(std::string text)
+       {
+               if(!m_conv) return text;
+ 
+               size_t in_size = text.size();
+               size_t out_size = 4*in_size; // Worst case scenario: ASCII -> 
UTF-32?
+               std::string result(out_size, ' ');
+                ICONV_CONST char* in_str  = &text[0];
+               char* out_str = &result[0];
+ 
+               // Try to convert the text.
+               if(iconv(m_conv, &in_str, &in_size, &out_str, &out_size) != 0)
+                       //PingusError::raise("Error while converting: " + 
strerror(errno));
+                       exit(1);
+               // Eat off the spare space.
+               result.resize(out_str - &result[0]);
+               return result;
+       }
+protected:
+       iconv_t m_conv;
+};
+
+
+/** Convert \a which is in \a from_charset to \a to_charset and return it */
+std::string convert(const std::string& text,
+                    const std::string& from_charset,
+                    const std::string& to_charset)           
+{
+  if (from_charset == to_charset)
+    return text;
+
+  charconv *cc = new charconv(from_charset, to_charset);
+  std::string ret = cc->convert(text);
+  cc->close();
+  return ret;
+}
+/*
+  iconv_t cd = iconv_open(to_charset.c_str(), from_charset.c_str());
+  
+  size_t in_len  = text.length();
+  size_t out_len = text.length()*4; // Should be large enough to hold UTF-32
+
+  char*  out_orig = new char[out_len]; // FIXME: cross fingers that this is 
enough
+  char*  in_orig  = new char[in_len+1];
+  strcpy(in_orig, text.c_str());
+
+  char* out = out_orig;
+  const char* in  = in_orig;
+
+  //std::cout << "IN: " << (int)in << " " << in_len << " " << (int)out << " " 
<< out_len << std::endl;
+  int retval = iconv(cd, &in, &in_len, &out, &out_len);
+  //std::cout << "OUT: " << (int)in << " " << in_len << " " << (int)out << " " 
<< out_len << std::endl;
+
+  if (retval != 0)
+    {
+      std::cerr << strerror(errno) << std::endl;
+      std::cerr << "Error: conversion from " << from_charset
+                << " to " << to_charset << " went wrong: " << retval << 
std::endl;
+    }
+  iconv_close(cd);
+
+  
+    <dolphin> your code is also buggy
+<dolphin> there will be extra spaces at the end of the string
+<dolphin> the lenght of the final string should be: out_str - out_orig
+<dolphin> or: out_size_before_iconv_call - out_size_after_iconv_call
+   
+  std::string ret(out_orig, out_len);
+  delete[] out_orig;
+  delete[] in_orig;
+  return ret;
+}
+*/
+
+bool has_suffix(const std::string& lhs, const std::string rhs)
+{
+  if (lhs.length() < rhs.length())
+    return false;
+  else
+    return lhs.compare(lhs.length() - rhs.length(), rhs.length(), rhs) == 0;
+}
+
+bool has_prefix(const std::string& lhs, const std::string rhs)
+{
+  if (lhs.length() < rhs.length())
+    return false;
+  else
+    return lhs.compare(0, rhs.length(), rhs) == 0;
+}
+
+int plural1(int )     { return 0; }
+int plural2_1(int n)  { return (n != 1); }
+int plural2_2(int n)  { return (n > 1); }
+int plural3_lv(int n) { return (n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2); }
+int plural3_ga(int n) { return n==1 ? 0 : n==2 ? 1 : 2; }
+int plural3_lt(int n) { return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && 
(n%100<10 || n%100>=20) ? 1 : 2); }
+int plural3_1(int n)  { return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 
&& (n%100<10 || n%100>=20) ? 1 : 2); }
+int plural3_sk(int n) { return (n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2; }
+int plural3_pl(int n) { return (n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2); }
+int plural3_sl(int n) { return (n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || 
n%100==4 ? 2 : 3); }
+
+/** Language Definitions */
+//*{
+LanguageDef lang_hu("hu", "Hungarian",         1, plural1); // "nplurals=1; 
plural=0;"
+LanguageDef lang_ja("ja", "Japanese",          1, plural1); // "nplurals=1; 
plural=0;"
+LanguageDef lang_ko("ko", "Korean",            1, plural1); // "nplurals=1; 
plural=0;"
+LanguageDef lang_tr("tr", "Turkish",           1, plural1); // "nplurals=1; 
plural=0;"
+LanguageDef lang_da("da", "Danish",            2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_nl("nl", "Dutch",             2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_en("en", "English",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_fo("fo", "Faroese",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_de("de", "German",            2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_nb("nb", "Norwegian Bokmal",  2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_no("no", "Norwegian",         2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_nn("nn", "Norwegian Nynorsk", 2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_sv("sv", "Swedish",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_et("et", "Estonian",          2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_fi("fi", "Finnish",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_el("el", "Greek",             2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_he("he", "Hebrew",            2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_it("it", "Italian",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_pt("pt", "Portuguese",        2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_es("es", "Spanish",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_eo("eo", "Esperanto",         2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
+LanguageDef lang_fr("fr", "French",            2, plural2_2); // "nplurals=2; 
plural=(n > 1);"
+LanguageDef lang_pt_BR("pt_BR", "Brazilian",   2, plural2_2); // "nplurals=2; 
plural=(n > 1);"
+LanguageDef lang_lv("lv", "Latvian",           3, plural3_lv); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);"
+LanguageDef lang_ga("ga", "Irish",             3, plural3_ga); // "nplurals=3; 
plural=n==1 ? 0 : n==2 ? 1 : 2;"
+LanguageDef lang_lt("lt", "Lithuanian",        3, plural3_lt); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);"
+LanguageDef lang_hr("hr", "Croatian",          3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
+LanguageDef lang_cs("cs", "Czech",             3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
+LanguageDef lang_ru("ru", "Russian",           3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
+LanguageDef lang_uk("uk", "Ukrainian",         3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
+LanguageDef lang_sk("sk", "Slovak",            3, plural3_sk); // "nplurals=3; 
plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"
+LanguageDef lang_pl("pl", "Polish",            3, plural3_pl); // "nplurals=3; 
plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);
+LanguageDef lang_sl("sl", "Slovenian",         3, plural3_sl); // "nplurals=4; 
plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);"
+//*}
+
+LanguageDef&
+get_language_def(const std::string& name)
+{
+  if (name == "hu") return lang_hu;
+  else if (name == "ja") return lang_ja;
+  else if (name == "ko") return lang_ko;
+  else if (name == "tr") return lang_tr;
+  else if (name == "da") return lang_da;
+  else if (name == "nl") return lang_nl;
+  else if (name == "en") return lang_en;
+  else if (name == "fo") return lang_fo;
+  else if (name == "de") return lang_de;
+  else if (name == "nb") return lang_nb;
+  else if (name == "no") return lang_no;
+  else if (name == "nn") return lang_nn;
+  else if (name == "sv") return lang_sv;
+  else if (name == "et") return lang_et;
+  else if (name == "fi") return lang_fi;
+  else if (name == "el") return lang_el;
+  else if (name == "he") return lang_he;
+  else if (name == "it") return lang_it;
+  else if (name == "pt") return lang_pt;
+  else if (name == "es") return lang_es;
+  else if (name == "eo") return lang_eo;
+  else if (name == "fr") return lang_fr;
+  else if (name == "pt_BR") return lang_pt_BR;
+  else if (name == "lv") return lang_lv;
+  else if (name == "ga") return lang_ga;
+  else if (name == "lt") return lang_lt;
+  else if (name == "hr") return lang_hr;
+  else if (name == "cs") return lang_cs;
+  else if (name == "ru") return lang_ru;
+  else if (name == "uk") return lang_uk;
+  else if (name == "sk") return lang_sk;
+  else if (name == "pl") return lang_pl;
+  else if (name == "sl") return lang_sl;
+  else return lang_en; 
+}
+
+DictionaryManager::DictionaryManager()
+  : current_dict(&empty_dict)
+{
+  parseLocaleAliases();
+  // setup language from environment vars
+  const char* lang = getenv("LC_ALL");
+  if(!lang)
+    lang = getenv("LC_MESSAGES");
+  if(!lang)
+    lang = getenv("LANG");
+  
+  if(lang)
+    set_language(lang);
+}
+
+void
+DictionaryManager::parseLocaleAliases()
+{
+  // try to parse language alias list
+  std::ifstream in("/usr/share/locale/locale.alias");
+  
+  char c = ' ';
+  while(in.good() && !in.eof()) {
+    while(isspace(c) && !in.eof())
+      in.get(c);
+    
+    if(c == '#') { // skip comments
+      while(c != '\n' && !in.eof())
+        in.get(c);
+      continue;
+    }
+    
+    std::string alias;
+    while(!isspace(c) && !in.eof()) {
+      alias += c;
+      in.get(c);
+    }
+    while(isspace(c) && !in.eof())
+      in.get(c);
+    std::string language;
+    while(!isspace(c) && !in.eof()) {
+      language += c;
+      in.get(c);
+    }
+
+    if(in.eof())
+      break;
+    set_language_alias(alias, language);
+  }
+}
+  
+Dictionary&
+DictionaryManager::get_dictionary(const std::string& spec)
+{
+  std::string lang = get_language_from_spec(spec);
+  Dictionaries::iterator i = dictionaries.find(get_language_from_spec(lang));
+  if (i != dictionaries.end())
+    {
+      return i->second;
+    }
+  else // Dictionary for languages lang isn't loaded, so we load it
+    {
+      //std::cout << "get_dictionary: " << lang << std::endl;
+      Dictionary& dict = dictionaries[lang];
+
+      dict.set_language(get_language_def(lang));
+      if(charset != "")
+        dict.set_charset(charset);
+
+      for (SearchPath::iterator p = search_path.begin(); p != 
search_path.end(); ++p)
+        {
+          DIR* dir = opendir(p->c_str());
+          if (!dir)
+            {
+              std::cerr << "Error: opendir() failed on " << *p << std::endl;
+            }
+          else
+            {
+              struct dirent* ent;
+              while((ent = readdir(dir)))
+                {
+                  if (std::string(ent->d_name) == lang + ".po")
+                    {
+                      std::string pofile = *p + "/" + ent->d_name;
+                      std::ifstream in(pofile.c_str());
+                      if (!in)
+                        {
+                          std::cerr << "Error: Failure file opening: " << 
pofile << std::endl;
+                        }
+                      else
+                        {
+                          read_po_file(dict, in);
+                        }
+                    }
+                }
+              closedir(dir);
+            }
+        }
+
+      return dict;
+    }
+}
+
+std::set<std::string>
+DictionaryManager::get_languages()
+{
+  std::set<std::string> languages;
+
+  for (SearchPath::iterator p = search_path.begin(); p != search_path.end(); 
++p)
+    {
+      DIR* dir = opendir(p->c_str());
+      if (!dir)
+        {
+          std::cerr << "Error: opendir() failed on " << *p << std::endl;
+        }
+      else
+        {
+          struct dirent* ent;
+          while((ent = readdir(dir)))
+            {
+              if (has_suffix(ent->d_name, ".po"))
+                {
+                  std::string filename = ent->d_name;
+                  languages.insert(filename.substr(0, filename.length()-3));
+                }
+            }
+          closedir(dir);
+        }
+    }  
+  return languages;
+}
+
+void
+DictionaryManager::set_language(const std::string& lang)
+{
+  language = get_language_from_spec(lang);
+  current_dict = & (get_dictionary(language));
+}
+
+void
+DictionaryManager::set_charset(const std::string& charset)
+{
+  dictionaries.clear(); // changing charset invalidates cache
+  this->charset = charset;
+  set_language(language);
+}
+
+void
+DictionaryManager::set_language_alias(const std::string& alias,
+    const std::string& language)
+{
+  language_aliases.insert(std::make_pair(alias, language));
+}
+
+std::string
+DictionaryManager::get_language_from_spec(const std::string& spec)
+{
+  std::string lang = spec;
+  Aliases::iterator i = language_aliases.find(lang);
+  if(i != language_aliases.end()) {
+    lang = i->second;
+  }
+  
+  std::string::size_type s = lang.find_first_of("_.");
+  if(s == std::string::npos)
+    return lang;
+
+  return std::string(lang, 0, s);  
+}
+
+void
+DictionaryManager::add_directory(const std::string& pathname)
+{
+  dictionaries.clear(); // adding directories invalidates cache
+  search_path.push_back(pathname);
+  set_language(language);
+}
+
+//---------------------------------------------------------------------------
+
+Dictionary::Dictionary(const LanguageDef& language_, const std::string& 
charset_)
+  : language(language_), charset(charset_)
+{
+}
+
+Dictionary::Dictionary()
+  : language(lang_en)
+{
+}
+
+std::string
+Dictionary::get_charset() const
+{
+  return charset;
+}
+
+void
+Dictionary::set_charset(const std::string& charset_)
+{
+  charset = charset_;
+}
+
+void
+Dictionary::set_language(const LanguageDef& lang)
+{
+  language = lang;
+}
+
+std::string
+Dictionary::translate(const std::string& msgid, const std::string& msgid2, int 
num) 
+{
+  PluralEntries::iterator i = plural_entries.find(msgid);
+  std::map<int, std::string>& msgstrs = i->second;
+
+  if (i != plural_entries.end() && !msgstrs.empty())
+    {
+      int g = language.plural(num);
+      std::map<int, std::string>::iterator j = msgstrs.find(g);
+      if (j != msgstrs.end())
+        {
+          return j->second;
+        }
+      else
+        {
+          // Return the first translation, in case we can't translate the 
specific number
+          return msgstrs.begin()->second;
+        }
+    }
+  else
+    {
+#ifdef TRANSLATION_DEBUG
+      std::cerr << "Warning: Couldn't translate: " << msgid << std::endl;
+      std::cerr << "Candidates: " << std::endl;
+      for (PluralEntries::iterator i = plural_entries.begin(); i != 
plural_entries.end(); ++i)
+        std::cout << "'" << i->first << "'" << std::endl;
+#endif
+
+      if (plural2_1(num)) // default to english rules
+        return msgid2;
+      else
+        return msgid;
+    }
+}
+
+std::string
+Dictionary::translate(const std::string& msgid) 
+{
+  Entries::iterator i = entries.find(msgid);
+  if (i != entries.end() && !i->second.empty())
+    {
+      return i->second;
+    }
+  else
+    {
+#ifdef TRANSLATION_DBEUG
+      std::cout << "Error: Couldn't translate: " << msgid << std::endl;
+#endif
+      return msgid;
+    }
+}
+  
+void
+Dictionary::add_translation(const std::string& msgid, const std::string& ,
+                            const std::map<int, std::string>& msgstrs)
+{
+  // Do we need msgid2 for anything? its after all supplied to the
+  // translate call, so we just throw it away
+  plural_entries[msgid] = msgstrs;
+}
+
+void 
+Dictionary::add_translation(const std::string& msgid, const std::string& 
msgstr) 
+{
+  entries[msgid] = msgstr;
+}
+
+class POFileReader
+{
+private:
+  struct Token
+  {
+    std::string keyword;
+    std::string content;
+  };
+
+  Dictionary& dict;
+
+  std::string from_charset;
+  std::string to_charset;
+
+  std::string current_msgid;
+  std::string current_msgid_plural;
+  std::map<int, std::string> msgstr_plural;
+
+  int line_num;
+
+  enum { WANT_MSGID, WANT_MSGSTR, WANT_MSGSTR_PLURAL, WANT_MSGID_PLURAL } 
state;
+
+public:
+  POFileReader(std::istream& in, Dictionary& dict_)
+    : dict(dict_)
+  {
+    state = WANT_MSGID;
+    line_num = 0;
+    tokenize_po(in);
+  }
+
+  void parse_header(const std::string& header)
+  {
+    // Seperate the header in lines
+    typedef std::vector<std::string> Lines;
+    Lines lines;
+    
+    std::string::size_type start = 0;
+    for(std::string::size_type i = 0; i < header.length(); ++i)
+      {
+        if (header[i] == '\n')
+          {
+            lines.push_back(header.substr(start, i - start));
+            start = i+1;
+          }
+      }
+
+    for(Lines::iterator i = lines.begin(); i != lines.end(); ++i)
+      {
+        if (has_prefix(*i, "Content-Type: text/plain; charset=")) {
+          from_charset = i->substr(strlen("Content-Type: text/plain; 
charset="));
+        }
+      }
+
+    if (from_charset.empty() || from_charset == "CHARSET")
+      {
+        std::cerr << "Error: Charset not specified for .po, fallback to 
ISO-8859-1" << std::endl;
+        from_charset = "ISO-8859-1";
+      }
+
+    to_charset = dict.get_charset();
+    if (to_charset.empty())
+      { // No charset requested from the dict, so we use the one from the .po 
+        to_charset = from_charset;
+        dict.set_charset(from_charset);
+      }
+  }
+
+  void add_token(const Token& token)
+  {
+    switch(state) 
+      {
+      case WANT_MSGID:
+        if (token.keyword == "msgid") 
+          {
+            current_msgid = token.content;
+            state = WANT_MSGID_PLURAL;
+          }
+        else if (token.keyword.empty())
+          {
+            //std::cerr << "Got EOF, everything looks ok." << std::endl;
+          }
+        else
+          {
+            std::cerr << "tinygettext: expected 'msgid' keyword, got '" << 
token.keyword 
+                      << "' at line " << line_num << std::endl;
+          }
+        break;
+    
+      case WANT_MSGID_PLURAL:
+        if (token.keyword == "msgid_plural") 
+          {
+            current_msgid_plural = token.content;
+            state = WANT_MSGSTR_PLURAL;
+          } 
+        else
+          {
+            state = WANT_MSGSTR;
+            add_token(token);
+          }
+        break;
+
+      case WANT_MSGSTR:
+        if (token.keyword == "msgstr") 
+          {
+            if (current_msgid == "") 
+              { // .po Header is hidden in the msgid with the empty string
+                parse_header(token.content);
+              }
+            else
+              {
+                dict.add_translation(current_msgid, convert(token.content, 
from_charset, to_charset));
+              }
+            state = WANT_MSGID;
+          } 
+        else
+          {
+            std::cerr << "tinygettext: expected 'msgstr' keyword, got " << 
token.keyword 
+                      << " at line " << line_num << std::endl;
+          }
+        break;
+
+      case WANT_MSGSTR_PLURAL:
+        if (has_prefix(token.keyword, "msgstr[")) 
+          {
+            int num;
+            if (sscanf(token.keyword.c_str(), "msgstr[%d]", &num) != 1) 
+              {
+                std::cerr << "Error: Couldn't parse: " << token.keyword << 
std::endl;
+              } 
+            else 
+              {
+                msgstr_plural[num] = convert(token.content, from_charset, 
to_charset);
+              }
+          }
+        else 
+          {
+            dict.add_translation(current_msgid, current_msgid_plural, 
msgstr_plural);
+
+            state = WANT_MSGID;
+            add_token(token);
+          }
+        break;
+      }
+  }
+  
+  inline int getchar(std::istream& in) 
+  {
+    int c = in.get();
+    if (c == '\n')
+      line_num += 1;
+    return c;
+  }
+  
+  void tokenize_po(std::istream& in)
+  {
+    enum State { READ_KEYWORD, 
+                 READ_CONTENT,
+                 READ_CONTENT_IN_STRING,
+                 SKIP_COMMENT };
+
+    State state = READ_KEYWORD;
+    int c;
+    Token token;
+
+    while((c = getchar(in)) != EOF)
+      {
+        //std::cout << "Lexing char: '" << char(c) << "' " << c << " state: " 
<< state << std::endl;
+        switch(state)
+          {
+          case READ_KEYWORD:
+            if (c == '#')
+              {
+                state = SKIP_COMMENT;
+              }
+            else if (isspace(c))
+              {
+                state = READ_KEYWORD;
+              }
+            else
+              {
+                // Read a new token
+                token = Token();
+                
+                do { // Read keyword 
+                  token.keyword += c;
+                } while((c = getchar(in)) != EOF && !isspace(c));
+                in.unget();
+
+                state = READ_CONTENT;
+              }
+            break;
+
+          case READ_CONTENT:
+            while((c = getchar(in)) != EOF)
+              {
+                if (c == '"') { 
+                  // Found start of content
+                  state = READ_CONTENT_IN_STRING;
+                  break;
+                } else if (isspace(c)) {
+                  // skip
+                } else { // Read something that may be a keyword
+                  in.unget();
+                  state = READ_KEYWORD;
+                  add_token(token);
+                  break;
+                }
+              }
+            break;
+
+          case READ_CONTENT_IN_STRING:
+            if (c == '\\') {
+              c = getchar(in);
+              if (c != EOF)
+                {
+                  if (c == 'n') token.content += '\n';
+                  else if (c == 't') token.content += '\t';
+                  else if (c == 'r') token.content += '\r';
+                  else if (c == '"') token.content += '"';
+                  else
+                    {
+                      std::cout << "Unhandled escape character: " << char(c) 
<< std::endl;
+                    }
+                }
+              else
+                {
+                  std::cout << "Unterminated string" << std::endl;
+                }
+            } else if (c == '"') { // Content string is terminated
+              state = READ_CONTENT;
+            } else {
+              token.content += c;
+            }
+            break;
+
+          case SKIP_COMMENT:
+            if (c == '\n')
+              state = READ_KEYWORD;
+            break;
+          }
+      }
+    // add_token(token);
+  }
+};
+
+void read_po_file(Dictionary& dict_, std::istream& in) 
+{
+  POFileReader reader(in, dict_);
+}
+
+} // namespace TinyGetText
+
+/* EOF */

Copied: trunk/src/tinygettext/tinygettext.hxx (from rev 2516, 
trunk/src/tinygettext.hxx)

Deleted: trunk/src/tinygettext.cxx
===================================================================
--- trunk/src/tinygettext.cxx   2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/tinygettext.cxx   2005-12-01 20:55:34 UTC (rev 2520)
@@ -1,794 +0,0 @@
-//  $Id: tinygettext.cpp,v 1.4 2004/11/25 13:15:56 matzebraun Exp $
-// 
-//  TinyGetText - A small flexible gettext() replacement
-//  Copyright (C) 2004 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-// 
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#include <config.h>
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#else
-#include "win32/uce_dirent.h"
-#endif
-
-#include <sys/types.h>
-#include <iconv.h>
-#include <fstream>
-#include <iostream>
-#include <ctype.h>
-#include <errno.h>
-#include "tinygettext.hxx"
-#include "pingus_error.hxx"
-
-
-//#define TRANSLATION_DEBUG
-
-namespace TinyGetText {
-
-class charconv
-{
-public:
-       charconv() : m_conv(0)
-       {}
- 
-       charconv(const std::string& incharset, const std::string& outcharset)
-       : m_conv(0)
-       {
-               create(incharset, outcharset);
-       }
- 
-       ~charconv()
-       {
-               close();
-       }
- 
-       void create(const std::string& incharset, const std::string& outcharset)
-       {
-               // Create the converter.
-               if(!(m_conv = iconv_open(incharset.c_str(), 
outcharset.c_str())))
-               {
-                       /*if(errno == EINVAL)
-                       {
-                               ostringstream sstr;
-                               sstr << "Unsupported conversion: " << incharset
-                                    << " => " << outcharset << "!";
-                               throw runtime_error(sstr.str());
-                       }
-                       else
-                               throw runtime_error(strerror(errno));
-                       */
-                       exit(1);
-               }
-       }
- 
-       void close()
-       {
-               // Free, if exists.
-               if(m_conv)
-               {
-                       iconv_close(m_conv);
-                       m_conv = 0;
-               }
-       }
- 
-       /// Convert a string from encoding to another.
-       std::string convert(std::string text)
-       {
-               if(!m_conv) return text;
- 
-               size_t in_size = text.size();
-               size_t out_size = 4*in_size; // Worst case scenario: ASCII -> 
UTF-32?
-               std::string result(out_size, ' ');
-                ICONV_CONST char* in_str  = &text[0];
-               char* out_str = &result[0];
- 
-               // Try to convert the text.
-               if(iconv(m_conv, &in_str, &in_size, &out_str, &out_size) != 0)
-                       //PingusError::raise("Error while converting: " + 
strerror(errno));
-                       exit(1);
-               // Eat off the spare space.
-               result.resize(out_str - &result[0]);
-               return result;
-       }
-protected:
-       iconv_t m_conv;
-};
-
-
-/** Convert \a which is in \a from_charset to \a to_charset and return it */
-std::string convert(const std::string& text,
-                    const std::string& from_charset,
-                    const std::string& to_charset)           
-{
-  if (from_charset == to_charset)
-    return text;
-
-  charconv *cc = new charconv(from_charset, to_charset);
-  std::string ret = cc->convert(text);
-  cc->close();
-  return ret;
-}
-/*
-  iconv_t cd = iconv_open(to_charset.c_str(), from_charset.c_str());
-  
-  size_t in_len  = text.length();
-  size_t out_len = text.length()*4; // Should be large enough to hold UTF-32
-
-  char*  out_orig = new char[out_len]; // FIXME: cross fingers that this is 
enough
-  char*  in_orig  = new char[in_len+1];
-  strcpy(in_orig, text.c_str());
-
-  char* out = out_orig;
-  const char* in  = in_orig;
-
-  //std::cout << "IN: " << (int)in << " " << in_len << " " << (int)out << " " 
<< out_len << std::endl;
-  int retval = iconv(cd, &in, &in_len, &out, &out_len);
-  //std::cout << "OUT: " << (int)in << " " << in_len << " " << (int)out << " " 
<< out_len << std::endl;
-
-  if (retval != 0)
-    {
-      std::cerr << strerror(errno) << std::endl;
-      std::cerr << "Error: conversion from " << from_charset
-                << " to " << to_charset << " went wrong: " << retval << 
std::endl;
-    }
-  iconv_close(cd);
-
-  
-    <dolphin> your code is also buggy
-<dolphin> there will be extra spaces at the end of the string
-<dolphin> the lenght of the final string should be: out_str - out_orig
-<dolphin> or: out_size_before_iconv_call - out_size_after_iconv_call
-   
-  std::string ret(out_orig, out_len);
-  delete[] out_orig;
-  delete[] in_orig;
-  return ret;
-}
-*/
-
-bool has_suffix(const std::string& lhs, const std::string rhs)
-{
-  if (lhs.length() < rhs.length())
-    return false;
-  else
-    return lhs.compare(lhs.length() - rhs.length(), rhs.length(), rhs) == 0;
-}
-
-bool has_prefix(const std::string& lhs, const std::string rhs)
-{
-  if (lhs.length() < rhs.length())
-    return false;
-  else
-    return lhs.compare(0, rhs.length(), rhs) == 0;
-}
-
-int plural1(int )     { return 0; }
-int plural2_1(int n)  { return (n != 1); }
-int plural2_2(int n)  { return (n > 1); }
-int plural3_lv(int n) { return (n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2); }
-int plural3_ga(int n) { return n==1 ? 0 : n==2 ? 1 : 2; }
-int plural3_lt(int n) { return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && 
(n%100<10 || n%100>=20) ? 1 : 2); }
-int plural3_1(int n)  { return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 
&& (n%100<10 || n%100>=20) ? 1 : 2); }
-int plural3_sk(int n) { return (n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2; }
-int plural3_pl(int n) { return (n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2); }
-int plural3_sl(int n) { return (n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || 
n%100==4 ? 2 : 3); }
-
-/** Language Definitions */
-//*{
-LanguageDef lang_hu("hu", "Hungarian",         1, plural1); // "nplurals=1; 
plural=0;"
-LanguageDef lang_ja("ja", "Japanese",          1, plural1); // "nplurals=1; 
plural=0;"
-LanguageDef lang_ko("ko", "Korean",            1, plural1); // "nplurals=1; 
plural=0;"
-LanguageDef lang_tr("tr", "Turkish",           1, plural1); // "nplurals=1; 
plural=0;"
-LanguageDef lang_da("da", "Danish",            2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_nl("nl", "Dutch",             2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_en("en", "English",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_fo("fo", "Faroese",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_de("de", "German",            2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_nb("nb", "Norwegian Bokmal",  2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_no("no", "Norwegian",         2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_nn("nn", "Norwegian Nynorsk", 2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_sv("sv", "Swedish",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_et("et", "Estonian",          2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_fi("fi", "Finnish",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_el("el", "Greek",             2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_he("he", "Hebrew",            2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_it("it", "Italian",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_pt("pt", "Portuguese",        2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_es("es", "Spanish",           2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_eo("eo", "Esperanto",         2, plural2_1); // "nplurals=2; 
plural=(n != 1);"
-LanguageDef lang_fr("fr", "French",            2, plural2_2); // "nplurals=2; 
plural=(n > 1);"
-LanguageDef lang_pt_BR("pt_BR", "Brazilian",   2, plural2_2); // "nplurals=2; 
plural=(n > 1);"
-LanguageDef lang_lv("lv", "Latvian",           3, plural3_lv); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);"
-LanguageDef lang_ga("ga", "Irish",             3, plural3_ga); // "nplurals=3; 
plural=n==1 ? 0 : n==2 ? 1 : 2;"
-LanguageDef lang_lt("lt", "Lithuanian",        3, plural3_lt); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);"
-LanguageDef lang_hr("hr", "Croatian",          3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
-LanguageDef lang_cs("cs", "Czech",             3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
-LanguageDef lang_ru("ru", "Russian",           3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
-LanguageDef lang_uk("uk", "Ukrainian",         3, plural3_1); // "nplurals=3; 
plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || 
n%100>=20) ? 1 : 2);"
-LanguageDef lang_sk("sk", "Slovak",            3, plural3_sk); // "nplurals=3; 
plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"
-LanguageDef lang_pl("pl", "Polish",            3, plural3_pl); // "nplurals=3; 
plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);
-LanguageDef lang_sl("sl", "Slovenian",         3, plural3_sl); // "nplurals=4; 
plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);"
-//*}
-
-LanguageDef&
-get_language_def(const std::string& name)
-{
-  if (name == "hu") return lang_hu;
-  else if (name == "ja") return lang_ja;
-  else if (name == "ko") return lang_ko;
-  else if (name == "tr") return lang_tr;
-  else if (name == "da") return lang_da;
-  else if (name == "nl") return lang_nl;
-  else if (name == "en") return lang_en;
-  else if (name == "fo") return lang_fo;
-  else if (name == "de") return lang_de;
-  else if (name == "nb") return lang_nb;
-  else if (name == "no") return lang_no;
-  else if (name == "nn") return lang_nn;
-  else if (name == "sv") return lang_sv;
-  else if (name == "et") return lang_et;
-  else if (name == "fi") return lang_fi;
-  else if (name == "el") return lang_el;
-  else if (name == "he") return lang_he;
-  else if (name == "it") return lang_it;
-  else if (name == "pt") return lang_pt;
-  else if (name == "es") return lang_es;
-  else if (name == "eo") return lang_eo;
-  else if (name == "fr") return lang_fr;
-  else if (name == "pt_BR") return lang_pt_BR;
-  else if (name == "lv") return lang_lv;
-  else if (name == "ga") return lang_ga;
-  else if (name == "lt") return lang_lt;
-  else if (name == "hr") return lang_hr;
-  else if (name == "cs") return lang_cs;
-  else if (name == "ru") return lang_ru;
-  else if (name == "uk") return lang_uk;
-  else if (name == "sk") return lang_sk;
-  else if (name == "pl") return lang_pl;
-  else if (name == "sl") return lang_sl;
-  else return lang_en; 
-}
-
-DictionaryManager::DictionaryManager()
-  : current_dict(&empty_dict)
-{
-  parseLocaleAliases();
-  // setup language from environment vars
-  const char* lang = getenv("LC_ALL");
-  if(!lang)
-    lang = getenv("LC_MESSAGES");
-  if(!lang)
-    lang = getenv("LANG");
-  
-  if(lang)
-    set_language(lang);
-}
-
-void
-DictionaryManager::parseLocaleAliases()
-{
-  // try to parse language alias list
-  std::ifstream in("/usr/share/locale/locale.alias");
-  
-  char c = ' ';
-  while(in.good() && !in.eof()) {
-    while(isspace(c) && !in.eof())
-      in.get(c);
-    
-    if(c == '#') { // skip comments
-      while(c != '\n' && !in.eof())
-        in.get(c);
-      continue;
-    }
-    
-    std::string alias;
-    while(!isspace(c) && !in.eof()) {
-      alias += c;
-      in.get(c);
-    }
-    while(isspace(c) && !in.eof())
-      in.get(c);
-    std::string language;
-    while(!isspace(c) && !in.eof()) {
-      language += c;
-      in.get(c);
-    }
-
-    if(in.eof())
-      break;
-    set_language_alias(alias, language);
-  }
-}
-  
-Dictionary&
-DictionaryManager::get_dictionary(const std::string& spec)
-{
-  std::string lang = get_language_from_spec(spec);
-  Dictionaries::iterator i = dictionaries.find(get_language_from_spec(lang));
-  if (i != dictionaries.end())
-    {
-      return i->second;
-    }
-  else // Dictionary for languages lang isn't loaded, so we load it
-    {
-      //std::cout << "get_dictionary: " << lang << std::endl;
-      Dictionary& dict = dictionaries[lang];
-
-      dict.set_language(get_language_def(lang));
-      if(charset != "")
-        dict.set_charset(charset);
-
-      for (SearchPath::iterator p = search_path.begin(); p != 
search_path.end(); ++p)
-        {
-          DIR* dir = opendir(p->c_str());
-          if (!dir)
-            {
-              std::cerr << "Error: opendir() failed on " << *p << std::endl;
-            }
-          else
-            {
-              struct dirent* ent;
-              while((ent = readdir(dir)))
-                {
-                  if (std::string(ent->d_name) == lang + ".po")
-                    {
-                      std::string pofile = *p + "/" + ent->d_name;
-                      std::ifstream in(pofile.c_str());
-                      if (!in)
-                        {
-                          std::cerr << "Error: Failure file opening: " << 
pofile << std::endl;
-                        }
-                      else
-                        {
-                          read_po_file(dict, in);
-                        }
-                    }
-                }
-              closedir(dir);
-            }
-        }
-
-      return dict;
-    }
-}
-
-std::set<std::string>
-DictionaryManager::get_languages()
-{
-  std::set<std::string> languages;
-
-  for (SearchPath::iterator p = search_path.begin(); p != search_path.end(); 
++p)
-    {
-      DIR* dir = opendir(p->c_str());
-      if (!dir)
-        {
-          std::cerr << "Error: opendir() failed on " << *p << std::endl;
-        }
-      else
-        {
-          struct dirent* ent;
-          while((ent = readdir(dir)))
-            {
-              if (has_suffix(ent->d_name, ".po"))
-                {
-                  std::string filename = ent->d_name;
-                  languages.insert(filename.substr(0, filename.length()-3));
-                }
-            }
-          closedir(dir);
-        }
-    }  
-  return languages;
-}
-
-void
-DictionaryManager::set_language(const std::string& lang)
-{
-  language = get_language_from_spec(lang);
-  current_dict = & (get_dictionary(language));
-}
-
-void
-DictionaryManager::set_charset(const std::string& charset)
-{
-  dictionaries.clear(); // changing charset invalidates cache
-  this->charset = charset;
-  set_language(language);
-}
-
-void
-DictionaryManager::set_language_alias(const std::string& alias,
-    const std::string& language)
-{
-  language_aliases.insert(std::make_pair(alias, language));
-}
-
-std::string
-DictionaryManager::get_language_from_spec(const std::string& spec)
-{
-  std::string lang = spec;
-  Aliases::iterator i = language_aliases.find(lang);
-  if(i != language_aliases.end()) {
-    lang = i->second;
-  }
-  
-  std::string::size_type s = lang.find_first_of("_.");
-  if(s == std::string::npos)
-    return lang;
-
-  return std::string(lang, 0, s);  
-}
-
-void
-DictionaryManager::add_directory(const std::string& pathname)
-{
-  dictionaries.clear(); // adding directories invalidates cache
-  search_path.push_back(pathname);
-  set_language(language);
-}
-
-//---------------------------------------------------------------------------
-
-Dictionary::Dictionary(const LanguageDef& language_, const std::string& 
charset_)
-  : language(language_), charset(charset_)
-{
-}
-
-Dictionary::Dictionary()
-  : language(lang_en)
-{
-}
-
-std::string
-Dictionary::get_charset() const
-{
-  return charset;
-}
-
-void
-Dictionary::set_charset(const std::string& charset_)
-{
-  charset = charset_;
-}
-
-void
-Dictionary::set_language(const LanguageDef& lang)
-{
-  language = lang;
-}
-
-std::string
-Dictionary::translate(const std::string& msgid, const std::string& msgid2, int 
num) 
-{
-  PluralEntries::iterator i = plural_entries.find(msgid);
-  std::map<int, std::string>& msgstrs = i->second;
-
-  if (i != plural_entries.end() && !msgstrs.empty())
-    {
-      int g = language.plural(num);
-      std::map<int, std::string>::iterator j = msgstrs.find(g);
-      if (j != msgstrs.end())
-        {
-          return j->second;
-        }
-      else
-        {
-          // Return the first translation, in case we can't translate the 
specific number
-          return msgstrs.begin()->second;
-        }
-    }
-  else
-    {
-#ifdef TRANSLATION_DEBUG
-      std::cerr << "Warning: Couldn't translate: " << msgid << std::endl;
-      std::cerr << "Candidates: " << std::endl;
-      for (PluralEntries::iterator i = plural_entries.begin(); i != 
plural_entries.end(); ++i)
-        std::cout << "'" << i->first << "'" << std::endl;
-#endif
-
-      if (plural2_1(num)) // default to english rules
-        return msgid2;
-      else
-        return msgid;
-    }
-}
-
-std::string
-Dictionary::translate(const std::string& msgid) 
-{
-  Entries::iterator i = entries.find(msgid);
-  if (i != entries.end() && !i->second.empty())
-    {
-      return i->second;
-    }
-  else
-    {
-#ifdef TRANSLATION_DBEUG
-      std::cout << "Error: Couldn't translate: " << msgid << std::endl;
-#endif
-      return msgid;
-    }
-}
-  
-void
-Dictionary::add_translation(const std::string& msgid, const std::string& ,
-                            const std::map<int, std::string>& msgstrs)
-{
-  // Do we need msgid2 for anything? its after all supplied to the
-  // translate call, so we just throw it away
-  plural_entries[msgid] = msgstrs;
-}
-
-void 
-Dictionary::add_translation(const std::string& msgid, const std::string& 
msgstr) 
-{
-  entries[msgid] = msgstr;
-}
-
-class POFileReader
-{
-private:
-  struct Token
-  {
-    std::string keyword;
-    std::string content;
-  };
-
-  Dictionary& dict;
-
-  std::string from_charset;
-  std::string to_charset;
-
-  std::string current_msgid;
-  std::string current_msgid_plural;
-  std::map<int, std::string> msgstr_plural;
-
-  int line_num;
-
-  enum { WANT_MSGID, WANT_MSGSTR, WANT_MSGSTR_PLURAL, WANT_MSGID_PLURAL } 
state;
-
-public:
-  POFileReader(std::istream& in, Dictionary& dict_)
-    : dict(dict_)
-  {
-    state = WANT_MSGID;
-    line_num = 0;
-    tokenize_po(in);
-  }
-
-  void parse_header(const std::string& header)
-  {
-    // Seperate the header in lines
-    typedef std::vector<std::string> Lines;
-    Lines lines;
-    
-    std::string::size_type start = 0;
-    for(std::string::size_type i = 0; i < header.length(); ++i)
-      {
-        if (header[i] == '\n')
-          {
-            lines.push_back(header.substr(start, i - start));
-            start = i+1;
-          }
-      }
-
-    for(Lines::iterator i = lines.begin(); i != lines.end(); ++i)
-      {
-        if (has_prefix(*i, "Content-Type: text/plain; charset=")) {
-          from_charset = i->substr(strlen("Content-Type: text/plain; 
charset="));
-        }
-      }
-
-    if (from_charset.empty() || from_charset == "CHARSET")
-      {
-        std::cerr << "Error: Charset not specified for .po, fallback to 
ISO-8859-1" << std::endl;
-        from_charset = "ISO-8859-1";
-      }
-
-    to_charset = dict.get_charset();
-    if (to_charset.empty())
-      { // No charset requested from the dict, so we use the one from the .po 
-        to_charset = from_charset;
-        dict.set_charset(from_charset);
-      }
-  }
-
-  void add_token(const Token& token)
-  {
-    switch(state) 
-      {
-      case WANT_MSGID:
-        if (token.keyword == "msgid") 
-          {
-            current_msgid = token.content;
-            state = WANT_MSGID_PLURAL;
-          }
-        else if (token.keyword.empty())
-          {
-            //std::cerr << "Got EOF, everything looks ok." << std::endl;
-          }
-        else
-          {
-            std::cerr << "tinygettext: expected 'msgid' keyword, got '" << 
token.keyword 
-                      << "' at line " << line_num << std::endl;
-          }
-        break;
-    
-      case WANT_MSGID_PLURAL:
-        if (token.keyword == "msgid_plural") 
-          {
-            current_msgid_plural = token.content;
-            state = WANT_MSGSTR_PLURAL;
-          } 
-        else
-          {
-            state = WANT_MSGSTR;
-            add_token(token);
-          }
-        break;
-
-      case WANT_MSGSTR:
-        if (token.keyword == "msgstr") 
-          {
-            if (current_msgid == "") 
-              { // .po Header is hidden in the msgid with the empty string
-                parse_header(token.content);
-              }
-            else
-              {
-                dict.add_translation(current_msgid, convert(token.content, 
from_charset, to_charset));
-              }
-            state = WANT_MSGID;
-          } 
-        else
-          {
-            std::cerr << "tinygettext: expected 'msgstr' keyword, got " << 
token.keyword 
-                      << " at line " << line_num << std::endl;
-          }
-        break;
-
-      case WANT_MSGSTR_PLURAL:
-        if (has_prefix(token.keyword, "msgstr[")) 
-          {
-            int num;
-            if (sscanf(token.keyword.c_str(), "msgstr[%d]", &num) != 1) 
-              {
-                std::cerr << "Error: Couldn't parse: " << token.keyword << 
std::endl;
-              } 
-            else 
-              {
-                msgstr_plural[num] = convert(token.content, from_charset, 
to_charset);
-              }
-          }
-        else 
-          {
-            dict.add_translation(current_msgid, current_msgid_plural, 
msgstr_plural);
-
-            state = WANT_MSGID;
-            add_token(token);
-          }
-        break;
-      }
-  }
-  
-  inline int getchar(std::istream& in) 
-  {
-    int c = in.get();
-    if (c == '\n')
-      line_num += 1;
-    return c;
-  }
-  
-  void tokenize_po(std::istream& in)
-  {
-    enum State { READ_KEYWORD, 
-                 READ_CONTENT,
-                 READ_CONTENT_IN_STRING,
-                 SKIP_COMMENT };
-
-    State state = READ_KEYWORD;
-    int c;
-    Token token;
-
-    while((c = getchar(in)) != EOF)
-      {
-        //std::cout << "Lexing char: '" << char(c) << "' " << c << " state: " 
<< state << std::endl;
-        switch(state)
-          {
-          case READ_KEYWORD:
-            if (c == '#')
-              {
-                state = SKIP_COMMENT;
-              }
-            else if (isspace(c))
-              {
-                state = READ_KEYWORD;
-              }
-            else
-              {
-                // Read a new token
-                token = Token();
-                
-                do { // Read keyword 
-                  token.keyword += c;
-                } while((c = getchar(in)) != EOF && !isspace(c));
-                in.unget();
-
-                state = READ_CONTENT;
-              }
-            break;
-
-          case READ_CONTENT:
-            while((c = getchar(in)) != EOF)
-              {
-                if (c == '"') { 
-                  // Found start of content
-                  state = READ_CONTENT_IN_STRING;
-                  break;
-                } else if (isspace(c)) {
-                  // skip
-                } else { // Read something that may be a keyword
-                  in.unget();
-                  state = READ_KEYWORD;
-                  add_token(token);
-                  break;
-                }
-              }
-            break;
-
-          case READ_CONTENT_IN_STRING:
-            if (c == '\\') {
-              c = getchar(in);
-              if (c != EOF)
-                {
-                  if (c == 'n') token.content += '\n';
-                  else if (c == 't') token.content += '\t';
-                  else if (c == 'r') token.content += '\r';
-                  else if (c == '"') token.content += '"';
-                  else
-                    {
-                      std::cout << "Unhandled escape character: " << char(c) 
<< std::endl;
-                    }
-                }
-              else
-                {
-                  std::cout << "Unterminated string" << std::endl;
-                }
-            } else if (c == '"') { // Content string is terminated
-              state = READ_CONTENT;
-            } else {
-              token.content += c;
-            }
-            break;
-
-          case SKIP_COMMENT:
-            if (c == '\n')
-              state = READ_KEYWORD;
-            break;
-          }
-      }
-    // add_token(token);
-  }
-};
-
-void read_po_file(Dictionary& dict_, std::istream& in) 
-{
-  POFileReader reader(in, dict_);
-}
-
-} // namespace TinyGetText
-
-/* EOF */

Deleted: trunk/src/tinygettext.hxx
===================================================================
--- trunk/src/tinygettext.hxx   2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/tinygettext.hxx   2005-12-01 20:55:34 UTC (rev 2520)
@@ -1,154 +0,0 @@
-//  $Id: tinygettext.h,v 1.2 2004/11/24 23:10:01 matzebraun Exp $
-// 
-//  TinyGetText - A small flexible gettext() replacement
-//  Copyright (C) 2004 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-// 
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#ifndef HEADER_TINYGETTEXT_HXX
-#define HEADER_TINYGETTEXT_HXX
-
-#include <map>
-#include <vector>
-#include <set>
-#include <string>
-
-namespace TinyGetText {
-
-typedef int (*PluralFunc)(int n);
-
-struct LanguageDef {
-  const char* code;
-  const char* name;
-  int         nplural;
-  PluralFunc  plural;
-
-  LanguageDef(const char* code_, const char* name_,  int nplural_, PluralFunc 
plural_)
-    : code(code_), name(name_), nplural(nplural_), plural(plural_)
-  {}
-};
-
-/** A simple dictionary class that mimics gettext() behaviour. Each
-    Dictionary only works for a single language, for managing multiple
-    languages and .po files at once use the DictionaryManager. */
-class Dictionary
-{
-private:
-  typedef std::map<std::string, std::string> Entries;
-  Entries entries;
-
-  typedef std::map<std::string, std::map<int, std::string> > PluralEntries;
-  PluralEntries plural_entries;
-
-  LanguageDef language;
-  std::string charset;
-public:
-  /** */
-  Dictionary(const LanguageDef& language_, const std::string& charset = "");
-
-  Dictionary();
-
-  /** Return the charset used for this dictionary */
-  std::string get_charset() const;
-
-  /** Set a charset for this dictionary, this will NOT convert stuff,
-      it is for information only, you have to convert stuff yourself
-      when you add it with \a add_translation() */
-  void set_charset(const std::string& charset);
-
-  /** Set the language that is used for this dictionary, this is
-      mainly needed to evaluate plural forms */
-  void set_language(const LanguageDef& lang);
-
-  /** Translate the string \a msgid to its correct plural form, based
-      on the number of items given by \a num. \a msgid2 is \a msgid in
-      plural form. */
-  std::string translate(const std::string& msgid, const std::string& msgid2, 
int num);
-
-  /** Translate the string \a msgid. */
-  std::string translate(const std::string& msgid);
-    
-  /** Add a translation from \a msgid to \a msgstr to the dictionary,
-      where \a msgid is the singular form of the message, msgid2 the
-      plural form and msgstrs a table of translations. The right
-      translation will be calculated based on the \a num argument to
-      translate(). */
-  void add_translation(const std::string& msgid, const std::string& msgid2,
-                       const std::map<int, std::string>& msgstrs);
-
-  /** Add a translation from \a msgid to \a msgstr to the
-      dictionary */
-  void add_translation(const std::string& msgid, const std::string& msgstr);
-};
-
-/** Manager class for dictionaries, you give it a bunch of directories
-    with .po files and it will then automatically load the right file
-    on demand depending on which language was set. */
-class DictionaryManager
-{
-private:
-  typedef std::map<std::string, Dictionary> Dictionaries;
-  Dictionaries dictionaries;
-  typedef std::vector<std::string> SearchPath;
-  SearchPath search_path;
-  typedef std::map<std::string, std::string> Aliases;
-  Aliases language_aliases;
-  std::string charset;
-  std::string language;
-  Dictionary* current_dict;
-  Dictionary empty_dict;
-
-public:
-  DictionaryManager();
-
-  /** Return the currently active dictionary, if none is set, an empty
-      dictionary is returned. */
-  Dictionary& get_dictionary()
-  { return *current_dict; }
-
-  /** Get dictionary for lang */
-  Dictionary& get_dictionary(const std::string& langspec);
-
-  /** Set a language based on a four? letter country code */
-  void set_language(const std::string& langspec);
-
-  /** Set a charset that will be set on the returned dictionaries */
-  void set_charset(const std::string& charset);
-
-  /** Define an alias for a language */
-  void set_language_alias(const std::string& alias, const std::string& lang);
-
-  /** Add a directory to the search path for dictionaries */
-  void add_directory(const std::string& pathname);
-  
-  /** Return a set of the available languages in their country code */
-  std::set<std::string> get_languages();
-
-private:
-  void parseLocaleAliases();
-  /// returns the language part in a language spec (like de_DE.UTF-8 -> de)
-  std::string get_language_from_spec(const std::string& spec);
-};
-
-/** Read the content of the .po file given as \a in into the
-    dictionary given as \a dict */
-void read_po_file(Dictionary& dict, std::istream& in);
-LanguageDef& get_language_def(const std::string& name);
-
-} // namespace TinyGetText
-
-#endif
-
-/* EOF */

Modified: trunk/src/world.cxx
===================================================================
--- trunk/src/world.cxx 2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/world.cxx 2005-12-01 20:55:34 UTC (rev 2520)
@@ -23,7 +23,7 @@
 #include <typeinfo>
 #include "pingu_holder.hxx"
 #include "sound/sound.hxx"
-#include "spot_map.hxx"
+#include "ground_map.hxx"
 #include "world.hxx"
 #include "particles/pingu_particle_holder.hxx"
 #include "particles/rain_particle_holder.hxx"
@@ -47,7 +47,7 @@
 
 World::World(const PingusLevel& plf)
   : ambient_light(CL_Color(plf.get_ambient_light())),
-    gfx_map(new PingusSpotMap(plf)),
+    gfx_map(new GroundMap(plf)),
     game_time(new GameTime (game_speed)),
     do_armageddon(false),
     pingus(new PinguHolder(plf)),
@@ -216,7 +216,7 @@
   return colmap;
 }
 
-PinguMap*
+GroundMap*
 World::get_gfx_map ()
 {
   return gfx_map;

Modified: trunk/src/world.hxx
===================================================================
--- trunk/src/world.hxx 2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/world.hxx 2005-12-01 20:55:34 UTC (rev 2520)
@@ -35,7 +35,7 @@
 class Hotspot;
 class Liquid;
 class PinguHolder;
-class PinguMap;
+class GroundMap;
 class PingusLevel;
 class Pingu;
 class Trap;
@@ -64,7 +64,7 @@
   CL_Color ambient_light;
 
   /** groundmap for the pingus */
-  PinguMap* gfx_map;
+  GroundMap* gfx_map;
 
   /** manager class for the time in the pingus world */
   GameTime* game_time;
@@ -127,7 +127,7 @@
   ColMap* get_colmap();
 
   /** @return A pointer to the gfx map of this world */
-  PinguMap* get_gfx_map();
+  GroundMap* get_gfx_map();
 
   /** @return A pointer to the worlds pingu particle holder */
   Particles::PinguParticleHolder* get_pingu_particle_holder () { return 
pingu_particle_holder; }

Modified: trunk/src/worldobjs/groundpiece.cxx
===================================================================
--- trunk/src/worldobjs/groundpiece.cxx 2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/worldobjs/groundpiece.cxx 2005-12-01 20:55:34 UTC (rev 2520)
@@ -19,7 +19,7 @@
 
 #include <iostream>
 #include "../world.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../col_map.hxx"
 #include "../resource.hxx"
 #include "groundpiece.hxx"

Modified: trunk/src/worldobjs/ice_block.cxx
===================================================================
--- trunk/src/worldobjs/ice_block.cxx   2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/worldobjs/ice_block.cxx   2005-12-01 20:55:34 UTC (rev 2520)
@@ -22,7 +22,7 @@
 #include "../display/scene_context.hxx"
 #include "../pingu.hxx"
 #include "../pingu_holder.hxx"
-#include "../pingu_map.hxx"
+#include "../ground_map.hxx"
 #include "../resource.hxx"
 #include "../world.hxx"
 #include "ice_block.hxx"

Modified: trunk/src/xml_pdf.hxx
===================================================================
--- trunk/src/xml_pdf.hxx       2005-12-01 20:18:15 UTC (rev 2519)
+++ trunk/src/xml_pdf.hxx       2005-12-01 20:55:34 UTC (rev 2520)
@@ -37,6 +37,7 @@
   PingusLevel plf;
   std::string levelname;
   std::vector<ServerEvent> events;
+
 public:
   XMLPDF(const std::string& filename);
   ~XMLPDF();





reply via email to

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