(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
authorrubidium
Sun, 29 Jul 2007 14:06:53 +0000
changeset 7855 0465a871522f
parent 7854 321c1ab24b61
child 7856 121ae75a45a0
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
src/main_gui.cpp
--- a/src/main_gui.cpp	Sun Jul 29 14:02:27 2007 +0000
+++ b/src/main_gui.cpp	Sun Jul 29 14:06:53 2007 +0000
@@ -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: