diff options
author | maedhros <maedhros@openttd.org> | 2007-03-25 16:09:36 +0000 |
---|---|---|
committer | maedhros <maedhros@openttd.org> | 2007-03-25 16:09:36 +0000 |
commit | 68248cad4ffaa1d755c8e9f16f8d7fc1180c3ae1 (patch) | |
tree | ad997b5cfb54a6cc8631757210a2d71acde0bfe7 /src | |
parent | 4a1f9286dd2c5c8b3366c7430b3690fbdb21685b (diff) | |
download | openttd-68248cad4ffaa1d755c8e9f16f8d7fc1180c3ae1.tar.xz |
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
Diffstat (limited to 'src')
-rw-r--r-- | src/gfx.cpp | 9 | ||||
-rw-r--r-- | src/gfx.h | 2 | ||||
-rw-r--r-- | src/newgrf_gui.cpp | 26 |
3 files changed, 22 insertions, 15 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index d6d1f8f25..ae2bd18f9 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -531,7 +531,7 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw) } -uint DrawStringMultiLine(int x, int y, StringID str, int maxw) +uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh) { char buffer[512]; uint32 tmp; @@ -548,6 +548,13 @@ uint DrawStringMultiLine(int x, int y, StringID str, int maxw) mt = GetCharacterHeight((FontSize)GB(tmp, 16, 16)); total_height = (num + 1) * mt; + if (maxh != -1 && total_height > (uint)maxh) { + num = maxh / mt - 1; + if (num < 1) return 0; + + total_height = (num + 1) * mt; + } + src = buffer; for (;;) { @@ -231,7 +231,7 @@ BoundingRect GetStringBoundingBox(const char *str); uint32 FormatStringLinebreaks(char *str, int maxw); void LoadStringWidthTable(); void DrawStringMultiCenter(int x, int y, StringID str, int maxw); -uint DrawStringMultiLine(int x, int y, StringID str, int maxw); +uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1); void DrawDirtyBlocks(); void SetDirtyBlocks(int left, int top, int right, int bottom); void MarkWholeScreenDirty(); diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index b1d604954..51f57fc5e 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -42,7 +42,7 @@ static int parse_intlist(const char *p, int *items, int maxitems) } -static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show_params) +static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bottom, bool show_params) { char buff[256]; @@ -62,24 +62,24 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show GetString(message, c->error->message, lastof(message)); SetDParamStr(0, message); - y += DrawStringMultiLine(x, y, c->error->severity, w); + y += DrawStringMultiLine(x, y, c->error->severity, w, bottom - y); } /* Draw filename or not if it is not known (GRF sent over internet) */ if (c->filename != NULL) { SetDParamStr(0, c->filename); - y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w); + y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w, bottom - y); } /* Prepare and draw GRF ID */ snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->grfid)); SetDParamStr(0, buff); - y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w); + y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w, bottom - y); /* Prepare and draw MD5 sum */ md5sumToString(buff, lastof(buff), c->md5sum); SetDParamStr(0, buff); - y += DrawStringMultiLine(x, y, STR_NEWGRF_MD5SUM, w); + y += DrawStringMultiLine(x, y, STR_NEWGRF_MD5SUM, w, bottom - y); /* Show GRF parameter list */ if (show_params) { @@ -89,20 +89,20 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show } else { SetDParam(0, STR_01A9_NONE); } - y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w); + y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w, bottom - y); } /* Show flags */ - if (c->status == GCS_NOT_FOUND) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w); - if (c->status == GCS_DISABLED) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w); - if (HASBIT(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w); + if (c->status == GCS_NOT_FOUND) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w, bottom - y); + if (c->status == GCS_DISABLED) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w, bottom - y); + if (HASBIT(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w, bottom - y); /* Draw GRF info if it exists */ if (c->info != NULL && !StrEmpty(c->info)) { SetDParamStr(0, c->info); - y += DrawStringMultiLine(x, y, STR_02BD, w); + y += DrawStringMultiLine(x, y, STR_02BD, w, bottom - y); } else { - y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w); + y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w, bottom - y); } } @@ -151,7 +151,7 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e) if (WP(w, newgrf_add_d).sel != NULL) { const Widget *wi = &w->widget[5]; - ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, false); + ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, false); } break; } @@ -366,7 +366,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e) if (WP(w, newgrf_d).sel != NULL) { /* Draw NewGRF file info */ const Widget *wi = &w->widget[SNGRFS_NEWGRF_INFO]; - ShowNewGRFInfo(WP(w, newgrf_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, WP(w, newgrf_d).show_params); + ShowNewGRFInfo(WP(w, newgrf_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, WP(w, newgrf_d).show_params); } break; |