Merge branch 'i18n'
authorMiriam Ruiz <miriam@debian.org>
Sun, 30 Nov 2008 18:51:05 +0000 (30 19:51 +0100)
committerMiriam Ruiz <miriam@debian.org>
Sun, 30 Nov 2008 18:51:05 +0000 (30 19:51 +0100)
1  2 
Makefile
gfx.cpp
gfx_list.h
hex_puzzzle.cpp
menus.h

diff --cc Makefile
+++ b/Makefile
@@@ -2,10 -2,9 +2,10 @@@
  NAME          = Hex-a-hop
  VERSION               = 1.0.0
  CC            = gcc
 -CXXFLAGS              += -D_VERSION=\"$(VERSION)\" -g
 +DATA_DIR="."
 +CXXFLAGS              += -Wall -W -g
  GCC =g++
- CXXSOURCES    = gfx.cpp hex_puzzzle.cpp
+ CXXSOURCES    = gfx.cpp hex_puzzzle.cpp i18n.cpp
  #INCLUDES     = 
  
  
  OBJS=$(CXXSOURCES:.cpp=.o)
  
  %.o   : %.cpp
 -      $(GCC) $(CXXFLAGS)  `sdl-config --cflags`  -c -o $@ $<
 +      $(GCC) $(CXXFLAGS) -D_VERSION=\"$(VERSION)\" -DDATA_DIR=\"$(DATA_DIR)\" `sdl-config --cflags`  -c -o $@ $<
        
  $(NAME) : $(OBJS)
-               $(GCC) $(CXXFLAGS) $(OBJS)  `sdl-config --libs` -lm  \
+               $(GCC) $(CXXFLAGS) $(OBJS)  `sdl-config --libs` -lSDL_Pango -lm  \
                -o $(NAME)
  
  clean :
diff --cc gfx.cpp
+++ b/gfx.cpp
        #undef USE_BBTABLET\r
  #endif\r
  \r
+ // If included multiple times:\r
+ // BUG: multiple definition of `MATRIX_WHITE_BACK'\r
+ // see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=437517\r
+ #include "SDL_Pango.h"\r
\r
+ #include <algorithm>\r
+ #include <string>\r
\r
 +#ifndef DATA_DIR\r
 +#define DATA_DIR "."\r
 +#endif\r
 +\r
  StateMakerBase* StateMakerBase::first = 0;\r
  State* StateMakerBase::current = 0;\r
  \r
@@@ -201,7 -292,11 +296,11 @@@ int main(int /*argc*/, char * /*argv*/[
        SDL_Flip(screen);\r
  */\r
  \r
 -      SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE);\r
 +      SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);\r
+       SDLPango_Init();\r
+       context = SDLPango_CreateContext_GivenFontDesc("sans-serif bold 12");\r
+       SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_WHITE_LETTER);\r
+       SDLPango_SetMinimumSize(context, SCREEN_W, 0);\r
  \r
        SDL_Surface* icon = SDL_LoadBMP("graphics/icon.bmp");\r
        if (icon)\r
diff --cc gfx_list.h
Simple merge
diff --cc hex_puzzzle.cpp
@@@ -1581,10 -1525,10 +1562,10 @@@ struct HexPuzzle : public Stat
                        return &tmp;\r
                }\r
  \r
 -              for (int i=0; i<sizeof(levelNames)/sizeof(levelNames[0]); i++)\r
 +              for (unsigned int i=0; i<sizeof(levelNames)/sizeof(levelNames[0]); i++)\r
                        if (strcmp(f, levelNames[i].file)==0)\r
                                return &levelNames[i];\r
-               static LevelInfo tmp = {0, "", "<<NO NAME>>"};\r
+               static LevelInfo tmp = {0, "", _("<<NO NAME>>")};\r
                return &tmp;\r
        }\r
  \r
