diff options
author | rubidium <rubidium@openttd.org> | 2009-03-25 01:10:24 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-03-25 01:10:24 +0000 |
commit | 3e93f8adda5f23808e66a973b1dce8d7e7c24d0f (patch) | |
tree | 6a8fb50166f8edf977cbf51774333b5004a3a679 | |
parent | 4a500bbcdb5c1f3b8bfe8dcc454c2d07b210bf88 (diff) | |
download | openttd-3e93f8adda5f23808e66a973b1dce8d7e7c24d0f.tar.xz |
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
-rw-r--r-- | src/ai/ai_gui.cpp | 4 | ||||
-rw-r--r-- | src/console_gui.cpp | 10 | ||||
-rw-r--r-- | src/gfx.cpp | 6 | ||||
-rw-r--r-- | src/gfx_func.h | 9 |
4 files changed, 16 insertions, 13 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index c8f88eaa8..6a93c6eaa 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -655,7 +655,7 @@ struct AIDebugWindow : public Window { assert(info != NULL); char name[1024]; snprintf(name, sizeof(name), "%s (v%d)", info->GetName(), info->GetVersion()); - DrawString(7, this->widget[AID_WIDGET_VIEW].right, 47, name, TC_BLACK); + DrawString(this->widget[AID_WIDGET_NAME_TEXT].left + 7, this->widget[AID_WIDGET_NAME_TEXT].right - 7, 47, name, TC_BLACK, SA_CENTER); CompanyID old_company = _current_company; _current_company = ai_debug_company; @@ -681,7 +681,7 @@ struct AIDebugWindow : public Window { default: colour = TC_BLACK; break; } - DrawString(this->widget[AID_WIDGET_LOG_PANEL].left + 7, this->widget[AID_WIDGET_LOG_PANEL].right - 7, this->widget[AID_WIDGET_LOG_PANEL].top + y, log->lines[pos], colour); + DrawString(this->widget[AID_WIDGET_LOG_PANEL].left + 7, this->widget[AID_WIDGET_LOG_PANEL].right - 7, this->widget[AID_WIDGET_LOG_PANEL].top + y, log->lines[pos], colour, SA_LEFT | SA_FORCE); y += 12; } } diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 957d3684b..e69b17d3e 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -163,24 +163,24 @@ struct IConsoleWindow : Window virtual void OnPaint() { const int max = (this->height / ICON_LINE_HEIGHT) - 1; - const int right = this->width - 1; + const int right = this->width - 5; const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll); GfxFillRect(this->left, this->top, this->width, this->height - 1, 0); for (int i = 0; i < max && print != NULL; i++, print = print->previous) { - DrawString(5, right, this->height - (2 + i) * ICON_LINE_HEIGHT, print->buffer, print->colour); + DrawString(5, right, this->height - (2 + i) * ICON_LINE_HEIGHT, print->buffer, print->colour, SA_LEFT | SA_FORCE); } /* If the text is longer than the window, don't show the starting ']' */ int delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH; if (delta > 0) { - DrawString(5, right, this->height - ICON_LINE_HEIGHT, "]", (TextColour)CC_COMMAND); + DrawString(5, right, this->height - ICON_LINE_HEIGHT, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE); delta = 0; } - DrawString(10 + delta, right, this->height - ICON_LINE_HEIGHT, _iconsole_cmdline.buf, (TextColour)CC_COMMAND); + DrawString(10 + delta, right, this->height - ICON_LINE_HEIGHT, _iconsole_cmdline.buf, (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE); if (_focused_window == this && _iconsole_cmdline.caret) { - DrawString(10 + delta + _iconsole_cmdline.caretxoffs, right, this->height - ICON_LINE_HEIGHT, "_", TC_WHITE); + DrawString(10 + delta + _iconsole_cmdline.caretxoffs, right, this->height - ICON_LINE_HEIGHT, "_", TC_WHITE, SA_LEFT | SA_FORCE); } } diff --git a/src/gfx.cpp b/src/gfx.cpp index 8d1d3c6a1..c334d24db 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -426,7 +426,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last, continue; } - if (align != SA_LEFT) { + if ((align & SA_MASK) != SA_LEFT) { DEBUG(grf, 1, "Using SETX and/or SETXY when not aligned to the left. Fixing alignment..."); align = SA_LEFT; } @@ -443,7 +443,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last, } /* In case we have a RTL language we swap the alignment. */ - if (_dynlang.text_dir == TD_RTL && align != SA_CENTER) align = (StringAlignment)(align ^ 2); + if (!(align & SA_FORCE) && _dynlang.text_dir == TD_RTL && align != SA_CENTER) align ^= SA_RIGHT; /* Now draw the parts. This is done in the reverse order so we can give the * BiDi algorithm the room to replace characters. It also simplifies @@ -470,7 +470,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last, * seen as lastof(todraw) and width as lengthof(todraw). They differ by 1. * So most +1/-1 additions are to move from lengthof to 'indices'. */ - switch (align) { + switch (align & SA_MASK) { case SA_LEFT: /* right + 1 = left + w */ left = initial_left + offset; diff --git a/src/gfx_func.h b/src/gfx_func.h index 88aebc07b..139056df3 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -87,10 +87,13 @@ void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = /** How to align the to-be drawn text. */ enum StringAlignment { - SA_LEFT, ///< Left align the text - SA_CENTER, ///< Center the text - SA_RIGHT, ///< Right align the text + SA_LEFT, ///< Left align the text + SA_CENTER, ///< Center the text + SA_RIGHT, ///< Right align the text + SA_MASK = 3, ///< Mask for base alignment + SA_FORCE = 4, ///< Force the alignment, i.e. don't swap for RTL languages. }; +DECLARE_ENUM_AS_BIT_SET(StringAlignment); int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false); int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false); |