Changeset - r26575:d5725bf82346
src/ai/ai_gui.cpp
Show inline comments
 
@@ -125,7 +125,7 @@ struct AIListWindow : public Window {
 
		switch (widget) {
 
			case WID_AIL_LIST: {
 
				/* Draw a list of all available AIs. */
 
				Rect tr = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.matrix);
 
				/* First AI in the list is hardcoded to random */
 
				if (this->vscroll->IsVisible(0)) {
 
					DrawString(tr, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE);
 
@@ -150,17 +150,17 @@ struct AIListWindow : public Window {
 
				}
 
				/* Some info about the currently selected AI. */
 
				if (selected_info != nullptr) {
 
					Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
					Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
					SetDParamStr(0, selected_info->GetAuthor());
 
					DrawString(tr, STR_AI_LIST_AUTHOR);
 
					tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
					SetDParam(0, selected_info->GetVersion());
 
					DrawString(tr, STR_AI_LIST_VERSION);
 
					tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
					if (selected_info->GetURL() != nullptr) {
 
						SetDParamStr(0, selected_info->GetURL());
 
						DrawString(tr, STR_AI_LIST_URL);
 
						tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
						tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
					}
 
					SetDParamStr(0, selected_info->GetDescription());
 
					DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_WHITE);
 
@@ -253,7 +253,7 @@ static const NWidgetPart _nested_ai_list
 
		NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIL_LIST), SetMinimalSize(188, 112), SetFill(1, 1), SetResize(1, 1), SetMatrixDataTip(1, 0, STR_AI_LIST_TOOLTIP), SetScrollbar(WID_AIL_SCROLLBAR),
 
		NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_AIL_SCROLLBAR),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE, WID_AIL_INFO_BG), SetMinimalTextLines(8, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE, WID_AIL_INFO_BG), SetMinimalTextLines(8, WidgetDimensions::unscaled.framerect.Vertical() + WidgetDimensions::unscaled.vsep_normal * 3), SetResize(1, 0),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
@@ -359,10 +359,10 @@ struct AISettingsWindow : public Window 
 
		int i = 0;
 
		for (; !this->vscroll->IsVisible(i); i++) it++;
 

	
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		bool rtl = _current_text_dir == TD_RTL;
 
		Rect br = ir.WithWidth(SETTING_BUTTON_WIDTH, rtl);
 
		Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
 
		Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide, rtl);
 

	
 
		int y = r.top;
 
		int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
@@ -426,7 +426,7 @@ struct AISettingsWindow : public Window 
 
	{
 
		switch (widget) {
 
			case WID_AIS_BACKGROUND: {
 
				Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WD_MATRIX_LEFT, 0, WD_MATRIX_RIGHT, 0);
 
				Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.matrix, RectPadding::zero);
 
				int num = (pt.y - r.top) / this->line_height + this->vscroll->GetPosition();
 
				if (num >= (int)this->visible_settings.size()) break;
 

	
 
@@ -791,7 +791,7 @@ struct AIConfigWindow : public Window {
 
	{
 
		switch (widget) {
 
			case WID_AIC_LIST: {
 
				Rect tr = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.matrix);
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) {
 
					StringID text;
 

	
 
@@ -1042,8 +1042,8 @@ struct AIDebugWindow : public Window {
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		if (widget == WID_AID_LOG_PANEL) {
 
			resize->height = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			size->height = 14 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
			resize->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
			size->height = 14 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
 
		}
 
	}
 

	
 
@@ -1157,8 +1157,8 @@ struct AIDebugWindow : public Window {
 
				ScriptLog::LogData *log = this->GetLogPointer();
 
				if (log == nullptr) return;
 

	
 
				Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < log->used; i++) {
 
					int pos = (i + log->pos + 1 - log->used + log->count) % log->count;
 
					if (log->lines[pos] == nullptr) break;
 
@@ -1352,7 +1352,7 @@ struct AIDebugWindow : public Window {
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_AID_LOG_PANEL);
 
		this->vscroll->SetCapacityFromWidget(this, WID_AID_LOG_PANEL, WidgetDimensions::scaled.framerect.Vertical());
 
	}
 

	
 
	static HotkeyList hotkeys;
src/aircraft_gui.cpp
Show inline comments
 
@@ -46,7 +46,7 @@ void DrawAircraftDetails(const Aircraft 
 
			SetDParam(3, u->Next()->cargo_cap);
 
			SetDParam(4, GetCargoSubtypeText(u));
 
			DrawString(r.left, r.right, y, (u->Next()->cargo_cap != 0) ? STR_VEHICLE_INFO_CAPACITY_CAPACITY : STR_VEHICLE_INFO_CAPACITY);
 
			y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
		}
 

	
 
		if (u->cargo_cap != 0) {
 
@@ -64,7 +64,7 @@ void DrawAircraftDetails(const Aircraft 
 
		}
 
	}
 

	
 
	y += WD_PAR_VSEP_NORMAL;
 
	y += WidgetDimensions::scaled.vsep_normal;
 
	SetDParam(0, feeder_share);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
}
src/airport_gui.cpp
Show inline comments
 
@@ -340,7 +340,7 @@ public:
 
					const AirportSpec *as = AirportSpec::Get(i);
 
					if (!as->enabled) continue;
 

	
 
					size->width = std::max(size->width, GetStringBoundingBox(as->name).width);
 
					size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width);
 
				}
 

	
 
				this->line_height = FONT_HEIGHT_NORMAL + padding.height;
 
@@ -356,8 +356,8 @@ public:
 
						SpriteID sprite = GetCustomAirportSprite(as, layout);
 
						if (sprite != 0) {
 
							Dimension d = GetSpriteSize(sprite);
 
							d.width += padding.width;
 
							d.height += padding.height;
 
							d.width += WidgetDimensions::scaled.framerect.Horizontal();
 
							d.height += WidgetDimensions::scaled.framerect.Vertical();
 
							*size = maxdim(d, *size);
 
						}
 
					}
 
@@ -375,8 +375,6 @@ public:
 
						/* STR_BLACK_STRING is used to start the string with {BLACK} */
 
						SetDParam(0, string);
 
						Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size);
 
						d.width += padding.width;
 
						d.height += padding.height;
 
						*size = maxdim(d, *size);
 
					}
 
				}
 
@@ -390,8 +388,8 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_AP_AIRPORT_LIST: {
 
				Rect row = r.WithHeight(this->line_height).Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				Rect text = r.WithHeight(this->line_height).Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
 
				Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
 
				AirportClass *apclass = AirportClass::Get(_selected_airport_class);
 
				for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
 
					const AirportSpec *as = apclass->GetSpec(i);
 
@@ -430,7 +428,7 @@ public:
 
		this->DrawWidgets();
 

	
 
		Rect r = this->GetWidget<NWidgetBase>(WID_AP_ACCEPTANCE)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		int top = r.top + WidgetDimensions::scaled.vsep_normal;
 

	
 
		if (_selected_airport_index != -1) {
 
			const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
 
@@ -441,19 +439,19 @@ public:
 
				/* show the noise of the selected airport */
 
				SetDParam(0, as->noise_level);
 
				DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE);
 
				top += FONT_HEIGHT_NORMAL + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
				top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
			}
 

	
 
			if (_settings_game.economy.infrastructure_maintenance) {
 
				Money monthly = _price[PR_INFRASTRUCTURE_AIRPORT] * as->maintenance_cost >> 3;
 
				SetDParam(0, monthly * 12);
 
				DrawString(r.left, r.right, top, STR_STATION_BUILD_INFRASTRUCTURE_COST);
 
				top += FONT_HEIGHT_NORMAL + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
				top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
			}
 

	
 
			/* strings such as 'Size' and 'Coverage Area' */
 
			top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
			top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
			top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
 
			top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + WidgetDimensions::scaled.vsep_normal;
 
		}
 

	
 
		/* Resize background if the window is too small.
 
@@ -607,7 +605,7 @@ static const NWidgetPart _nested_build_a
 
	EndContainer(),
 
	/* Bottom panel. */
 
	NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetPadding(WidgetDimensions::unscaled.framerect), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
@@ -618,7 +616,7 @@ static const NWidgetPart _nested_build_a
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), SetFill(1, 0),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1), SetFill(1, 0),
 
	EndContainer(),
 
};
 

	
src/autoreplace_gui.cpp
Show inline comments
 
@@ -422,7 +422,7 @@ public:
 
					str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
 
				}
 

	
 
				DrawString(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM), str, TC_BLACK, SA_HOR_CENTER);
 
				DrawString(r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect), str, TC_BLACK, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
@@ -485,7 +485,7 @@ public:
 
					ted.capacity = e->GetDisplayDefaultCapacity(&ted.mail_capacity);
 

	
 
					const Rect r = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect()
 
							.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
							.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
					int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine[side], ted);
 
					needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL);
 
				}
src/bootstrap_gui.cpp
Show inline comments
 
@@ -101,14 +101,14 @@ public:
 
	{
 
		if (widget == WID_BEM_MESSAGE) {
 
			*size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR);
 
			size->height = GetStringHeight(STR_MISSING_GRAPHICS_ERROR, size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT) + WD_FRAMETEXT_BOTTOM + WD_FRAMETEXT_TOP;
 
			size->height = GetStringHeight(STR_MISSING_GRAPHICS_ERROR, size->width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical();
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget == WID_BEM_MESSAGE) {
 
			DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
@@ -124,7 +124,7 @@ public:
 
static const NWidgetPart _nested_bootstrap_download_status_window_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_NCDS_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(3, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 30),
 
		NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(3, WidgetDimensions::unscaled.framerect.Vertical() + 30),
 
	EndContainer(),
 
};
 

	
 
@@ -214,15 +214,15 @@ public:
 
		/* We cache the button size. This is safe as no reinit can happen here. */
 
		if (this->button_size.width == 0) {
 
			this->button_size = maxdim(GetStringBoundingBox(STR_MISSING_GRAPHICS_YES_DOWNLOAD), GetStringBoundingBox(STR_MISSING_GRAPHICS_NO_QUIT));
 
			this->button_size.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
			this->button_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
			this->button_size.width += WidgetDimensions::scaled.frametext.Horizontal();
 
			this->button_size.height += WidgetDimensions::scaled.frametext.Vertical();
 
		}
 

	
 
		switch (widget) {
 
			case WID_BAFD_QUESTION:
 
				/* The question is twice as wide as the buttons, and determine the height based on the width. */
 
				size->width = this->button_size.width * 2;
 
				size->height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT) + WD_FRAMETEXT_BOTTOM + WD_FRAMETEXT_TOP;
 
				size->height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size->width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical();
 
				break;
 

	
 
			case WID_BAFD_YES:
 
@@ -236,7 +236,7 @@ public:
 
	{
 
		if (widget != 0) return;
 

	
 
		DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER);
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
src/bridge_gui.cpp
Show inline comments
 
@@ -194,10 +194,10 @@ public:
 
				}
 
				sprite_dim.height++; // Sprite is rendered one pixel down in the matrix field.
 
				text_dim.height++; // Allowing the bottom row pixels to be rendered on the edge of the matrix field.
 
				resize->height = std::max(sprite_dim.height, text_dim.height) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; // Max of both sizes + account for matrix edges.
 
				resize->height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges.
 

	
 
				this->bridgetext_offset = sprite_dim.width + 1; // Left edge of text, 1 pixel distance from the sprite.
 
				size->width = WD_MATRIX_LEFT + this->bridgetext_offset + text_dim.width + WD_MATRIX_RIGHT;
 
				this->bridgetext_offset = sprite_dim.width + WidgetDimensions::scaled.hsep_normal; // Left edge of text, 1 pixel distance from the sprite.
 
				size->width = this->bridgetext_offset + text_dim.width + padding.width;
 
				size->height = 4 * resize->height; // Smallest bridge gui is 4 entries high in the matrix.
 
				break;
 
			}
 
@@ -222,7 +222,7 @@ public:
 
				break;
 

	
 
			case WID_BBS_BRIDGE_LIST: {
 
				Rect tr = r.WithHeight(this->resize.step_height).Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect tr = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
 
					const BridgeSpec *b = this->bridges->at(i).spec;
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -48,7 +48,7 @@
 
 */
 
uint GetEngineListHeight(VehicleType type)
 
{
 
	return std::max<uint>(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM, GetVehicleImageCellSize(type, EIT_PURCHASE).height);
 
	return std::max<uint>(FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical(), GetVehicleImageCellSize(type, EIT_PURCHASE).height);
 
}
 

	
 
static const NWidgetPart _nested_build_vehicle_widgets[] = {
 
@@ -975,7 +975,7 @@ void DrawEngineList(VehicleType type, co
 
	int sprite_right = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_right;
 
	int sprite_width = sprite_left + sprite_right;
 

	
 
	Rect ir      = r.WithHeight(step_size).Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
	Rect ir      = r.WithHeight(step_size).Shrink(WidgetDimensions::scaled.matrix);
 
	int sprite_x = ir.WithWidth(sprite_width, rtl).left + sprite_left;
 
	int sprite_y_offset = ScaleGUITrad(sprite_y_offsets[type]) + ir.Height() / 2;
 

	
 
@@ -987,10 +987,10 @@ void DrawEngineList(VehicleType type, co
 
		count_width = GetStringBoundingBox(STR_TINY_BLACK_COMA).width;
 
	}
 

	
 
	Rect tr = ir.Indent(sprite_width + 6, rtl);                                     // Name position
 
	Rect cr = tr.Indent(replace_icon.width + 6, !rtl).WithWidth(count_width, !rtl);  // Count position
 
	Rect rr = tr.WithWidth(replace_icon.width, !rtl);                                // Replace icon position
 
	if (show_count) tr = tr.Indent(count_width + 2 + replace_icon.width + 6, !rtl);
 
	Rect tr = ir.Indent(sprite_width + WidgetDimensions::scaled.hsep_wide, rtl);                                      // Name position
 
	Rect cr = tr.Indent(replace_icon.width + WidgetDimensions::scaled.hsep_wide, !rtl).WithWidth(count_width, !rtl);  // Count position
 
	Rect rr = tr.WithWidth(replace_icon.width, !rtl);                                                                 // Replace icon position
 
	if (show_count) tr = tr.Indent(count_width + WidgetDimensions::scaled.hsep_normal + replace_icon.width + WidgetDimensions::scaled.hsep_wide, !rtl);
 

	
 
	int normal_text_y_offset = (ir.Height() - FONT_HEIGHT_NORMAL) / 2;
 
	int small_text_y_offset  = ir.Height() - FONT_HEIGHT_SMALL;
 
@@ -1551,7 +1551,7 @@ struct BuildVehicleWindow : Window {
 
			case WID_BV_LIST:
 
				resize->height = GetEngineListHeight(this->vehicle_type);
 
				size->height = 3 * resize->height;
 
				size->width = std::max(size->width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165);
 
				size->width = std::max(size->width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width;
 
				break;
 

	
 
			case WID_BV_PANEL:
 
@@ -1620,7 +1620,7 @@ struct BuildVehicleWindow : Window {
 
			int needed_height = this->details_height;
 
			/* Draw details panels. */
 
			if (this->sel_engine != INVALID_ENGINE) {
 
				const Rect r = this->GetWidget<NWidgetBase>(WID_BV_PANEL)->GetCurrentRect().Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				const Rect r = this->GetWidget<NWidgetBase>(WID_BV_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
				int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine, this->te);
 
				needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL);
 
			}
src/cheat_gui.cpp
Show inline comments
 
@@ -208,7 +208,7 @@ static const NWidgetPart _nested_cheat_w
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), SetDataTip(0x0, STR_CHEATS_TOOLTIP), EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(WWT_LABEL, COLOUR_GREY, WID_C_NOTE), SetFill(1, 1), SetDataTip(STR_CHEATS_NOTE, STR_NULL), SetPadding(WD_PAR_VSEP_NORMAL, 4, WD_PAR_VSEP_NORMAL, 4),
 
		NWidget(WWT_LABEL, COLOUR_GREY, WID_C_NOTE), SetFill(1, 1), SetDataTip(STR_CHEATS_NOTE, STR_NULL), SetPadding(WidgetDimensions::unscaled.frametext),
 
	EndContainer(),
 
};
 

	
 
@@ -235,14 +235,14 @@ struct CheatWindow : Window {
 
	{
 
		if (widget != WID_C_PANEL) return;
 

	
 
		const Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		const Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		int y = ir.top;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint box_left    = rtl ? ir.right - this->box.width - 5 : ir.left + 5;
 
		uint button_left = rtl ? ir.right - this->box.width - 10 - SETTING_BUTTON_WIDTH : ir.left + this->box.width + 10;
 
		uint text_left   = ir.left + (rtl ? 0 : 20 + this->box.width + SETTING_BUTTON_WIDTH);
 
		uint text_right  = ir.right - (rtl ? 20 + this->box.width + SETTING_BUTTON_WIDTH : 0);
 
		uint box_left    = rtl ? ir.right - this->box.width - WidgetDimensions::scaled.hsep_wide : ir.left + WidgetDimensions::scaled.hsep_wide;
 
		uint button_left = rtl ? ir.right - this->box.width - WidgetDimensions::scaled.hsep_wide * 2 - SETTING_BUTTON_WIDTH : ir.left + this->box.width + WidgetDimensions::scaled.hsep_wide * 2;
 
		uint text_left   = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH);
 
		uint text_right  = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH : 0);
 

	
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 
		int box_y_offset = (this->line_height - this->box.height) / 2;
 
@@ -258,7 +258,7 @@ struct CheatWindow : Window {
 
				case SLE_BOOL: {
 
					bool on = (*(bool*)ce->variable);
 

	
 
					DrawBoolButton(button_left, y + icon_y_offset, on, true);
 
					DrawBoolButton(button_left, y + button_y_offset, on, true);
 
					SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
 
					break;
 
				}
 
@@ -278,8 +278,8 @@ struct CheatWindow : Window {
 
						case STR_CHEAT_CHANGE_COMPANY: {
 
							SetDParam(0, val + 1);
 
							GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf));
 
							uint offset = 10 + GetStringBoundingBox(buf).width;
 
							DrawCompanyIcon(_local_company, rtl ? text_right - offset - 10 : text_left + offset, y + icon_y_offset);
 
							uint offset = WidgetDimensions::scaled.hsep_indent + GetStringBoundingBox(buf).width;
 
							DrawCompanyIcon(_local_company, rtl ? text_right - offset - WidgetDimensions::scaled.hsep_indent : text_left + offset, y + icon_y_offset);
 
							break;
 
						}
 

	
 
@@ -321,7 +321,7 @@ struct CheatWindow : Window {
 
						/* Draw coloured flag for change company cheat */
 
						case STR_CHEAT_CHANGE_COMPANY:
 
							SetDParamMaxValue(0, MAX_COMPANIES);
 
							width = std::max(width, GetStringBoundingBox(ce->str).width + 10 + 10);
 
							width = std::max(width, GetStringBoundingBox(ce->str).width + WidgetDimensions::scaled.hsep_wide * 4);
 
							break;
 

	
 
						default:
 
@@ -333,21 +333,21 @@ struct CheatWindow : Window {
 
			}
 
		}
 

	
 
		this->line_height = std::max(GetSpriteSize(SPR_BOX_CHECKED).height, GetSpriteSize(SPR_BOX_EMPTY).height);
 
		this->line_height = std::max(this->box.height, this->icon.height);
 
		this->line_height = std::max<uint>(this->line_height, SETTING_BUTTON_HEIGHT);
 
		this->line_height = std::max<uint>(this->line_height, FONT_HEIGHT_NORMAL) + WD_PAR_VSEP_NORMAL;
 
		this->line_height = std::max<uint>(this->line_height, FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
 

	
 
		size->width = width + 20 + this->box.width + SETTING_BUTTON_WIDTH /* stuff on the left */ + 10 /* extra spacing on right */;
 
		size->height = WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + this->line_height * lengthof(_cheats_ui);
 
		size->width = width + WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH /* stuff on the left */ + WidgetDimensions::scaled.hsep_wide * 2 /* extra spacing on right */;
 
		size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_C_PANEL);
 
		uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP) / this->line_height;
 
		uint x = pt.x - wid->pos_x;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_C_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
		uint btn = (pt.y - r.top) / this->line_height;
 
		uint x = pt.x - r.left;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		if (rtl) x = wid->current_x - x;
 
		if (rtl) x = r.Width() - 1 - x;
 

	
 
		if (btn >= lengthof(_cheats_ui)) return;
 

	
 
@@ -355,13 +355,13 @@ struct CheatWindow : Window {
 
		int value = (int32)ReadValue(ce->variable, ce->type);
 
		int oldvalue = value;
 

	
 
		if (btn == CHT_CHANGE_DATE && x >= 20 + this->box.width + SETTING_BUTTON_WIDTH) {
 
		if (btn == CHT_CHANGE_DATE && x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH) {
 
			/* Click at the date text directly. */
 
			clicked_widget = CHT_CHANGE_DATE;
 
			SetDParam(0, value);
 
			ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
 
			return;
 
		} else if (btn == CHT_EDIT_MAX_HL && x >= 20 + this->box.width + SETTING_BUTTON_WIDTH) {
 
		} else if (btn == CHT_EDIT_MAX_HL && x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH) {
 
			clicked_widget = CHT_EDIT_MAX_HL;
 
			SetDParam(0, value);
 
			ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
 
@@ -369,7 +369,7 @@ struct CheatWindow : Window {
 
		}
 

	
 
		/* Not clicking a button? */
 
		if (!IsInsideMM(x, 10 + this->box.width, 10 + this->box.width + SETTING_BUTTON_WIDTH)) return;
 
		if (!IsInsideMM(x, WidgetDimensions::scaled.hsep_wide * 2 + this->box.width, WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH)) return;
 

	
 
		*ce->been_used = true;
 

	
 
@@ -381,10 +381,10 @@ struct CheatWindow : Window {
 

	
 
			default:
 
				/* Take whatever the function returns */
 
				value = ce->proc(value + ((x >= 10 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 10 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
 
				value = ce->proc(value + ((x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
 

	
 
				/* The first cheat (money), doesn't return a different value. */
 
				if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 10 + this->box.width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
 
				if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
 
				break;
 
		}
 

	
src/company_gui.cpp
Show inline comments
 
@@ -148,7 +148,7 @@ static uint GetMaxCategoriesWidth()
 
		/* Title of category */
 
		max_width = std::max(max_width, GetStringBoundingBox(STR_FINANCES_REVENUE_TITLE + i).width);
 
		/* Entries in category */
 
		max_width = std::max(max_width, _expenses_list_types[i].GetListWidth());
 
		max_width = std::max(max_width, _expenses_list_types[i].GetListWidth() + WidgetDimensions::scaled.hsep_indent);
 
	}
 

	
 
	return max_width;
 
@@ -292,7 +292,7 @@ static const NWidgetPart _nested_company
 
	EndContainer(),
 
	NWidget(NWID_SELECTION, INVALID_COLOUR, WID_CF_SEL_PANEL),
 
		NWidget(WWT_PANEL, COLOUR_GREY),
 
			NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetPIP(0, 9, 0),
 
			NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CF_EXPS_CATEGORY), SetMinimalSize(120, 0), SetFill(0, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CF_EXPS_PRICE1), SetMinimalSize(86, 0), SetFill(0, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CF_EXPS_PRICE2), SetMinimalSize(86, 0), SetFill(0, 0),
 
@@ -301,7 +301,7 @@ static const NWidgetPart _nested_company
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT),
 
		NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect),
 
			NWidget(NWID_VERTICAL), // Vertical column with 'bank balance', 'loan'
 
				NWidget(WWT_TEXT, COLOUR_GREY), SetDataTip(STR_FINANCES_OWN_FUNDS_TITLE, STR_NULL), SetFill(1, 0),
 
				NWidget(WWT_TEXT, COLOUR_GREY), SetDataTip(STR_FINANCES_LOAN_TITLE, STR_NULL), SetFill(1, 0),
 
@@ -607,18 +607,15 @@ public:
 
		bool rtl = _current_text_dir == TD_RTL;
 
		int icon_y = CenterBounds(r.top, r.bottom, 0);
 
		int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
 
		Rect tr = r.Shrink(WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_BOTTOM);
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext);
 
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + (this->result % COLOUR_END),
 
				   rtl ? tr.right - ScaleGUITrad(14) : tr.left + ScaleGUITrad(14),
 
				   icon_y);
 
		DrawString(rtl ? tr.left : tr.left + ScaleGUITrad(28) + 2,
 
				rtl ? tr.right - ScaleGUITrad(28) - 2 : tr.right,
 
				text_y, this->String(), sel ? TC_WHITE : TC_BLACK);
 
		tr = tr.Indent(ScaleGUITrad(28) + WidgetDimensions::scaled.hsep_normal, rtl);
 
		DrawString(tr.left, tr.right, text_y, this->String(), sel ? TC_WHITE : TC_BLACK);
 
	}
 
};
 

	
 
static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels
 

	
 
typedef GUIList<const Group*> GUIGroupList;
 

	
 
/** Company livery colour scheme window. */
 
@@ -823,14 +820,14 @@ public:
 
					}
 
				}
 

	
 
				size->width = std::max(size->width, 5 + d.width + WD_FRAMERECT_RIGHT);
 
				size->width = std::max(size->width, 5 + d.width + padding.width);
 
				break;
 
			}
 

	
 
			case WID_SCL_MATRIX: {
 
				/* 11 items in the default rail class */
 
				this->square = GetSpriteSize(SPR_SQUARE);
 
				this->line_height = std::max(this->square.height, (uint)FONT_HEIGHT_NORMAL) + 4;
 
				this->line_height = std::max(this->square.height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
 

	
 
				size->height = 11 * this->line_height;
 
				resize->width = 1;
 
@@ -847,7 +844,7 @@ public:
 

	
 
			case WID_SCL_PRI_COL_DROPDOWN: {
 
				this->square = GetSpriteSize(SPR_SQUARE);
 
				int string_padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
 
				int string_padding = this->square.width + WidgetDimensions::scaled.hsep_normal + padding.width;
 
				for (const StringID *id = _colour_dropdown; id != endof(_colour_dropdown); id++) {
 
					size->width = std::max(size->width, GetStringBoundingBox(*id).width + string_padding);
 
				}
 
@@ -919,21 +916,21 @@ public:
 

	
 
		/* Coordinates of scheme name column. */
 
		const NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_SCL_SPACER_DROPDOWN);
 
		Rect sch = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect sch = nwi->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
		/* Coordinates of first dropdown. */
 
		nwi = this->GetWidget<NWidgetBase>(WID_SCL_PRI_COL_DROPDOWN);
 
		Rect pri = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect pri = nwi->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
		/* Coordinates of second dropdown. */
 
		nwi = this->GetWidget<NWidgetBase>(WID_SCL_SEC_COL_DROPDOWN);
 
		Rect sec = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect sec = nwi->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 

	
 
		Rect pri_squ = pri.WithWidth(this->square.width, rtl);
 
		Rect sec_squ = sec.WithWidth(this->square.width, rtl);
 

	
 
		pri = pri.Indent(this->square.width + ScaleGUITrad(2), rtl);
 
		sec = sec.Indent(this->square.width + ScaleGUITrad(2), rtl);
 

	
 
		Rect ir = r.WithHeight(this->resize.step_height).Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
		pri = pri.Indent(this->square.width + WidgetDimensions::scaled.hsep_normal, rtl);
 
		sec = sec.Indent(this->square.width + WidgetDimensions::scaled.hsep_normal, rtl);
 

	
 
		Rect ir = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
 
		int square_offs = (ir.Height() - this->square.height) / 2;
 
		int text_offs   = (ir.Height() - FONT_HEIGHT_NORMAL) / 2;
 

	
 
@@ -971,7 +968,7 @@ public:
 
			for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
				const Group *g = this->groups[i];
 
				SetDParam(0, g->index);
 
				draw_livery(STR_GROUP_NAME, g->livery, this->sel == g->index, false, this->indents[i] * LEVEL_WIDTH);
 
				draw_livery(STR_GROUP_NAME, g->livery, this->sel == g->index, false, this->indents[i] * WidgetDimensions::scaled.hsep_indent);
 
			}
 
		}
 
	}
 
@@ -1269,81 +1266,81 @@ static const NWidgetPart _nested_select_
 
						EndContainer(),
 
						NWidget(NWID_SPACER), SetMinimalSize(0, 4),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_EYECOLOUR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_HAS_MOUSTACHE_EARRING), SetDataTip(STR_WHITE_STRING, STR_FACE_MOUSTACHE_EARRING_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAS_GLASSES_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAS_GLASSES_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_GLASSES, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_HAS_GLASSES), SetDataTip(STR_WHITE_STRING, STR_FACE_GLASSES_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetFill(1, 0),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAIR_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAIR_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_HAIR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_HAIR_L), SetDataTip(AWV_DECREASE, STR_FACE_HAIR_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_HAIR), SetDataTip(STR_WHITE_STRING, STR_FACE_HAIR_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_HAIR_R), SetDataTip(AWV_INCREASE, STR_FACE_HAIR_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_EYEBROWS_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_EYEBROWS_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_EYEBROWS, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYEBROWS_L), SetDataTip(AWV_DECREASE, STR_FACE_EYEBROWS_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_EYEBROWS), SetDataTip(STR_WHITE_STRING, STR_FACE_EYEBROWS_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYEBROWS_R), SetDataTip(AWV_INCREASE, STR_FACE_EYEBROWS_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_EYECOLOUR_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_EYECOLOUR_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_EYECOLOUR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYECOLOUR_L), SetDataTip(AWV_DECREASE, STR_FACE_EYECOLOUR_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_EYECOLOUR), SetDataTip(STR_WHITE_STRING, STR_FACE_EYECOLOUR_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYECOLOUR_R), SetDataTip(AWV_INCREASE, STR_FACE_EYECOLOUR_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_GLASSES_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_GLASSES_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_GLASSES, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_GLASSES_L), SetDataTip(AWV_DECREASE, STR_FACE_GLASSES_TOOLTIP_2),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_GLASSES), SetDataTip(STR_WHITE_STRING, STR_FACE_GLASSES_TOOLTIP_2),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_GLASSES_R), SetDataTip(AWV_INCREASE, STR_FACE_GLASSES_TOOLTIP_2),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_NOSE_TEXT), SetFill(1, 0),  SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_NOSE_TEXT), SetFill(1, 0),  SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_NOSE, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_NOSE_L), SetDataTip(AWV_DECREASE, STR_FACE_NOSE_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_NOSE), SetDataTip(STR_WHITE_STRING, STR_FACE_NOSE_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_NOSE_R), SetDataTip(AWV_INCREASE, STR_FACE_NOSE_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_LIPS_MOUSTACHE_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_LIPS_MOUSTACHE_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_MOUSTACHE, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_LIPS_MOUSTACHE_L), SetDataTip(AWV_DECREASE, STR_FACE_LIPS_MOUSTACHE_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_LIPS_MOUSTACHE), SetDataTip(STR_WHITE_STRING, STR_FACE_LIPS_MOUSTACHE_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_LIPS_MOUSTACHE_R), SetDataTip(AWV_INCREASE, STR_FACE_LIPS_MOUSTACHE_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_CHIN_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_CHIN_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_CHIN, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_CHIN_L), SetDataTip(AWV_DECREASE, STR_FACE_CHIN_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_CHIN), SetDataTip(STR_WHITE_STRING, STR_FACE_CHIN_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_CHIN_R), SetDataTip(AWV_INCREASE, STR_FACE_CHIN_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_JACKET_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_JACKET_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_JACKET, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_JACKET_L), SetDataTip(AWV_DECREASE, STR_FACE_JACKET_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_JACKET), SetDataTip(STR_WHITE_STRING, STR_FACE_JACKET_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_JACKET_R), SetDataTip(AWV_INCREASE, STR_FACE_JACKET_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_COLLAR_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_COLLAR_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_COLLAR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_COLLAR_L), SetDataTip(AWV_DECREASE, STR_FACE_COLLAR_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_COLLAR), SetDataTip(STR_WHITE_STRING, STR_FACE_COLLAR_TOOLTIP),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_COLLAR_R), SetDataTip(AWV_INCREASE, STR_FACE_COLLAR_TOOLTIP),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_TIE_EARRING_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
 
							NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_TIE_EARRING_TEXT), SetFill(1, 0), SetPadding(WidgetDimensions::unscaled.framerect),
 
								SetDataTip(STR_FACE_EARRING, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
							NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_TIE_EARRING_L), SetDataTip(AWV_DECREASE, STR_FACE_TIE_EARRING_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_TIE_EARRING), SetDataTip(STR_WHITE_STRING, STR_FACE_TIE_EARRING_TOOLTIP),
 
@@ -1447,17 +1444,17 @@ public:
 
	{
 
		/* Size of the boolean yes/no button. */
 
		Dimension yesno_dim = maxdim(GetStringBoundingBox(STR_FACE_YES), GetStringBoundingBox(STR_FACE_NO));
 
		yesno_dim.width  += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
		yesno_dim.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		yesno_dim.width  += WidgetDimensions::scaled.framerect.Horizontal();
 
		yesno_dim.height += WidgetDimensions::scaled.framerect.Vertical();
 
		/* Size of the number button + arrows. */
 
		Dimension number_dim = {0, 0};
 
		for (int val = 1; val <= 12; val++) {
 
			SetDParam(0, val);
 
			number_dim = maxdim(number_dim, GetStringBoundingBox(STR_JUST_INT));
 
		}
 
		uint arrows_width = GetSpriteSize(SPR_ARROW_LEFT).width + GetSpriteSize(SPR_ARROW_RIGHT).width + 2 * (WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT);
 
		number_dim.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + arrows_width;
 
		number_dim.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		uint arrows_width = GetSpriteSize(SPR_ARROW_LEFT).width + GetSpriteSize(SPR_ARROW_RIGHT).width + 2 * (WidgetDimensions::scaled.imgbtn.Horizontal());
 
		number_dim.width += WidgetDimensions::scaled.framerect.Horizontal() + arrows_width;
 
		number_dim.height += WidgetDimensions::scaled.framerect.Vertical();
 
		/* Compute width of both buttons. */
 
		yesno_dim.width = std::max(yesno_dim.width, number_dim.width);
 
		number_dim.width = yesno_dim.width - arrows_width;
 
@@ -1796,28 +1793,28 @@ static const NWidgetPart _nested_company
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_VERTICAL), SetPIP(WD_FRAMERECT_TOP, WD_PAR_VSEP_NORMAL * 2, WD_FRAMERECT_BOTTOM),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
		NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.framerect), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_RAIL_DESC), SetMinimalTextLines(2, 0), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_RAIL_COUNT), SetMinimalTextLines(2, 0), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_ROAD_DESC), SetMinimalTextLines(2, 0), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_ROAD_COUNT), SetMinimalTextLines(2, 0), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TRAM_DESC), SetMinimalTextLines(2, 0), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TRAM_COUNT), SetMinimalTextLines(2, 0), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_WATER_DESC), SetMinimalTextLines(2, 0), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_WATER_COUNT), SetMinimalTextLines(2, 0), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_STATION_DESC), SetMinimalTextLines(3, 0), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_STATION_COUNT), SetMinimalTextLines(3, 0), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TOTAL_DESC), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TOTAL), SetFill(0, 1),
 
			EndContainer(),
 
@@ -1918,12 +1915,12 @@ struct CompanyInfrastructureWindow : Win
 
					if (HasBit(this->railtypes, rt)) {
 
						lines++;
 
						SetDParam(0, GetRailTypeInfo(rt)->strings.name);
 
						size->width = std::max(size->width, GetStringBoundingBox(STR_WHITE_STRING).width + WD_FRAMERECT_LEFT);
 
						size->width = std::max(size->width, GetStringBoundingBox(STR_WHITE_STRING).width + WidgetDimensions::scaled.hsep_indent);
 
					}
 
				}
 
				if (this->railtypes != RAILTYPES_NONE) {
 
					lines++;
 
					size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + WD_FRAMERECT_LEFT);
 
					size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + WidgetDimensions::scaled.hsep_indent);
 
				}
 

	
 
				size->height = std::max(size->height, lines * FONT_HEIGHT_NORMAL);
 
@@ -1940,7 +1937,7 @@ struct CompanyInfrastructureWindow : Win
 
					if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) {
 
						lines++;
 
						SetDParam(0, GetRoadTypeInfo(rt)->strings.name);
 
						size->width = std::max(size->width, GetStringBoundingBox(STR_WHITE_STRING).width + WD_FRAMERECT_LEFT);
 
						size->width = std::max(size->width, GetStringBoundingBox(STR_WHITE_STRING).width + WidgetDimensions::scaled.hsep_indent);
 
					}
 
				}
 

	
 
@@ -1950,13 +1947,13 @@ struct CompanyInfrastructureWindow : Win
 

	
 
			case WID_CI_WATER_DESC:
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT).width);
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS).width + WD_FRAMERECT_LEFT);
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS).width + WidgetDimensions::scaled.hsep_indent);
 
				break;
 

	
 
			case WID_CI_STATION_DESC:
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT).width);
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS).width + WD_FRAMERECT_LEFT);
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS).width + WD_FRAMERECT_LEFT);
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS).width + WidgetDimensions::scaled.hsep_indent);
 
				size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS).width + WidgetDimensions::scaled.hsep_indent);
 
				break;
 

	
 
			case WID_CI_RAIL_COUNT:
 
@@ -1990,11 +1987,11 @@ struct CompanyInfrastructureWindow : Win
 
				max_cost = std::max(max_cost, AirportMaintenanceCost(c->index));
 

	
 
				SetDParamMaxValue(0, max_val);
 
				uint count_width = GetStringBoundingBox(STR_WHITE_COMMA).width + 20; // Reserve some wiggle room
 
				uint count_width = GetStringBoundingBox(STR_WHITE_COMMA).width + WidgetDimensions::scaled.hsep_indent; // Reserve some wiggle room
 

	
 
				if (_settings_game.economy.infrastructure_maintenance) {
 
					SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
 
					this->total_width = GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width + 20;
 
					this->total_width = GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width + WidgetDimensions::scaled.hsep_indent * 2;
 
					size->width = std::max(size->width, this->total_width);
 

	
 
					SetDParamMaxValue(0, max_cost * 12); // Convert to per year
 
@@ -2034,9 +2031,10 @@ struct CompanyInfrastructureWindow : Win
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 

	
 
		int y = r.top;
 

	
 
		Rect ir = r.Indent(LEVEL_WIDTH, _current_text_dir == TD_RTL);
 
		Rect ir = r.Indent(WidgetDimensions::scaled.hsep_indent, _current_text_dir == TD_RTL);
 
		switch (widget) {
 
			case WID_CI_RAIL_DESC:
 
				DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT);
src/console_gui.cpp
Show inline comments
 
@@ -31,7 +31,6 @@
 
#include "safeguards.h"
 

	
 
static const uint ICON_HISTORY_SIZE       = 20;
 
static const uint ICON_LINE_SPACING       =  2;
 
static const uint ICON_RIGHT_BORDERWIDTH  = 10;
 
static const uint ICON_BOTTOM_BORDERWIDTH = 12;
 

	
 
@@ -121,14 +120,18 @@ struct IConsoleWindow : Window
 
	IConsoleWindow() : Window(&_console_window_desc)
 
	{
 
		_iconsole_mode = ICONSOLE_OPENED;
 
		this->line_height = FONT_HEIGHT_NORMAL + ICON_LINE_SPACING;
 
		this->line_offset = GetStringBoundingBox("] ").width + 5;
 

	
 
		this->InitNested(0);
 
		this->truncate_timer.SetInterval(3000);
 
		ResizeWindow(this, _screen.width, _screen.height / 3);
 
	}
 

	
 
	void OnInit() override
 
	{
 
		this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.hsep_normal;
 
		this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left;
 
	}
 

	
 
	void Close() override
 
	{
 
		_iconsole_mode = ICONSOLE_CLOSED;
 
@@ -156,20 +159,20 @@ struct IConsoleWindow : Window
 

	
 
	void OnPaint() override
 
	{
 
		const int right = this->width - 5;
 
		const int right = this->width - WidgetDimensions::scaled.frametext.right;
 

	
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, PC_BLACK);
 
		int ypos = this->height - this->line_height;
 
		for (size_t line_index = IConsoleWindow::scroll; line_index < _iconsole_buffer.size(); line_index++) {
 
			const IConsoleLine &print = _iconsole_buffer[line_index];
 
			SetDParamStr(0, print.buffer);
 
			ypos = DrawStringMultiLine(5, right, -this->line_height, ypos, STR_JUST_RAW_STRING, print.colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - ICON_LINE_SPACING;
 
			ypos = DrawStringMultiLine(WidgetDimensions::scaled.frametext.left, right, -this->line_height, ypos, STR_JUST_RAW_STRING, print.colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - WidgetDimensions::scaled.hsep_normal;
 
			if (ypos < 0) break;
 
		}
 
		/* If the text is longer than the window, don't show the starting ']' */
 
		int delta = this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH;
 
		if (delta > 0) {
 
			DrawString(5, right, this->height - this->line_height, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE);
 
			DrawString(WidgetDimensions::scaled.frametext.left, right, this->height - this->line_height, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE);
 
			delta = 0;
 
		}
 

	
src/depot_gui.cpp
Show inline comments
 
@@ -325,13 +325,13 @@ struct DepotWindow : Window {
 
						ScaleGUITrad(_consistent_train_width != 0 ? _consistent_train_width : TRAININFO_DEFAULT_VEHICLE_WIDTH) :
 
						0;
 

	
 
				DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
 
				DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y,
 
						this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
 

	
 
				/* Length of consist in tiles with 1 fractional digit (rounded up) */
 
				SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE));
 
				SetDParam(1, 1);
 
				DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter
 
				DrawString(rtl ? left : right - this->count_width, rtl ? left + this->count_width : right, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter
 
				break;
 
			}
 

	
 
@@ -344,23 +344,23 @@ struct DepotWindow : Window {
 
		uint diff_x, diff_y;
 
		if (v->IsGroundVehicle()) {
 
			/* Arrange unitnumber and flag horizontally */
 
			diff_x = this->flag_width + WD_FRAMERECT_LEFT;
 
			diff_y = (this->resize.step_height - this->flag_height) / 2 - 2;
 
			diff_x = this->flag_width;
 
			diff_y = (this->resize.step_height - this->flag_height) / 2;
 
		} else {
 
			/* Arrange unitnumber and flag vertically */
 
			diff_x = WD_FRAMERECT_LEFT;
 
			diff_y = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			diff_x = 0;
 
			diff_y = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
		}
 
		int text_left  = rtl ? right - this->header_width - 1 : left + diff_x;
 
		int text_right = rtl ? right - diff_x : left + this->header_width - 1;
 

	
 
		if (free_wagon) {
 
			DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
 
			DrawString(text_left, text_right, y + WidgetDimensions::scaled.framerect.top, STR_DEPOT_NO_ENGINE);
 
		} else {
 
			DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, rtl ? right - this->flag_width : left + WD_FRAMERECT_LEFT, y + diff_y);
 
			DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, rtl ? right - this->flag_width : left + WidgetDimensions::scaled.framerect.left, y + diff_y);
 

	
 
			SetDParam(0, v->unitnumber);
 
			DrawString(text_left, text_right, y + 2, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_BLACK_COMMA : STR_RED_COMMA);
 
			DrawString(text_left, text_right, y + WidgetDimensions::scaled.framerect.top, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_BLACK_COMMA : STR_RED_COMMA);
 
		}
 
	}
 

	
 
@@ -373,6 +373,8 @@ struct DepotWindow : Window {
 
		/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
 
		const NWidgetCore *wid = this->GetWidget<NWidgetCore>(WID_D_MATRIX);
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 

	
 
		/* Draw vertical separators at whole tiles.
 
		 * This only works in two cases:
 
		 *  - All vehicles use VEHICLEINFO_FULL_VEHICLE_WIDTH as reference width.
 
@@ -381,16 +383,16 @@ struct DepotWindow : Window {
 
		if (this->type == VEH_TRAIN && _consistent_train_width != 0) {
 
			int w = ScaleGUITrad(2 * _consistent_train_width);
 
			int col = _colour_gradient[wid->colour][4];
 
			int image_left  = rtl ? r.left  + this->count_width  : r.left  + this->header_width;
 
			int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
 
			int image_left  = rtl ? ir.left  + this->count_width  : ir.left  + this->header_width;
 
			int image_right = rtl ? ir.right - this->header_width : ir.right - this->count_width;
 
			int first_line = w + (-this->hscroll->GetPosition()) % w;
 
			if (rtl) {
 
				for (int x = image_right - first_line; x >= image_left; x -= w) {
 
					GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
 
					GfxDrawLine(x, r.top, x, r.bottom, col, ScaleGUITrad(1), ScaleGUITrad(3));
 
				}
 
			} else {
 
				for (int x = image_left + first_line; x <= image_right; x += w) {
 
					GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
 
					GfxDrawLine(x, r.top, x, r.bottom, col, ScaleGUITrad(1), ScaleGUITrad(3));
 
				}
 
			}
 
		}
 
@@ -400,15 +402,15 @@ struct DepotWindow : Window {
 
		uint num = this->vscroll->GetPosition() * this->num_columns;
 
		uint maxval = static_cast<uint>(std::min<size_t>(this->vehicle_list.size(), num + (rows_in_display * this->num_columns)));
 
		int y;
 
		for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
 
		for (y = r.top; num < maxval; y += this->resize.step_height) { // Draw the rows
 
			for (uint i = 0; i < this->num_columns && num < maxval; i++, num++) {
 
				/* Draw all vehicles in the current row */
 
				const Vehicle *v = this->vehicle_list[num];
 
				if (this->num_columns == 1) {
 
					this->DrawVehicleInDepot(v, r.left, r.right, y);
 
					this->DrawVehicleInDepot(v, ir.left, ir.right, y);
 
				} else {
 
					int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->resize.step_width;
 
					this->DrawVehicleInDepot(v, x, x + this->resize.step_width - 1, y);
 
					int x = ir.left + (rtl ? (this->num_columns - i - 1) : i) * this->resize.step_width;
 
					this->DrawVehicleInDepot(v, x, x + this->resize.step_width - 1 - WidgetDimensions::scaled.framerect.Horizontal(), y);
 
				}
 
			}
 
		}
 
@@ -418,7 +420,7 @@ struct DepotWindow : Window {
 
		/* Draw the train wagons without an engine in front. */
 
		for (; num < maxval; num++, y += this->resize.step_height) {
 
			const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
 
			this->DrawVehicleInDepot(v, r.left, r.right, y);
 
			this->DrawVehicleInDepot(v, ir.left, ir.right, y);
 
		}
 
	}
 

	
 
@@ -506,7 +508,7 @@ struct DepotWindow : Window {
 

	
 
				case VEH_SHIP:
 
				case VEH_AIRCRAFT:
 
					if (xm <= this->flag_width && ym >= (uint)(FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL)) return MODE_START_STOP;
 
					if (xm <= this->flag_width && ym >= (uint)(FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP;
 
					break;
 

	
 
				default: NOT_REACHED();
 
@@ -657,7 +659,7 @@ struct DepotWindow : Window {
 
				if (this->type == VEH_TRAIN) {
 
					SetDParamMaxValue(0, 1000, 0, FS_SMALL);
 
					SetDParam(1, 1);
 
					this->count_width = GetStringBoundingBox(STR_TINY_BLACK_DECIMAL).width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
					this->count_width = GetStringBoundingBox(STR_TINY_BLACK_DECIMAL).width + WidgetDimensions::scaled.framerect.Horizontal();
 
				} else {
 
					this->count_width = 0;
 
				}
 
@@ -665,15 +667,15 @@ struct DepotWindow : Window {
 
				SetDParamMaxDigits(0, this->unitnumber_digits);
 
				Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
 
				const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
 
				this->flag_width  = UnScaleGUI(spr->width) + WD_FRAMERECT_RIGHT;
 
				this->flag_width  = UnScaleGUI(spr->width) + WidgetDimensions::scaled.framerect.right;
 
				this->flag_height = UnScaleGUI(spr->height);
 

	
 
				if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
 
					min_height = std::max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleGUI(spr->height));
 
					this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
 
					min_height = std::max<uint>(unumber.height + WidgetDimensions::scaled.matrix.top, UnScaleGUI(spr->height));
 
					this->header_width = unumber.width + this->flag_width + WidgetDimensions::scaled.framerect.left;
 
				} else {
 
					min_height = unumber.height + UnScaleGUI(spr->height) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
 
					this->header_width = std::max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
 
					min_height = unumber.height + UnScaleGUI(spr->height) + padding.height + WidgetDimensions::scaled.vsep_normal;
 
					this->header_width = std::max<uint>(unumber.width, this->flag_width) + WidgetDimensions::scaled.framerect.right;
 
				}
 
				int base_width = this->count_width + this->header_width;
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -447,9 +447,9 @@ public:
 

	
 
		/* strings such as 'Size' and 'Coverage Area' */
 
		Rect r = this->GetWidget<NWidgetBase>(BDSW_ACCEPTANCE)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		int top = r.top + WidgetDimensions::scaled.vsep_normal;
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + WidgetDimensions::scaled.vsep_normal;
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
@@ -486,12 +486,12 @@ static const NWidgetPart _nested_build_d
 
		NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDSW_BACKGROUND),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(14, 0, 14),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
		EndContainer(),
 
		NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1),
 
		NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1),
 
	EndContainer(),
 
};
 

	
 
@@ -531,8 +531,8 @@ public:
 
		switch (widget) {
 
			case WID_BDD_X:
 
			case WID_BDD_Y:
 
				size->width  = ScaleGUITrad(96) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
				size->height = ScaleGUITrad(64) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
				size->width  = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				break;
 
		}
 
	}
src/engine_gui.cpp
Show inline comments
 
@@ -98,7 +98,7 @@ struct EnginePreviewWindow : Window {
 

	
 
		size->width = std::max(size->width, x - x_offs);
 
		SetDParam(0, GetEngineCategoryName(engine));
 
		size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WD_PAR_VSEP_WIDE + FONT_HEIGHT_NORMAL + this->vehicle_space;
 
		size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + FONT_HEIGHT_NORMAL + this->vehicle_space;
 
		SetDParam(0, engine);
 
		size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
 
	}
 
@@ -109,7 +109,7 @@ struct EnginePreviewWindow : Window {
 

	
 
		EngineID engine = this->window_number;
 
		SetDParam(0, GetEngineCategoryName(engine));
 
		int y = DrawStringMultiLine(r, STR_ENGINE_PREVIEW_MESSAGE, TC_FROMSTRING, SA_HOR_CENTER | SA_TOP) + WD_PAR_VSEP_WIDE;
 
		int y = DrawStringMultiLine(r, STR_ENGINE_PREVIEW_MESSAGE, TC_FROMSTRING, SA_HOR_CENTER | SA_TOP) + WidgetDimensions::scaled.vsep_wide;
 

	
 
		SetDParam(0, engine);
 
		DrawString(r.left, r.right, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER);
src/error_gui.cpp
Show inline comments
 
@@ -35,7 +35,7 @@ static const NWidgetPart _nested_errmsg_
 
		NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_RED),
 
		NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT), SetFill(1, 0), SetMinimalSize(236, 0),
 
		NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(WidgetDimensions::unscaled.frametext), SetFill(1, 0), SetMinimalSize(236, 0),
 
	EndContainer(),
 
};
 

	
 
@@ -54,7 +54,7 @@ static const NWidgetPart _nested_errmsg_
 
	NWidget(WWT_PANEL, COLOUR_RED),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_FACE), SetPadding(2, 0, 2, 2), SetFill(0, 1), SetMinimalSize(92, 119),
 
			NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT), SetFill(1, 1), SetMinimalSize(236, 0),
 
			NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(WidgetDimensions::unscaled.frametext), SetFill(1, 1), SetMinimalSize(236, 0),
 
		EndContainer(),
 
	EndContainer(),
 
};
 
@@ -206,7 +206,7 @@ public:
 
				if (this->textref_stack_size > 0) StopTextRefStackUsage();
 

	
 
				uint panel_height = this->height_summary;
 
				if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE;
 
				if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide;
 

	
 
				size->height = std::max(size->height, panel_height);
 
				break;
 
@@ -284,7 +284,7 @@ public:
 
					DrawStringMultiLine(r, this->summary_msg, TC_FROMSTRING, SA_CENTER);
 
				} else {
 
					/* Extra space when message is shorter than company face window */
 
					int extra = (r.Height() - this->height_summary - this->height_detailed - WD_PAR_VSEP_WIDE) / 2;
 
					int extra = (r.Height() - this->height_summary - this->height_detailed - WidgetDimensions::scaled.vsep_wide) / 2;
 

	
 
					/* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
 
					DrawStringMultiLine(r.WithHeight(this->height_summary + extra, false), this->summary_msg, TC_WHITE, SA_CENTER);
src/fios_gui.cpp
Show inline comments
 
@@ -83,8 +83,8 @@ static const NWidgetPart _nested_load_di
 
		NWidget(NWID_VERTICAL),
 
			/* Filter box with label */
 
			NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
 
				NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0),
 
					SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0),
 
				NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0),
 
					SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
 
						NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
 
						NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
 
							SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
@@ -141,8 +141,8 @@ static const NWidgetPart _nested_load_he
 

	
 
	/* Filter box with label */
 
	NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
 
		NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0),
 
			SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0),
 
		NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0),
 
			SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
 
				NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
 
					SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
@@ -188,8 +188,8 @@ static const NWidgetPart _nested_save_di
 
		NWidget(NWID_VERTICAL),
 
			/* Filter box with label */
 
			NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
 
				NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0),
 
					SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0),
 
				NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0),
 
					SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
 
					NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
 
					NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
 
						SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
@@ -223,10 +223,10 @@ static const NWidgetPart _nested_save_di
 
		EndContainer(),
 

	
 
		/* Right side : game details */
 
		NWidget(WWT_PANEL, COLOUR_GREY),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1), EndContainer(),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(NWID_SPACER), SetResize(1, 0), SetFill(1, 1),
 
				NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY),
 
			EndContainer(),
 
		EndContainer(),
 
@@ -437,7 +437,7 @@ public:
 
					_fios_path_changed = false;
 
				}
 

	
 
				Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 

	
 
				if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
 
				DrawString(ir.left, ir.right, ir.top + FONT_HEIGHT_NORMAL, str);
 
@@ -446,10 +446,10 @@ public:
 
			}
 

	
 
			case WID_SL_DRIVES_DIRECTORIES_LIST: {
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WD_INSET_LEFT, WD_INSET_TOP, WD_INSET_RIGHT, 0).WithHeight(this->resize.step_height);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.inset).WithHeight(this->resize.step_height);
 
				uint scroll_pos = this->vscroll->GetPosition();
 
				for (uint row = 0; row < this->fios_items.size() && tr.top < br.bottom; row++) {
 
					if (!this->fios_items_shown[row]) {
 
@@ -480,14 +480,14 @@ public:
 
	void DrawDetails(const Rect &r) const
 
	{
 
		/* Header panel */
 
		int HEADER_HEIGHT = FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
		int HEADER_HEIGHT = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical();
 

	
 
		Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
 
		tr.top += HEADER_HEIGHT;
 

	
 
		/* Create the nice grayish rectangle at the details top */
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, 0), PC_GREY);
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, WidgetDimensions::scaled.bevel.right, 0), PC_GREY);
 
		DrawString(hr.left, hr.right, hr.top, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
		if (this->selected == nullptr) return;
 
@@ -520,7 +520,7 @@ public:
 
				tr.top += FONT_HEIGHT_NORMAL;
 
			}
 

	
 
			tr.top += WD_PAR_VSEP_WIDE;
 
			tr.top += WidgetDimensions::scaled.vsep_normal;
 
			if (tr.top > tr.bottom) return;
 

	
 
			/* Start date (if available) */
 
@@ -541,7 +541,7 @@ public:
 

	
 
			/* Hide the NewGRF stuff when saving. We also hide the button. */
 
			if (this->fop == SLO_LOAD && (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO)) {
 
				tr.top += WD_PAR_VSEP_NORMAL;
 
				tr.top += WidgetDimensions::scaled.vsep_normal;
 
				if (tr.top > tr.bottom) return;
 

	
 
				/* NewGrf compatibility */
 
@@ -554,7 +554,7 @@ public:
 

	
 
			/* Hide the company stuff for scenarios */
 
			if (this->abstract_filetype != FT_SCENARIO) {
 
				tr.top += WD_PAR_VSEP_WIDE;
 
				tr.top += WidgetDimensions::scaled.vsep_wide;
 
				if (tr.top > tr.bottom) return;
 

	
 
				/* Companies / AIs */
 
@@ -580,12 +580,12 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_SL_BACKGROUND:
 
				size->height = 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				size->height = 2 * FONT_HEIGHT_NORMAL + padding.height;
 
				break;
 

	
 
			case WID_SL_DRIVES_DIRECTORIES_LIST:
 
				resize->height = FONT_HEIGHT_NORMAL;
 
				size->height = resize->height * 10 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				size->height = resize->height * 10 + padding.height;
 
				break;
 
			case WID_SL_SORT_BYNAME:
 
			case WID_SL_SORT_BYDATE: {
 
@@ -665,7 +665,7 @@ public:
 
				break;
 

	
 
			case WID_SL_DRIVES_DIRECTORIES_LIST: { // Click the listbox
 
				int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
 
				int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top);
 
				if (y == INT_MAX) return;
 

	
 
				/* Get the corresponding non-filtered out item from the list */
 
@@ -745,7 +745,7 @@ public:
 
	void OnMouseOver(Point pt, int widget) override
 
	{
 
		if (widget == WID_SL_DRIVES_DIRECTORIES_LIST) {
 
			int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
 
			int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top);
 
			if (y == INT_MAX) return;
 

	
 
			/* Get the corresponding non-filtered out item from the list */
src/framerate_gui.cpp
Show inline comments
 
@@ -380,7 +380,7 @@ static const NWidgetPart _framerate_wind
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_VERTICAL), SetPadding(6), SetPIP(0, 3, 0),
 
		NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.frametext), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
 
			NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_RATE_GAMELOOP), SetDataTip(STR_FRAMERATE_RATE_GAMELOOP, STR_FRAMERATE_RATE_GAMELOOP_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_RATE_DRAWING),  SetDataTip(STR_FRAMERATE_RATE_BLITTER,  STR_FRAMERATE_RATE_BLITTER_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_RATE_FACTOR),   SetDataTip(STR_FRAMERATE_SPEED_FACTOR,  STR_FRAMERATE_SPEED_FACTOR_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
@@ -388,8 +388,8 @@ static const NWidgetPart _framerate_wind
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PANEL, COLOUR_GREY),
 
			NWidget(NWID_VERTICAL), SetPadding(6), SetPIP(0, 3, 0),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, 8, 0),
 
			NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.frametext), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_NAMES), SetScrollbar(WID_FRW_SCROLLBAR),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_CURRENT), SetScrollbar(WID_FRW_SCROLLBAR),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_AVERAGE), SetScrollbar(WID_FRW_SCROLLBAR),
 
@@ -447,7 +447,6 @@ struct FramerateWindow : Window {
 
	CachedDecimal times_shortterm[PFE_MAX]; ///< cached short term average times
 
	CachedDecimal times_longterm[PFE_MAX];  ///< cached long term average times
 

	
 
	static constexpr int VSPACING = 3;          ///< space between column heading and values
 
	static constexpr int MIN_ELEMENTS = 5;      ///< smallest number of elements to display
 

	
 
	FramerateWindow(WindowDesc *desc, WindowNumber number) : Window(desc)
 
@@ -567,7 +566,7 @@ struct FramerateWindow : Window {
 

	
 
			case WID_FRW_TIMES_NAMES: {
 
				size->width = 0;
 
				size->height = FONT_HEIGHT_NORMAL + VSPACING + MIN_ELEMENTS * FONT_HEIGHT_NORMAL;
 
				size->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * FONT_HEIGHT_NORMAL;
 
				resize->width = 0;
 
				resize->height = FONT_HEIGHT_NORMAL;
 
				for (PerformanceElement e : DISPLAY_ORDER_PFE) {
 
@@ -593,7 +592,7 @@ struct FramerateWindow : Window {
 
				SetDParam(1, 2);
 
				Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD);
 
				size->width = std::max(size->width, item_size.width);
 
				size->height += FONT_HEIGHT_NORMAL * MIN_ELEMENTS + VSPACING;
 
				size->height += FONT_HEIGHT_NORMAL * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal;
 
				resize->width = 0;
 
				resize->height = FONT_HEIGHT_NORMAL;
 
				break;
 
@@ -609,7 +608,7 @@ struct FramerateWindow : Window {
 
		int drawable = this->num_displayed;
 
		int y = r.top;
 
		DrawString(r.left, r.right, y, heading_str, TC_FROMSTRING, SA_CENTER, true);
 
		y += FONT_HEIGHT_NORMAL + VSPACING;
 
		y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
		for (PerformanceElement e : DISPLAY_ORDER_PFE) {
 
			if (_pf_data[e].num_valid == 0) continue;
 
			if (skip > 0) {
 
@@ -631,7 +630,7 @@ struct FramerateWindow : Window {
 
		int drawable = this->num_displayed;
 
		int y = r.top;
 
		DrawString(r.left, r.right, y, STR_FRAMERATE_MEMORYUSE, TC_FROMSTRING, SA_CENTER, true);
 
		y += FONT_HEIGHT_NORMAL + VSPACING;
 
		y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
		for (PerformanceElement e : DISPLAY_ORDER_PFE) {
 
			if (_pf_data[e].num_valid == 0) continue;
 
			if (skip > 0) {
 
@@ -663,7 +662,7 @@ struct FramerateWindow : Window {
 
				const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
 
				uint16 skip = sb->GetPosition();
 
				int drawable = this->num_displayed;
 
				int y = r.top + FONT_HEIGHT_NORMAL + VSPACING; // first line contains headings in the value columns
 
				int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns
 
				for (PerformanceElement e : DISPLAY_ORDER_PFE) {
 
					if (_pf_data[e].num_valid == 0) continue;
 
					if (skip > 0) {
 
@@ -705,7 +704,7 @@ struct FramerateWindow : Window {
 
			case WID_FRW_TIMES_AVERAGE: {
 
				/* Open time graph windows when clicking detail measurement lines */
 
				const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
 
				int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, VSPACING + FONT_HEIGHT_NORMAL);
 
				int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL);
 
				if (line != INT_MAX) {
 
					line++;
 
					/* Find the visible line that was clicked */
 
@@ -725,7 +724,7 @@ struct FramerateWindow : Window {
 
	void OnResize() override
 
	{
 
		auto *wid = this->GetWidget<NWidgetResizeBase>(WID_FRW_TIMES_NAMES);
 
		this->num_displayed = (wid->current_y - wid->min_y - VSPACING) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings
 
		this->num_displayed = (wid->current_y - wid->min_y - WidgetDimensions::scaled.vsep_normal) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings
 
		this->GetScrollbar(WID_FRW_SCROLLBAR)->SetCapacity(this->num_displayed);
 
	}
 
};
src/game/game_gui.cpp
Show inline comments
 
@@ -186,7 +186,7 @@ struct GSConfigWindow : public Window {
 
				}
 

	
 
				/* There is only one slot, unlike with the GS GUI, so it should never be white */
 
				DrawString(r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM), text, (IsEditable() ? TC_ORANGE : TC_SILVER));
 
				DrawString(r.Shrink(WidgetDimensions::scaled.matrix), text, (IsEditable() ? TC_ORANGE : TC_SILVER));
 
				break;
 
			}
 
			case WID_GSC_SETTINGS: {
 
@@ -195,10 +195,10 @@ struct GSConfigWindow : public Window {
 
				int i = 0;
 
				for (; !this->vscroll->IsVisible(i); i++) it++;
 

	
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
				bool rtl = _current_text_dir == TD_RTL;
 
				Rect br = ir.WithWidth(SETTING_BUTTON_WIDTH, rtl);
 
				Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
 
				Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide, rtl);
 

	
 
				int y = r.top;
 
				int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
@@ -290,7 +290,7 @@ struct GSConfigWindow : public Window {
 
				break;
 

	
 
			case WID_GSC_SETTINGS: {
 
				Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WD_MATRIX_LEFT, 0, WD_MATRIX_RIGHT, 0);
 
				Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.matrix, RectPadding::zero);
 
				int num = (pt.y - r.top) / this->line_height + this->vscroll->GetPosition();
 
				if (num >= (int)this->visible_settings.size()) break;
 

	
src/genworld_gui.cpp
Show inline comments
 
@@ -1405,8 +1405,8 @@ struct GenerateProgressWindow : public W
 
				SetDParamMaxValue(0, 100);
 
				*size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
 
				/* We need some spacing for the 'border' */
 
				size->height += 8;
 
				size->width += 8;
 
				size->height += WidgetDimensions::scaled.frametext.Horizontal();
 
				size->width  += WidgetDimensions::scaled.frametext.Vertical();
 
				break;
 
			}
 

	
 
@@ -1414,7 +1414,7 @@ struct GenerateProgressWindow : public W
 
				for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
 
					size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width);
 
				}
 
				size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
 
				size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal;
 
				break;
 
		}
 
	}
 
@@ -1425,7 +1425,7 @@ struct GenerateProgressWindow : public W
 
			case WID_GP_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY);
 
				Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE);
 
				SetDParam(0, _gws.percent);
 
				DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
 
@@ -1439,7 +1439,7 @@ struct GenerateProgressWindow : public W
 
				/* And say where we are in that class */
 
				SetDParam(0, _gws.current);
 
				SetDParam(1, _gws.total);
 
				DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
 
		}
 
	}
 
};
src/goal_gui.cpp
Show inline comments
 
@@ -76,7 +76,7 @@ struct GoalListWindow : public Window {
 
				break;
 

	
 
			case WID_GOAL_LIST: {
 
				int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
 
				int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WidgetDimensions::scaled.framerect.top);
 
				for (const Goal *s : Goal::Iterate()) {
 
					if (s->company == this->window_number) {
 
						if (y == 0) {
 
@@ -174,11 +174,12 @@ struct GoalListWindow : public Window {
 
		if (widget != WID_GOAL_LIST) return;
 
		Dimension d = GetStringBoundingBox(STR_GOALS_NONE);
 

	
 
		resize->width = 1;
 
		resize->height = d.height;
 

	
 
		d.height *= 5;
 
		d.width += padding.width + WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT;
 
		d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		d.width += WidgetDimensions::scaled.framerect.Horizontal();
 
		d.height += WidgetDimensions::scaled.framerect.Vertical();
 
		*size = maxdim(*size, d);
 
	}
 

	
 
@@ -192,7 +193,7 @@ struct GoalListWindow : public Window {
 
	void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
 
	{
 
		/* Get column draw area. */
 
		Rect r = wid->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect r = wid->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		int pos = -this->vscroll->GetPosition();
 
@@ -206,7 +207,7 @@ struct GoalListWindow : public Window {
 
						case GC_GOAL: {
 
							/* Display the goal. */
 
							SetDParamStr(0, s->text);
 
							uint width_reduction = progress_col_width > 0 ? progress_col_width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT : 0;
 
							uint width_reduction = progress_col_width > 0 ? progress_col_width + WidgetDimensions::scaled.framerect.Horizontal() : 0;
 
							DrawString(r.Indent(width_reduction, !rtl), STR_GOALS_TEXT);
 
							break;
 
						}
 
@@ -261,7 +262,7 @@ struct GoalListWindow : public Window {
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST);
 
		this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST, WidgetDimensions::scaled.framerect.Vertical());
 
	}
 

	
 
	/**
 
@@ -285,8 +286,8 @@ static const NWidgetPart _nested_goals_l
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN, WID_GOAL_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GOAL_SELECT_BUTTONS),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_GLOBAL_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GOALS_GLOBAL_BUTTON, STR_GOALS_GLOBAL_BUTTON_HELPTEXT),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_COMPANY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GOALS_COMPANY_BUTTON, STR_GOALS_COMPANY_BUTTON_HELPTEXT),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_GLOBAL_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical()), SetDataTip(STR_GOALS_GLOBAL_BUTTON, STR_GOALS_GLOBAL_BUTTON_HELPTEXT),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_COMPANY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical()), SetDataTip(STR_GOALS_COMPANY_BUTTON, STR_GOALS_COMPANY_BUTTON_HELPTEXT),
 
		EndContainer(),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
@@ -399,7 +400,7 @@ struct GoalQuestionWindow : public Windo
 
		if (widget != WID_GQ_QUESTION) return;
 

	
 
		SetDParamStr(0, this->question);
 
		size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WD_PAR_VSEP_WIDE;
 
		size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WidgetDimensions::scaled.vsep_wide;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
src/graph_gui.cpp
Show inline comments
 
@@ -65,11 +65,11 @@ struct GraphLegendWindow : Window {
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		const Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		const Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
 
		DrawCompanyIcon(cid, rtl ? ir.right - d.width : ir.left, CenterBounds(ir.top, ir.bottom, d.height));
 

	
 
		const Rect tr = ir.Indent(d.width + ScaleGUITrad(2), rtl);
 
		const Rect tr = ir.Indent(d.width + WidgetDimensions::scaled.hsep_normal, rtl);
 
		SetDParam(0, cid);
 
		SetDParam(1, cid);
 
		DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
 
@@ -118,8 +118,8 @@ static NWidgetBase *MakeNWidgetCompanyLi
 

	
 
	for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum);
 
		panel->SetMinimalSize(246, sprite_height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
		panel->SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, FS_NORMAL);
 
		panel->SetMinimalSize(246, sprite_height + WidgetDimensions::unscaled.framerect.Vertical());
 
		panel->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL);
 
		panel->SetFill(1, 1);
 
		panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
 
		vert->Add(panel);
 
@@ -299,15 +299,15 @@ protected:
 

	
 
		/* Rect r will be adjusted to contain just the graph, with labels being
 
		 * placed outside the area. */
 
		r.top    += 5 + GetCharacterHeight(FS_SMALL) / 2;
 
		r.bottom -= (this->month == 0xFF ? 1 : 2) * GetCharacterHeight(FS_SMALL) + 4;
 
		r.left   += 9;
 
		r.right  -= 5;
 
		r.top    += ScaleGUITrad(5) + GetCharacterHeight(FS_SMALL) / 2;
 
		r.bottom -= (this->month == 0xFF ? 1 : 2) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4);
 
		r.left   += ScaleGUITrad(9);
 
		r.right  -= ScaleGUITrad(5);
 

	
 
		/* Initial number of horizontal lines. */
 
		int num_hori_lines = 160 / MIN_GRID_PIXEL_SIZE;
 
		int num_hori_lines = 160 / ScaleGUITrad(MIN_GRID_PIXEL_SIZE);
 
		/* For the rest of the height, the number of horizontal lines will increase more slowly. */
 
		int resize = (r.bottom - r.top - 160) / (2 * MIN_GRID_PIXEL_SIZE);
 
		int resize = (r.bottom - r.top - 160) / (2 * ScaleGUITrad(MIN_GRID_PIXEL_SIZE));
 
		if (resize > 0) num_hori_lines += resize;
 

	
 
		interval = GetValuesInterval(num_hori_lines);
 
@@ -345,7 +345,7 @@ protected:
 
		y = r.bottom;
 

	
 
		for (int i = 0; i < (num_hori_lines + 1); i++) {
 
			GfxFillRect(r.left - 3, y, r.left - 1, y, GRAPH_AXIS_LINE_COLOUR);
 
			GfxFillRect(r.left - ScaleGUITrad(3), y, r.left - 1, y, GRAPH_AXIS_LINE_COLOUR);
 
			GfxFillRect(r.left, y, r.right, y, GRAPH_GRID_COLOUR);
 
			y -= y_sep;
 
		}
 
@@ -372,7 +372,7 @@ protected:
 
		for (int i = 0; i < (num_hori_lines + 1); i++) {
 
			SetDParam(0, this->format_str_y_axis);
 
			SetDParam(1, y_label);
 
			DrawString(r.left - label_width - 4, r.left - 4, y, STR_GRAPH_Y_LABEL, GRAPH_AXIS_LABEL_COLOUR, SA_RIGHT);
 
			DrawString(r.left - label_width - ScaleGUITrad(4), r.left - ScaleGUITrad(4), y, STR_GRAPH_Y_LABEL, GRAPH_AXIS_LABEL_COLOUR, SA_RIGHT);
 

	
 
			y_label -= y_label_separation;
 
			y += y_sep;
 
@@ -381,7 +381,7 @@ protected:
 
		/* Draw x-axis labels and markings for graphs based on financial quarters and years.  */
 
		if (this->month != 0xFF) {
 
			x = r.left;
 
			y = r.bottom + 2;
 
			y = r.bottom + ScaleGUITrad(2);
 
			byte month = this->month;
 
			Year year  = this->year;
 
			for (int i = 0; i < this->num_on_x_axis; i++) {
 
@@ -402,7 +402,7 @@ protected:
 
		} else {
 
			/* Draw x-axis labels for graphs not based on quarterly performance (cargo payment rates). */
 
			x = r.left;
 
			y = r.bottom + 2;
 
			y = r.bottom + ScaleGUITrad(2);
 
			uint16 label = this->x_values_start;
 

	
 
			for (int i = 0; i < this->num_on_x_axis; i++) {
 
@@ -522,8 +522,8 @@ public:
 
		SetDParam(1, INT64_MAX);
 
		uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width;
 

	
 
		size->width  = std::max<uint>(size->width,  5 + y_label_width + this->num_on_x_axis * (x_label_width + 5) + 9);
 
		size->height = std::max<uint>(size->height, 5 + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + 4);
 
		size->width  = std::max<uint>(size->width,  ScaleGUITrad(5) + y_label_width + this->num_on_x_axis * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9));
 
		size->height = std::max<uint>(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + ScaleGUITrad(4));
 
		size->height = std::max<uint>(size->height, size->width / 3);
 
	}
 

	
 
@@ -636,7 +636,7 @@ static const NWidgetPart _nested_operati
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
@@ -687,7 +687,7 @@ static const NWidgetPart _nested_income_
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
@@ -736,7 +736,7 @@ static const NWidgetPart _nested_deliver
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
@@ -791,8 +791,8 @@ static const NWidgetPart _nested_perform
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_PHG_DETAILED_PERFORMANCE), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_PHG_KEY), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_PHG_DETAILED_PERFORMANCE), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_PHG_KEY), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
@@ -841,7 +841,7 @@ static const NWidgetPart _nested_company
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
@@ -924,9 +924,9 @@ struct PaymentRatesGraphWindow : BaseGra
 
		for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
 
			SetDParam(0, cs->name);
 
			Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO);
 
			d.width += this->legend_width + 4; // colour field
 
			d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
			d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
			d.width += this->legend_width + WidgetDimensions::scaled.hsep_normal; // colour field
 
			d.width += WidgetDimensions::scaled.framerect.Horizontal();
 
			d.height += WidgetDimensions::scaled.framerect.Vertical();
 
			*size = maxdim(d, *size);
 
		}
 

	
 
@@ -958,16 +958,16 @@ struct PaymentRatesGraphWindow : BaseGra
 
			/* Redraw frame if lowered */
 
			if (lowered) DrawFrameRect(line, COLOUR_BROWN, FR_LOWERED);
 

	
 
			const Rect text = line.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM).Translate(lowered ? 1 : 0, lowered ? 1 : 0);
 
			const Rect text = line.Shrink(WidgetDimensions::scaled.framerect).Translate(lowered ? WidgetDimensions::scaled.pressed : 0, lowered ? WidgetDimensions::scaled.pressed : 0);
 

	
 
			/* Cargo-colour box with outline */
 
			const Rect cargo = text.WithWidth(this->legend_width, rtl);
 
			GfxFillRect(cargo, PC_BLACK);
 
			GfxFillRect(cargo.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), cs->legend_colour);
 
			GfxFillRect(cargo.Shrink(WidgetDimensions::scaled.bevel), cs->legend_colour);
 

	
 
			/* Cargo name */
 
			SetDParam(0, cs->name);
 
			DrawString(text.Indent(this->legend_width + 4, rtl), STR_GRAPH_CARGO_PAYMENT_CARGO);
 
			DrawString(text.Indent(this->legend_width + WidgetDimensions::scaled.hsep_normal, rtl), STR_GRAPH_CARGO_PAYMENT_CARGO);
 

	
 
			line = line.Translate(0, this->line_height);
 
		}
 
@@ -1079,7 +1079,7 @@ static const NWidgetPart _nested_cargo_p
 
			NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_TEXT, COLOUR_BROWN, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
 
			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CPR_RESIZE),
 
@@ -1179,7 +1179,7 @@ public:
 
	{
 
		if (widget != WID_CL_BACKGROUND) return;
 

	
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		int icon_y_offset = (this->line_height - this->icon.height) / 2;
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 

	
 
@@ -1210,7 +1210,7 @@ public:
 
		for (uint i = 0; i < MAX_COMPANIES; i++) {
 
			this->ordinal_width = std::max(this->ordinal_width, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i).width);
 
		}
 
		this->ordinal_width += 5; // Keep some extra spacing
 
		this->ordinal_width += WidgetDimensions::scaled.hsep_wide; // Keep some extra spacing
 

	
 
		uint widest_width = 0;
 
		uint widest_title = 0;
 
@@ -1223,7 +1223,7 @@ public:
 
		}
 

	
 
		this->icon = GetSpriteSize(SPR_COMPANY_ICON);
 
		this->line_height = std::max<int>(this->icon.height + 2, FONT_HEIGHT_NORMAL);
 
		this->line_height = std::max<int>(this->icon.height + WidgetDimensions::scaled.vsep_normal, FONT_HEIGHT_NORMAL);
 

	
 
		for (const Company *c : Company::Iterate()) {
 
			SetDParam(0, c->index);
 
@@ -1232,10 +1232,10 @@ public:
 
			widest_width = std::max(widest_width, GetStringBoundingBox(STR_COMPANY_LEAGUE_COMPANY_NAME).width);
 
		}
 

	
 
		this->text_width = widest_width + 30; // Keep some extra spacing
 
		this->text_width = widest_width + WidgetDimensions::scaled.hsep_indent * 3; // Keep some extra spacing
 

	
 
		size->width = WD_FRAMERECT_LEFT + this->ordinal_width + WD_FRAMERECT_RIGHT + this->icon.width + WD_FRAMERECT_LEFT + this->text_width + WD_FRAMERECT_RIGHT;
 
		size->height = WD_FRAMERECT_TOP + this->line_height * MAX_COMPANIES + WD_FRAMERECT_BOTTOM;
 
		size->width = WidgetDimensions::scaled.framerect.Horizontal() + this->ordinal_width + this->icon.width + this->text_width + WidgetDimensions::scaled.framerect.Horizontal();
 
		size->height = this->line_height * MAX_COMPANIES + WidgetDimensions::scaled.framerect.Vertical();
 
	}
 

	
 

	
 
@@ -1269,7 +1269,7 @@ static const NWidgetPart _nested_company
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CL_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CL_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WidgetDimensions::unscaled.framerect.Vertical()),
 
};
 

	
 
static WindowDesc _company_league_desc(
 
@@ -1324,18 +1324,18 @@ struct PerformanceRatingDetailWindow : W
 
	{
 
		switch (widget) {
 
			case WID_PRD_SCORE_FIRST:
 
				this->bar_height = FONT_HEIGHT_NORMAL + 4;
 
				size->height = this->bar_height + 2 * WD_MATRIX_TOP;
 
				this->bar_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.Vertical();
 
				size->height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical();
 

	
 
				uint score_info_width = 0;
 
				for (uint i = SCORE_BEGIN; i < SCORE_END; i++) {
 
					score_info_width = std::max(score_info_width, GetStringBoundingBox(STR_PERFORMANCE_DETAIL_VEHICLES + i).width);
 
				}
 
				SetDParamMaxValue(0, 1000);
 
				score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WD_FRAMERECT_LEFT;
 
				score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WidgetDimensions::scaled.hsep_wide;
 

	
 
				SetDParamMaxValue(0, 100);
 
				this->bar_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_PERCENT).width + 20; // Wide bars!
 
				this->bar_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_PERCENT).width + WidgetDimensions::scaled.hsep_indent * 2; // Wide bars!
 

	
 
				/* At this number we are roughly at the max; it can become wider,
 
				 * but then you need at 1000 times more money. At that time you're
 
@@ -1361,9 +1361,9 @@ struct PerformanceRatingDetailWindow : W
 
				SetDParam(1, max);
 
				uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width;
 

	
 
				size->width = 7 + score_info_width + 5 + this->bar_width + 5 + score_detail_width + 7;
 
				uint left  = 7;
 
				uint right = size->width - 7;
 
				size->width = WidgetDimensions::scaled.frametext.Horizontal() + score_info_width + WidgetDimensions::scaled.hsep_wide + this->bar_width + WidgetDimensions::scaled.hsep_wide + score_detail_width;
 
				uint left  = WidgetDimensions::scaled.frametext.left;
 
				uint right = size->width - WidgetDimensions::scaled.frametext.right;
 

	
 
				bool rtl = _current_text_dir == TD_RTL;
 
				this->score_info_left  = rtl ? right - score_info_width : left;
 
@@ -1372,8 +1372,8 @@ struct PerformanceRatingDetailWindow : W
 
				this->score_detail_left  = rtl ? left : right - score_detail_width;
 
				this->score_detail_right = rtl ? left + score_detail_width : right;
 

	
 
				this->bar_left  = left + (rtl ? score_detail_width : score_info_width) + 5;
 
				this->bar_right = this->bar_left + this->bar_width;
 
				this->bar_left  = left + (rtl ? score_detail_width : score_info_width) + WidgetDimensions::scaled.hsep_wide;
 
				this->bar_right = this->bar_left + this->bar_width - 1;
 
				break;
 
		}
 
	}
 
@@ -1386,7 +1386,7 @@ struct PerformanceRatingDetailWindow : W
 
		if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) {
 
			if (this->IsWidgetDisabled(widget)) return;
 
			CompanyID cid = (CompanyID)(widget - WID_PRD_COMPANY_FIRST);
 
			int offset = (cid == this->company) ? 1 : 0;
 
			int offset = (cid == this->company) ? WidgetDimensions::scaled.pressed : 0;
 
			Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
			DrawCompanyIcon(cid, CenterBounds(r.left, r.right, sprite_size.width) + offset, CenterBounds(r.top, r.bottom, sprite_size.height) + offset);
 
			return;
 
@@ -1411,8 +1411,8 @@ struct PerformanceRatingDetailWindow : W
 
			needed = SCORE_MAX;
 
		}
 

	
 
		uint bar_top  = r.top + WD_MATRIX_TOP;
 
		uint text_top = bar_top + 2;
 
		uint bar_top  = CenterBounds(r.top, r.bottom, this->bar_height);
 
		uint text_top = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
 

	
 
		DrawString(this->score_info_left, this->score_info_right, text_top, STR_PERFORMANCE_DETAIL_VEHICLES + score_type);
 

	
 
@@ -1430,8 +1430,8 @@ struct PerformanceRatingDetailWindow : W
 
		}
 

	
 
		/* Draw the bar */
 
		if (x != this->bar_left)  GfxFillRect(this->bar_left, bar_top, x, bar_top + this->bar_height, rtl ? colour_notdone : colour_done);
 
		if (x != this->bar_right) GfxFillRect(x, bar_top, this->bar_right, bar_top + this->bar_height, rtl ? colour_done : colour_notdone);
 
		if (x != this->bar_left)  GfxFillRect(this->bar_left, bar_top, x,               bar_top + this->bar_height - 1, rtl ? colour_notdone : colour_done);
 
		if (x != this->bar_right) GfxFillRect(x,              bar_top, this->bar_right, bar_top + this->bar_height - 1, rtl ? colour_done : colour_notdone);
 

	
 
		/* Draw it */
 
		SetDParam(0, Clamp<int64>(val, 0, needed) * 100 / needed);
 
@@ -1562,7 +1562,7 @@ static const NWidgetPart _nested_perform
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_BROWN),
 
		NWidgetFunction(MakeCompanyButtonRowsGraphGUI), SetPadding(0, 1, 1, 2),
 
		NWidgetFunction(MakeCompanyButtonRowsGraphGUI), SetPadding(2),
 
	EndContainer(),
 
	NWidgetFunction(MakePerformanceDetailPanels),
 
};
src/group_gui.cpp
Show inline comments
 
@@ -34,8 +34,6 @@
 

	
 
#include "safeguards.h"
 

	
 
static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels
 

	
 
typedef GUIList<const Group*> GUIGroupList;
 

	
 
static const NWidgetPart _nested_group_widgets[] = {
 
@@ -56,7 +54,7 @@ static const NWidgetPart _nested_group_w
 
						SetFill(1, 0), SetResize(0, 1), SetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR),
 
				NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_GROUP_SCROLLBAR),
 
			EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_INFO), SetFill(1, 1), SetMinimalTextLines(3, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_INFO), SetFill(1, 1), SetMinimalTextLines(3, WidgetDimensions::unscaled.framerect.Vertical()), EndContainer(),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_CREATE_GROUP),
 
						SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP),
 
@@ -207,7 +205,7 @@ private:
 
		this->tiny_step_height = this->column_size[VGC_FOLD].height;
 

	
 
		this->column_size[VGC_NAME] = maxdim(GetStringBoundingBox(STR_GROUP_DEFAULT_TRAINS + this->vli.vtype), GetStringBoundingBox(STR_GROUP_ALL_TRAINS + this->vli.vtype));
 
		this->column_size[VGC_NAME].width = std::max(170u, this->column_size[VGC_NAME].width);
 
		this->column_size[VGC_NAME].width = std::max(170u, this->column_size[VGC_NAME].width) + WidgetDimensions::scaled.hsep_indent;
 
		this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[VGC_NAME].height);
 

	
 
		this->column_size[VGC_PROTECT] = GetSpriteSize(SPR_GROUP_REPLACE_PROTECT);
 
@@ -231,16 +229,16 @@ private:
 
		this->column_size[VGC_NUMBER] = GetStringBoundingBox(STR_GROUP_COUNT_WITH_SUBGROUP);
 
		this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[VGC_NUMBER].height);
 

	
 
		this->tiny_step_height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		this->tiny_step_height += WidgetDimensions::scaled.framerect.Vertical();
 

	
 
		return WD_FRAMERECT_LEFT + 8 +
 
			this->column_size[VGC_FOLD].width + 2 +
 
			this->column_size[VGC_NAME].width + 8 +
 
			this->column_size[VGC_PROTECT].width + 2 +
 
			this->column_size[VGC_AUTOREPLACE].width + 2 +
 
			this->column_size[VGC_PROFIT].width + 2 +
 
			this->column_size[VGC_NUMBER].width + 2 +
 
			WD_FRAMERECT_RIGHT;
 
		return WidgetDimensions::scaled.framerect.left +
 
			this->column_size[VGC_FOLD].width + WidgetDimensions::scaled.hsep_normal +
 
			this->column_size[VGC_NAME].width + WidgetDimensions::scaled.hsep_wide +
 
			this->column_size[VGC_PROTECT].width + WidgetDimensions::scaled.hsep_normal +
 
			this->column_size[VGC_AUTOREPLACE].width + WidgetDimensions::scaled.hsep_normal +
 
			this->column_size[VGC_PROFIT].width + WidgetDimensions::scaled.hsep_normal +
 
			this->column_size[VGC_NUMBER].width +
 
			WidgetDimensions::scaled.framerect.right;
 
	}
 

	
 
	/**
 
@@ -257,7 +255,7 @@ private:
 
	{
 
		/* Highlight the group if a vehicle is dragged over it */
 
		if (g_id == this->group_over) {
 
			GfxFillRect(left + WD_FRAMERECT_LEFT, y + WD_FRAMERECT_TOP + 1, right - WD_FRAMERECT_RIGHT, y + this->tiny_step_height - WD_FRAMERECT_BOTTOM - 1, _colour_gradient[COLOUR_GREY][7]);
 
			GfxFillRect(left + WidgetDimensions::scaled.bevel.left, y + WidgetDimensions::scaled.framerect.top, right - WidgetDimensions::scaled.bevel.right, y + this->tiny_step_height - 1 - WidgetDimensions::scaled.framerect.bottom, _colour_gradient[COLOUR_GREY][7]);
 
		}
 

	
 
		if (g_id == NEW_GROUP) return;
 
@@ -268,7 +266,7 @@ private:
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		/* draw fold / unfold button */
 
		int x = rtl ? right - WD_FRAMERECT_RIGHT - 8 - this->column_size[VGC_FOLD].width + 1 : left + WD_FRAMERECT_LEFT + 8;
 
		int x = rtl ? right - WidgetDimensions::scaled.framerect.right - this->column_size[VGC_FOLD].width + 1 : left + WidgetDimensions::scaled.framerect.left;
 
		if (has_children) {
 
			DrawSprite(Group::Get(g_id)->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED, PAL_NONE, rtl ? x - indent : x + indent, y + (this->tiny_step_height - this->column_size[VGC_FOLD].height) / 2);
 
		}
 
@@ -283,19 +281,19 @@ private:
 
			SetDParam(0, g_id);
 
			str = STR_GROUP_NAME;
 
		}
 
		x = rtl ? x - 2 - this->column_size[VGC_NAME].width : x + 2 + this->column_size[VGC_FOLD].width;
 
		x = rtl ? x - WidgetDimensions::scaled.hsep_normal - this->column_size[VGC_NAME].width : x + WidgetDimensions::scaled.hsep_normal + this->column_size[VGC_FOLD].width;
 
		DrawString(x + (rtl ? 0 : indent), x + this->column_size[VGC_NAME].width - 1 - (rtl ? indent : 0), y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, str, colour);
 

	
 
		/* draw autoreplace protection */
 
		x = rtl ? x - 8 - this->column_size[VGC_PROTECT].width : x + 8 + this->column_size[VGC_NAME].width;
 
		x = rtl ? x - WidgetDimensions::scaled.hsep_wide - this->column_size[VGC_PROTECT].width : x + WidgetDimensions::scaled.hsep_wide + this->column_size[VGC_NAME].width;
 
		if (protection) DrawSprite(SPR_GROUP_REPLACE_PROTECT, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_PROTECT].height) / 2);
 

	
 
		/* draw autoreplace status */
 
		x = rtl ? x - 2 - this->column_size[VGC_AUTOREPLACE].width : x + 2 + this->column_size[VGC_PROTECT].width;
 
		x = rtl ? x - WidgetDimensions::scaled.hsep_normal - this->column_size[VGC_AUTOREPLACE].width : x + WidgetDimensions::scaled.hsep_normal + this->column_size[VGC_PROTECT].width;
 
		if (stats.autoreplace_defined) DrawSprite(SPR_GROUP_REPLACE_ACTIVE, stats.autoreplace_finished ? PALETTE_CRASH : PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_AUTOREPLACE].height) / 2);
 

	
 
		/* draw the profit icon */
 
		x = rtl ? x - 2 - this->column_size[VGC_PROFIT].width : x + 2 + this->column_size[VGC_AUTOREPLACE].width;
 
		x = rtl ? x - WidgetDimensions::scaled.hsep_normal - this->column_size[VGC_PROFIT].width : x + WidgetDimensions::scaled.hsep_normal + this->column_size[VGC_AUTOREPLACE].width;
 
		SpriteID spr;
 
		uint num_profit_vehicle = GetGroupNumProfitVehicle(this->vli.company, g_id, this->vli.vtype);
 
		Money profit_last_year = GetGroupProfitLastYear(this->vli.company, g_id, this->vli.vtype);
 
@@ -311,7 +309,7 @@ private:
 
		DrawSprite(spr, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_PROFIT].height) / 2);
 

	
 
		/* draw the number of vehicles of the group */
 
		x = rtl ? x - 2 - this->column_size[VGC_NUMBER].width : x + 2 + this->column_size[VGC_PROFIT].width;
 
		x = rtl ? x - WidgetDimensions::scaled.hsep_normal - this->column_size[VGC_NUMBER].width : x + WidgetDimensions::scaled.hsep_normal + this->column_size[VGC_PROFIT].width;
 
		int num_vehicle_with_subgroups = GetGroupNumVehicle(this->vli.company, g_id, this->vli.vtype);
 
		int num_vehicle = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype).num_vehicle;
 
		if (IsAllGroupID(g_id) || IsDefaultGroupID(g_id) || num_vehicle_with_subgroups == num_vehicle) {
 
@@ -563,7 +561,7 @@ public:
 
					occupancy += v->trip_occupancy;
 
				}
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 

	
 
				DrawString(tr, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
 
				SetDParam(0, this_year);
 
@@ -593,7 +591,7 @@ public:
 

	
 
					assert(g->owner == this->owner);
 

	
 
					DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * LEVEL_WIDTH, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (i + 1 < (int)this->groups.size() && indents[i + 1] > this->indents[i]));
 
					DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * WidgetDimensions::scaled.hsep_indent, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (i + 1 < (int)this->groups.size() && indents[i + 1] > this->indents[i]));
 

	
 
					y1 += this->tiny_step_height;
 
				}
 
@@ -615,7 +613,7 @@ public:
 
					for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
						const Vehicle *v = this->vehgroups[i].GetSingleVehicle();
 
						if (v->group_id != this->vli.index) {
 
							GfxFillRect(mr.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
 
							GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
 
						}
 
						mr = mr.Translate(0, this->resize.step_height);
 
					}
 
@@ -679,8 +677,8 @@ public:
 
					/* The group has children, check if the user clicked the fold / unfold button. */
 
					NWidgetCore *group_display = this->GetWidget<NWidgetCore>(widget);
 
					int x = _current_text_dir == TD_RTL ?
 
							group_display->pos_x + group_display->current_x - WD_FRAMERECT_RIGHT - 8 - this->indents[id_g] * LEVEL_WIDTH - this->column_size[VGC_FOLD].width :
 
							group_display->pos_x + WD_FRAMERECT_LEFT + 8 + this->indents[id_g] * LEVEL_WIDTH;
 
							group_display->pos_x + group_display->current_x - WidgetDimensions::scaled.framerect.right - this->indents[id_g] * WidgetDimensions::scaled.hsep_indent - this->column_size[VGC_FOLD].width :
 
							group_display->pos_x + WidgetDimensions::scaled.framerect.left + this->indents[id_g] * WidgetDimensions::scaled.hsep_indent;
 
					if (click_count > 1 || (pt.x >= x && pt.x < (int)(x + this->column_size[VGC_FOLD].width))) {
 

	
 
						GroupID g = this->vli.index;
src/industry_gui.cpp
Show inline comments
 
@@ -423,7 +423,7 @@ public:
 
					d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(this->index[i])->name));
 
				}
 
				resize->height = std::max<uint>(this->legend.height, FONT_HEIGHT_NORMAL) + padding.height;
 
				d.width += this->legend.width + ScaleFontTrad(7) + padding.width;
 
				d.width += this->legend.width + WidgetDimensions::scaled.hsep_wide + padding.width;
 
				d.height = 5 * resize->height;
 
				*size = maxdim(*size, d);
 
				break;
 
@@ -514,15 +514,14 @@ public:
 
		switch (widget) {
 
			case WID_DPI_MATRIX_WIDGET: {
 
				bool rtl = _current_text_dir == TD_RTL;
 
				Rect text = r.WithHeight(this->resize.step_height).Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect text = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
 
				Rect icon = text.WithWidth(this->legend.width, rtl);
 
				text = text.Indent(this->legend.width + ScaleFontTrad(7), rtl);
 
				text = text.Indent(this->legend.width + WidgetDimensions::scaled.hsep_wide, rtl);
 

	
 
				/* Vertical offset for legend icon. */
 
				icon.top    = r.top + (this->resize.step_height - this->legend.height + 1) / 2;
 
				icon.bottom = icon.top + this->legend.height - 1;
 

	
 
				int y = r.top;
 
				for (uint16 i = 0; i < this->vscroll->GetCapacity() && i + this->vscroll->GetPosition() < this->count; i++) {
 
					bool selected = this->selected_index == i + this->vscroll->GetPosition();
 

	
 
@@ -534,7 +533,7 @@ public:
 
						/* Draw the name of the industry in white is selected, otherwise, in orange */
 
						DrawString(text, indsp->name, selected ? TC_WHITE : TC_ORANGE);
 
						GfxFillRect(icon, selected ? PC_WHITE : PC_BLACK);
 
						GfxFillRect(icon.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), indsp->map_colour);
 
						GfxFillRect(icon.Shrink(WidgetDimensions::scaled.bevel), indsp->map_colour);
 
					}
 

	
 
					text = text.Translate(0, this->resize.step_height);
 
@@ -544,7 +543,7 @@ public:
 
			}
 

	
 
			case WID_DPI_INFOPANEL: {
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 

	
 
				if (this->selected_type == INVALID_INDUSTRYTYPE) {
 
					DrawStringMultiLine(ir, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP);
 
@@ -822,7 +821,7 @@ public:
 
		this->editbox_line = IL_NONE;
 
		this->clicked_line = IL_NONE;
 
		this->clicked_button = 0;
 
		this->info_height = WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + 1; // Info panel has at least two lines text.
 
		this->info_height = WidgetDimensions::scaled.framerect.Vertical() + 2 * FONT_HEIGHT_NORMAL; // Info panel has at least two lines text.
 

	
 
		this->InitNested(window_number);
 
		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_IV_VIEWPORT);
 
@@ -848,16 +847,14 @@ public:
 

	
 
	/**
 
	 * Draw the text in the #WID_IV_INFO panel.
 
	 * @param left  Left edge of the panel.
 
	 * @param right Right edge of the panel.
 
	 * @param top   Top edge of the panel.
 
	 * @param r Rectangle of the panel.
 
	 * @return Expected position of the bottom edge of the panel.
 
	 */
 
	int DrawInfo(const Rect &r)
 
	{
 
		Industry *i = Industry::Get(this->window_number);
 
		const IndustrySpec *ind = GetIndustrySpec(i->type);
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		bool first = true;
 
		bool has_accept = false;
 

	
 
@@ -901,7 +898,7 @@ public:
 
				default:
 
					NOT_REACHED();
 
			}
 
			DrawString(ir.Indent(10, _current_text_dir == TD_RTL), str);
 
			DrawString(ir.Indent(WidgetDimensions::scaled.hsep_indent, _current_text_dir == TD_RTL), str);
 
			ir.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
@@ -910,7 +907,7 @@ public:
 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
			if (i->produced_cargo[j] == CT_INVALID) continue;
 
			if (first) {
 
				if (has_accept) ir.top += WD_PAR_VSEP_WIDE;
 
				if (has_accept) ir.top += WidgetDimensions::scaled.vsep_wide;
 
				DrawString(ir, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
 
				ir.top += FONT_HEIGHT_NORMAL;
 
				if (this->editable == EA_RATE) this->production_offset_y = ir.top;
 
@@ -921,7 +918,7 @@ public:
 
			SetDParam(1, i->last_month_production[j]);
 
			SetDParamStr(2, cargo_suffix[j].text);
 
			SetDParam(3, ToPercent8(i->last_month_pct_transported[j]));
 
			DrawString(ir.Indent(this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + 10 : 0, false), STR_INDUSTRY_VIEW_TRANSPORTED);
 
			DrawString(ir.Indent(this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_indent : 0, false), STR_INDUSTRY_VIEW_TRANSPORTED);
 
			/* Let's put out those buttons.. */
 
			if (this->editable == EA_RATE) {
 
				DrawArrowButtons(ir.left, ir.top, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0,
 
@@ -932,10 +929,10 @@ public:
 

	
 
		/* Display production multiplier if editable */
 
		if (this->editable == EA_MULTIPLIER) {
 
			ir.top += WD_PAR_VSEP_WIDE;
 
			ir.top += WidgetDimensions::scaled.vsep_wide;
 
			this->production_offset_y = ir.top;
 
			SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
 
			DrawString(ir.Indent(SETTING_BUTTON_WIDTH + 10, false), STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
 
			DrawString(ir.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_indent, false), STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
 
			DrawArrowButtons(ir.left, ir.top, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0,
 
					i->prod_level > PRODLEVEL_MINIMUM, i->prod_level < PRODLEVEL_MAXIMUM);
 
			ir.top += FONT_HEIGHT_NORMAL;
 
@@ -950,7 +947,7 @@ public:
 
				} else {
 
					StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res);
 
					if (message != STR_NULL && message != STR_UNDEFINED) {
 
						ir.top += WD_PAR_VSEP_WIDE;
 
						ir.top += WidgetDimensions::scaled.vsep_wide;
 

	
 
						StartTextRefStackUsage(ind->grf_prop.grffile, 6);
 
						/* Use all the available space left from where we stand up to the
 
@@ -965,11 +962,12 @@ public:
 

	
 
		if (!i->text.empty()) {
 
			SetDParamStr(0, i->text);
 
			ir.top += WD_PAR_VSEP_WIDE;
 
			ir.top += WidgetDimensions::scaled.vsep_wide;
 
			ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
 
		}
 

	
 
		return ir.top - 1 + WD_FRAMERECT_BOTTOM;
 
		/* Return required bottom position, the last pixel row plus some padding. */
 
		return ir.top - 1 + WidgetDimensions::scaled.framerect.bottom;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
@@ -1013,8 +1011,8 @@ public:
 
				if (line == IL_NONE) return;
 

	
 
				NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
 
				int left = nwi->pos_x + WD_FRAMETEXT_LEFT;
 
				int right = nwi->pos_x + nwi->current_x - 1 - WD_FRAMERECT_RIGHT;
 
				int left = nwi->pos_x + WidgetDimensions::scaled.framerect.left;
 
				int right = nwi->pos_x + nwi->current_x - 1 - WidgetDimensions::scaled.framerect.right;
 
				if (IsInsideMM(pt.x, left, left + SETTING_BUTTON_WIDTH)) {
 
					/* Clicked buttons, decrease or increase production */
 
					byte button = (pt.x < left + SETTING_BUTTON_WIDTH / 2) ? 1 : 2;
 
@@ -1049,7 +1047,7 @@ public:
 
					this->SetTimeout();
 
					this->clicked_line = line;
 
					this->clicked_button = button;
 
				} else if (IsInsideMM(pt.x, left + SETTING_BUTTON_WIDTH + 10, right)) {
 
				} else if (IsInsideMM(pt.x, left + SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_indent, right)) {
 
					/* clicked the text */
 
					this->editbox_line = line;
 
					switch (this->editable) {
 
@@ -1181,7 +1179,7 @@ static const NWidgetPart _nested_industr
 
			NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_IV_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 0), SetResize(1, 1),
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_CREAM, WID_IV_INFO), SetMinimalSize(260, 2), SetResize(1, 0),
 
	NWidget(WWT_PANEL, COLOUR_CREAM, WID_IV_INFO), SetMinimalSize(260, 0), SetMinimalTextLines(2, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_DISPLAY), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
 
@@ -1647,7 +1645,7 @@ public:
 

	
 
			case WID_ID_INDUSTRY_LIST: {
 
				int n = 0;
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
				if (this->industries.size() == 0) {
 
					DrawString(ir, STR_INDUSTRY_DIRECTORY_NONE);
 
					break;
 
@@ -1701,8 +1699,8 @@ public:
 
				}
 
				resize->height = d.height;
 
				d.height *= 5;
 
				d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				d.width += padding.width;
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
@@ -1731,7 +1729,7 @@ public:
 
				break;
 

	
 
			case WID_ID_INDUSTRY_LIST: {
 
				uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP);
 
				uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WidgetDimensions::scaled.framerect.top);
 
				if (p < this->industries.size()) {
 
					if (_ctrl_pressed) {
 
						ShowExtraViewportWindow(this->industries[p]->location.tile);
 
@@ -1892,8 +1890,8 @@ static const uint MAX_CARGOES = 16; ///<
 

	
 
/** Data about a single field in the #IndustryCargoesWindow panel. */
 
struct CargoesField {
 
	static const int VERT_INTER_INDUSTRY_SPACE;
 
	static const int BLOB_DISTANCE;
 
	static int vert_inter_industry_space;
 
	static int blob_distance;
 

	
 
	static Dimension legend;
 
	static Dimension cargo_border;
 
@@ -2083,8 +2081,8 @@ struct CargoesField {
 
				break;
 

	
 
			case CFT_INDUSTRY: {
 
				int ypos1 = ypos + VERT_INTER_INDUSTRY_SPACE / 2;
 
				int ypos2 = ypos + normal_height - 1 - VERT_INTER_INDUSTRY_SPACE / 2;
 
				int ypos1 = ypos + vert_inter_industry_space / 2;
 
				int ypos2 = ypos + normal_height - 1 - vert_inter_industry_space / 2;
 
				int xpos2 = xpos + industry_width - 1;
 
				GfxDrawLine(xpos,  ypos1, xpos2, ypos1, INDUSTRY_LINE_COLOUR);
 
				GfxDrawLine(xpos,  ypos1, xpos,  ypos2, INDUSTRY_LINE_COLOUR);
 
@@ -2098,14 +2096,14 @@ struct CargoesField {
 
					/* Draw the industry legend. */
 
					int blob_left, blob_right;
 
					if (_current_text_dir == TD_RTL) {
 
						blob_right = xpos2 - BLOB_DISTANCE;
 
						blob_right = xpos2 - blob_distance;
 
						blob_left  = blob_right - CargoesField::legend.width;
 
					} else {
 
						blob_left  = xpos + BLOB_DISTANCE;
 
						blob_left  = xpos + blob_distance;
 
						blob_right = blob_left + CargoesField::legend.width;
 
					}
 
					GfxFillRect(blob_left,     ypos2 - BLOB_DISTANCE - CargoesField::legend.height,     blob_right,     ypos2 - BLOB_DISTANCE,     PC_BLACK); // Border
 
					GfxFillRect(blob_left + 1, ypos2 - BLOB_DISTANCE - CargoesField::legend.height + 1, blob_right - 1, ypos2 - BLOB_DISTANCE - 1, indsp->map_colour);
 
					GfxFillRect(blob_left,     ypos2 - blob_distance - CargoesField::legend.height,     blob_right,     ypos2 - blob_distance,     PC_BLACK); // Border
 
					GfxFillRect(blob_left + 1, ypos2 - blob_distance - CargoesField::legend.height + 1, blob_right - 1, ypos2 - blob_distance - 1, indsp->map_colour);
 
				} else {
 
					DrawString(xpos, xpos2, ypos, STR_INDUSTRY_CARGOES_HOUSES, TC_FROMSTRING, SA_HOR_CENTER);
 
				}
 
@@ -2140,8 +2138,8 @@ struct CargoesField {
 

	
 
			case CFT_CARGO: {
 
				int cargo_base = this->GetCargoBase(xpos);
 
				int top = ypos + (this->u.cargo.top_end ? VERT_INTER_INDUSTRY_SPACE / 2 + 1 : 0);
 
				int bot = ypos - (this->u.cargo.bottom_end ? VERT_INTER_INDUSTRY_SPACE / 2 + 1 : 0) + normal_height - 1;
 
				int top = ypos + (this->u.cargo.top_end ? vert_inter_industry_space / 2 + 1 : 0);
 
				int bot = ypos - (this->u.cargo.bottom_end ? vert_inter_industry_space / 2 + 1 : 0) + normal_height - 1;
 
				int colpos = cargo_base;
 
				for (int i = 0; i < this->u.cargo.num_cargoes; i++) {
 
					if (this->u.cargo.top_end) GfxDrawLine(colpos, top - 1, colpos + CargoesField::cargo_line.width - 1, top - 1, CARGO_LINE_COLOUR);
 
@@ -2163,7 +2161,7 @@ struct CargoesField {
 
					hor_left  = this->u.cargo.supp_cargoes;
 
					hor_right = this->u.cargo.cust_cargoes;
 
				}
 
				ypos += CargoesField::cargo_border.height + VERT_INTER_INDUSTRY_SPACE / 2 + (FONT_HEIGHT_NORMAL - CargoesField::cargo_line.height) / 2;
 
				ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2 + (FONT_HEIGHT_NORMAL - CargoesField::cargo_line.height) / 2;
 
				for (uint i = 0; i < MAX_CARGOES; i++) {
 
					if (hor_left[i] != INVALID_CARGO) {
 
						int col = hor_left[i];
 
@@ -2193,11 +2191,11 @@ struct CargoesField {
 
			}
 

	
 
			case CFT_CARGO_LABEL:
 
				ypos += CargoesField::cargo_border.height + VERT_INTER_INDUSTRY_SPACE / 2;
 
				ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2;
 
				for (uint i = 0; i < MAX_CARGOES; i++) {
 
					if (this->u.cargo_label.cargoes[i] != INVALID_CARGO) {
 
						const CargoSpec *csp = CargoSpec::Get(this->u.cargo_label.cargoes[i]);
 
						DrawString(xpos + WD_FRAMERECT_LEFT, xpos + industry_width - 1 - WD_FRAMERECT_RIGHT, ypos, csp->name, TC_WHITE,
 
						DrawString(xpos + WidgetDimensions::scaled.framerect.left, xpos + industry_width - 1 - WidgetDimensions::scaled.framerect.right, ypos, csp->name, TC_WHITE,
 
								(this->u.cargo_label.left_align) ? SA_LEFT : SA_RIGHT);
 
					}
 
					ypos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height;
 
@@ -2230,7 +2228,7 @@ struct CargoesField {
 
		}
 
		/* col = 0 -> left of first col, 1 -> left of 2nd col, ... this->u.cargo.num_cargoes right of last-col. */
 

	
 
		int vpos = VERT_INTER_INDUSTRY_SPACE / 2 + CargoesField::cargo_border.width;
 
		int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.width;
 
		uint row;
 
		for (row = 0; row < MAX_CARGOES; row++) {
 
			if (pt.y < vpos) return INVALID_CARGO;
 
@@ -2277,7 +2275,7 @@ struct CargoesField {
 
	{
 
		assert(this->type == CFT_CARGO_LABEL);
 

	
 
		int vpos = VERT_INTER_INDUSTRY_SPACE / 2 + CargoesField::cargo_border.height;
 
		int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.height;
 
		uint row;
 
		for (row = 0; row < MAX_CARGOES; row++) {
 
			if (pt.y < vpos) return INVALID_CARGO;
 
@@ -2318,9 +2316,9 @@ int CargoesField::normal_height;     ///
 
int CargoesField::industry_width;    ///< Width of an industry field.
 
int CargoesField::cargo_field_width; ///< Width of a cargo field.
 
uint CargoesField::max_cargoes;      ///< Largest number of cargoes actually on any industry.
 
const int CargoesField::VERT_INTER_INDUSTRY_SPACE = 6; ///< Amount of space between two industries in a column.
 

	
 
const int CargoesField::BLOB_DISTANCE =  5; ///< Distance of the industry legend colour from the edge of the industry box.
 
int CargoesField::vert_inter_industry_space; ///< Amount of space between two industries in a column.
 

	
 
int CargoesField::blob_distance; ///< Distance of the industry legend colour from the edge of the industry box.
 

	
 
const int CargoesField::INDUSTRY_LINE_COLOUR = PC_YELLOW; ///< Line colour of the industry type box.
 
const int CargoesField::CARGO_LINE_COLOUR    = PC_YELLOW; ///< Line colour around the cargo.
 
@@ -2463,8 +2461,6 @@ next_cargo: ;
 
 * customer industries). The remaining two columns are set to #CFT_EMPTY with a width equal to the average of a cargo and an industry column.
 
 */
 
struct IndustryCargoesWindow : public Window {
 
	static const int HOR_TEXT_PADDING, VERT_TEXT_PADDING;
 

	
 
	typedef std::vector<CargoesRow> Fields;
 

	
 
	Fields fields;  ///< Fields to display in the #WID_IC_PANEL.
 
@@ -2487,8 +2483,8 @@ struct IndustryCargoesWindow : public Wi
 
		/* Initialize static CargoesField size variables. */
 
		Dimension d = GetStringBoundingBox(STR_INDUSTRY_CARGOES_PRODUCERS);
 
		d = maxdim(d, GetStringBoundingBox(STR_INDUSTRY_CARGOES_CUSTOMERS));
 
		d.width  += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
		d.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
		d.width  += WidgetDimensions::scaled.frametext.Horizontal();
 
		d.height += WidgetDimensions::scaled.frametext.Vertical();
 
		CargoesField::small_height = d.height;
 

	
 
		/* Size of the legend blob -- slightly larger than the smallmap legend blob. */
 
@@ -2496,7 +2492,7 @@ struct IndustryCargoesWindow : public Wi
 
		CargoesField::legend.width = CargoesField::legend.height * 8 / 5;
 

	
 
		/* Size of cargo lines. */
 
		CargoesField::cargo_line.width = FONT_HEIGHT_NORMAL;
 
		CargoesField::cargo_line.width = ScaleGUITrad(6);
 
		CargoesField::cargo_line.height = CargoesField::cargo_line.width;
 

	
 
		/* Size of border between cargo lines and industry boxes. */
 
@@ -2511,6 +2507,9 @@ struct IndustryCargoesWindow : public Wi
 
		CargoesField::cargo_stub.width = CargoesField::cargo_line.width / 2;
 
		CargoesField::cargo_stub.height = CargoesField::cargo_line.height; /* Unused */
 

	
 
		CargoesField::vert_inter_industry_space = WidgetDimensions::scaled.vsep_wide;
 
		CargoesField::blob_distance = WidgetDimensions::scaled.hsep_normal;
 

	
 
		/* Decide about the size of the box holding the text of an industry type. */
 
		this->ind_textsize.width = 0;
 
		this->ind_textsize.height = 0;
 
@@ -2537,13 +2536,13 @@ struct IndustryCargoesWindow : public Wi
 
		d = maxdim(d, this->cargo_textsize); // Box must also be wide enough to hold any cargo label.
 
		this->cargo_textsize = maxdim(this->cargo_textsize, GetStringBoundingBox(STR_INDUSTRY_CARGOES_SELECT_CARGO));
 

	
 
		d.width  += 2 * HOR_TEXT_PADDING;
 
		d.width += WidgetDimensions::scaled.frametext.Horizontal();
 
		/* Ensure the height is enough for the industry type text, for the horizontal connections, and for the cargo labels. */
 
		uint min_ind_height = CargoesField::cargo_border.height * 2 + CargoesField::max_cargoes * FONT_HEIGHT_NORMAL + (CargoesField::max_cargoes - 1) * CargoesField::cargo_space.height;
 
		d.height = std::max(d.height + 2 * VERT_TEXT_PADDING, min_ind_height);
 
		d.height = std::max(d.height + WidgetDimensions::scaled.frametext.Vertical(), min_ind_height);
 

	
 
		CargoesField::industry_width = d.width;
 
		CargoesField::normal_height = d.height + CargoesField::VERT_INTER_INDUSTRY_SPACE;
 
		CargoesField::normal_height = d.height + CargoesField::vert_inter_industry_space;
 

	
 
		/* Width of a #CFT_CARGO field. */
 
		CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1);
 
@@ -2554,8 +2553,8 @@ struct IndustryCargoesWindow : public Wi
 
		switch (widget) {
 
			case WID_IC_PANEL:
 
				resize->height = CargoesField::normal_height;
 
				size->width = WD_FRAMETEXT_LEFT + CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WD_FRAMETEXT_RIGHT;
 
				size->height = WD_FRAMETEXT_TOP + CargoesField::small_height + 2 * resize->height + WD_FRAMETEXT_BOTTOM;
 
				size->width = CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WidgetDimensions::scaled.frametext.Horizontal();
 
				size->height = CargoesField::small_height + 2 * resize->height + WidgetDimensions::scaled.frametext.Vertical();
 
				break;
 

	
 
			case WID_IC_IND_DROPDOWN:
 
@@ -2906,7 +2905,7 @@ struct IndustryCargoesWindow : public Wi
 
	{
 
		if (widget != WID_IC_PANEL) return;
 

	
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		DrawPixelInfo tmp_dpi, *old_dpi;
 
		if (!FillDrawPixelInfo(&tmp_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
		old_dpi = _cur_dpi;
 
@@ -2956,7 +2955,7 @@ struct IndustryCargoesWindow : public Wi
 
		pt.x -= nw->pos_x;
 
		pt.y -= nw->pos_y;
 

	
 
		int vpos = WD_FRAMERECT_TOP + CargoesField::small_height - this->vscroll->GetPosition() * nw->resize_y;
 
		int vpos = WidgetDimensions::scaled.framerect.top + CargoesField::small_height - this->vscroll->GetPosition() * nw->resize_y;
 
		if (pt.y < vpos) return false;
 

	
 
		int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.
 
@@ -2964,7 +2963,7 @@ struct IndustryCargoesWindow : public Wi
 
		vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field
 
		row++; // rebase row to match index of this->fields.
 

	
 
		int xpos = 2 * WD_FRAMERECT_LEFT + ((this->ind_cargo < NUM_INDUSTRYTYPES) ? 0 :  (CargoesField::industry_width + CargoesField::cargo_field_width) / 2);
 
		int xpos = 2 * WidgetDimensions::scaled.framerect.left + ((this->ind_cargo < NUM_INDUSTRYTYPES) ? 0 :  (CargoesField::industry_width + CargoesField::cargo_field_width) / 2);
 
		if (pt.x < xpos) return false;
 
		int column;
 
		for (column = 0; column <= 5; column++) {
 
@@ -3120,13 +3119,10 @@ struct IndustryCargoesWindow : public Wi
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL, WD_FRAMERECT_TOP + CargoesField::small_height);
 
		this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL, WidgetDimensions::scaled.framerect.top + CargoesField::small_height);
 
	}
 
};
 

	
 
const int IndustryCargoesWindow::HOR_TEXT_PADDING  = 5; ///< Horizontal padding around the industry type text.
 
const int IndustryCargoesWindow::VERT_TEXT_PADDING = 5; ///< Vertical padding around the industry type text.
 

	
 
/**
 
 * Open the industry and cargoes window.
 
 * @param id Industry type to display, \c NUM_INDUSTRYTYPES selects a default industry type.
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -509,13 +509,11 @@ static const NWidgetPart _nested_linkgra
 
		NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
 
		NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect), SetPIP(0, WidgetDimensions::unscaled.framerect.Horizontal(), 0),
 
			NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_LGL_SATURATION),
 
				SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, WD_CAPTIONTEXT_LEFT),
 
				NWidgetFunction(MakeSaturationLegendLinkGraphGUI),
 
			EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_LGL_COMPANIES),
 
				SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, WD_CAPTIONTEXT_LEFT),
 
				NWidget(NWID_VERTICAL, NC_EQUALSIZE),
 
					NWidgetFunction(MakeCompanyButtonRowsLinkGraphGUI),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_LGL_COMPANIES_ALL), SetDataTip(STR_LINKGRAPH_LEGEND_ALL, STR_NULL),
 
@@ -523,7 +521,6 @@ static const NWidgetPart _nested_linkgra
 
				EndContainer(),
 
			EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_LGL_CARGOES),
 
				SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_CAPTIONTEXT_LEFT),
 
				NWidget(NWID_VERTICAL, NC_EQUALSIZE),
 
					NWidgetFunction(MakeCargoesLegendLinkGraphGUI),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_LGL_CARGOES_ALL), SetDataTip(STR_LINKGRAPH_LEGEND_ALL, STR_NULL),
 
@@ -610,8 +607,8 @@ void LinkGraphLegendWindow::UpdateWidget
 

	
 
void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
 
{
 
	Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
	if (this->IsWidgetLowered(widget)) br = br.Translate(1, 1);
 
	Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
	if (this->IsWidgetLowered(widget)) br = br.Translate(WidgetDimensions::scaled.pressed, WidgetDimensions::scaled.pressed);
 
	if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
 
		if (this->IsWidgetDisabled(widget)) return;
 
		CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST);
src/misc_gui.cpp
Show inline comments
 
@@ -75,10 +75,10 @@ public:
 
	{
 
		if (widget != WID_LI_BACKGROUND) return;
 

	
 
		Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_TEXTPANEL_TOP, WD_FRAMETEXT_RIGHT, WD_TEXTPANEL_BOTTOM);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.frametext);
 
		for (size_t i = 0; i < this->landinfo_data.size(); i++) {
 
			DrawString(ir, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_HOR_CENTER);
 
			ir.top += FONT_HEIGHT_NORMAL + (i == 0 ? WD_PAR_VSEP_WIDE : WD_PAR_VSEP_NORMAL);
 
			ir.top += FONT_HEIGHT_NORMAL + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
 
		}
 

	
 
		if (!this->cargo_acceptance.empty()) {
 
@@ -91,19 +91,19 @@ public:
 
	{
 
		if (widget != WID_LI_BACKGROUND) return;
 

	
 
		size->height = WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM;
 
		size->height = WidgetDimensions::scaled.frametext.Vertical();
 
		for (size_t i = 0; i < this->landinfo_data.size(); i++) {
 
			uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
			uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal();
 
			size->width = std::max(size->width, width);
 

	
 
			size->height += FONT_HEIGHT_NORMAL + (i == 0 ? WD_PAR_VSEP_WIDE : WD_PAR_VSEP_NORMAL);
 
			size->height += FONT_HEIGHT_NORMAL + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
 
		}
 

	
 
		if (!this->cargo_acceptance.empty()) {
 
			uint width = GetStringBoundingBox(this->cargo_acceptance).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
			uint width = GetStringBoundingBox(this->cargo_acceptance).width + WidgetDimensions::scaled.frametext.Horizontal();
 
			size->width = std::max(size->width, std::min(300u, width));
 
			SetDParamStr(0, cargo_acceptance);
 
			size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT);
 
			size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.frametext.Horizontal());
 
		}
 
	}
 

	
 
@@ -721,20 +721,20 @@ struct TooltipsWindow : public Window
 
		size->height = GetStringHeight(this->string_id, size->width);
 

	
 
		/* Increase slightly to have some space around the box. */
 
		size->width  += 2 + padding.width;
 
		size->height += 2 + padding.height;
 
		size->width  += padding.width  + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height += padding.height + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		/* There is only one widget. */
 
		GfxFillRect(r, PC_BLACK);
 
		GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_LIGHT_YELLOW);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_LIGHT_YELLOW);
 

	
 
		for (uint arg = 0; arg < this->paramcount; arg++) {
 
			SetDParam(arg, this->params[arg]);
 
		}
 
		DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM), this->string_id, TC_FROMSTRING, SA_CENTER);
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect), this->string_id, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnMouseLoop() override
 
@@ -796,20 +796,20 @@ void QueryString::DrawEditBox(const Wind
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Dimension sprite_size = GetSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
 
	int clearbtn_width = sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT;
 
	int clearbtn_width = sprite_size.width + WidgetDimensions::scaled.imgbtn.Horizontal();
 

	
 
	Rect r = wi->GetCurrentRect();
 
	Rect cr = r.WithWidth(clearbtn_width, !rtl);
 
	Rect fr = r.Indent(clearbtn_width, !rtl);
 

	
 
	DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FR_LOWERED : FR_NONE);
 
	DrawSprite(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr.left + WD_IMGBTN_LEFT + (wi->IsLowered() ? 1 : 0), CenterBounds(r.top, r.bottom, sprite_size.height) + (wi->IsLowered() ? 1 : 0));
 
	if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), _colour_gradient[wi->colour & 0xF][2], FILLRECT_CHECKER);
 
	DrawSprite(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr.left + WidgetDimensions::scaled.imgbtn.left + (wi->IsLowered() ? 1 : 0), CenterBounds(r.top, r.bottom, sprite_size.height) + (wi->IsLowered() ? 1 : 0));
 
	if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[wi->colour & 0xF][2], FILLRECT_CHECKER);
 

	
 
	DrawFrameRect(fr, wi->colour, FR_LOWERED | FR_DARKENED);
 
	GfxFillRect(fr.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK);
 
	GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
 

	
 
	fr = fr.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
	fr = fr.Shrink(WidgetDimensions::scaled.framerect);
 
	/* Limit the drawing of the string inside the widget boundaries */
 
	DrawPixelInfo dpi;
 
	if (!FillDrawPixelInfo(&dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
 
@@ -851,9 +851,9 @@ Point QueryString::GetCaretPosition(cons
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Dimension sprite_size = GetSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
 
	int clearbtn_width = sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT;
 
	int clearbtn_width = sprite_size.width + WidgetDimensions::scaled.imgbtn.Horizontal();
 

	
 
	Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
	Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WidgetDimensions::scaled.framerect);
 

	
 
	/* Clamp caret position to be inside out current width. */
 
	const Textbuf *tb = &this->text;
 
@@ -880,9 +880,9 @@ Rect QueryString::GetBoundingRect(const 
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Dimension sprite_size = GetSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
 
	int clearbtn_width = sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT;
 
	int clearbtn_width = sprite_size.width + WidgetDimensions::scaled.imgbtn.Horizontal();
 

	
 
	Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
	Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WidgetDimensions::scaled.framerect);
 

	
 
	/* Clamp caret position to be inside our current width. */
 
	const Textbuf *tb = &this->text;
 
@@ -911,9 +911,9 @@ const char *QueryString::GetCharAtPositi
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Dimension sprite_size = GetSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
 
	int clearbtn_width = sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT;
 
	int clearbtn_width = sprite_size.width + WidgetDimensions::scaled.imgbtn.Horizontal();
 

	
 
	Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
	Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WidgetDimensions::scaled.framerect);
 

	
 
	if (!IsInsideMM(pt.y, r.top, r.bottom)) return nullptr;
 

	
 
@@ -996,9 +996,9 @@ struct QueryStringWindow : public Window
 
	{
 
		if (this->flags & QSF_PASSWORD) {
 
			assert(this->nested_root->smallest_x > 0);
 
			this->warning_size.width = this->nested_root->current_x - (WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
 
			this->warning_size.width = this->nested_root->current_x - WidgetDimensions::scaled.frametext.Horizontal() - WidgetDimensions::scaled.framerect.Horizontal();
 
			this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
 
			this->warning_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
			this->warning_size.height += WidgetDimensions::scaled.frametext.Vertical() + WidgetDimensions::scaled.framerect.Vertical();
 
		} else {
 
			this->warning_size = Dimension{ 0, 0 };
 
		}
 
@@ -1025,7 +1025,7 @@ struct QueryStringWindow : public Window
 
		if (widget != WID_QS_WARNING) return;
 

	
 
		if (this->flags & QSF_PASSWORD) {
 
			DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT + WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP + WD_FRAMETEXT_TOP, WD_FRAMERECT_RIGHT + WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM + WD_FRAMETEXT_BOTTOM),
 
			DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect).Shrink(WidgetDimensions::scaled.frametext),
 
				STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 
@@ -1168,8 +1168,8 @@ struct QueryWindow : public Window {
 
		if (widget != WID_Q_TEXT) return;
 

	
 
		Dimension d = GetStringMultiLineBoundingBox(this->message, *size);
 
		d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
		d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		d.width += WidgetDimensions::scaled.frametext.Horizontal();
 
		d.height += WidgetDimensions::scaled.framerect.Vertical();
 
		*size = d;
 
	}
 

	
 
@@ -1177,7 +1177,7 @@ struct QueryWindow : public Window {
 
	{
 
		if (widget != WID_Q_TEXT) return;
 

	
 
		DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM),
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect),
 
				this->message, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
src/music_gui.cpp
Show inline comments
 
@@ -522,9 +522,9 @@ struct MusicTrackSelectionWindow : publi
 
	{
 
		switch (widget) {
 
			case WID_MTS_LIST_LEFT: {
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK);
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				for (MusicSystem::Playlist::const_iterator song = _music.music_set.begin(); song != _music.music_set.end(); ++song) {
 
					SetDParam(0, song->tracknr);
 
					SetDParam(1, 2);
 
@@ -536,9 +536,9 @@ struct MusicTrackSelectionWindow : publi
 
			}
 

	
 
			case WID_MTS_LIST_RIGHT: {
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK);
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				for (MusicSystem::Playlist::const_iterator song = _music.active_playlist.begin(); song != _music.active_playlist.end(); ++song) {
 
					SetDParam(0, song->tracknr);
 
					SetDParam(1, 2);
 
@@ -712,7 +712,7 @@ struct MusicWindow : public Window {
 
	{
 
		switch (widget) {
 
			case WID_M_TRACK_NR: {
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, 0, WD_BEVEL_BOTTOM), PC_BLACK);
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, 0, WidgetDimensions::scaled.bevel.bottom), PC_BLACK);
 
				if (BaseMusic::GetUsedSet()->num_available == 0) {
 
					break;
 
				}
 
@@ -722,12 +722,12 @@ struct MusicWindow : public Window {
 
					SetDParam(1, 2);
 
					str = STR_MUSIC_TRACK_DIGIT;
 
				}
 
				DrawString(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM), str);
 
				DrawString(r.Shrink(WidgetDimensions::scaled.framerect), str);
 
				break;
 
			}
 

	
 
			case WID_M_TRACK_NAME: {
 
				GfxFillRect(r.Shrink(0, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK);
 
				GfxFillRect(r.Shrink(0, WidgetDimensions::scaled.bevel.top, WidgetDimensions::scaled.bevel.right, WidgetDimensions::scaled.bevel.bottom), PC_BLACK);
 
				StringID str = STR_MUSIC_TITLE_NONE;
 
				MusicSystem::PlaylistEntry entry(_music.GetCurrentSong());
 
				if (BaseMusic::GetUsedSet()->num_available == 0) {
 
@@ -736,7 +736,7 @@ struct MusicWindow : public Window {
 
					str = STR_MUSIC_TITLE_NAME;
 
					SetDParamStr(0, entry.songname);
 
				}
 
				DrawString(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM), str, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(r.Shrink(WidgetDimensions::scaled.framerect), str, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "../window_func.h"
 
#include "../toolbar_gui.h"
 
#include "../core/geometry_func.hpp"
 
#include "../zoom_func.h"
 
#include "network.h"
 
#include "network_client.h"
 
#include "network_base.h"
 
@@ -106,7 +107,7 @@ void CDECL NetworkAddChatMessage(TextCol
 
void NetworkReInitChatBoxSize()
 
{
 
	_chatmsg_box.y       = 3 * FONT_HEIGHT_NORMAL;
 
	_chatmsg_box.height  = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING) + 4;
 
	_chatmsg_box.height  = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4);
 
	_chatmessage_backup  = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactory::GetCurrentBlitter()->GetBytesPerPixel());
 
}
 

	
 
@@ -116,7 +117,7 @@ void NetworkInitChatMessage()
 
	MAX_CHAT_MESSAGES    = _settings_client.gui.network_chat_box_height;
 

	
 
	_chatmsg_list.clear();
 
	_chatmsg_box.x       = 10;
 
	_chatmsg_box.x       = ScaleGUITrad(10);
 
	_chatmsg_box.width   = _settings_client.gui.network_chat_box_width_pct * _screen.width / 100;
 
	NetworkReInitChatBoxSize();
 
	_chatmessage_visible = false;
 
@@ -242,7 +243,7 @@ void NetworkDrawChatMessage()
 

	
 
	for (auto &cmsg : _chatmsg_list) {
 
		if (!show_all && cmsg.remove_time < now) continue;
 
		ypos = DrawStringMultiLine(_chatmsg_box.x + 3, _chatmsg_box.x + _chatmsg_box.width - 1, top, ypos, cmsg.message, cmsg.colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - NETWORK_CHAT_LINE_SPACING;
 
		ypos = DrawStringMultiLine(_chatmsg_box.x + ScaleGUITrad(3), _chatmsg_box.x + _chatmsg_box.width - 1, top, ypos, cmsg.message, cmsg.colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - NETWORK_CHAT_LINE_SPACING;
 
		if (ypos < top) break;
 
	}
 

	
src/network/network_content_gui.cpp
Show inline comments
 
@@ -82,7 +82,7 @@ void ShowContentTextfileWindow(TextfileT
 
static const NWidgetPart _nested_network_content_download_status_window_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_NCDS_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(3, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 30),
 
		NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(4, WidgetDimensions::unscaled.framerect.Vertical() + WidgetDimensions::unscaled.frametext.Vertical() * 2),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(125, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCDS_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
@@ -119,14 +119,17 @@ void BaseNetworkContentDownloadStatusWin
 
{
 
	if (widget != WID_NCDS_BACKGROUND) return;
 

	
 
	Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
	int y = ir.top + WidgetDimensions::scaled.frametext.top;
 

	
 
	/* Draw nice progress bar :) */
 
	DrawFrameRect(r.left + 20, r.top + 4, r.left + 20 + (int)((this->width - 40LL) * this->downloaded_bytes / this->total_bytes), r.top + 14, COLOUR_MAUVE, FR_NONE);
 
	DrawFrameRect(ir.left, y, ir.left + (int)((ir.Width() - 1LL) * this->downloaded_bytes / this->total_bytes), y + FONT_HEIGHT_NORMAL - 1, COLOUR_MAUVE, FR_NONE);
 

	
 
	int y = r.top + 20;
 
	y += WidgetDimensions::scaled.frametext.bottom + FONT_HEIGHT_NORMAL;
 
	SetDParam(0, this->downloaded_bytes);
 
	SetDParam(1, this->total_bytes);
 
	SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes);
 
	DrawString(r.left + 2, r.right - 2, y, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
 
	DrawString(ir.left, ir.right, y, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
	StringID str;
 
	if (this->downloaded_bytes == this->total_bytes) {
 
@@ -140,8 +143,8 @@ void BaseNetworkContentDownloadStatusWin
 
		str = STR_CONTENT_DOWNLOAD_INITIALISE;
 
	}
 

	
 
	y += FONT_HEIGHT_NORMAL + 5;
 
	DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER);
 
	y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.top;
 
	DrawStringMultiLine(ir.left, ir.right, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER);
 
}
 

	
 
void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes)
 
@@ -524,8 +527,6 @@ public:
 
			selected(nullptr),
 
			list_pos(0)
 
	{
 
		this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
 

	
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
 
		this->FinishInitNested(WN_NETWORK_WINDOW_CONTENT_LIST);
 
@@ -556,11 +557,16 @@ public:
 
		this->Window::Close();
 
	}
 

	
 
	void OnInit() override
 
	{
 
		this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		switch (widget) {
 
			case WID_NCL_CHECKBOX:
 
				size->width = this->checkbox_size.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT;
 
				size->width = this->checkbox_size.width + padding.width;
 
				break;
 

	
 
			case WID_NCL_TYPE: {
 
@@ -568,7 +574,7 @@ public:
 
				for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
 
					d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS));
 
				}
 
				size->width = d.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT;
 
				size->width = d.width + padding.width;
 
				break;
 
			}
 

	
 
@@ -617,7 +623,7 @@ public:
 
	void DrawMatrix(const Rect &r) const
 
	{
 
		Rect checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX)->GetCurrentRect();
 
		Rect name = this->GetWidget<NWidgetBase>(WID_NCL_NAME)->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, 0, WD_FRAMERECT_RIGHT, 0);
 
		Rect name = this->GetWidget<NWidgetBase>(WID_NCL_NAME)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
		Rect type = this->GetWidget<NWidgetBase>(WID_NCL_TYPE)->GetCurrentRect();
 

	
 
		/* Fill the matrix with the information */
 
@@ -632,7 +638,7 @@ public:
 
		for (/**/; iter != end; iter++) {
 
			const ContentInfo *ci = *iter;
 

	
 
			if (ci == this->selected) GfxFillRect(mr.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_GREY);
 
			if (ci == this->selected) GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), PC_GREY);
 

	
 
			SpriteID sprite;
 
			SpriteID pal = PAL_NONE;
 
@@ -661,14 +667,14 @@ public:
 
	void DrawDetails(const Rect &r) const
 
	{
 
		/* Height for the title banner */
 
		int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
		int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical();
 

	
 
		Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
 
		tr.top += HEADER_HEIGHT;
 

	
 
		/* Create the nice grayish rectangle at the details top */
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, 0), PC_DARK_BLUE);
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, WidgetDimensions::scaled.bevel.right, 0), PC_DARK_BLUE);
 
		DrawString(hr.left, hr.right, hr.top, STR_CONTENT_DETAIL_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
		/* Draw the total download size */
 
@@ -681,12 +687,12 @@ public:
 
		DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER);
 

	
 
		/* Also show the total download size, so keep some space from the bottom */
 
		tr.bottom -= FONT_HEIGHT_NORMAL + WD_PAR_VSEP_WIDE;
 
		tr.bottom -= FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
 

	
 
		if (this->selected->upgrade) {
 
			SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_UPDATE);
 
			tr.top += WD_PAR_VSEP_WIDE;
 
			tr.top += WidgetDimensions::scaled.vsep_wide;
 
		}
 

	
 
		SetDParamStr(0, this->selected->name);
 
@@ -710,7 +716,7 @@ public:
 
		SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
 
		tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_TYPE);
 

	
 
		tr.top += WD_PAR_VSEP_WIDE;
 
		tr.top += WidgetDimensions::scaled.vsep_wide;
 
		SetDParam(0, this->selected->filesize);
 
		tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_FILESIZE);
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -391,66 +391,71 @@ protected:
 
	 * @param y         from where to draw?
 
	 * @param highlight does the line need to be highlighted?
 
	 */
 
	void DrawServerLine(const NetworkGameList *cur_item, uint y, bool highlight) const
 
	void DrawServerLine(const NetworkGameList *cur_item, int y, bool highlight) const
 
	{
 
		const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NG_NAME);
 
		const NWidgetBase *nwi_info = this->GetWidget<NWidgetBase>(WID_NG_INFO);
 
		Rect name = this->GetWidget<NWidgetBase>(WID_NG_NAME)->GetCurrentRect();
 
		Rect info = this->GetWidget<NWidgetBase>(WID_NG_INFO)->GetCurrentRect();
 

	
 
		/* show highlighted item with a different colour */
 
		if (highlight) GfxFillRect(nwi_name->pos_x + 1, y + 1, nwi_info->pos_x + nwi_info->current_x - 2, y + this->resize.step_height - 2, PC_GREY);
 
		if (highlight) {
 
			Rect r = {name.left, y, info.right, y + (int)this->resize.step_height - 1};
 
			Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
			GfxFillRect(ir.left, ir.top, ir.right, ir.bottom, PC_GREY);
 
		}
 

	
 
		/* offsets to vertically centre text and icons */
 
		int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2 + 1;
 
		int icon_y_offset = (this->resize.step_height - GetSpriteSize(SPR_BLOT).height) / 2;
 
		int lock_y_offset = (this->resize.step_height - GetSpriteSize(SPR_LOCK).height) / 2;
 

	
 
		DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + text_y_offset, cur_item->info.server_name, TC_BLACK);
 
		name = name.Shrink(WidgetDimensions::scaled.framerect);
 
		DrawString(name.left, name.right, y + text_y_offset, cur_item->info.server_name, TC_BLACK);
 

	
 
		/* only draw details if the server is online */
 
		if (cur_item->status == NGLS_ONLINE) {
 
			const NWidgetServerListHeader *nwi_header = this->GetWidget<NWidgetServerListHeader>(WID_NG_HEADER);
 

	
 
			if (nwi_header->IsWidgetVisible(WID_NG_CLIENTS)) {
 
				const NWidgetBase *nwi_clients = this->GetWidget<NWidgetBase>(WID_NG_CLIENTS);
 
				Rect clients = this->GetWidget<NWidgetBase>(WID_NG_CLIENTS)->GetCurrentRect();
 
				SetDParam(0, cur_item->info.clients_on);
 
				SetDParam(1, cur_item->info.clients_max);
 
				SetDParam(2, cur_item->info.companies_on);
 
				SetDParam(3, cur_item->info.companies_max);
 
				DrawString(nwi_clients->pos_x, nwi_clients->pos_x + nwi_clients->current_x - 1, y + text_y_offset, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(clients.left, clients.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
 
			}
 

	
 
			if (nwi_header->IsWidgetVisible(WID_NG_MAPSIZE)) {
 
				/* map size */
 
				const NWidgetBase *nwi_mapsize = this->GetWidget<NWidgetBase>(WID_NG_MAPSIZE);
 
				Rect mapsize = this->GetWidget<NWidgetBase>(WID_NG_MAPSIZE)->GetCurrentRect();
 
				SetDParam(0, cur_item->info.map_width);
 
				SetDParam(1, cur_item->info.map_height);
 
				DrawString(nwi_mapsize->pos_x, nwi_mapsize->pos_x + nwi_mapsize->current_x - 1, y + text_y_offset, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(mapsize.left, mapsize.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
 
			}
 

	
 
			if (nwi_header->IsWidgetVisible(WID_NG_DATE)) {
 
				/* current date */
 
				const NWidgetBase *nwi_date = this->GetWidget<NWidgetBase>(WID_NG_DATE);
 
				Rect date = this->GetWidget<NWidgetBase>(WID_NG_DATE)->GetCurrentRect();
 
				YearMonthDay ymd;
 
				ConvertDateToYMD(cur_item->info.game_date, &ymd);
 
				SetDParam(0, ymd.year);
 
				DrawString(nwi_date->pos_x, nwi_date->pos_x + nwi_date->current_x - 1, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
 
				DrawString(date.left, date.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
 
			}
 

	
 
			if (nwi_header->IsWidgetVisible(WID_NG_YEARS)) {
 
				/* number of years the game is running */
 
				const NWidgetBase *nwi_years = this->GetWidget<NWidgetBase>(WID_NG_YEARS);
 
				Rect years = this->GetWidget<NWidgetBase>(WID_NG_YEARS)->GetCurrentRect();
 
				YearMonthDay ymd_cur, ymd_start;
 
				ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
 
				ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
 
				SetDParam(0, ymd_cur.year - ymd_start.year);
 
				DrawString(nwi_years->pos_x, nwi_years->pos_x + nwi_years->current_x - 1, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
 
				DrawString(years.left, years.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
 
			}
 

	
 
			/* draw a lock if the server is password protected */
 
			if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + this->lock_offset, y + lock_y_offset);
 
			if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, info.left + this->lock_offset, y + lock_y_offset);
 

	
 
			/* draw red or green icon, depending on compatibility with server */
 
			DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), nwi_info->pos_x + this->blot_offset, y + icon_y_offset + 1);
 
			DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), info.left + this->blot_offset, y + icon_y_offset + 1);
 
		}
 
	}
 

	
 
@@ -473,10 +478,6 @@ public:
 
		this->list_pos = SLP_INVALID;
 
		this->server = nullptr;
 

	
 
		this->lock_offset = 5;
 
		this->blot_offset = this->lock_offset + 3 + GetSpriteSize(SPR_LOCK).width;
 
		this->flag_offset = this->blot_offset + 2 + GetSpriteSize(SPR_BLOT).width;
 

	
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
 
		this->FinishInitNested(WN_NETWORK_WINDOW_GAME);
 
@@ -512,17 +513,24 @@ public:
 
		this->last_sorting = this->servers.GetListing();
 
	}
 

	
 
	void OnInit() override
 
	{
 
		this->lock_offset = ScaleGUITrad(5);
 
		this->blot_offset = this->lock_offset + ScaleGUITrad(3) + GetSpriteSize(SPR_LOCK).width;
 
		this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width;
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		switch (widget) {
 
			case WID_NG_MATRIX:
 
				resize->height = WD_MATRIX_TOP + std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
 
				resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
 
				fill->height = resize->height;
 
				size->height = 12 * resize->height;
 
				break;
 

	
 
			case WID_NG_LASTJOINED:
 
				size->height = WD_MATRIX_TOP + std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
 
				size->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
 
				break;
 

	
 
			case WID_NG_LASTJOINED_SPACER:
 
@@ -634,15 +642,15 @@ public:
 
		NetworkGameList *sel = this->server;
 

	
 
		/* Height for the title banner */
 
		int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
		int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical();
 

	
 
		Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
 
		tr.top += HEADER_HEIGHT;
 

	
 
		/* Draw the right menu */
 
		/* Create the nice grayish rectangle at the details top */
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, 0), PC_DARK_BLUE);
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, WidgetDimensions::scaled.bevel.right, 0), PC_DARK_BLUE);
 
		if (sel == nullptr) {
 
			DrawString(hr.left, hr.right, hr.top, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 
		} else if (sel->status != NGLS_ONLINE) {
 
@@ -704,7 +712,7 @@ public:
 
				tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_GAMESCRIPT); // gamescript name and version
 
			}
 

	
 
			tr.top += WD_PAR_VSEP_WIDE;
 
			tr.top += WidgetDimensions::scaled.vsep_wide;
 

	
 
			if (!sel->info.compatible) {
 
				DrawString(tr, sel->info.version_compatible ? STR_NETWORK_SERVER_LIST_GRF_MISMATCH : STR_NETWORK_SERVER_LIST_VERSION_MISMATCH, TC_FROMSTRING, SA_HOR_CENTER); // server mismatch
 
@@ -959,7 +967,7 @@ static const NWidgetPart _nested_network
 
					EndContainer(),
 
					NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_DETAILS),
 
						NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(5, 5, 5),
 
							NWidget(WWT_EMPTY, INVALID_COLOUR, WID_NG_DETAILS_SPACER), SetMinimalSize(140, 0), SetMinimalTextLines(15, 24 + WD_PAR_VSEP_NORMAL), SetResize(0, 1), SetFill(1, 1), // Make sure it's at least this wide
 
							NWidget(WWT_EMPTY, INVALID_COLOUR, WID_NG_DETAILS_SPACER), SetMinimalSize(140, 0), SetMinimalTextLines(15, 24 + WidgetDimensions::unscaled.vsep_normal), SetResize(0, 1), SetFill(1, 1), // Make sure it's at least this wide
 
							NWidget(NWID_HORIZONTAL, NC_NONE), SetPIP(5, 5, 5),
 
								NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NG_NEWGRF_MISSING_SEL),
 
									NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NEWGRF_MISSING), SetFill(1, 0), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP),
 
@@ -1073,7 +1081,7 @@ struct NetworkStartServerWindow : public
 
		switch (widget) {
 
			case WID_NSS_SETPWD:
 
				/* If password is set, draw red '*' next to 'Set password' button. */
 
				if (!_settings_client.network.server_password.empty()) DrawString(r.right + WD_FRAMERECT_LEFT, this->width - WD_FRAMERECT_RIGHT, r.top, "*", TC_RED);
 
				if (!_settings_client.network.server_password.empty()) DrawString(r.right + WidgetDimensions::scaled.framerect.left, this->width - WidgetDimensions::scaled.framerect.right, r.top, "*", TC_RED);
 
		}
 
	}
 

	
 
@@ -1438,8 +1446,8 @@ public:
 
		disabled(disabled)
 
	{
 
		Dimension d = GetSpriteSize(sprite);
 
		this->height = d.height + ScaleGUITrad(WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
		this->width = d.width + ScaleGUITrad(WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
 
		this->height = d.height + WidgetDimensions::scaled.framerect.Vertical();
 
		this->width = d.width + WidgetDimensions::scaled.framerect.Horizontal();
 
	}
 
	virtual ~ButtonCommon() {}
 

	
 
@@ -1681,10 +1689,10 @@ private:
 
	ButtonCommon *GetButtonAtPoint(Point pt)
 
	{
 
		uint index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CL_MATRIX);
 
		NWidgetBase *widget_matrix = this->GetWidget<NWidgetBase>(WID_CL_MATRIX);
 
		Rect matrix = this->GetWidget<NWidgetBase>(WID_CL_MATRIX)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint x = rtl ? (uint)widget_matrix->pos_x + WD_FRAMERECT_LEFT : widget_matrix->current_x - WD_FRAMERECT_RIGHT;
 
		uint x = rtl ? matrix.left : matrix.right;
 

	
 
		/* Find the buttons for this row. */
 
		auto button_find = this->buttons.find(index);
 
@@ -1699,7 +1707,7 @@ private:
 
				return button.get();
 
			}
 

	
 
			int width = button->width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
			int width = button->width + WidgetDimensions::scaled.framerect.Horizontal();
 
			x += rtl ? width : -width;
 
		}
 

	
 
@@ -1744,8 +1752,8 @@ public:
 

	
 
			case WID_CL_MATRIX: {
 
				uint height = std::max({GetSpriteSize(SPR_COMPANY_ICON).height, GetSpriteSize(SPR_JOIN).height, GetSpriteSize(SPR_ADMIN).height, GetSpriteSize(SPR_CHAT).height});
 
				height += ScaleGUITrad(WD_FRAMERECT_TOP) + ScaleGUITrad(WD_FRAMERECT_BOTTOM);
 
				this->line_height = std::max(height, (uint)FONT_HEIGHT_NORMAL) + ScaleGUITrad(WD_MATRIX_TOP + WD_MATRIX_BOTTOM);
 
				height += WidgetDimensions::scaled.framerect.Vertical();
 
				this->line_height = std::max(height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
 

	
 
				resize->width = 1;
 
				resize->height = this->line_height;
 
@@ -1836,14 +1844,14 @@ public:
 
				int index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CL_MATRIX);
 

	
 
				bool rtl = _current_text_dir == TD_RTL;
 
				NWidgetBase *widget_matrix = this->GetWidget<NWidgetBase>(WID_CL_MATRIX);
 
				Rect matrix = this->GetWidget<NWidgetBase>(WID_CL_MATRIX)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 

	
 
				Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
 
				uint text_left = widget_matrix->pos_x + (rtl ? (uint)WD_FRAMERECT_LEFT : d.width + 8);
 
				uint text_right = widget_matrix->pos_x + widget_matrix->current_x - (rtl ? d.width + 8 : (uint)WD_FRAMERECT_RIGHT);
 
				uint text_left  = matrix.left  + (rtl ? 0 : d.width + WidgetDimensions::scaled.hsep_wide);
 
				uint text_right = matrix.right - (rtl ? d.width + WidgetDimensions::scaled.hsep_wide : 0);
 

	
 
				Dimension d2 = GetSpriteSize(SPR_PLAYER_SELF);
 
				uint offset_x = CLIENT_OFFSET_LEFT - d2.width - 3;
 
				uint offset_x = CLIENT_OFFSET_LEFT - d2.width - ScaleGUITrad(3);
 

	
 
				uint player_icon_x = rtl ? text_right - offset_x - d2.width : text_left + offset_x;
 

	
 
@@ -1976,23 +1984,26 @@ public:
 
	 * @param y The y-position to start with the buttons.
 
	 * @param buttons The buttons to draw.
 
	 */
 
	void DrawButtons(uint &x, uint y, const std::vector<std::unique_ptr<ButtonCommon>> &buttons) const
 
	void DrawButtons(int &x, uint y, const std::vector<std::unique_ptr<ButtonCommon>> &buttons) const
 
	{
 
		Rect r;
 

	
 
		for (auto &button : buttons) {
 
			bool rtl = _current_text_dir == TD_RTL;
 

	
 
			uint left = rtl ? x : x - button->width;
 
			uint right = rtl ? x + button->width : x;
 

	
 
			int offset = std::max(0, ((int)(this->line_height + 1) - (int)button->height) / 2);
 
			int offset = (this->line_height - button->height) / 2;
 
			r.left = rtl ? x : x - button->width + 1;
 
			r.right = rtl ? x + button->width - 1 : x;
 
			r.top = y + offset;
 
			r.bottom = r.top + button->height - 1;
 

	
 
			DrawFrameRect(left, y + offset, right, y + offset + button->height, button->colour, FR_NONE);
 
			DrawSprite(button->sprite, PAL_NONE, left + ScaleGUITrad(WD_FRAMERECT_LEFT), y + offset + ScaleGUITrad(WD_FRAMERECT_TOP));
 
			DrawFrameRect(r, button->colour, FR_NONE);
 
			DrawSprite(button->sprite, PAL_NONE, r.left + WidgetDimensions::scaled.framerect.left, r.top + WidgetDimensions::scaled.framerect.top);
 
			if (button->disabled) {
 
				GfxFillRect(left + 1, y + offset + 1, right - 1, y + offset + button->height - 1, _colour_gradient[button->colour & 0xF][2], FILLRECT_CHECKER);
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[button->colour & 0xF][2], FILLRECT_CHECKER);
 
			}
 

	
 
			int width = button->width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
			int width = button->width + WidgetDimensions::scaled.hsep_normal;
 
			x += rtl ? width : -width;
 
		}
 
	}
 
@@ -2000,30 +2011,27 @@ public:
 
	/**
 
	 * Draw a company and its clients on the matrix.
 
	 * @param company_id The company to draw.
 
	 * @param left The most left pixel of the line.
 
	 * @param right The most right pixel of the line.
 
	 * @param top The top of the first line.
 
	 * @param r The rect to draw within.
 
	 * @param line The Nth line we are drawing. Updated during this function.
 
	 */
 
	void DrawCompany(CompanyID company_id, uint left, uint right, uint top, uint &line) const
 
	void DrawCompany(CompanyID company_id, const Rect &r, uint &line) const
 
	{
 
		bool rtl = _current_text_dir == TD_RTL;
 
		int text_y_offset = std::max(0, ((int)(this->line_height + 1) - (int)FONT_HEIGHT_NORMAL) / 2) + WD_MATRIX_BOTTOM;
 
		int text_y_offset = CenterBounds(0, this->line_height, FONT_HEIGHT_NORMAL);
 

	
 
		Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
 
		int offset = std::max(0, ((int)(this->line_height + 1) - (int)d.height) / 2);
 

	
 
		uint text_left = left + (rtl ? (uint)WD_FRAMERECT_LEFT : d.width + 8);
 
		uint text_right = right - (rtl ? d.width + 8 : (uint)WD_FRAMERECT_RIGHT);
 
		int offset = CenterBounds(0, this->line_height, d.height);
 

	
 
		uint line_start = this->vscroll->GetPosition();
 
		uint line_end = line_start + this->vscroll->GetCapacity();
 

	
 
		uint y = top + (this->line_height * (line - line_start));
 
		uint y = r.top + (this->line_height * (line - line_start));
 

	
 
		/* Draw the company line (if in range of scrollbar). */
 
		if (IsInsideMM(line, line_start, line_end)) {
 
			uint x = rtl ? text_left : text_right;
 
			int icon_left = r.WithWidth(d.width, rtl).left;
 
			Rect tr = r.Indent(d.width + WidgetDimensions::scaled.hsep_normal, rtl);
 
			int &x = rtl ? tr.left : tr.right;
 

	
 
			/* If there are buttons for this company, draw them. */
 
			auto button_find = this->buttons.find(line);
 
@@ -2032,17 +2040,17 @@ public:
 
			}
 

	
 
			if (company_id == COMPANY_SPECTATOR) {
 
				DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, rtl ? right - d.width - 4 : left + 4, y + offset);
 
				DrawString(rtl ? x : text_left, rtl ? text_right : x, y + text_y_offset, STR_NETWORK_CLIENT_LIST_SPECTATORS, TC_SILVER);
 
				DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, icon_left, y + offset);
 
				DrawString(tr.left, tr.right, y + text_y_offset, STR_NETWORK_CLIENT_LIST_SPECTATORS, TC_SILVER);
 
			} else if (company_id == COMPANY_NEW_COMPANY) {
 
				DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, rtl ? right - d.width - 4 : left + 4, y + offset);
 
				DrawString(rtl ? x : text_left, rtl ? text_right : x, y + text_y_offset, STR_NETWORK_CLIENT_LIST_NEW_COMPANY, TC_WHITE);
 
				DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, icon_left, y + offset);
 
				DrawString(tr.left, tr.right, y + text_y_offset, STR_NETWORK_CLIENT_LIST_NEW_COMPANY, TC_WHITE);
 
			} else {
 
				DrawCompanyIcon(company_id, rtl ? right - d.width - 4 : left + 4, y + offset);
 
				DrawCompanyIcon(company_id, icon_left, y + offset);
 

	
 
				SetDParam(0, company_id);
 
				SetDParam(1, company_id);
 
				DrawString(rtl ? x : text_left, rtl ? text_right : x, y + text_y_offset, STR_COMPANY_NAME, TC_SILVER);
 
				DrawString(tr.left, tr.right, y + text_y_offset, STR_COMPANY_NAME, TC_SILVER);
 
			}
 
		}
 

	
 
@@ -2054,11 +2062,12 @@ public:
 

	
 
			/* Draw the player line (if in range of scrollbar). */
 
			if (IsInsideMM(line, line_start, line_end)) {
 
				uint x = rtl ? text_left : text_right;
 
				Rect tr = r.Indent(WidgetDimensions::scaled.hsep_indent, rtl);
 

	
 
				/* If there are buttons for this client, draw them. */
 
				auto button_find = this->buttons.find(line);
 
				if (button_find != this->buttons.end()) {
 
					int &x = rtl ? tr.left : tr.right;
 
					this->DrawButtons(x, y, button_find->second);
 
				}
 

	
 
@@ -2071,13 +2080,13 @@ public:
 

	
 
				if (player_icon != 0) {
 
					Dimension d2 = GetSpriteSize(player_icon);
 
					uint offset_x = CLIENT_OFFSET_LEFT - 3;
 
					int offset_y = std::max(0, ((int)(this->line_height + 1) - (int)d2.height) / 2);
 
					DrawSprite(player_icon, PALETTE_TO_GREY, rtl ? text_right - offset_x : text_left + offset_x - d2.width, y + offset_y);
 
					int offset_y = CenterBounds(0, this->line_height, d2.height);
 
					DrawSprite(player_icon, PALETTE_TO_GREY, rtl ? tr.right - d2.width : tr.left, y + offset_y);
 
					tr = tr.Indent(d2.width + WidgetDimensions::scaled.hsep_normal, rtl);
 
				}
 

	
 
				SetDParamStr(0, ci->client_name);
 
				DrawString(rtl ? x : text_left + CLIENT_OFFSET_LEFT, rtl ? text_right - CLIENT_OFFSET_LEFT : x, y + text_y_offset, STR_JUST_RAW_STRING, TC_BLACK);
 
				DrawString(tr.left, tr.right, y + text_y_offset, STR_JUST_RAW_STRING, TC_BLACK);
 
			}
 

	
 
			y += this->line_height;
 
@@ -2089,31 +2098,32 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_CL_MATRIX: {
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero);
 
				uint line = 0;
 

	
 
				if (this->hover_index >= 0) {
 
					Rect br = r.WithHeight(this->line_height).Translate(0, this->hover_index * this->line_height);
 
					GfxFillRect(br.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), GREY_SCALE(9));
 
					GfxFillRect(br.Shrink(WidgetDimensions::scaled.bevel), GREY_SCALE(9));
 
				}
 

	
 
				NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
 
				CompanyID client_playas = own_ci == nullptr ? COMPANY_SPECTATOR : own_ci->client_playas;
 

	
 
				if (client_playas == COMPANY_SPECTATOR && !NetworkMaxCompaniesReached()) {
 
					this->DrawCompany(COMPANY_NEW_COMPANY, r.left, r.right, r.top, line);
 
					this->DrawCompany(COMPANY_NEW_COMPANY, ir, line);
 
				}
 

	
 
				if (client_playas != COMPANY_SPECTATOR) {
 
					this->DrawCompany(client_playas, r.left, r.right, r.top, line);
 
					this->DrawCompany(client_playas, ir, line);
 
				}
 

	
 
				for (const Company *c : Company::Iterate()) {
 
					if (client_playas == c->index) continue;
 
					this->DrawCompany(c->index, r.left, r.right, r.top, line);
 
					this->DrawCompany(c->index, ir, line);
 
				}
 

	
 
				/* Spectators */
 
				this->DrawCompany(COMPANY_SPECTATOR, r.left, r.right, r.top, line);
 
				this->DrawCompany(COMPANY_SPECTATOR, ir, line);
 

	
 
				break;
 
			}
 
@@ -2160,8 +2170,10 @@ struct NetworkJoinStatusWindow : Window 
 
	{
 
		if (widget != WID_NJS_BACKGROUND) return;
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 

	
 
		uint8 progress; // used for progress bar
 
		DrawString(r.left + 2, r.right - 2, r.top + 20, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
 
		DrawString(ir.left, ir.right, ir.top + 20, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
 
		switch (_network_join_status) {
 
			case NETWORK_JOIN_STATUS_CONNECTING: case NETWORK_JOIN_STATUS_AUTHORIZING:
 
			case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO:
 
@@ -2169,13 +2181,13 @@ struct NetworkJoinStatusWindow : Window 
 
				break;
 
			case NETWORK_JOIN_STATUS_WAITING:
 
				SetDParam(0, _network_join_waiting);
 
				DrawString(r.left + 2, r.right - 2, r.top + 20 + FONT_HEIGHT_NORMAL, STR_NETWORK_CONNECTING_WAITING, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(ir.left, ir.right, ir.top + 20 + FONT_HEIGHT_NORMAL, STR_NETWORK_CONNECTING_WAITING, TC_FROMSTRING, SA_HOR_CENTER);
 
				progress = 15; // third stage is 15%
 
				break;
 
			case NETWORK_JOIN_STATUS_DOWNLOADING:
 
				SetDParam(0, _network_join_bytes);
 
				SetDParam(1, _network_join_bytes_total);
 
				DrawString(r.left + 2, r.right - 2, r.top + 20 + FONT_HEIGHT_NORMAL, _network_join_bytes_total == 0 ? STR_NETWORK_CONNECTING_DOWNLOADING_1 : STR_NETWORK_CONNECTING_DOWNLOADING_2, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(ir.left, ir.right, ir.top + 20 + FONT_HEIGHT_NORMAL, _network_join_bytes_total == 0 ? STR_NETWORK_CONNECTING_DOWNLOADING_1 : STR_NETWORK_CONNECTING_DOWNLOADING_2, TC_FROMSTRING, SA_HOR_CENTER);
 
				if (_network_join_bytes_total == 0) {
 
					progress = 15; // We don't have the final size yet; the server is still compressing!
 
					break;
 
@@ -2213,7 +2225,7 @@ struct NetworkJoinStatusWindow : Window 
 
		width = std::max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_2).width);
 

	
 
		/* Give a bit more clearing for the widest strings than strictly needed */
 
		size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10;
 
		size->width = width + padding.width + WidgetDimensions::scaled.hsep_indent;
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
@@ -2300,9 +2312,9 @@ struct NetworkCompanyPasswordWindow : pu
 
	void UpdateWarningStringSize()
 
	{
 
		assert(this->nested_root->smallest_x > 0);
 
		this->warning_size.width = this->nested_root->current_x - (WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
 
		this->warning_size.width = this->nested_root->current_x - (WidgetDimensions::scaled.framerect.Horizontal()) * 2;
 
		this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
 
		this->warning_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		this->warning_size.height += (WidgetDimensions::scaled.framerect.Vertical()) * 2;
 

	
 
		this->ReInit();
 
	}
 
@@ -2318,7 +2330,7 @@ struct NetworkCompanyPasswordWindow : pu
 
	{
 
		if (widget != WID_NCP_WARNING) return;
 

	
 
		DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM),
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect),
 
			STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
@@ -2411,14 +2423,14 @@ struct NetworkAskRelayWindow : public Wi
 
	{
 
		if (widget == WID_NAR_TEXT) {
 
			*size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT);
 
			size->height = GetStringHeight(STR_NETWORK_ASK_RELAY_TEXT, size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT) + WD_FRAMETEXT_BOTTOM + WD_FRAMETEXT_TOP;
 
			size->height = GetStringHeight(STR_NETWORK_ASK_RELAY_TEXT, size->width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical();
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget == WID_NAR_TEXT) {
 
			DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -371,15 +371,15 @@ struct NewGRFInspectWindow : Window {
 
			case WID_NGRFI_VEH_CHAIN: {
 
				assert(this->HasChainIndex());
 
				GrfSpecFeature f = GetFeatureNum(this->window_number);
 
				size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WD_BEVEL_TOP + WD_BEVEL_BOTTOM);
 
				size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
 
				break;
 
			}
 

	
 
			case WID_NGRFI_MAINPANEL:
 
				resize->height = std::max(11, FONT_HEIGHT_NORMAL + 1);
 
				resize->height = std::max(11, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal);
 
				resize->width  = 1;
 

	
 
				size->height = 5 * resize->height + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
				size->height = 5 * resize->height + WidgetDimensions::scaled.frametext.Vertical();
 
				break;
 
		}
 
	}
 
@@ -402,7 +402,7 @@ struct NewGRFInspectWindow : Window {
 
		offset -= this->vscroll->GetPosition();
 
		if (offset < 0 || offset >= this->vscroll->GetCapacity()) return;
 

	
 
		::DrawString(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP + (offset * this->resize.step_height), WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), buf, TC_BLACK);
 
		::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), buf, TC_BLACK);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -423,7 +423,7 @@ struct NewGRFInspectWindow : Window {
 
					if (u == v) sel_end = total_width;
 
				}
 

	
 
				Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				int width = br.Width();
 
				int skip = 0;
 
				if (total_width > width) {
 
@@ -580,7 +580,7 @@ struct NewGRFInspectWindow : Window {
 
				if (nif->variables == nullptr) return;
 

	
 
				/* Get the line, make sure it's within the boundaries. */
 
				int line = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NGRFI_MAINPANEL, WD_FRAMETEXT_TOP);
 
				int line = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NGRFI_MAINPANEL, WidgetDimensions::scaled.frametext.top);
 
				if (line == INT_MAX) return;
 

	
 
				/* Find the variable related to the line */
 
@@ -606,7 +606,7 @@ struct NewGRFInspectWindow : Window {
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_NGRFI_MAINPANEL, WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM);
 
		this->vscroll->SetCapacityFromWidget(this, WID_NGRFI_MAINPANEL, WidgetDimensions::scaled.frametext.Vertical());
 
	}
 

	
 
	/**
 
@@ -874,7 +874,7 @@ struct SpriteAlignerWindow : Window {
 
			case WID_SA_SPRITE: {
 
				/* Center the sprite ourselves */
 
				const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
 
				Rect ir = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
				int x = -UnScaleGUI(spr->x_offs) + (ir.Width()  - UnScaleGUI(spr->width) ) / 2;
 
				int y = -UnScaleGUI(spr->y_offs) + (ir.Height() - UnScaleGUI(spr->height)) / 2;
 

	
 
@@ -897,7 +897,7 @@ struct SpriteAlignerWindow : Window {
 
				std::vector<SpriteID> &list = _newgrf_debug_sprite_picker.sprites;
 
				int max = std::min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)list.size());
 

	
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
				for (int i = this->vscroll->GetPosition(); i < max; i++) {
 
					SetDParam(0, list[i]);
 
					DrawString(ir, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
src/newgrf_gui.cpp
Show inline comments
 
@@ -68,7 +68,7 @@ void ShowNewGRFError()
 

	
 
static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params)
 
{
 
	Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
	Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
 
	if (c->error != nullptr) {
 
		char message[512];
 
		SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages
 
@@ -213,7 +213,7 @@ struct NewGRFParametersWindow : public W
 
			}
 

	
 
			case WID_NP_BACKGROUND:
 
				this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
 
				this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height;
 

	
 
				resize->width = 1;
 
				resize->height = this->line_height;
 
@@ -222,14 +222,14 @@ struct NewGRFParametersWindow : public W
 

	
 
			case WID_NP_DESCRIPTION:
 
				/* Minimum size of 4 lines. The 500 is the default size of the window. */
 
				Dimension suggestion = {500 - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT, (uint)FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM};
 
				Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), (uint)FONT_HEIGHT_NORMAL * 4 + WidgetDimensions::scaled.frametext.Vertical()};
 
				for (uint i = 0; i < this->grf_config->param_info.size(); i++) {
 
					const GRFParameterInfo *par_info = this->grf_config->param_info[i];
 
					if (par_info == nullptr) continue;
 
					const char *desc = GetGRFStringFromGRFText(par_info->desc);
 
					if (desc == nullptr) continue;
 
					Dimension d = GetStringMultiLineBoundingBox(desc, suggestion);
 
					d.height += WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM;
 
					d.height += WidgetDimensions::scaled.frametext.Vertical();
 
					suggestion = maxdim(d, suggestion);
 
				}
 
				size->height = suggestion.height;
 
@@ -253,16 +253,16 @@ struct NewGRFParametersWindow : public W
 
			if (par_info == nullptr) return;
 
			const char *desc = GetGRFStringFromGRFText(par_info->desc);
 
			if (desc == nullptr) return;
 
			DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT, WD_TEXTPANEL_TOP, WD_FRAMERECT_RIGHT, WD_TEXTPANEL_BOTTOM), desc, TC_BLACK);
 
			DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect), desc, TC_BLACK);
 
			return;
 
		} else if (widget != WID_NP_BACKGROUND) {
 
			return;
 
		}
 

	
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, 0, WD_FRAMERECT_RIGHT, 0);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.frametext, RectPadding::zero);
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint buttons_left = rtl ? ir.right - SETTING_BUTTON_WIDTH - 3 : ir.left + 4;
 
		Rect tr = r.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
 
		uint buttons_left = rtl ? ir.right - SETTING_BUTTON_WIDTH : ir.left;
 
		Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide, rtl);
 

	
 
		int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 
@@ -347,10 +347,9 @@ struct NewGRFParametersWindow : public W
 
					this->clicked_dropdown = false;
 
				}
 

	
 
				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_NP_BACKGROUND);
 
				int x = pt.x - wid->pos_x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
 
				x -= 4;
 
				Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext, RectPadding::zero);
 
				int x = pt.x - r.left;
 
				if (_current_text_dir == TD_RTL) x = r.Width() - 1 - x;
 

	
 
				GRFParameterInfo *par_info = (num < this->grf_config->param_info.size()) ? this->grf_config->param_info[num] : nullptr;
 
				if (par_info == nullptr) par_info = GetDummyParameterInfo(num);
 
@@ -364,8 +363,7 @@ struct NewGRFParametersWindow : public W
 
						this->clicked_dropdown = false;
 
						this->closing_dropdown = false;
 
					} else {
 
						const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_NP_BACKGROUND);
 
						int rel_y = (pt.y - (int)wid->pos_y) % this->line_height;
 
						int rel_y = (pt.y - r.top) % this->line_height;
 

	
 
						Rect wi_rect;
 
						wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);;
 
@@ -731,25 +729,28 @@ struct NewGRFWindow : public Window, New
 
			case WID_NS_FILE_LIST:
 
			{
 
				Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
 
				resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL + 2U);
 
				resize->height = std::max<uint>(d.height + 2U, FONT_HEIGHT_NORMAL);
 
				size->height = std::max(size->height, padding.height + 6 * resize->height);
 
				break;
 
			}
 

	
 
			case WID_NS_AVAIL_LIST:
 
				resize->height = std::max(12, FONT_HEIGHT_NORMAL + 2);
 
			{
 
				Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
 
				resize->height = std::max<uint>(d.height + 2U, FONT_HEIGHT_NORMAL);
 
				size->height = std::max(size->height, padding.height + 8 * resize->height);
 
				break;
 
			}
 

	
 
			case WID_NS_NEWGRF_INFO_TITLE: {
 
				Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE);
 
				size->height = std::max(size->height, dim.height + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM);
 
				size->width  = std::max(size->width,  dim.width  + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
 
				size->height = std::max(size->height, dim.height + WidgetDimensions::scaled.frametext.Vertical());
 
				size->width  = std::max(size->width,  dim.width  + WidgetDimensions::scaled.frametext.Horizontal());
 
				break;
 
			}
 

	
 
			case WID_NS_NEWGRF_INFO:
 
				size->height = std::max(size->height, WD_FRAMERECT_TOP + 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + padding.height + 2);
 
				size->height = std::max<uint>(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * FONT_HEIGHT_NORMAL);
 
				break;
 

	
 
			case WID_NS_PRESET_LIST: {
 
@@ -833,10 +834,10 @@ struct NewGRFWindow : public Window, New
 
	{
 
		switch (widget) {
 
			case WID_NS_FILE_LIST: {
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_NS_FILE_LIST)->resize_y;
 
				Dimension square = GetSpriteSize(SPR_SQUARE);
 
				Dimension warning = GetSpriteSize(SPR_WARNING_SIGN);
 
@@ -882,10 +883,10 @@ struct NewGRFWindow : public Window, New
 
			}
 

	
 
			case WID_NS_AVAIL_LIST: {
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				GfxFillRect(br, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y;
 
				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 
				uint min_index = this->vscroll2->GetPosition();
 
@@ -903,11 +904,12 @@ struct NewGRFWindow : public Window, New
 
				break;
 
			}
 

	
 
			case WID_NS_NEWGRF_INFO_TITLE:
 
			case WID_NS_NEWGRF_INFO_TITLE: {
 
				/* Create the nice grayish rectangle at the details top. */
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_DARK_BLUE);
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_DARK_BLUE);
 
				DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
			case WID_NS_NEWGRF_INFO: {
 
				const GRFConfig *selected = this->active_sel;
 
@@ -1782,8 +1784,8 @@ public:
 
	}
 
};
 

	
 
const uint NWidgetNewGRFDisplay::INTER_LIST_SPACING      = WD_RESIZEBOX_WIDTH + 1;
 
const uint NWidgetNewGRFDisplay::INTER_COLUMN_SPACING    = WD_RESIZEBOX_WIDTH;
 
const uint NWidgetNewGRFDisplay::INTER_COLUMN_SPACING    = 12;
 
const uint NWidgetNewGRFDisplay::INTER_LIST_SPACING      = NWidgetNewGRFDisplay::INTER_COLUMN_SPACING + 1;
 
const uint NWidgetNewGRFDisplay::MAX_EXTRA_INFO_WIDTH    = 150;
 
const uint NWidgetNewGRFDisplay::MIN_EXTRA_FOR_3_COLUMNS = 50;
 

	
 
@@ -1791,7 +1793,7 @@ static const NWidgetPart _nested_newgrf_
 
	/* Left side, presets. */
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_TEXT, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_SELECT_PRESET, STR_NULL),
 
				SetPadding(0, WD_FRAMETEXT_RIGHT, 0, 0),
 
				SetPadding(0, WidgetDimensions::unscaled.frametext.right, 0, 0),
 
		NWidget(WWT_DROPDOWN, COLOUR_YELLOW, WID_NS_PRESET_LIST), SetFill(1, 0), SetResize(1, 0),
 
				SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
 
	EndContainer(),
 
@@ -1802,10 +1804,10 @@ static const NWidgetPart _nested_newgrf_
 
				SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
 
	EndContainer(),
 

	
 
	NWidget(NWID_SPACER), SetMinimalSize(0, WD_RESIZEBOX_WIDTH), SetResize(1, 0), SetFill(1, 0),
 
	NWidget(NWID_SPACER), SetMinimalSize(0, NWidgetNewGRFDisplay::INTER_COLUMN_SPACING), SetResize(1, 0), SetFill(1, 0),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE),
 
		NWidget(WWT_LABEL, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_ACTIVE_LIST, STR_NULL),
 
				SetFill(1, 0), SetResize(1, 0), SetPadding(3, WD_FRAMETEXT_RIGHT, 0, WD_FRAMETEXT_LEFT),
 
				SetFill(1, 0), SetResize(1, 0), SetPadding(3, WidgetDimensions::unscaled.frametext.right, 0, WidgetDimensions::unscaled.frametext.left),
 
		/* Left side, active grfs. */
 
		NWidget(NWID_HORIZONTAL), SetPadding(0, 2, 0, 2),
 
			NWidget(WWT_PANEL, COLOUR_MAUVE),
 
@@ -1817,7 +1819,7 @@ static const NWidgetPart _nested_newgrf_
 
		EndContainer(),
 
		/* Buttons. */
 
		NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_REMOVE),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(2, 2, 2, 2), SetPIP(0, WD_RESIZEBOX_WIDTH, 0),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(2, 2, 2, 2), SetPIP(0, NWidgetNewGRFDisplay::INTER_COLUMN_SPACING, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_REMOVE), SetFill(1, 0), SetResize(1, 0),
 
						SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
 
				NWidget(NWID_VERTICAL),
 
@@ -1843,10 +1845,10 @@ static const NWidgetPart _nested_newgrf_
 
static const NWidgetPart _nested_newgrf_availables_widgets[] = {
 
	NWidget(WWT_PANEL, COLOUR_MAUVE),
 
		NWidget(WWT_LABEL, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_INACTIVE_LIST, STR_NULL),
 
				SetFill(1, 0), SetResize(1, 0), SetPadding(3, WD_FRAMETEXT_RIGHT, 0, WD_FRAMETEXT_LEFT),
 
				SetFill(1, 0), SetResize(1, 0), SetPadding(3, WidgetDimensions::unscaled.frametext.right, 0, WidgetDimensions::unscaled.frametext.left),
 
		/* Left side, available grfs, filter edit box. */
 
		NWidget(NWID_HORIZONTAL), SetPadding(WD_TEXTPANEL_TOP, 0, WD_TEXTPANEL_BOTTOM, 0),
 
				SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
 
		NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.frametext.top, 0, WidgetDimensions::unscaled.frametext.bottom, 0),
 
				SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, WidgetDimensions::unscaled.frametext.right),
 
			NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_NEWGRF_FILTER_TITLE, STR_NULL),
 
			NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_NS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
 
					SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
@@ -1861,7 +1863,7 @@ static const NWidgetPart _nested_newgrf_
 
			NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_NS_SCROLL2BAR),
 
		EndContainer(),
 
		/* Left side, available grfs, buttons. */
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(2, 2, 2, 2), SetPIP(0, WD_RESIZEBOX_WIDTH, 0),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(2, 2, 2, 2), SetPIP(0, NWidgetNewGRFDisplay::INTER_COLUMN_SPACING, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_ADD), SetFill(1, 0), SetResize(1, 0),
 
					SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
 
			NWidget(NWID_VERTICAL),
 
@@ -1894,7 +1896,7 @@ static const NWidgetPart _nested_newgrf_
 
	EndContainer(),
 
	NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_APPLY),
 
		/* Right side, buttons. */
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, WD_RESIZEBOX_WIDTH, 0),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, NWidgetNewGRFDisplay::INTER_COLUMN_SPACING, 0),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_SET_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
 
						SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
 
@@ -1932,7 +1934,7 @@ static const NWidgetPart _nested_newgrf_
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE),
 
		NWidgetFunction(NewGRFDisplay), SetPadding(WD_RESIZEBOX_WIDTH, WD_RESIZEBOX_WIDTH, 2, WD_RESIZEBOX_WIDTH),
 
		NWidgetFunction(NewGRFDisplay), SetPadding(NWidgetNewGRFDisplay::INTER_COLUMN_SPACING, NWidgetNewGRFDisplay::INTER_COLUMN_SPACING, 2, NWidgetNewGRFDisplay::INTER_COLUMN_SPACING),
 
		/* Resize button. */
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
@@ -2009,11 +2011,13 @@ static const NWidgetPart _nested_save_pr
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_INSET, COLOUR_GREY, WID_SVP_PRESET_LIST), SetPadding(2, 1, 0, 2),
 
			NWidget(WWT_INSET, COLOUR_GREY, WID_SVP_PRESET_LIST), SetPadding(2, 1, 2, 2),
 
					SetDataTip(0x0, STR_SAVE_PRESET_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SVP_SCROLLBAR), EndContainer(),
 
			NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SVP_SCROLLBAR),
 
		EndContainer(),
 
		NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SVP_EDITBOX), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SVP_EDITBOX), SetPadding(2, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
 
				SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
@@ -2076,14 +2080,14 @@ struct SavePresetWindow : public Window 
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				resize->height = FONT_HEIGHT_NORMAL + 2U;
 
				resize->height = FONT_HEIGHT_NORMAL;
 
				size->height = 0;
 
				for (uint i = 0; i < this->presets.size(); i++) {
 
					Dimension d = GetStringBoundingBox(this->presets[i].c_str());
 
					size->width = std::max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
 
					size->width = std::max(size->width, d.width + padding.width);
 
					resize->height = std::max(resize->height, d.height);
 
				}
 
				size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + 1;
 
				size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + padding.height;
 
				break;
 
			}
 
		}
 
@@ -2093,12 +2097,12 @@ struct SavePresetWindow : public Window 
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_SVP_PRESET_LIST)->resize_y;
 
				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				uint min_index = this->vscroll->GetPosition();
 
				uint max_index = std::min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size());
 

	
 
@@ -2214,7 +2218,7 @@ struct ScanProgressWindow : public Windo
 
				/* We really don't know the width. We could determine it by scanning the NewGRFs,
 
				 * but this is the status window for scanning them... */
 
				size->width = std::max(400U, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width);
 
				size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
 
				size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal;
 
				break;
 
		}
 
	}
 
@@ -2225,10 +2229,11 @@ struct ScanProgressWindow : public Windo
 
			case WID_SP_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
				uint percent = scanned * 100 / std::max(1U, _settings_client.gui.last_newgrf_count);
 
				DrawFrameRect(r.left + 1, r.top + 1, (int)((r.right - r.left - 2) * percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE);
 
				DrawFrameRect(ir.left, ir.top, ir.left + (ir.Width() - 1) * percent / 100, ir.bottom, COLOUR_MAUVE, FR_NONE);
 
				SetDParam(0, percent);
 
				DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
@@ -2237,7 +2242,7 @@ struct ScanProgressWindow : public Windo
 
				SetDParam(1, _settings_client.gui.last_newgrf_count);
 
				DrawString(r.left, r.right, r.top, STR_NEWGRF_SCAN_STATUS, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
				DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, this->last_name == nullptr ? "" : this->last_name, TC_BLACK, SA_HOR_CENTER);
 
				DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, this->last_name == nullptr ? "" : this->last_name, TC_BLACK, SA_HOR_CENTER);
 
				break;
 
		}
 
	}
src/news_gui.cpp
Show inline comments
 
@@ -329,12 +329,14 @@ struct NewsWindow : Window {
 

	
 
	void DrawNewsBorder(const Rect &r) const
 
	{
 
		GfxFillRect(r.left,  r.top,    r.right, r.bottom, PC_WHITE);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
		GfxFillRect(ir, PC_WHITE);
 

	
 
		GfxFillRect(r.left,  r.top,    r.left,  r.bottom, PC_BLACK);
 
		GfxFillRect(r.right, r.top,    r.right, r.bottom, PC_BLACK);
 
		GfxFillRect(r.left,  r.top,    r.right, r.top,    PC_BLACK);
 
		GfxFillRect(r.left,  r.bottom, r.right, r.bottom, PC_BLACK);
 
		ir = ir.Expand(1);
 
		GfxFillRect( r.left,   r.top,    ir.left,   r.bottom, PC_BLACK);
 
		GfxFillRect(ir.right,  r.top,     r.right,  r.bottom, PC_BLACK);
 
		GfxFillRect( r.left,   r.top,     r.right, ir.top,    PC_BLACK);
 
		GfxFillRect( r.left,  ir.bottom,  r.right,  r.bottom, PC_BLACK);
 
	}
 

	
 
	Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
 
@@ -351,7 +353,7 @@ struct NewsWindow : Window {
 
				/* Caption is not a real caption (so that the window cannot be moved)
 
				 * thus it doesn't get the default sizing of a caption. */
 
				Dimension d2 = GetStringBoundingBox(STR_NEWS_MESSAGE_CAPTION);
 
				d2.height += WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM;
 
				d2.height += WidgetDimensions::scaled.captiontext.Vertical();
 
				*size = maxdim(*size, d2);
 
				return;
 
			}
 
@@ -389,8 +391,8 @@ struct NewsWindow : Window {
 
			case WID_N_SHOW_GROUP:
 
				if (this->ni->reftype1 == NR_VEHICLE) {
 
					Dimension d2 = GetStringBoundingBox(this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP)->widget_data);
 
					d2.height += WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM;
 
					d2.width += WD_CAPTIONTEXT_LEFT + WD_CAPTIONTEXT_RIGHT;
 
					d2.height += WidgetDimensions::scaled.captiontext.Vertical();
 
					d2.width += WidgetDimensions::scaled.captiontext.Horizontal();
 
					*size = d2;
 
				} else {
 
					/* Hide 'Show group window' button if this news is not about a vehicle. */
 
@@ -1151,15 +1153,15 @@ struct MessageHistoryWindow : Window {
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		if (widget == WID_MH_BACKGROUND) {
 
			this->line_height = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
			resize->height = this->line_height;
 

	
 
			/* Months are off-by-one, so it's actually 8. Not using
 
			 * month 12 because the 1 is usually less wide. */
 
			SetDParam(0, ConvertYMDToDate(ORIGINAL_MAX_YEAR, 7, 30));
 
			this->date_width = GetStringBoundingBox(STR_SHORT_DATE).width;
 
			this->date_width = GetStringBoundingBox(STR_SHORT_DATE).width + ScaleFontTrad(5);
 

	
 
			size->height = 4 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; // At least 4 lines are visible.
 
			size->height = 4 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible.
 
			size->width = std::max(200u, size->width); // At least 200 pixels wide.
 
		}
 
	}
 
@@ -1183,8 +1185,8 @@ struct MessageHistoryWindow : Window {
 

	
 
		/* Fill the widget with news items. */
 
		bool rtl = _current_text_dir == TD_RTL;
 
		Rect news = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM).Indent(this->date_width + ScaleFontTrad(5), rtl);
 
		Rect date = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM).WithWidth(this->date_width, rtl);
 
		Rect news = r.Shrink(WidgetDimensions::scaled.framerect).Indent(this->date_width + WidgetDimensions::scaled.hsep_wide, rtl);
 
		Rect date = r.Shrink(WidgetDimensions::scaled.framerect).WithWidth(this->date_width, rtl);
 
		int y = news.top;
 
		for (int n = this->vscroll->GetCapacity(); n > 0; n--) {
 
			SetDParam(0, ni->date);
 
@@ -1215,7 +1217,7 @@ struct MessageHistoryWindow : Window {
 
			NewsItem *ni = _latest_news;
 
			if (ni == nullptr) return;
 

	
 
			for (int n = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_MH_BACKGROUND, WD_FRAMERECT_TOP); n > 0; n--) {
 
			for (int n = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_MH_BACKGROUND, WidgetDimensions::scaled.framerect.top); n > 0; n--) {
 
				ni = ni->prev;
 
				if (ni == nullptr) return;
 
			}
src/object_gui.cpp
Show inline comments
 
@@ -313,8 +313,8 @@ public:
 
				break;
 

	
 
			case WID_BO_SELECT_IMAGE:
 
				size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
				size->height = ScaleGUITrad(58) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
				size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				break;
 

	
 
			default: break;
 
@@ -325,7 +325,7 @@ public:
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BO_CLASS_LIST: {
 
				Rect mr = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect mr = r.Shrink(WidgetDimensions::scaled.matrix);
 
				uint pos = 0;
 
				for (auto object_class_id : this->object_classes) {
 
					ObjectClass *objclass = ObjectClass::Get(object_class_id);
 
@@ -377,7 +377,7 @@ public:
 
				if (spec == nullptr) break;
 

	
 
				if (!spec->IsAvailable()) {
 
					GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER);
 
				}
 
				DrawPixelInfo tmp_dpi;
 
				/* Set up a clipping area for the preview. */
src/order_gui.cpp
Show inline comments
 
@@ -550,7 +550,7 @@ private:
 
	VehicleOrderID GetOrderFromPt(int y)
 
	{
 
		NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
 
		uint sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
 
		uint sel = (y - nwid->pos_y - WidgetDimensions::scaled.framerect.top) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
 

	
 
		if (sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
 

	
 
@@ -1074,10 +1074,10 @@ public:
 
	{
 
		if (widget != WID_O_ORDER_LIST) return;
 

	
 
		Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
		bool rtl = _current_text_dir == TD_RTL;
 
		SetDParamMaxValue(0, this->vehicle->GetNumOrders(), 2);
 
		int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
 
		int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + WidgetDimensions::scaled.hsep_normal;
 
		int middle = rtl ? ir.right - index_column_width : ir.left + index_column_width;
 

	
 
		int y = ir.top;
 
@@ -1093,7 +1093,7 @@ public:
 

	
 
				if (i != this->selected_order && i == this->order_over) {
 
					/* Highlight dragged order destination. */
 
					int top = (this->order_over < this->selected_order ? y : y + line_height) - WD_FRAMERECT_TOP;
 
					int top = (this->order_over < this->selected_order ? y : y + line_height) - WidgetDimensions::scaled.framerect.top;
 
					int bottom = std::min(top + 2, ir.bottom);
 
					top = std::max(top - 3, ir.top);
 
					GfxFillRect(ir.left, top, ir.right, bottom, _colour_gradient[COLOUR_GREY][7]);
src/rail_gui.cpp
Show inline comments
 
@@ -968,7 +968,7 @@ private:
 
public:
 
	BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE)
 
	{
 
		this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WD_PAR_VSEP_NORMAL;
 
		this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WidgetDimensions::scaled.vsep_normal;
 
		this->vscroll = nullptr;
 
		_railstation.newstations = newstation;
 

	
 
@@ -1180,9 +1180,9 @@ public:
 
		if (this->IsShaded()) return;
 
		/* 'Accepts' and 'Supplies' texts. */
 
		Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		int top = r.top + WidgetDimensions::scaled.vsep_normal;
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + WidgetDimensions::scaled.vsep_normal;
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
@@ -1232,8 +1232,8 @@ public:
 
			case WID_BRAS_PLATFORM_DIR_X:
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
			case WID_BRAS_IMAGE:
 
				size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
				size->height = ScaleGUITrad(58) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
				size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				break;
 

	
 
			case WID_BRAS_COVERAGE_TEXTS:
 
@@ -1281,7 +1281,7 @@ public:
 
				break;
 

	
 
			case WID_BRAS_NEWST_LIST: {
 
				Rect ir = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.matrix);
 
				uint statclass = 0;
 
				for (auto station_class : this->station_classes) {
 
					if (this->vscroll->IsVisible(statclass)) {
 
@@ -1301,7 +1301,7 @@ public:
 
				/* Check station availability callback */
 
				const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type);
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER);
 
				}
 

	
 
				/* Set up a clipping area for the station preview. */
 
@@ -1609,7 +1609,7 @@ static const NWidgetPart _nested_station
 
					NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
 
					NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
 
				EndContainer(),
 
				NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetFill(1, 0),
 
				NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(WidgetDimensions::unscaled.framerect), SetFill(1, 0),
 
				NWidget(NWID_HORIZONTAL),
 
					NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
 
					NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
 
@@ -1634,7 +1634,7 @@ static const NWidgetPart _nested_station
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetFill(1, 1), SetResize(1, 0),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(WidgetDimensions::unscaled.framerect), SetFill(1, 1), SetResize(1, 0),
 
			NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_RESIZE),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
 
@@ -1677,9 +1677,10 @@ private:
 
	{
 
		Point offset;
 
		Dimension sprite_size = GetSpriteSize(image, &offset);
 
		int x = CenterBounds(r.left, r.right, sprite_size.width - offset.x);
 
		int y = r.top - sig_sprite_bottom_offset + WD_IMGBTN_TOP +
 
				(r.bottom - r.top - WD_IMGBTN_TOP - WD_IMGBTN_BOTTOM + sig_sprite_size.height) / 2; // aligned to bottom
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.imgbtn);
 
		int x = CenterBounds(ir.left, ir.right, sprite_size.width - offset.x); // centered
 
		int y = ir.top - sig_sprite_bottom_offset +
 
				(ir.Height() + sig_sprite_size.height) / 2; // aligned to bottom
 

	
 
		DrawSprite(image, PAL_NONE,
 
				x + this->IsWidgetLowered(widget_index),
 
@@ -1740,12 +1741,12 @@ public:
 
	{
 
		if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
 
			/* Two digits for signals density. */
 
			size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
 
			size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal());
 
		} else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
 
			size->width = std::max(size->width, this->sig_sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT);
 
			size->height = std::max(size->height, this->sig_sprite_size.height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
 
			size->width = std::max(size->width, this->sig_sprite_size.width + padding.width);
 
			size->height = std::max(size->height, this->sig_sprite_size.height + padding.height);
 
		} else if (widget == WID_BS_CAPTION) {
 
			size->width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
			size->width += WidgetDimensions::scaled.frametext.Horizontal();
 
		}
 
	}
 

	
 
@@ -1929,8 +1930,8 @@ struct BuildRailDepotWindow : public Pic
 
	{
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
		size->height = ScaleGUITrad(48) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
		size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -2036,8 +2037,8 @@ struct BuildRailWaypointWindow : PickerW
 
				break;
 

	
 
			case WID_BRW_WAYPOINT:
 
				size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
				size->height = ScaleGUITrad(58) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
				size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				break;
 
		}
 
	}
 
@@ -2060,7 +2061,7 @@ struct BuildRailWaypointWindow : PickerW
 
				}
 

	
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER);
 
				}
 
			}
 
		}
src/road_gui.cpp
Show inline comments
 
@@ -974,8 +974,8 @@ struct BuildRoadDepotWindow : public Pic
 
	{
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
		size->height = ScaleGUITrad(48) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
		size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -1092,9 +1092,9 @@ struct BuildRoadStationWindow : public P
 
		/* 'Accepts' and 'Supplies' texts. */
 
		StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		int top = r.top + WidgetDimensions::scaled.vsep_normal;
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + WidgetDimensions::scaled.vsep_normal;
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true) + WidgetDimensions::scaled.vsep_normal;
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
@@ -1107,8 +1107,8 @@ struct BuildRoadStationWindow : public P
 
	{
 
		if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
 

	
 
		size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
		size->height = ScaleGUITrad(48) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
		size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -1189,7 +1189,7 @@ static const NWidgetPart _nested_road_st
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL), SetPadding(3),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
 
@@ -1198,7 +1198,7 @@ static const NWidgetPart _nested_road_st
 
											SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1),
 
	EndContainer(),
 
};
 

	
 
@@ -1226,7 +1226,7 @@ static const NWidgetPart _nested_tram_st
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL), SetPadding(3),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
 
@@ -1235,7 +1235,7 @@ static const NWidgetPart _nested_tram_st
 
											SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1),
 
	EndContainer(),
 
};
 

	
src/roadveh_gui.cpp
Show inline comments
 
@@ -76,7 +76,7 @@ void DrawRoadVehDetails(const Vehicle *v
 
		}
 

	
 
		DrawString(r.left, r.right, y, capacity, TC_BLUE);
 
		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
		y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 

	
 
		for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
 
			if (u->cargo_cap == 0) continue;
 
@@ -92,13 +92,13 @@ void DrawRoadVehDetails(const Vehicle *v
 
			DrawString(r.left, r.right, y, str);
 
			y += FONT_HEIGHT_NORMAL;
 
		}
 
		y += WD_PAR_VSEP_NORMAL;
 
		y += WidgetDimensions::scaled.vsep_normal;
 
	} else {
 
		SetDParam(0, v->cargo_type);
 
		SetDParam(1, v->cargo_cap);
 
		SetDParam(4, GetCargoSubtypeText(v));
 
		DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
 
		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
		y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 

	
 
		str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
 
		if (v->cargo.StoredCount() > 0) {
 
@@ -109,7 +109,7 @@ void DrawRoadVehDetails(const Vehicle *v
 
			feeder_share += v->cargo.FeederShare();
 
		}
 
		DrawString(r.left, r.right, y, str);
 
		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
		y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
	}
 

	
 
	/* Draw Transfer credits text */
src/settings_gui.cpp
Show inline comments
 
@@ -1000,8 +1000,8 @@ uint BaseSettingEntry::Draw(GameSettings
 
	if (cur_row >= max_row) return cur_row;
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int offset = rtl ? -4 : 4;
 
	int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
 
	int offset = (rtl ? -(int)_circle_size.width : _circle_size.width) / 2;
 
	int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
 

	
 
	int x = rtl ? right : left;
 
	if (cur_row >= first_row) {
 
@@ -1018,7 +1018,7 @@ uint BaseSettingEntry::Draw(GameSettings
 
		int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
 
		GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
 
		/* Small horizontal line from the last vertical line */
 
		GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
 
		GfxDrawLine(x + offset, halfway_y, x + level_width - WidgetDimensions::scaled.hsep_normal, halfway_y, colour);
 
		x += level_width;
 

	
 
		this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
 
@@ -1210,8 +1210,8 @@ void SettingEntry::DrawSetting(GameSetti
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
 
	uint text_left  = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + 5);
 
	uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + 5 : 0);
 
	uint text_left  = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide);
 
	uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide : 0);
 
	uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
 

	
 
	/* We do not allow changes of some items when we are a client in a networkgame */
 
@@ -1558,7 +1558,7 @@ void SettingsPage::DrawSetting(GameSetti
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 
	DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
 
	DrawString(rtl ? left : left + _circle_size.width + 2, rtl ? right - _circle_size.width - 2 : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title);
 
	DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title);
 
}
 

	
 
/** Construct settings tree */
 
@@ -1962,10 +1962,10 @@ struct GameSettingsWindow : Window {
 
	{
 
		switch (widget) {
 
			case WID_GS_OPTIONSPANEL:
 
				resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1;
 
				resize->width  = 1;
 

	
 
				size->height = 5 * resize->height + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 
				resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + WidgetDimensions::scaled.vsep_normal;
 
				resize->width = 1;
 

	
 
				size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
 
				break;
 

	
 
			case WID_GS_HELP_TEXT: {
 
@@ -1978,7 +1978,7 @@ struct GameSettingsWindow : Window {
 
					SetDParam(0, setting_types[i]);
 
					size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
 
				}
 
				size->height = 2 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL +
 
				size->height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal +
 
						std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
 
				break;
 
			}
 
@@ -2003,7 +2003,7 @@ struct GameSettingsWindow : Window {
 
		}
 

	
 
		/* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
 
		const Rect panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL)->GetCurrentRect().Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
		const Rect panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext);
 
		StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
 
		int new_warn_lines;
 
		if (this->warn_missing == WHR_NONE) {
 
@@ -2072,7 +2072,7 @@ struct GameSettingsWindow : Window {
 
	{
 
		switch (widget) {
 
			case WID_GS_OPTIONSPANEL: {
 
				Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
				tr.top += this->warn_lines * SETTING_HEIGHT;
 
				uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
 
				int next_row = GetSettingsTree().Draw(settings_ptr, tr.left, tr.right, tr.top,
 
@@ -2097,7 +2097,7 @@ struct GameSettingsWindow : Window {
 

	
 
					this->last_clicked->SetValueDParams(0, sd->def);
 
					DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE);
 
					tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 

	
 
					DrawStringMultiLine(tr, this->last_clicked->GetHelpText(), TC_WHITE);
 
				}
 
@@ -2161,7 +2161,7 @@ struct GameSettingsWindow : Window {
 

	
 
		if (widget != WID_GS_OPTIONSPANEL) return;
 

	
 
		uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, WD_FRAMETEXT_TOP);
 
		uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, WidgetDimensions::scaled.framerect.top);
 
		if (btn == INT_MAX || (int)btn < this->warn_lines) return;
 
		btn -= this->warn_lines;
 

	
 
@@ -2170,7 +2170,7 @@ struct GameSettingsWindow : Window {
 

	
 
		if (clicked_entry == nullptr) return;  // Clicked below the last setting of the page
 

	
 
		int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - WD_FRAMETEXT_LEFT - (clicked_entry->level + 1) * LEVEL_WIDTH;  // Shift x coordinate
 
		int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - WidgetDimensions::scaled.frametext.left - (clicked_entry->level + 1) * WidgetDimensions::scaled.hsep_indent;  // Shift x coordinate
 
		if (x < 0) return;  // Clicked left of the entry
 

	
 
		SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
 
@@ -2211,7 +2211,7 @@ struct GameSettingsWindow : Window {
 
				this->closing_dropdown = false;
 

	
 
				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
 
				int rel_y = (pt.y - (int)wid->pos_y - WD_FRAMETEXT_TOP) % wid->resize_y;
 
				int rel_y = (pt.y - (int)wid->pos_y - WidgetDimensions::scaled.framerect.top) % wid->resize_y;
 

	
 
				Rect wi_rect;
 
				wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
 
@@ -2439,7 +2439,7 @@ struct GameSettingsWindow : Window {
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM);
 
		this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, WidgetDimensions::scaled.framerect.Vertical());
 
	}
 
};
 

	
 
@@ -2452,16 +2452,16 @@ static const NWidgetPart _nested_setting
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE),
 
		NWidget(NWID_VERTICAL), SetPIP(WD_TEXTPANEL_TOP, WD_PAR_VSEP_NORMAL, WD_TEXTPANEL_BOTTOM),
 
			NWidget(NWID_HORIZONTAL), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
 
		NWidget(NWID_VERTICAL), SetPIP(WidgetDimensions::unscaled.frametext.top, WidgetDimensions::unscaled.vsep_normal, WidgetDimensions::unscaled.frametext.bottom),
 
			NWidget(NWID_HORIZONTAL), SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.hsep_wide, WidgetDimensions::unscaled.frametext.right),
 
				NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL),
 
				NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
 
			NWidget(NWID_HORIZONTAL), SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.hsep_wide, WidgetDimensions::unscaled.frametext.right),
 
				NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL),
 
				NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_TYPE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
 
			NWidget(NWID_HORIZONTAL), SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.hsep_wide, WidgetDimensions::unscaled.frametext.right),
 
				NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetMinimalSize(50, 12), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
			EndContainer(),
 
@@ -2473,7 +2473,7 @@ static const NWidgetPart _nested_setting
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE),
 
		NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
 
				SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT),
 
				SetPadding(WidgetDimensions::unscaled.frametext),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
 
@@ -2511,21 +2511,26 @@ void ShowGameSettings()
 
 */
 
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
 
{
 
	extern void DrawSpriteIgnorePadding(const Rect &r, SpriteID img, bool clicked, StringAlignment align);
 

	
 
	int colour = _colour_gradient[button_colour][2];
 
	Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
 

	
 
	DrawFrameRect(x,             y, x + dim.width - 1,             y + dim.height - 1, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(x + dim.width, y, x + dim.width + dim.width - 1, y + dim.height - 1, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
 
	DrawSprite(SPR_ARROW_LEFT, PAL_NONE, x + WD_IMGBTN_LEFT, y + WD_IMGBTN_TOP);
 
	DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + dim.width, y + WD_IMGBTN_TOP);
 
	Rect lr = {x,                  y, x + (int)dim.width     - 1, y + (int)dim.height - 1};
 
	Rect rr = {x + (int)dim.width, y, x + (int)dim.width * 2 - 1, y + (int)dim.height - 1};
 

	
 
	DrawFrameRect(lr, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(rr, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
 
	DrawSpriteIgnorePadding(lr, SPR_ARROW_LEFT,  (state == 1), SA_CENTER);
 
	DrawSpriteIgnorePadding(rr, SPR_ARROW_RIGHT, (state == 2), SA_CENTER);
 

	
 
	/* Grey out the buttons that aren't clickable */
 
	bool rtl = _current_text_dir == TD_RTL;
 
	if (rtl ? !clickable_right : !clickable_left) {
 
		GfxFillRect(x + 1, y, x + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
 
		GfxFillRect(lr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
 
	}
 
	if (rtl ? !clickable_left : !clickable_right) {
 
		GfxFillRect(x + dim.width + 1, y, x + dim.width + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
 
		GfxFillRect(rr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
 
	}
 
}
 

	
 
@@ -2539,13 +2544,17 @@ void DrawArrowButtons(int x, int y, Colo
 
 */
 
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
 
{
 
	extern void DrawSpriteIgnorePadding(const Rect &r, SpriteID img, bool clicked, StringAlignment align);
 

	
 
	int colour = _colour_gradient[button_colour][2];
 

	
 
	DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, state ? FR_LOWERED : FR_NONE);
 
	DrawSprite(SPR_ARROW_DOWN, PAL_NONE, x + (SETTING_BUTTON_WIDTH - NWidgetScrollbar::GetVerticalDimension().width) / 2 + state, y + 2 + state);
 
	Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
 

	
 
	DrawFrameRect(r, button_colour, state ? FR_LOWERED : FR_NONE);
 
	DrawSpriteIgnorePadding(r, SPR_ARROW_DOWN, state, SA_CENTER);
 

	
 
	if (!clickable) {
 
		GfxFillRect(x +  1, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
 
	}
 
}
 

	
 
@@ -2559,7 +2568,9 @@ void DrawDropDownButton(int x, int y, Co
 
void DrawBoolButton(int x, int y, bool state, bool clickable)
 
{
 
	static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
 
	DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
 

	
 
	Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
 
	DrawFrameRect(r, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
 
}
 

	
 
struct CustomCurrencyWindow : Window {
src/ship_gui.cpp
Show inline comments
 
@@ -73,7 +73,7 @@ void DrawShipDetails(const Vehicle *v, c
 
	SetDParam(1, v->cargo_cap);
 
	SetDParam(4, GetCargoSubtypeText(v));
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
 
	y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
	y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 

	
 
	StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
 
	if (v->cargo.StoredCount() > 0) {
 
@@ -83,7 +83,7 @@ void DrawShipDetails(const Vehicle *v, c
 
		str = STR_VEHICLE_DETAILS_CARGO_FROM;
 
	}
 
	DrawString(r.left, r.right, y, str);
 
	y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
	y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 

	
 
	/* Draw Transfer credits text */
 
	SetDParam(0, v->cargo.FeederShare());
src/signs_gui.cpp
Show inline comments
 
@@ -194,7 +194,7 @@ struct SignListWindow : Window, SignList
 
	{
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				uint text_offset_y = (this->resize.step_height - FONT_HEIGHT_NORMAL + 1) / 2;
 
				/* No signs? */
 
				if (this->vscroll->GetCount() == 0) {
 
@@ -209,7 +209,8 @@ struct SignListWindow : Window, SignList
 
				tr = tr.Indent(this->text_offset, rtl);
 

	
 
				/* At least one sign available. */
 
				for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
 
				for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++)
 
				{
 
					const Sign *si = this->signs[i];
 

	
 
					if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, tr.top + sprite_offset_y);
 
@@ -232,7 +233,7 @@ struct SignListWindow : Window, SignList
 
	{
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WD_FRAMERECT_TOP);
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.top);
 
				if (id_v == INT_MAX) return;
 

	
 
				const Sign *si = this->signs[id_v];
 
@@ -257,7 +258,7 @@ struct SignListWindow : Window, SignList
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
		this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical());
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
@@ -265,9 +266,9 @@ struct SignListWindow : Window, SignList
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
 
				this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
 
				this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
 
				resize->height = std::max<uint>(FONT_HEIGHT_NORMAL, spr_dim.height + 2);
 
				Dimension d = {(uint)(this->text_offset + WD_FRAMETEXT_RIGHT), WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
 
				Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height};
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
@@ -367,7 +368,7 @@ static const NWidgetPart _nested_sign_li
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + 255 + WD_FRAMETEXT_RIGHT, 0),
 
			NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WidgetDimensions::unscaled.frametext.Horizontal() + 16 + 255, 0),
 
								SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_SIL_SCROLLBAR), EndContainer(),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
src/smallmap_gui.cpp
Show inline comments
 
@@ -1191,7 +1191,7 @@ void SmallMapWindow::RebuildColourIndexI
 
	this->legend_width = (FONT_HEIGHT_SMALL - ScaleFontTrad(1)) * 8 / 5;
 

	
 
	/* The width of a column is the minimum width of all texts + the size of the blob + some spacing */
 
	this->column_width = min_width + this->legend_width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
	this->column_width = min_width + this->legend_width + WidgetDimensions::scaled.framerect.Horizontal();
 
}
 

	
 
/* virtual */ void SmallMapWindow::OnPaint()
 
@@ -1214,7 +1214,7 @@ void SmallMapWindow::RebuildColourIndexI
 
{
 
	switch (widget) {
 
		case WID_SM_MAP: {
 
			Rect ir = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
			Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
			DrawPixelInfo new_dpi;
 
			if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
			this->DrawSmallMap(&new_dpi);
 
@@ -1227,10 +1227,10 @@ void SmallMapWindow::RebuildColourIndexI
 
			bool rtl = _current_text_dir == TD_RTL;
 
			uint i = 0; // Row counter for industry legend.
 
			uint row_height = FONT_HEIGHT_SMALL;
 
			int padding = ScaleFontTrad(1);
 
			int padding = ScaleGUITrad(1);
 

	
 
			Rect origin = r.WithWidth(this->column_width, rtl).Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM).WithHeight(row_height);
 
			Rect text = origin.Indent(this->legend_width + padding, rtl);
 
			Rect origin = r.WithWidth(this->column_width, rtl).Shrink(WidgetDimensions::scaled.framerect).WithHeight(row_height);
 
			Rect text = origin.Indent(this->legend_width + WidgetDimensions::scaled.hsep_normal, rtl);
 
			Rect icon = origin.WithWidth(this->legend_width, rtl).Shrink(0, padding, 0, 0);
 

	
 
			StringID string = STR_NULL;
 
@@ -1298,7 +1298,7 @@ void SmallMapWindow::RebuildColourIndexI
 
						DrawString(text, tbl->legend);
 
						break;
 
				}
 
				GfxFillRect(icon.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), legend_colour); // Legend colour
 
				GfxFillRect(icon.Shrink(WidgetDimensions::scaled.bevel), legend_colour); // Legend colour
 

	
 
				text = text.Translate(0, row_height);
 
				icon = icon.Translate(0, row_height);
 
@@ -1396,7 +1396,7 @@ void SmallMapWindow::SetOverlayCargoMask
 
int SmallMapWindow::GetPositionOnLegend(Point pt)
 
{
 
	const NWidgetBase *wi = this->GetWidget<NWidgetBase>(WID_SM_LEGEND);
 
	uint line = (pt.y - wi->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_SMALL;
 
	uint line = (pt.y - wi->pos_y - WidgetDimensions::scaled.framerect.top) / FONT_HEIGHT_SMALL;
 
	uint columns = this->GetNumberColumnsLegend(wi->current_x);
 
	uint number_of_rows = this->GetNumberRowsLegend(columns);
 
	if (line >= number_of_rows) return -1;
 
@@ -1404,7 +1404,7 @@ int SmallMapWindow::GetPositionOnLegend(
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int x = pt.x - wi->pos_x;
 
	if (rtl) x = wi->current_x - x;
 
	uint column = (x - WD_FRAMERECT_LEFT) / this->column_width;
 
	uint column = (x - WidgetDimensions::scaled.framerect.left) / this->column_width;
 

	
 
	return (column * number_of_rows) + line;
 
}
src/smallmap_gui.h
Show inline comments
 
@@ -123,7 +123,7 @@ protected:
 
	 */
 
	inline uint GetMinLegendWidth() const
 
	{
 
		return WD_FRAMERECT_LEFT + this->min_number_of_columns * this->column_width;
 
		return WidgetDimensions::scaled.framerect.left + this->min_number_of_columns * this->column_width;
 
	}
 

	
 
	/**
 
@@ -142,7 +142,7 @@ protected:
 
	 */
 
	inline uint GetLegendHeight(uint num_columns) const
 
	{
 
		return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
 
		return WidgetDimensions::scaled.framerect.Vertical() +
 
				this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
 
	}
 

	

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)