diff --cc menus.h
+++ b/menus.h
@@@ -201,15 -233,33 +233,33 @@@ struct HintMessage : public Men
  \r
        void Render(int x, int y)\r
        {\r
-               SDL_Rect r2 = {x+TILE_W1, y, SCREEN_W-TILE_W1*2, numLines*FONT_SPACING+FONT_SPACING};\r
-               SDL_Rect r = {r2.x-2, r2.y-2-FONT_SPACING, r2.w+4, r2.h+4+FONT_SPACING};\r
+               //if (y<0) {\r
+               //  std::cout << "Error in Render: " << x << " " << y << "\n"; // CHECKME\r
+               //  y = 0;\r
+               //}\r
+               InnerTextWindowRect.x = x+TILE_W1;\r
+               InnerTextWindowRect.y = y;\r
+               OuterTextWindowRect.x = InnerTextWindowRect.x-2;\r
+               OuterTextWindowRect.y = InnerTextWindowRect.y-2-FONT_SPACING;\r
+               // Height is reduced in SDL_FillRect!!? Why? ==> Use a copy:\r
+               SDL_Rect r2 = InnerTextWindowRect;\r
+               SDL_Rect r = OuterTextWindowRect;\r
                SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 60,90,90));\r
                SDL_FillRect(screen, &r2, SDL_MapRGB(screen->format, 20,50,50));\r
-               Print(r.x+FONT_SPACING/4, y-FONT_SPACING, title);\r
-               PrintC(true, x+SCREEN_W/2, y+FONT_SPACING/2, msg);\r
+               Print(OuterTextWindowRect.x+FONT_SPACING/4, y-FONT_SPACING, "%s", title);\r
+               /* TRANSLATORS: This specifies how the text in the help dialog should\r
+                  be aligned. Do *not* translate the text itself but use one of "left",\r
+        "center" or "right" (untranslated!). The default is "center". */\r
+               std::string alignment = _("text alignment");\r
+               if (alignment == "right")\r
+                       Print_Aligned(true, InnerTextWindowRect.x + InnerTextWindowRect.w - FONT_SPACING, y+FONT_SPACING/2, InnerTextWindowRect.w - 2*FONT_SPACING, msg, 2);\r
+               else if (alignment == "left")\r
+                       Print_Aligned(true, InnerTextWindowRect.x + FONT_SPACING, y+FONT_SPACING/2, InnerTextWindowRect.w - 2*FONT_SPACING, msg, 0);\r
+               else\r
+                       Print_Aligned(true, x+SCREEN_W/2, y+FONT_SPACING/2, InnerTextWindowRect.w - 2*FONT_SPACING, msg, 1);\r
        }\r
  \r
 -      virtual void Mouse(int x, int y, int dx, int dy, int buttons_pressed, int buttons_released, int buttons\r
 +      virtual void Mouse(int /*x*/, int /*y*/, int /*dx*/, int /*dy*/, int buttons_pressed, int /*buttons_released*/, int /*buttons*/\r
        {\r
                if (buttons_pressed && state==0 && time>0.2)\r
                        state = 1, time=0;\r
@@@ -500,8 -548,9 +552,8 @@@ struct OptMenu : public Men
        }\r
        void RenderTitle()\r
        {\r
 -              int y = r2.y + FONT_SPACING / 2;\r
                if (left_align)\r
-                       Print(r2.x+font[' '].w, r.y+4, title);\r
+                       Print(r2.x+SDLPangoTextWidth(" "), r.y+4, title);\r
                else\r
                        PrintC(false, r2.x+r2.w/2, r.y+4, title);\r
        }\r
@@@ -923,11 -972,11 +975,11 @@@ struct TitleMenu : public OptMenuTitl
                                fclose(f);\r
  \r
                                if (p.general.completionPercentage==100 && p.general.masteredPercentage==100)\r
 -                                      sprintf(optionSlotName[i], _("Continue game %d (All Clear!)"), i+1, p.general.completionPercentage, p.general.masteredPercentage);\r
 +                                      sprintf(optionSlotName[i], _("Continue game %d (All Clear!)"), i+1);\r
                                else if (p.general.completionPercentage==100)\r
-                                       sprintf(optionSlotName[i], "Continue game %d (%d%% + %d%%)", i+1, p.general.completionPercentage, p.general.masteredPercentage);\r
+                                       sprintf(optionSlotName[i], _("Continue game %d (%d%% + %d%%)"), i+1, p.general.completionPercentage, p.general.masteredPercentage);\r
                                else\r
-                                       sprintf(optionSlotName[i], "Continue game %d (%d%% complete)", i+1, p.general.completionPercentage);\r
+                                       sprintf(optionSlotName[i], _("Continue game %d (%d%% complete)"), i+1, p.general.completionPercentage);\r
        \r
                                opt[num_opt++] = OPT_GAMESLOT_0 + i;\r
                        }\r