(svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
authorsmatz
Sat, 21 Jun 2008 18:59:15 +0000
changeset 11045 60c076d531f9
parent 11041 5a7b939e6846
child 11046 b26cfd2a54f6
(svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
src/misc_gui.cpp
--- a/src/misc_gui.cpp	Sat Jun 21 01:40:56 2008 +0000
+++ b/src/misc_gui.cpp	Sat Jun 21 18:59:15 2008 +0000
@@ -59,12 +59,12 @@
 static const Widget _land_info_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   279,     0,    13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    92, 0x0,                            STR_NULL},
+{      WWT_PANEL, RESIZE_BOTTOM,    14,     0,   279,    14,    99, 0x0,                            STR_NULL},
 {    WIDGETS_END},
 };
 
 static const WindowDesc _land_info_desc = {
-	WDP_AUTO, WDP_AUTO, 280, 93, 280, 93,
+	WDP_AUTO, WDP_AUTO, 280, 100, 280, 100,
 	WC_LAND_INFO, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 	_land_info_widgets,
@@ -86,15 +86,15 @@
 	{
 		this->DrawWidgets();
 
-		uint y = 16;
+		uint y = 21;
 		for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) {
-			if (StrEmpty(this->landinfo_data[i])) continue;
+			if (StrEmpty(this->landinfo_data[i])) break;
 
 			DoDrawStringCentered(140, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING);
-			y += 11;
+			y += i == 0 ? 16 : 12;
 		}
 
-		y += 5;
+		y += 6;
 
 		if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) DrawStringMultiCenter(140, y, BindCString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]), this->width - 4);
 	}
@@ -181,10 +181,8 @@
 			line_nr++;
 		}
 
-		/* Remaining lines stay empty */
-		for (; line_nr < LAND_INFO_CENTERED_LINES; line_nr++) {
-			this->landinfo_data[line_nr][0] = '\0';
-		}
+		/* Mark last line empty */
+		this->landinfo_data[line_nr][0] = '\0';
 
 		/* Cargo acceptance is displayed in a extra multiline */
 		char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
@@ -211,6 +209,12 @@
 		}
 		if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
 
+		if (found) line_nr += 2;
+
+		if (line_nr > 6) ResizeWindow(this, 0, 12 * (line_nr - 6));
+
+		this->FindWindowPlacementAndResize(&_land_info_desc);
+
 #if defined(_DEBUG)
 #	define LANDINFOD_LEVEL 0
 #else
@@ -226,8 +230,6 @@
 		DEBUG(misc, LANDINFOD_LEVEL, "m6           = %#x", _m[tile].m6);
 		DEBUG(misc, LANDINFOD_LEVEL, "m7           = %#x", _me[tile].m7);
 #undef LANDINFOD_LEVEL
-
-		this->FindWindowPlacementAndResize(&_land_info_desc);
 	}
 };