From: Miriam Ruiz Date: Sun, 30 Nov 2008 18:51:05 +0000 (+0100) Subject: Merge branch 'i18n' X-Git-Url: https://repo.or.cz/w/hex-a-hop.git/commitdiff_plain/edec0624e1643cadb10748b4c152f462277553e3 Merge branch 'i18n' --- edec0624e1643cadb10748b4c152f462277553e3 diff --cc Makefile index d2975c4,12b5a08..9d316f7 --- a/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 = @@@ -14,10 -13,10 +14,10 @@@ 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 index 503a72a,ff4f1ad..0c8e5ae --- a/gfx.cpp +++ b/gfx.cpp @@@ -28,10 -31,14 +31,18 @@@ #undef USE_BBTABLET #endif + // If included multiple times: + // BUG: multiple definition of `MATRIX_WHITE_BACK' + // see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=437517 + #include "SDL_Pango.h" + + #include + #include + +#ifndef DATA_DIR +#define DATA_DIR "." +#endif + StateMakerBase* StateMakerBase::first = 0; State* StateMakerBase::current = 0; @@@ -201,7 -292,11 +296,11 @@@ int main(int /*argc*/, char * /*argv*/[ SDL_Flip(screen); */ - SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE); + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); + SDLPango_Init(); + context = SDLPango_CreateContext_GivenFontDesc("sans-serif bold 12"); + SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_WHITE_LETTER); + SDLPango_SetMinimumSize(context, SCREEN_W, 0); SDL_Surface* icon = SDL_LoadBMP("graphics/icon.bmp"); if (icon) diff --cc hex_puzzzle.cpp index ee4eef0,580eb44..e2f2c13 --- a/hex_puzzzle.cpp +++ b/hex_puzzzle.cpp @@@ -1581,10 -1525,10 +1562,10 @@@ struct HexPuzzle : public Stat return &tmp; } - for (int i=0; i>"}; + static LevelInfo tmp = {0, "", _("<>")}; return &tmp; } diff --cc menus.h index 0151cf6,9365dd8..5912977 --- a/menus.h +++ b/menus.h @@@ -201,15 -233,33 +233,33 @@@ struct HintMessage : public Men void Render(int x, int y) { - SDL_Rect r2 = {x+TILE_W1, y, SCREEN_W-TILE_W1*2, numLines*FONT_SPACING+FONT_SPACING}; - SDL_Rect r = {r2.x-2, r2.y-2-FONT_SPACING, r2.w+4, r2.h+4+FONT_SPACING}; + //if (y<0) { + // std::cout << "Error in Render: " << x << " " << y << "\n"; // CHECKME + // y = 0; + //} + InnerTextWindowRect.x = x+TILE_W1; + InnerTextWindowRect.y = y; + OuterTextWindowRect.x = InnerTextWindowRect.x-2; + OuterTextWindowRect.y = InnerTextWindowRect.y-2-FONT_SPACING; + // Height is reduced in SDL_FillRect!!? Why? ==> Use a copy: + SDL_Rect r2 = InnerTextWindowRect; + SDL_Rect r = OuterTextWindowRect; SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 60,90,90)); SDL_FillRect(screen, &r2, SDL_MapRGB(screen->format, 20,50,50)); - Print(r.x+FONT_SPACING/4, y-FONT_SPACING, title); - PrintC(true, x+SCREEN_W/2, y+FONT_SPACING/2, msg); + Print(OuterTextWindowRect.x+FONT_SPACING/4, y-FONT_SPACING, "%s", title); + /* TRANSLATORS: This specifies how the text in the help dialog should + be aligned. Do *not* translate the text itself but use one of "left", + "center" or "right" (untranslated!). The default is "center". */ + std::string alignment = _("text alignment"); + if (alignment == "right") + Print_Aligned(true, InnerTextWindowRect.x + InnerTextWindowRect.w - FONT_SPACING, y+FONT_SPACING/2, InnerTextWindowRect.w - 2*FONT_SPACING, msg, 2); + else if (alignment == "left") + Print_Aligned(true, InnerTextWindowRect.x + FONT_SPACING, y+FONT_SPACING/2, InnerTextWindowRect.w - 2*FONT_SPACING, msg, 0); + else + Print_Aligned(true, x+SCREEN_W/2, y+FONT_SPACING/2, InnerTextWindowRect.w - 2*FONT_SPACING, msg, 1); } - virtual void Mouse(int x, int y, int dx, int dy, int buttons_pressed, int buttons_released, int buttons) + virtual void Mouse(int /*x*/, int /*y*/, int /*dx*/, int /*dy*/, int buttons_pressed, int /*buttons_released*/, int /*buttons*/) { if (buttons_pressed && state==0 && time>0.2) state = 1, time=0; @@@ -500,8 -548,9 +552,8 @@@ struct OptMenu : public Men } void RenderTitle() { - int y = r2.y + FONT_SPACING / 2; if (left_align) - Print(r2.x+font[' '].w, r.y+4, title); + Print(r2.x+SDLPangoTextWidth(" "), r.y+4, title); else PrintC(false, r2.x+r2.w/2, r.y+4, title); } @@@ -923,11 -972,11 +975,11 @@@ struct TitleMenu : public OptMenuTitl fclose(f); if (p.general.completionPercentage==100 && p.general.masteredPercentage==100) - sprintf(optionSlotName[i], _("Continue game %d (All Clear!)"), i+1, p.general.completionPercentage, p.general.masteredPercentage); + sprintf(optionSlotName[i], _("Continue game %d (All Clear!)"), i+1); else if (p.general.completionPercentage==100) - sprintf(optionSlotName[i], "Continue game %d (%d%% + %d%%)", i+1, p.general.completionPercentage, p.general.masteredPercentage); + sprintf(optionSlotName[i], _("Continue game %d (%d%% + %d%%)"), i+1, p.general.completionPercentage, p.general.masteredPercentage); else - sprintf(optionSlotName[i], "Continue game %d (%d%% complete)", i+1, p.general.completionPercentage); + sprintf(optionSlotName[i], _("Continue game %d (%d%% complete)"), i+1, p.general.completionPercentage); opt[num_opt++] = OPT_GAMESLOT_0 + i; }