changeset 7359:2309901e577d draft

(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
author rubidium <rubidium@openttd.org>
date Sun, 29 Jul 2007 14:06:53 +0000
parents 97a745274d85
children 11ff61f55c0c
files src/main_gui.cpp
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -1912,7 +1912,7 @@
 extern GetNewsStringCallbackProc * const _get_news_string_callback[];
 
 
-static bool DrawScrollingStatusText(const NewsItem *ni, int pos)
+static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width)
 {
 	char buf[512];
 	StringID str;
@@ -1947,7 +1947,7 @@
 		}
 	}
 
-	if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, 358, 11)) return true;
+	if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
 
 	old_dpi = _cur_dpi;
 	_cur_dpi = &tmp_dpi;
@@ -1973,29 +1973,35 @@
 		if (p != NULL) {
 			/* Draw player money */
 			SetDParam(0, p->player_money);
-			DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0);
+			DrawStringCentered(w->widget[2].left + 70, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0);
 		}
 
 		/* Draw status bar */
 		if (w->message.msg) { // true when saving is active
-			DrawStringCentered(320, 1, STR_SAVING_GAME, 0);
+			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, 0);
 		} else if (_do_autosave) {
-			DrawStringCentered(320, 1, STR_032F_AUTOSAVE, 0);
+			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, 0);
 		} else if (_pause_game) {
-			DrawStringCentered(320, 1, STR_0319_PAUSED, 0);
+			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, 0);
 		} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
 			/* Draw the scrolling news text */
-			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1))
+			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
 				WP(w,def_d).data_1 = -1280;
+				if (p != NULL) {
+					/* This is the default text */
+					SetDParam(0, p->index);
+					DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, 0);
+				}
+			}
 		} else {
 			if (p != NULL) {
 				/* This is the default text */
 				SetDParam(0, p->index);
-				DrawStringCentered(320, 1, STR_02BA, 0);
+				DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, 0);
 			}
 		}
 
-		if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, 489, 2);
+		if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, w->widget[1].right - 11, 2);
 	} break;
 
 	case WE_MESSAGE: