Changeset - r26549:82dacf005b0a
[Not reviewed]
src/ai/ai_gui.cpp
Show inline comments
 
@@ -125,18 +125,18 @@ struct AIListWindow : public Window {
 
		switch (widget) {
 
			case WID_AIL_LIST: {
 
				/* Draw a list of all available AIs. */
 
				int y = this->GetWidget<NWidgetBase>(WID_AIL_LIST)->pos_y;
 
				Rect tr = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				/* First AI in the list is hardcoded to random */
 
				if (this->vscroll->IsVisible(0)) {
 
					DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_LEFT, y + WD_MATRIX_TOP, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE);
 
					y += this->line_height;
 
					DrawString(tr, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE);
 
					tr.top += this->line_height;
 
				}
 
				int i = 0;
 
				for (const auto &item : *this->info_list) {
 
					i++;
 
					if (this->vscroll->IsVisible(i)) {
 
						DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, item.second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_ORANGE);
 
						y += this->line_height;
 
						DrawString(tr, item.second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_ORANGE);
 
						tr.top += this->line_height;
 
					}
 
				}
 
				break;
 
@@ -150,20 +150,20 @@ struct AIListWindow : public Window {
 
				}
 
				/* Some info about the currently selected AI. */
 
				if (selected_info != nullptr) {
 
					int y = r.top + WD_FRAMERECT_TOP;
 
					Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
					SetDParamStr(0, selected_info->GetAuthor());
 
					DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_AUTHOR);
 
					y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					DrawString(tr, STR_AI_LIST_AUTHOR);
 
					tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					SetDParam(0, selected_info->GetVersion());
 
					DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_VERSION);
 
					y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					DrawString(tr, STR_AI_LIST_VERSION);
 
					tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					if (selected_info->GetURL() != nullptr) {
 
						SetDParamStr(0, selected_info->GetURL());
 
						DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_URL);
 
						y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
						DrawString(tr, STR_AI_LIST_URL);
 
						tr.top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
					}
 
					SetDParamStr(0, selected_info->GetDescription());
 
					DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, r.bottom - WD_FRAMERECT_BOTTOM, STR_JUST_RAW_STRING, TC_WHITE);
 
					DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_WHITE);
 
				}
 
				break;
 
			}
 
@@ -359,11 +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);
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
 
		uint text_right   = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
 

	
 
		Rect br = ir.WithWidth(SETTING_BUTTON_WIDTH, rtl);
 
		Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
 

	
 
		int y = r.top;
 
		int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
@@ -392,13 +391,13 @@ struct AISettingsWindow : public Window 
 
			}
 

	
 
			if ((config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
 
				DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, editable);
 
				DrawBoolButton(br.left, y + button_y_offset, current_value != 0, editable);
 
				SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
 
			} else {
 
				if (config_item.complete_labels) {
 
					DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
 
					DrawDropDownButton(br.left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
 
				} else {
 
					DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
 
					DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
 
				}
 
				if (config_item.labels != nullptr && config_item.labels->Contains(current_value)) {
 
					SetDParam(idx++, STR_JUST_RAW_STRING);
 
@@ -409,7 +408,7 @@ struct AISettingsWindow : public Window 
 
				}
 
			}
 

	
 
			DrawString(text_left, text_right, y + text_y_offset, str, colour);
 
			DrawString(tr.left, tr.right, y + text_y_offset, str, colour);
 
			y += this->line_height;
 
		}
 
	}
 
@@ -427,8 +426,8 @@ struct AISettingsWindow : public Window 
 
	{
 
		switch (widget) {
 
			case WID_AIS_BACKGROUND: {
 
				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_AIS_BACKGROUND);
 
				int num = (pt.y - wid->pos_y) / this->line_height + this->vscroll->GetPosition();
 
				Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WD_MATRIX_LEFT, 0, WD_MATRIX_RIGHT, 0);
 
				int num = (pt.y - r.top) / this->line_height + this->vscroll->GetPosition();
 
				if (num >= (int)this->visible_settings.size()) break;
 

	
 
				VisibleSettingsList::const_iterator it = this->visible_settings.begin();
 
@@ -445,9 +444,8 @@ struct AISettingsWindow : public Window 
 

	
 
				bool bool_item = (config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0;
 

	
 
				int x = pt.x - wid->pos_x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
 
				x -= 4;
 
				int x = pt.x - r.left;
 
				if (_current_text_dir == TD_RTL) x = r.Width() - 1 - x;
 

	
 
				/* One of the arrows is clicked (or green/red rect in case of bool value) */
 
				int old_val = this->ai_config->GetSetting(config_item.name);
 
@@ -458,8 +456,7 @@ struct AISettingsWindow : public Window 
 
						this->clicked_dropdown = false;
 
						this->closing_dropdown = false;
 
					} else {
 
						const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_AIS_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);
 
@@ -794,7 +791,7 @@ struct AIConfigWindow : public Window {
 
	{
 
		switch (widget) {
 
			case WID_AIC_LIST: {
 
				int y = r.top;
 
				Rect tr = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) {
 
					StringID text;
 

	
 
@@ -806,9 +803,9 @@ struct AIConfigWindow : public Window {
 
					} else {
 
						text = STR_AI_CONFIG_RANDOM_AI;
 
					}
 
					DrawString(r.left + 10, r.right - 10, y + WD_MATRIX_TOP, text,
 
					DrawString(tr, text,
 
							(this->selected_slot == i) ? TC_WHITE : (IsEditable((CompanyID)i) ? TC_ORANGE : TC_SILVER));
 
					y += this->line_height;
 
					tr.top += this->line_height;
 
				}
 
				break;
 
			}
src/airport_gui.cpp
Show inline comments
 
@@ -388,15 +388,17 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_AP_AIRPORT_LIST: {
 
				int y = r.top;
 
				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);
 
				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);
 
					if (!as->IsAvailable()) {
 
						GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, PC_BLACK, FILLRECT_CHECKER);
 
						GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
 
					}
 
					DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
 
					y += this->line_height;
 
					DrawString(text, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
 
					row = row.Translate(0, this->line_height);
 
					text = text.Translate(0, this->line_height);
 
				}
 
				break;
 
			}
src/autoreplace_gui.cpp
Show inline comments
 
@@ -422,7 +422,7 @@ public:
 
					str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
 
				}
 

	
 
				DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_BLACK, SA_HOR_CENTER);
 
				DrawString(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM), str, TC_BLACK, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
@@ -433,7 +433,8 @@ public:
 
				EngineID end    = static_cast<EngineID>(std::min<size_t>(this->vscroll[side]->GetCapacity() + start, this->engines[side].size()));
 

	
 
				/* Do the actual drawing */
 
				DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
 
				const Rect list = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				DrawEngineList((VehicleType)this->window_number, list.left, list.right, list.top,
 
						&this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
 
				break;
 
			}
 
@@ -485,10 +486,10 @@ public:
 
					ted.cargo = e->GetDefaultCargoType();
 
					ted.capacity = e->GetDisplayDefaultCapacity(&ted.mail_capacity);
 

	
 
					NWidgetBase *nwi = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS);
 
					int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
 
							nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side], ted);
 
					needed_height = std::max(needed_height, (text_end - (int)nwi->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL);
 
					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);
 
					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);
 
				}
 
			}
 
			if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
src/bootstrap_gui.cpp
Show inline comments
 
@@ -108,7 +108,7 @@ public:
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget == WID_BEM_MESSAGE) {
 
			DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMETEXT_BOTTOM, STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

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

	
 
		DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMETEXT_BOTTOM, STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER);
 
		DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), 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) + 2; // Max of both sizes + account for matrix edges.
 
				resize->height = std::max(sprite_dim.height, text_dim.height) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; // Max of both sizes + account for matrix edges.
 

	
 
				this->bridgetext_offset = WD_MATRIX_LEFT + sprite_dim.width + 1; // Left edge of text, 1 pixel distance from the sprite.
 
				size->width = this->bridgetext_offset + text_dim.width + WD_MATRIX_RIGHT;
 
				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;
 
				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: {
 
				uint y = r.top;
 
				Rect tr = r.WithHeight(this->resize.step_height).Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
 
					const BridgeSpec *b = this->bridges->at(i).spec;
 

	
 
@@ -230,10 +230,10 @@ public:
 
					SetDParam(1, b->speed);
 
					SetDParam(0, b->material);
 

	
 
					DrawSprite(b->sprite, b->pal, r.left + WD_MATRIX_LEFT, y + this->resize.step_height - 1 - GetSpriteSize(b->sprite).height);
 
					DrawStringMultiLine(r.left + this->bridgetext_offset, r.right, y + 2, y + this->resize.step_height,
 
					DrawSprite(b->sprite, b->pal, tr.left, tr.bottom - GetSpriteSize(b->sprite).height);
 
					DrawStringMultiLine(tr.Indent(this->bridgetext_offset, false),
 
							_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO);
 
					y += this->resize.step_height;
 
					tr = tr.Translate(0, this->resize.step_height);
 
				}
 
				break;
 
			}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1622,10 +1622,9 @@ struct BuildVehicleWindow : Window {
 
			int needed_height = this->details_height;
 
			/* Draw details panels. */
 
			if (this->sel_engine != INVALID_ENGINE) {
 
				NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_BV_PANEL);
 
				int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
 
						nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine, this->te);
 
				needed_height = std::max(needed_height, (text_end - (int)nwi->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL);
 
				const Rect r = this->GetWidget<NWidgetBase>(WID_BV_PANEL)->GetCurrentRect().Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				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);
 
			}
 
			if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
 
				int resize = needed_height - this->details_height;
src/cheat_gui.cpp
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include "newgrf.h"
 
#include "error.h"
 
#include "misc_cmd.h"
 
#include "core/geometry_func.hpp"
 

	
 
#include "widgets/cheat_widget.h"
 

	
 
@@ -216,33 +217,42 @@ struct CheatWindow : Window {
 
	int clicked;
 
	int clicked_widget;
 
	uint line_height;
 
	int box_width;
 
	Dimension box;      ///< Dimension of box sprite
 
	Dimension icon;     ///< Dimension of company icon sprite
 

	
 
	CheatWindow(WindowDesc *desc) : Window(desc)
 
	{
 
		this->box_width = GetSpriteSize(SPR_BOX_EMPTY).width;
 
		this->InitNested();
 
	}
 

	
 
	void OnInit() override
 
	{
 
		this->box = maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED));
 
		this->icon = GetSpriteSize(SPR_COMPANY_ICON);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget != WID_C_PANEL) return;
 

	
 
		int y = r.top + WD_FRAMERECT_TOP + WD_PAR_VSEP_NORMAL;
 
		const Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		int y = ir.top;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint box_left    = rtl ? r.right - this->box_width - 5 : r.left + 5;
 
		uint button_left = rtl ? r.right - this->box_width - 10 - SETTING_BUTTON_WIDTH : r.left + this->box_width + 10;
 
		uint text_left   = r.left + (rtl ? WD_FRAMERECT_LEFT : 20 + this->box_width + SETTING_BUTTON_WIDTH);
 
		uint text_right  = r.right - (rtl ? 20 + this->box_width + SETTING_BUTTON_WIDTH : WD_FRAMERECT_RIGHT);
 
		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);
 

	
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 
		int icon_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
		int box_y_offset = (this->line_height - this->box.height) / 2;
 
		int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
		int icon_y_offset = (this->line_height - this->icon.height) / 2;
 

	
 
		for (int i = 0; i != lengthof(_cheats_ui); i++) {
 
			const CheatEntry *ce = &_cheats_ui[i];
 

	
 
			DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + icon_y_offset + 2);
 
			DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + box_y_offset);
 

	
 
			switch (ce->type) {
 
				case SLE_BOOL: {
 
@@ -258,7 +268,7 @@ struct CheatWindow : Window {
 
					char buf[512];
 

	
 
					/* Draw [<][>] boxes for settings of an integer-type */
 
					DrawArrowButtons(button_left, y + icon_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
 
					DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
 

	
 
					switch (ce->str) {
 
						/* Display date for change date cheat */
 
@@ -269,7 +279,7 @@ struct CheatWindow : Window {
 
							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 + 2);
 
							DrawCompanyIcon(_local_company, rtl ? text_right - offset - 10 : text_left + offset, y + icon_y_offset);
 
							break;
 
						}
 

	
 
@@ -327,15 +337,15 @@ struct CheatWindow : Window {
 
		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;
 

	
 
		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_PAR_VSEP_NORMAL + WD_FRAMERECT_BOTTOM + this->line_height * lengthof(_cheats_ui);
 
		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);
 
	}
 

	
 
	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 - WD_PAR_VSEP_NORMAL) / this->line_height;
 
		int x = pt.x - wid->pos_x;
 
		uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP) / this->line_height;
 
		uint x = pt.x - wid->pos_x;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		if (rtl) x = wid->current_x - x;
 

	
 
@@ -345,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 >= 20 + 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 >= 20 + 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);
 
@@ -359,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, 10 + this->box.width, 10 + this->box.width + SETTING_BUTTON_WIDTH)) return;
 

	
 
		*ce->been_used = true;
 

	
 
@@ -371,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 >= 10 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 10 + 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 >= 10 + this->box.width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
 
				break;
 
		}
 

	
src/company_gui.cpp
Show inline comments
 
@@ -159,16 +159,15 @@ static uint GetMaxCategoriesWidth()
 
 */
 
static void DrawCategory(const Rect &r, int start_y, ExpensesList list)
 
{
 
	int offs_left = _current_text_dir == TD_LTR ? EXP_INDENT : 0;
 
	int offs_right = _current_text_dir == TD_LTR ? 0 : EXP_INDENT;
 

	
 
	int y = start_y;
 
	Rect tr = r.Indent(EXP_INDENT, _current_text_dir == TD_RTL);
 

	
 
	tr.top = start_y;
 
	ExpensesType et;
 

	
 
	for (uint i = 0; i < list.length; i++) {
 
		et = list.et[i];
 
		DrawString(r.left + offs_left, r.right - offs_right, y, STR_FINANCES_SECTION_CONSTRUCTION + et);
 
		y += FONT_HEIGHT_NORMAL;
 
		DrawString(tr, STR_FINANCES_SECTION_CONSTRUCTION + et);
 
		tr.top += FONT_HEIGHT_NORMAL;
 
	}
 
}
 

	
 
@@ -608,11 +607,12 @@ 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);
 
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + (this->result % COLOUR_END),
 
				rtl ? r.right - 2 - ScaleGUITrad(14) : r.left + ScaleGUITrad(14) + 2,
 
				icon_y);
 
		DrawString(rtl ? r.left + 2 : r.left + ScaleGUITrad(28) + 4,
 
				rtl ? r.right - ScaleGUITrad(28) - 4 : r.right - 2,
 
				   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);
 
	}
 
};
 
@@ -917,40 +917,41 @@ public:
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		/* Horizontal coordinates of scheme name column. */
 
		/* Coordinates of scheme name column. */
 
		const NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_SCL_SPACER_DROPDOWN);
 
		int sch_left = nwi->pos_x;
 
		int sch_right = sch_left + nwi->current_x - 1;
 
		/* Horizontal coordinates of first dropdown. */
 
		Rect sch = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		/* Coordinates of first dropdown. */
 
		nwi = this->GetWidget<NWidgetBase>(WID_SCL_PRI_COL_DROPDOWN);
 
		int pri_left = nwi->pos_x;
 
		int pri_right = pri_left + nwi->current_x - 1;
 
		/* Horizontal coordinates of second dropdown. */
 
		Rect pri = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		/* Coordinates of second dropdown. */
 
		nwi = this->GetWidget<NWidgetBase>(WID_SCL_SEC_COL_DROPDOWN);
 
		int sec_left = nwi->pos_x;
 
		int sec_right = sec_left + nwi->current_x - 1;
 

	
 
		int text_left  = (rtl ? (uint)WD_FRAMERECT_LEFT : (this->square.width + 5));
 
		int text_right = (rtl ? (this->square.width + 5) : (uint)WD_FRAMERECT_RIGHT);
 

	
 
		int square_offs = (this->line_height - this->square.height) / 2 + 1;
 
		int text_offs   = (this->line_height - FONT_HEIGHT_NORMAL) / 2 + 1;
 

	
 
		int y = r.top;
 
		Rect sec = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		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);
 
		int square_offs = (ir.Height() - this->square.height) / 2;
 
		int text_offs   = (ir.Height() - FONT_HEIGHT_NORMAL) / 2;
 

	
 
		int y = ir.top;
 

	
 
		/* Helper function to draw livery info. */
 
		auto draw_livery = [&](StringID str, const Livery &liv, bool sel, bool def, int indent) {
 
			/* Livery Label. */
 
			DrawString(sch_left + WD_FRAMERECT_LEFT + (rtl ? 0 : indent), sch_right - WD_FRAMERECT_RIGHT - (rtl ? indent : 0), y + text_offs, str, sel ? TC_WHITE : TC_BLACK);
 
			DrawString(sch.left + (rtl ? 0 : indent), sch.right - (rtl ? indent : 0), y + text_offs, str, sel ? TC_WHITE : TC_BLACK);
 

	
 
			/* Text below the first dropdown. */
 
			DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour1), (rtl ? pri_right - (this->square.width + 5) + WD_FRAMERECT_RIGHT : pri_left) + WD_FRAMERECT_LEFT, y + square_offs);
 
			DrawString(pri_left + text_left, pri_right - text_right, y + text_offs, (def || HasBit(liv.in_use, 0)) ? STR_COLOUR_DARK_BLUE + liv.colour1 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
 
			DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour1), pri_squ.left, y + square_offs);
 
			DrawString(pri.left, pri.right, y + text_offs, (def || HasBit(liv.in_use, 0)) ? STR_COLOUR_DARK_BLUE + liv.colour1 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
 

	
 
			/* Text below the second dropdown. */
 
			if (sec_right > sec_left) { // Second dropdown has non-zero size.
 
				DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour2), (rtl ? sec_right - (this->square.width + 5) + WD_FRAMERECT_RIGHT : sec_left) + WD_FRAMERECT_LEFT, y + square_offs);
 
				DrawString(sec_left + text_left, sec_right - text_right, y + text_offs, (def || HasBit(liv.in_use, 1)) ? STR_COLOUR_DARK_BLUE + liv.colour2 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
 
			if (sec.right > sec.left) { // Second dropdown has non-zero size.
 
				DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour2), sec_squ.left, y + square_offs);
 
				DrawString(sec.left, sec.right, y + text_offs, (def || HasBit(liv.in_use, 1)) ? STR_COLOUR_DARK_BLUE + liv.colour2 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
 
			}
 

	
 
			y += this->line_height;
 
@@ -1795,7 +1796,7 @@ static const NWidgetPart _nested_company
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_VERTICAL), SetPIP(WD_FRAMERECT_TOP, 4, WD_FRAMETEXT_BOTTOM),
 
		NWidget(NWID_VERTICAL), SetPIP(WD_FRAMERECT_TOP, WD_PAR_VSEP_NORMAL * 2, WD_FRAMERECT_BOTTOM),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
				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),
 
@@ -2025,8 +2026,8 @@ struct CompanyInfrastructureWindow : Win
 

	
 
		if (_settings_game.economy.infrastructure_maintenance) {
 
			SetDParam(0, monthly_cost * 12); // Convert to per year
 
			int left = _current_text_dir == TD_RTL ? r.right - this->total_width : r.left;
 
			DrawString(left, left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
 
			Rect tr = r.WithWidth(this->total_width, _current_text_dir == TD_RTL);
 
			DrawString(tr.left, tr.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
 
		}
 
	}
 

	
 
@@ -2109,11 +2110,11 @@ struct CompanyInfrastructureWindow : Win
 

	
 
			case WID_CI_TOTAL:
 
				if (_settings_game.economy.infrastructure_maintenance) {
 
					int left = _current_text_dir == TD_RTL ? r.right - this->total_width : r.left;
 
					GfxFillRect(left, y, left + this->total_width, y, PC_WHITE);
 
					Rect tr = r.WithWidth(this->total_width, _current_text_dir == TD_RTL);
 
					GfxFillRect(tr.left, y, tr.right, y, PC_WHITE);
 
					y += EXP_LINESPACE;
 
					SetDParam(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
 
					DrawString(left, left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
 
					DrawString(tr.left, tr.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
 
				}
 
				break;
 

	
src/error_gui.cpp
Show inline comments
 
@@ -287,8 +287,8 @@ public:
 
					int extra = (r.Height() - this->height_summary - this->height_detailed - WD_PAR_VSEP_WIDE) / 2;
 

	
 
					/* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
 
					DrawStringMultiLine(r.SetHeight(this->height_summary + extra, false), this->summary_msg, TC_WHITE, SA_CENTER);
 
					DrawStringMultiLine(r.SetHeight(this->height_detailed + extra, true), this->detailed_msg, TC_WHITE, SA_CENTER);
 
					DrawStringMultiLine(r.WithHeight(this->height_summary + extra, false), this->summary_msg, TC_WHITE, SA_CENTER);
 
					DrawStringMultiLine(r.WithHeight(this->height_detailed + extra, true), this->detailed_msg, TC_WHITE, SA_CENTER);
 
				}
 

	
 
				if (this->textref_stack_size > 0) StopTextRefStackUsage();
src/fios_gui.cpp
Show inline comments
 
@@ -437,18 +437,21 @@ public:
 
					_fios_path_changed = false;
 
				}
 

	
 
				Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 

	
 
				if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP, str);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, path, TC_BLACK);
 
				DrawString(ir.left, ir.right, ir.top + FONT_HEIGHT_NORMAL, str);
 
				DrawString(ir.left, ir.right, ir.top, path, TC_BLACK);
 
				break;
 
			}
 

	
 
			case WID_SL_DRIVES_DIRECTORIES_LIST: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
				uint y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_INSET_LEFT, WD_INSET_TOP, WD_INSET_RIGHT, 0).WithHeight(this->resize.step_height);
 
				uint scroll_pos = this->vscroll->GetPosition();
 
				for (uint row = 0; row < this->fios_items.size(); row++) {
 
				for (uint row = 0; row < this->fios_items.size() && tr.top < br.bottom; row++) {
 
					if (!this->fios_items_shown[row]) {
 
						/* The current item is filtered out : we do not show it */
 
						scroll_pos++;
 
@@ -458,107 +461,117 @@ public:
 
					const FiosItem *item = &this->fios_items[row];
 

	
 
					if (item == this->selected) {
 
						GfxFillRect(r.left + 1, y, r.right - 1, y + this->resize.step_height - 1, PC_DARK_BLUE);
 
						GfxFillRect(br.left, tr.top, br.right, tr.bottom, PC_DARK_BLUE);
 
					} else if (item == this->highlighted) {
 
						GfxFillRect(r.left + 1, y, r.right - 1, y + this->resize.step_height - 1, PC_VERY_DARK_BLUE);
 
						GfxFillRect(br.left, tr.top, br.right, tr.bottom, PC_VERY_DARK_BLUE);
 
					}
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[GetDetailedFileType(item->type)]);
 
					y += this->resize.step_height;
 
					if (y >= this->vscroll->GetCapacity() * this->resize.step_height + r.top + WD_FRAMERECT_TOP) break;
 
					DrawString(tr, item->title, _fios_colours[GetDetailedFileType(item->type)]);
 
					tr = tr.Translate(0, this->resize.step_height);
 
				}
 
				break;
 
			}
 

	
 
			case WID_SL_DETAILS: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, PC_GREY);
 
				DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL / 2 + WD_FRAMERECT_TOP, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
 
			case WID_SL_DETAILS:
 
				this->DrawDetails(r);
 
				break;
 
		}
 
	}
 

	
 
	void DrawDetails(const Rect &r) const
 
	{
 
		/* Header panel */
 
		int HEADER_HEIGHT = FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 

	
 
		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);
 
		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);
 
		DrawString(hr.left, hr.right, hr.top, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
				if (this->selected == nullptr) break;
 
		if (this->selected == nullptr) return;
 

	
 
		/* Details panel */
 
		tr.bottom -= FONT_HEIGHT_NORMAL - 1;
 
		if (tr.top > tr.bottom) return;
 

	
 
				uint y = r.top + FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				uint y_max = r.bottom - FONT_HEIGHT_NORMAL - WD_FRAMERECT_BOTTOM;
 
		if (!_load_check_data.checkable) {
 
			/* Old savegame, no information available */
 
			DrawString(tr, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
		} else if (_load_check_data.error != INVALID_STRING_ID) {
 
			/* Incompatible / broken savegame */
 
			SetDParamStr(0, _load_check_data.error_data);
 
			tr.top = DrawStringMultiLine(tr, _load_check_data.error, TC_RED);
 
		} else {
 
			/* Mapsize */
 
			SetDParam(0, _load_check_data.map_size_x);
 
			SetDParam(1, _load_check_data.map_size_y);
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
			if (tr.top > tr.bottom) return;
 

	
 
				if (y > y_max) break;
 
				if (!_load_check_data.checkable) {
 
					/* Old savegame, no information available */
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
 
					y += FONT_HEIGHT_NORMAL;
 
				} else if (_load_check_data.error != INVALID_STRING_ID) {
 
					/* Incompatible / broken savegame */
 
					SetDParamStr(0, _load_check_data.error_data);
 
					y = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT,
 
							y, r.bottom - WD_FRAMERECT_BOTTOM, _load_check_data.error, TC_RED);
 
				} else {
 
					/* Mapsize */
 
					SetDParam(0, _load_check_data.map_size_x);
 
					SetDParam(1, _load_check_data.map_size_y);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_MAP_SIZE);
 
					y += FONT_HEIGHT_NORMAL;
 
					if (y > y_max) break;
 
			/* Climate */
 
			byte landscape = _load_check_data.settings.game_creation.landscape;
 
			if (landscape < NUM_LANDSCAPE) {
 
				SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
 
				DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
			}
 

	
 
			tr.top += WD_PAR_VSEP_WIDE;
 
			if (tr.top > tr.bottom) return;
 

	
 
			/* Start date (if available) */
 
			if (_load_check_data.settings.game_creation.starting_year != 0) {
 
				SetDParam(0, ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1));
 
				DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
			}
 
			if (tr.top > tr.bottom) return;
 

	
 
			/* Hide current date for scenarios */
 
			if (this->abstract_filetype != FT_SCENARIO) {
 
				/* Current date */
 
				SetDParam(0, _load_check_data.current_date);
 
				DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
			}
 

	
 
					/* Climate */
 
					byte landscape = _load_check_data.settings.game_creation.landscape;
 
					if (landscape < NUM_LANDSCAPE) {
 
						SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
 
						DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANDSCAPE);
 
						y += FONT_HEIGHT_NORMAL;
 
					}
 
			/* 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;
 
				if (tr.top > tr.bottom) return;
 

	
 
				/* NewGrf compatibility */
 
				SetDParam(0, _load_check_data.grfconfig == nullptr ? STR_NEWGRF_LIST_NONE :
 
						STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
 
				DrawString(tr, STR_SAVELOAD_DETAIL_GRFSTATUS);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
			}
 
			if (tr.top > tr.bottom) return;
 

	
 
					y += WD_PAR_VSEP_NORMAL;
 
					if (y > y_max) break;
 
			/* Hide the company stuff for scenarios */
 
			if (this->abstract_filetype != FT_SCENARIO) {
 
				tr.top += WD_PAR_VSEP_WIDE;
 
				if (tr.top > tr.bottom) return;
 

	
 
					/* Start date (if available) */
 
					if (_load_check_data.settings.game_creation.starting_year != 0) {
 
						SetDParam(0, ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1));
 
						DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_START_DATE);
 
						y += FONT_HEIGHT_NORMAL;
 
				/* Companies / AIs */
 
				for (auto &pair : _load_check_data.companies) {
 
					SetDParam(0, pair.first + 1);
 
					const CompanyProperties &c = *pair.second;
 
					if (!c.name.empty()) {
 
						SetDParam(1, STR_JUST_RAW_STRING);
 
						SetDParamStr(2, c.name);
 
					} else {
 
						SetDParam(1, c.name_1);
 
						SetDParam(2, c.name_2);
 
					}
 
					if (y > y_max) break;
 

	
 
					/* Hide current date for scenarios */
 
					if (this->abstract_filetype != FT_SCENARIO) {
 
						/* Current date */
 
						SetDParam(0, _load_check_data.current_date);
 
						DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CURRENT_DATE);
 
						y += FONT_HEIGHT_NORMAL;
 
					}
 

	
 
					/* 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)) {
 
						y += WD_PAR_VSEP_NORMAL;
 
						if (y > y_max) break;
 

	
 
						/* NewGrf compatibility */
 
						SetDParam(0, _load_check_data.grfconfig == nullptr ? STR_NEWGRF_LIST_NONE :
 
								STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
 
						DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_GRFSTATUS);
 
						y += FONT_HEIGHT_NORMAL;
 
					}
 
					if (y > y_max) break;
 

	
 
					/* Hide the company stuff for scenarios */
 
					if (this->abstract_filetype != FT_SCENARIO) {
 
						y += FONT_HEIGHT_NORMAL;
 
						if (y > y_max) break;
 

	
 
						/* Companies / AIs */
 
						for (auto &pair : _load_check_data.companies) {
 
							SetDParam(0, pair.first + 1);
 
							const CompanyProperties &c = *pair.second;
 
							if (!c.name.empty()) {
 
								SetDParam(1, STR_JUST_RAW_STRING);
 
								SetDParamStr(2, c.name);
 
							} else {
 
								SetDParam(1, c.name_1);
 
								SetDParam(2, c.name_2);
 
							}
 
							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_COMPANY_INDEX);
 
							y += FONT_HEIGHT_NORMAL;
 
							if (y > y_max) break;
 
						}
 
					}
 
					DrawString(tr, STR_SAVELOAD_DETAIL_COMPANY_INDEX);
 
					tr.top += FONT_HEIGHT_NORMAL;
 
					if (tr.top > tr.bottom) break;
 
				}
 
				break;
 
			}
 
		}
 
	}
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.left + 10, r.right - 10, r.top + WD_MATRIX_TOP, text, (IsEditable() ? TC_ORANGE : TC_SILVER));
 
				DrawString(r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM), text, (IsEditable() ? TC_ORANGE : TC_SILVER));
 
				break;
 
			}
 
			case WID_GSC_SETTINGS: {
 
@@ -195,11 +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);
 
				bool rtl = _current_text_dir == TD_RTL;
 
				uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
 
				uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
 
				uint text_right = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
 

	
 
				Rect br = ir.WithWidth(SETTING_BUTTON_WIDTH, rtl);
 
				Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
 

	
 
				int y = r.top;
 
				int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
@@ -228,13 +227,13 @@ struct GSConfigWindow : public Window {
 
					}
 

	
 
					if ((config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
 
						DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, editable);
 
						DrawBoolButton(br.left, y + button_y_offset, current_value != 0, editable);
 
						SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
 
					} else {
 
						if (config_item.complete_labels) {
 
							DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
 
							DrawDropDownButton(br.left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
 
						} else {
 
							DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
 
							DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
 
						}
 
						if (config_item.labels != nullptr && config_item.labels->Contains(current_value)) {
 
							SetDParam(idx++, STR_JUST_RAW_STRING);
 
@@ -245,7 +244,7 @@ struct GSConfigWindow : public Window {
 
						}
 
					}
 

	
 
					DrawString(text_left, text_right, y + text_y_offset, str, colour);
 
					DrawString(tr.left, tr.right, y + text_y_offset, str, colour);
 
					y += this->line_height;
 
				}
 
				break;
 
@@ -289,9 +288,10 @@ struct GSConfigWindow : public Window {
 
					ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_GAME);
 
				}
 
				break;
 

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

	
 
				VisibleSettingsList::const_iterator it = this->visible_settings.begin();
 
@@ -308,9 +308,8 @@ struct GSConfigWindow : public Window {
 

	
 
				bool bool_item = (config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0;
 

	
 
				int x = pt.x - wid->pos_x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
 
				x -= 4;
 
				int x = pt.x - r.left;
 
				if (_current_text_dir == TD_RTL) x = r.Width() - 1 - x;
 

	
 
				/* One of the arrows is clicked (or green/red rect in case of bool value) */
 
				int old_val = this->gs_config->GetSetting(config_item.name);
 
@@ -321,8 +320,7 @@ struct GSConfigWindow : public Window {
 
						this->clicked_dropdown = false;
 
						this->closing_dropdown = false;
 
					} else {
 
						const NWidgetBase* wid = this->GetWidget<NWidgetBase>(WID_GSC_SETTINGS);
 
						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);
src/genworld_gui.cpp
Show inline comments
 
@@ -1422,13 +1422,15 @@ struct GenerateProgressWindow : public W
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GP_PROGRESS_BAR:
 
			case WID_GP_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
 
				DrawFrameRect(r.left + 1, r.top + 1, (int)((r.right - r.left - 2) * _gws.percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE);
 
				DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY);
 
				Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE);
 
				SetDParam(0, _gws.percent);
 
				DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
			case WID_GP_PROGRESS_TEXT:
 
				/* Tell which class we are generating */
src/goal_gui.cpp
Show inline comments
 
@@ -192,9 +192,7 @@ struct GoalListWindow : public Window {
 
	void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
 
	{
 
		/* Get column draw area. */
 
		int y = wid->pos_y + WD_FRAMERECT_TOP;
 
		int x = wid->pos_x + WD_FRAMERECT_LEFT;
 
		int right = x + wid->current_x - WD_FRAMERECT_RIGHT;
 
		Rect r = wid->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		int pos = -this->vscroll->GetPosition();
 
@@ -209,7 +207,7 @@ struct GoalListWindow : public Window {
 
							/* Display the goal. */
 
							SetDParamStr(0, s->text);
 
							uint width_reduction = progress_col_width > 0 ? progress_col_width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT : 0;
 
							DrawString(x + (rtl ? width_reduction : 0), right - (rtl ? 0 : width_reduction), y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_TEXT);
 
							DrawString(r.Indent(width_reduction, !rtl), STR_GOALS_TEXT);
 
							break;
 
						}
 

	
 
@@ -217,12 +215,11 @@ struct GoalListWindow : public Window {
 
							if (s->progress != nullptr) {
 
								SetDParamStr(0, s->progress);
 
								StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
 
								int progress_x = x;
 
								int progress_right = rtl ? x + progress_col_width : right;
 
								DrawString(progress_x, progress_right, y + pos * FONT_HEIGHT_NORMAL, str, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
 
								DrawString(r.WithWidth(progress_col_width, !rtl), str, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
 
							}
 
							break;
 
					}
 
					r.top += FONT_HEIGHT_NORMAL;
 
				}
 
				pos++;
 
				num++;
 
@@ -231,9 +228,8 @@ struct GoalListWindow : public Window {
 

	
 
		if (num == 0) {
 
			if (column == GC_GOAL && IsInsideMM(pos, 0, cap)) {
 
				DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_NONE);
 
				DrawString(r, STR_GOALS_NONE);
 
			}
 
			pos++;
 
		}
 
	}
 

	
 
@@ -297,8 +293,7 @@ static const NWidgetPart _nested_goals_l
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PANEL, COLOUR_BROWN), SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetScrollbar(WID_GOAL_SCROLLBAR),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_GOAL_LIST), SetResize(1, 1), SetMinimalTextLines(2, 0), SetFill(1, 1), SetPadding(WD_FRAMERECT_TOP, 2, WD_FRAMETEXT_BOTTOM, 2),
 
		NWidget(WWT_PANEL, COLOUR_BROWN, WID_GOAL_LIST), SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetScrollbar(WID_GOAL_SCROLLBAR), SetResize(1, 1), SetMinimalTextLines(2, 0),
 
		EndContainer(),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_GOAL_SCROLLBAR),
 
@@ -412,7 +407,7 @@ struct GoalQuestionWindow : public Windo
 
		if (widget != WID_GQ_QUESTION) return;
 

	
 
		SetDParamStr(0, this->question);
 
		DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, this->colour, SA_TOP | SA_HOR_CENTER);
 
		DrawStringMultiLine(r, STR_JUST_RAW_STRING, this->colour, SA_TOP | SA_HOR_CENTER);
 
	}
 
};
 

	
src/graph_gui.cpp
Show inline comments
 
@@ -65,12 +65,14 @@ 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);
 
		Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
 
		DrawCompanyIcon(cid, rtl ? r.right - d.width - ScaleGUITrad(2) : r.left + ScaleGUITrad(2), CenterBounds(r.top, r.bottom, d.height));
 
		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);
 
		SetDParam(0, cid);
 
		SetDParam(1, cid);
 
		DrawString(r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : (d.width + ScaleGUITrad(4))), r.right - (rtl ? (d.width + ScaleGUITrad(4)) : (uint)WD_FRAMERECT_RIGHT), CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
 
		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);
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
@@ -943,32 +945,31 @@ struct PaymentRatesGraphWindow : BaseGra
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		int x = r.left + WD_FRAMERECT_LEFT;
 
		int y = r.top;
 
		uint row_height = FONT_HEIGHT_SMALL;
 
		int padding = ScaleFontTrad(1);
 

	
 
		int pos = this->vscroll->GetPosition();
 
		int max = pos + this->vscroll->GetCapacity();
 

	
 
		Rect line = r.WithHeight(this->line_height);
 
		for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
 
			if (pos-- > 0) continue;
 
			if (--max < 0) break;
 

	
 
			bool lowered = !HasBit(_legend_excluded_cargo, cs->Index());
 

	
 
			/* Redraw box if lowered */
 
			if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_BROWN, FR_LOWERED);
 
			/* Redraw frame if lowered */
 
			if (lowered) DrawFrameRect(line, COLOUR_BROWN, FR_LOWERED);
 

	
 
			byte clk_dif = lowered ? 1 : 0;
 
			int rect_x = clk_dif + (rtl ? r.right - this->legend_width - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT);
 
			const Rect text = line.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM).Translate(lowered ? 1 : 0, lowered ? 1 : 0);
 

	
 
			GfxFillRect(rect_x, y + padding + clk_dif, rect_x + this->legend_width, y + row_height - 1 + clk_dif, PC_BLACK);
 
			GfxFillRect(rect_x + 1, y + padding + 1 + clk_dif, rect_x + this->legend_width - 1, y + row_height - 2 + clk_dif, cs->legend_colour);
 
			/* 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);
 

	
 
			/* Cargo name */
 
			SetDParam(0, cs->name);
 
			DrawString(rtl ? r.left : x + this->legend_width + 4 + clk_dif, (rtl ? r.right - this->legend_width - 4 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
 
			DrawString(text.Indent(this->legend_width + 4, rtl), STR_GRAPH_CARGO_PAYMENT_CARGO);
 

	
 
			y += this->line_height;
 
			line = line.Translate(0, this->line_height);
 
		}
 
	}
 

	
 
@@ -1132,8 +1133,8 @@ private:
 
	GUIList<const Company*> companies;
 
	uint ordinal_width; ///< The width of the ordinal number
 
	uint text_width;    ///< The width of the actual text
 
	uint icon_width;    ///< The width of the company icon
 
	int line_height;    ///< Height of the text lines
 
	Dimension icon;     ///< Dimenion of the company icon.
 

	
 
	/**
 
	 * (Re)Build the company league list
 
@@ -1178,27 +1179,26 @@ public:
 
	{
 
		if (widget != WID_CL_BACKGROUND) return;
 

	
 
		int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - this->line_height) / 2;
 
		uint y = r.top + WD_FRAMERECT_TOP - icon_y_offset;
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		int icon_y_offset = (this->line_height - this->icon.height) / 2;
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint ordinal_left  = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT;
 
		uint ordinal_right = rtl ? r.right - WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->ordinal_width;
 
		uint icon_left     = r.left + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + (rtl ? this->text_width : this->ordinal_width);
 
		uint text_left     = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width;
 
		uint text_right    = rtl ? r.left + WD_FRAMERECT_LEFT + this->text_width : r.right - WD_FRAMERECT_LEFT;
 
		Rect ordinal = ir.WithWidth(this->ordinal_width, rtl);
 
		uint icon_left = ir.Indent(rtl ? this->text_width : this->ordinal_width, rtl).left;
 
		Rect text    = ir.WithWidth(this->text_width, !rtl);
 

	
 
		for (uint i = 0; i != this->companies.size(); i++) {
 
			const Company *c = this->companies[i];
 
			DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
 
			DrawString(ordinal.left, ordinal.right, ir.top + text_y_offset, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
 

	
 
			DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
 
			DrawCompanyIcon(c->index, icon_left, ir.top + icon_y_offset);
 

	
 
			SetDParam(0, c->index);
 
			SetDParam(1, c->index);
 
			SetDParam(2, GetPerformanceTitleFromValue(c->old_economy[0].performance_history));
 
			DrawString(text_left, text_right, y, STR_COMPANY_LEAGUE_COMPANY_NAME);
 
			y += this->line_height;
 
			DrawString(text.left, text.right, ir.top + text_y_offset, STR_COMPANY_LEAGUE_COMPANY_NAME);
 
			ir.top += this->line_height;
 
		}
 
	}
 

	
 
@@ -1222,9 +1222,8 @@ public:
 
			}
 
		}
 

	
 
		Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
 
		this->icon_width = d.width + 2;
 
		this->line_height = std::max<int>(d.height + 2, FONT_HEIGHT_NORMAL);
 
		this->icon = GetSpriteSize(SPR_COMPANY_ICON);
 
		this->line_height = std::max<int>(this->icon.height + 2, FONT_HEIGHT_NORMAL);
 

	
 
		for (const Company *c : Company::Iterate()) {
 
			SetDParam(0, c->index);
 
@@ -1235,7 +1234,7 @@ public:
 

	
 
		this->text_width = widest_width + 30; // 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->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;
 
	}
 

	
src/group_gui.cpp
Show inline comments
 
@@ -563,25 +563,23 @@ public:
 
					occupancy += v->trip_occupancy;
 
				}
 

	
 
				const int left  = r.left + WD_FRAMERECT_LEFT + 8;
 
				const int right = r.right - WD_FRAMERECT_RIGHT - 8;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				DrawString(left, right, y, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
 
				DrawString(tr, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
 
				SetDParam(0, this_year);
 
				DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
 
				DrawString(tr, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
 

	
 
				y += FONT_HEIGHT_NORMAL;
 
				DrawString(left, right, y, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
				DrawString(tr, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
 
				SetDParam(0, last_year);
 
				DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
 
				DrawString(tr, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
 

	
 
				y += FONT_HEIGHT_NORMAL;
 
				DrawString(left, right, y, STR_GROUP_OCCUPANCY, TC_BLACK);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
				DrawString(tr, STR_GROUP_OCCUPANCY, TC_BLACK);
 
				const size_t vehicle_count = this->vehicles.size();
 
				if (vehicle_count > 0) {
 
					SetDParam(0, occupancy / vehicle_count);
 
					DrawString(left, right, y, STR_GROUP_OCCUPANCY_VALUE, TC_BLACK, SA_RIGHT);
 
					DrawString(tr, STR_GROUP_OCCUPANCY_VALUE, TC_BLACK, SA_RIGHT);
 
				}
 

	
 
				break;
 
@@ -612,14 +610,14 @@ public:
 
			case WID_GL_LIST_VEHICLE:
 
				if (this->vli.index != ALL_GROUP && this->grouping == GB_NONE) {
 
					/* Mark vehicles which are in sub-groups (only if we are not using shared order coalescing) */
 
					int y = r.top;
 
					Rect mr = r.WithHeight(this->resize.step_height);
 
					uint max = static_cast<uint>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
 
					for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
						const Vehicle *v = this->vehgroups[i].GetSingleVehicle();
 
						if (v->group_id != this->vli.index) {
 
							GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 2, _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
 
							GfxFillRect(mr.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
 
						}
 
						y += this->resize.step_height;
 
						mr = mr.Translate(0, this->resize.step_height);
 
					}
 
				}
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -513,52 +513,41 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_DPI_MATRIX_WIDGET: {
 
				uint text_left, text_right, icon_left, icon_right;
 
				if (_current_text_dir == TD_RTL) {
 
					icon_right = r.right    - WD_MATRIX_RIGHT;
 
					icon_left  = icon_right - this->legend.width;
 
					text_right = icon_left  - ScaleFontTrad(7);
 
					text_left  = r.left     + WD_MATRIX_LEFT;
 
				} else {
 
					icon_left  = r.left     + WD_MATRIX_LEFT;
 
					icon_right = icon_left  + this->legend.width;
 
					text_left  = icon_right + ScaleFontTrad(7);
 
					text_right = r.right    - WD_MATRIX_RIGHT;
 
				}
 
				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 icon = text.WithWidth(this->legend.width, rtl);
 
				text = text.Indent(this->legend.width + ScaleFontTrad(7), rtl);
 

	
 
				/* Vertical offset for legend icon. */
 
				int icon_top    = (this->resize.step_height - this->legend.height + 1) / 2;
 
				int icon_bottom = icon_top + this->legend.height;
 
				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();
 

	
 
					if (this->index[i + this->vscroll->GetPosition()] == INVALID_INDUSTRYTYPE) {
 
						DrawString(text_left, text_right, y + WD_MATRIX_TOP, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES, selected ? TC_WHITE : TC_ORANGE);
 
						y += this->resize.step_height;
 
						continue;
 
						DrawString(text, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES, selected ? TC_WHITE : TC_ORANGE);
 
					} else {
 
						const IndustrySpec *indsp = GetIndustrySpec(this->index[i + this->vscroll->GetPosition()]);
 

	
 
						/* 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);
 
					}
 
					const IndustrySpec *indsp = GetIndustrySpec(this->index[i + this->vscroll->GetPosition()]);
 

	
 
					/* Draw the name of the industry in white is selected, otherwise, in orange */
 
					DrawString(text_left, text_right, y + WD_MATRIX_TOP, indsp->name, selected ? TC_WHITE : TC_ORANGE);
 
					GfxFillRect(icon_left,     y + icon_top,     icon_right,     y + icon_bottom,     selected ? PC_WHITE : PC_BLACK);
 
					GfxFillRect(icon_left + 1, y + icon_top + 1, icon_right - 1, y + icon_bottom - 1, indsp->map_colour);
 

	
 
					y += this->resize.step_height;
 

	
 
					text = text.Translate(0, this->resize.step_height);
 
					icon = icon.Translate(0, this->resize.step_height);
 
				}
 
				break;
 
			}
 

	
 
			case WID_DPI_INFOPANEL: {
 
				int y      = r.top    + WD_FRAMERECT_TOP;
 
				int bottom = r.bottom - WD_FRAMERECT_BOTTOM;
 
				int left   = r.left   + WD_FRAMERECT_LEFT;
 
				int right  = r.right  - WD_FRAMERECT_RIGHT;
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
				if (this->selected_type == INVALID_INDUSTRYTYPE) {
 
					DrawStringMultiLine(left, right, y,  bottom, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP);
 
					DrawStringMultiLine(ir, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP);
 
					break;
 
				}
 

	
 
@@ -566,8 +555,8 @@ public:
 

	
 
				if (_game_mode != GM_EDITOR) {
 
					SetDParam(0, indsp->GetConstructionCost());
 
					DrawString(left, right, y, STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST);
 
					y += FONT_HEIGHT_NORMAL;
 
					DrawString(ir, STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST);
 
					ir.top += FONT_HEIGHT_NORMAL;
 
				}
 

	
 
				CargoSuffix cargo_suffix[lengthof(indsp->accepts_cargo)];
 
@@ -575,12 +564,12 @@ public:
 
				/* Draw the accepted cargoes, if any. Otherwise, will print "Nothing". */
 
				GetAllCargoSuffixes(CARGOSUFFIX_IN, CST_FUND, nullptr, this->selected_type, indsp, indsp->accepts_cargo, cargo_suffix);
 
				std::string cargostring = this->MakeCargoListString(indsp->accepts_cargo, cargo_suffix, lengthof(indsp->accepts_cargo), STR_INDUSTRY_VIEW_REQUIRES_N_CARGO);
 
				y = DrawStringMultiLine(left, right, y, bottom, cargostring);
 
				ir.top = DrawStringMultiLine(ir, cargostring);
 

	
 
				/* Draw the produced cargoes, if any. Otherwise, will print "Nothing". */
 
				GetAllCargoSuffixes(CARGOSUFFIX_OUT, CST_FUND, nullptr, this->selected_type, indsp, indsp->produced_cargo, cargo_suffix);
 
				cargostring = this->MakeCargoListString(indsp->produced_cargo, cargo_suffix, lengthof(indsp->produced_cargo), STR_INDUSTRY_VIEW_PRODUCES_N_CARGO);
 
				y = DrawStringMultiLine(left, right, y, bottom, cargostring);
 
				ir.top = DrawStringMultiLine(ir, cargostring);
 

	
 
				/* Get the additional purchase info text, if it has not already been queried. */
 
				if (HasBit(indsp->callback_mask, CBM_IND_FUND_MORE_TEXT)) {
 
@@ -592,7 +581,7 @@ public:
 
							StringID str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res);  // No. here's the new string
 
							if (str != STR_UNDEFINED) {
 
								StartTextRefStackUsage(indsp->grf_prop.grffile, 6);
 
								DrawStringMultiLine(left, right, y, bottom, str, TC_YELLOW);
 
								DrawStringMultiLine(ir, str, TC_YELLOW);
 
								StopTextRefStackUsage();
 
							}
 
						}
 
@@ -848,10 +837,10 @@ public:
 

	
 
		if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
 

	
 
		NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_IV_INFO);
 
		uint expected = this->DrawInfo(nwi->pos_x, nwi->pos_x + nwi->current_x - 1, nwi->pos_y) - nwi->pos_y;
 
		if (expected > nwi->current_y - 1) {
 
			this->info_height = expected + 1;
 
		const Rect r = this->GetWidget<NWidgetBase>(WID_IV_INFO)->GetCurrentRect();
 
		int expected = this->DrawInfo(r);
 
		if (expected > r.bottom) {
 
			this->info_height = expected - r.top + 1;
 
			this->ReInit();
 
			return;
 
		}
 
@@ -864,30 +853,29 @@ public:
 
	 * @param top   Top edge of the panel.
 
	 * @return Expected position of the bottom edge of the panel.
 
	 */
 
	int DrawInfo(uint left, uint right, uint top)
 
	int DrawInfo(const Rect &r)
 
	{
 
		Industry *i = Industry::Get(this->window_number);
 
		const IndustrySpec *ind = GetIndustrySpec(i->type);
 
		int y = top + WD_FRAMERECT_TOP;
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		bool first = true;
 
		bool has_accept = false;
 

	
 
		if (i->prod_level == PRODLEVEL_CLOSURE) {
 
			DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE);
 
			y += 2 * FONT_HEIGHT_NORMAL;
 
			DrawString(ir, STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE);
 
			ir.top += 2 * FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		CargoSuffix cargo_suffix[lengthof(i->accepts_cargo)];
 
		GetAllCargoSuffixes(CARGOSUFFIX_IN, CST_VIEW, i, i->type, ind, i->accepts_cargo, cargo_suffix);
 
		bool stockpiling = HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS);
 

	
 
		uint left_side = left + WD_FRAMERECT_LEFT * 4; // Indent accepted cargoes.
 
		for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 
			if (i->accepts_cargo[j] == CT_INVALID) continue;
 
			has_accept = true;
 
			if (first) {
 
				DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_REQUIRES);
 
				y += FONT_HEIGHT_NORMAL;
 
				DrawString(ir, STR_INDUSTRY_VIEW_REQUIRES);
 
				ir.top += FONT_HEIGHT_NORMAL;
 
				first = false;
 
			}
 
			SetDParam(0, CargoSpec::Get(i->accepts_cargo[j])->name);
 
@@ -913,8 +901,8 @@ public:
 
				default:
 
					NOT_REACHED();
 
			}
 
			DrawString(left_side, right - WD_FRAMERECT_RIGHT, y, str);
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(ir.Indent(10, _current_text_dir == TD_RTL), str);
 
			ir.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		GetAllCargoSuffixes(CARGOSUFFIX_OUT, CST_VIEW, i, i->type, ind, i->produced_cargo, cargo_suffix);
 
@@ -922,10 +910,10 @@ public:
 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
			if (i->produced_cargo[j] == CT_INVALID) continue;
 
			if (first) {
 
				if (has_accept) y += WD_PAR_VSEP_WIDE;
 
				DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
 
				y += FONT_HEIGHT_NORMAL;
 
				if (this->editable == EA_RATE) this->production_offset_y = y;
 
				if (has_accept) ir.top += WD_PAR_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;
 
				first = false;
 
			}
 

	
 
@@ -933,26 +921,24 @@ public:
 
			SetDParam(1, i->last_month_production[j]);
 
			SetDParamStr(2, cargo_suffix[j].text);
 
			SetDParam(3, ToPercent8(i->last_month_pct_transported[j]));
 
			uint x = left + WD_FRAMETEXT_LEFT + (this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + 10 : 0);
 
			DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_TRANSPORTED);
 
			DrawString(ir.Indent(this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + 10 : 0, false), STR_INDUSTRY_VIEW_TRANSPORTED);
 
			/* Let's put out those buttons.. */
 
			if (this->editable == EA_RATE) {
 
				DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0,
 
				DrawArrowButtons(ir.left, ir.top, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0,
 
						i->production_rate[j] > 0, i->production_rate[j] < 255);
 
			}
 
			y += FONT_HEIGHT_NORMAL;
 
			ir.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		/* Display production multiplier if editable */
 
		if (this->editable == EA_MULTIPLIER) {
 
			y += WD_PAR_VSEP_WIDE;
 
			this->production_offset_y = y;
 
			ir.top += WD_PAR_VSEP_WIDE;
 
			this->production_offset_y = ir.top;
 
			SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
 
			uint x = left + WD_FRAMETEXT_LEFT + SETTING_BUTTON_WIDTH + 10;
 
			DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
 
			DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0,
 
			DrawString(ir.Indent(SETTING_BUTTON_WIDTH + 10, 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);
 
			y += FONT_HEIGHT_NORMAL;
 
			ir.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		/* Get the extra message for the GUI */
 
@@ -964,13 +950,13 @@ public:
 
				} else {
 
					StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res);
 
					if (message != STR_NULL && message != STR_UNDEFINED) {
 
						y += WD_PAR_VSEP_WIDE;
 
						ir.top += WD_PAR_VSEP_WIDE;
 

	
 
						StartTextRefStackUsage(ind->grf_prop.grffile, 6);
 
						/* Use all the available space left from where we stand up to the
 
						 * end of the window. We ALSO enlarge the window if needed, so we
 
						 * can 'go' wild with the bottom of the window. */
 
						y = DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, UINT16_MAX, message, TC_BLACK);
 
						ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, message, TC_BLACK);
 
						StopTextRefStackUsage();
 
					}
 
				}
 
@@ -979,11 +965,11 @@ public:
 

	
 
		if (!i->text.empty()) {
 
			SetDParamStr(0, i->text);
 
			y += WD_PAR_VSEP_WIDE;
 
			y = DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
 
			ir.top += WD_PAR_VSEP_WIDE;
 
			ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
 
		}
 

	
 
		return y + WD_FRAMERECT_BOTTOM;
 
		return ir.top - 1 + WD_FRAMERECT_BOTTOM;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
@@ -1661,9 +1647,9 @@ public:
 

	
 
			case WID_ID_INDUSTRY_LIST: {
 
				int n = 0;
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				if (this->industries.size() == 0) {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_DIRECTORY_NONE);
 
					DrawString(ir, STR_INDUSTRY_DIRECTORY_NONE);
 
					break;
 
				}
 
				TextColour tc;
 
@@ -1676,9 +1662,9 @@ public:
 
							tc = TC_GREY | TC_FORCED;
 
						}
 
					}
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, this->GetIndustryString(this->industries[i]), tc);
 

	
 
					y += this->resize.step_height;
 
					DrawString(ir, this->GetIndustryString(this->industries[i]), tc);
 

	
 
					ir.top += this->resize.step_height;
 
					if (++n == this->vscroll->GetCapacity()) break; // max number of industries in 1 window
 
				}
 
				break;
 
@@ -2920,14 +2906,13 @@ 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);
 
		DrawPixelInfo tmp_dpi, *old_dpi;
 
		int width = r.Width();
 
		int height = r.Height() - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM;
 
		if (!FillDrawPixelInfo(&tmp_dpi, r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, width, height)) return;
 
		if (!FillDrawPixelInfo(&tmp_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
		old_dpi = _cur_dpi;
 
		_cur_dpi = &tmp_dpi;
 

	
 
		int left_pos = WD_FRAMERECT_LEFT;
 
		int left_pos = ir.left;
 
		if (this->ind_cargo >= NUM_INDUSTRYTYPES) left_pos += (CargoesField::industry_width + CargoesField::cargo_field_width) / 2;
 
		int last_column = (this->ind_cargo < NUM_INDUSTRYTYPES) ? 4 : 2;
 

	
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -610,15 +610,17 @@ 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);
 
	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);
 
		Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
		DrawCompanyIcon(cid, CenterBounds(r.left, r.right, sprite_size.width), CenterBounds(r.top, r.bottom, sprite_size.height));
 
		DrawCompanyIcon(cid, CenterBounds(br.left, br.right, sprite_size.width), CenterBounds(br.top, br.bottom, sprite_size.height));
 
	}
 
	if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) {
 
		uint8 colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][widget - WID_LGL_SATURATION_FIRST];
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, colour);
 
		GfxFillRect(br, colour);
 
		StringID str = STR_NULL;
 
		if (widget == WID_LGL_SATURATION_FIRST) {
 
			str = STR_LINKGRAPH_LEGEND_UNUSED;
 
@@ -628,14 +630,14 @@ void LinkGraphLegendWindow::DrawWidget(c
 
			str = STR_LINKGRAPH_LEGEND_SATURATED;
 
		}
 
		if (str != STR_NULL) {
 
			DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_SMALL), str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER);
 
			DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER);
 
		}
 
	}
 
	if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
 
		if (this->IsWidgetDisabled(widget)) return;
 
		CargoSpec *cargo = CargoSpec::Get(widget - WID_LGL_CARGO_FIRST);
 
		GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, cargo->legend_colour);
 
		DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_SMALL), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER);
 
		GfxFillRect(br, cargo->legend_colour);
 
		DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER);
 
	}
 
}
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -75,16 +75,15 @@ public:
 
	{
 
		if (widget != WID_LI_BACKGROUND) return;
 

	
 
		uint y = r.top + WD_TEXTPANEL_TOP;
 
		Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_TEXTPANEL_TOP, WD_FRAMETEXT_RIGHT, WD_TEXTPANEL_BOTTOM);
 
		for (size_t i = 0; i < this->landinfo_data.size(); i++) {
 
			DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_HOR_CENTER);
 
			y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			if (i == 0) y += 4;
 
			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);
 
		}
 

	
 
		if (!this->cargo_acceptance.empty()) {
 
			SetDParamStr(0, this->cargo_acceptance);
 
			DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, r.bottom - WD_TEXTPANEL_BOTTOM, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(ir, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
@@ -97,8 +96,7 @@ public:
 
			uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
 
			size->width = std::max(size->width, width);
 

	
 
			size->height += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			if (i == 0) size->height += 4;
 
			size->height += FONT_HEIGHT_NORMAL + (i == 0 ? WD_PAR_VSEP_WIDE : WD_PAR_VSEP_NORMAL);
 
		}
 

	
 
		if (!this->cargo_acceptance.empty()) {
 
@@ -730,13 +728,13 @@ struct TooltipsWindow : public Window
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		/* There is only one widget. */
 
		GfxFillRect(r.left, r.top, r.right, r.bottom, PC_BLACK);
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_LIGHT_YELLOW);
 
		GfxFillRect(r, PC_BLACK);
 
		GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_LIGHT_YELLOW);
 

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

	
 
	void OnMouseLoop() override
 
@@ -1041,8 +1039,7 @@ struct QueryStringWindow : public Window
 
		if (widget != WID_QS_WARNING) return;
 

	
 
		if (this->flags & QSF_PASSWORD) {
 
			DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT - WD_FRAMERECT_RIGHT,
 
				r.top + WD_FRAMERECT_TOP + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMERECT_BOTTOM - WD_FRAMETEXT_BOTTOM,
 
			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),
 
				STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 
@@ -1194,7 +1191,7 @@ struct QueryWindow : public Window {
 
	{
 
		if (widget != WID_Q_TEXT) return;
 

	
 
		DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
 
		DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM),
 
				this->message, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
src/music_gui.cpp
Show inline comments
 
@@ -522,29 +522,29 @@ struct MusicTrackSelectionWindow : publi
 
	{
 
		switch (widget) {
 
			case WID_MTS_LIST_LEFT: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK);
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				for (MusicSystem::Playlist::const_iterator song = _music.music_set.begin(); song != _music.music_set.end(); ++song) {
 
					SetDParam(0, song->tracknr);
 
					SetDParam(1, 2);
 
					SetDParamStr(2, song->songname);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_PLAYLIST_TRACK_NAME);
 
					y += FONT_HEIGHT_SMALL;
 
					DrawString(tr, STR_PLAYLIST_TRACK_NAME);
 
					tr.top += FONT_HEIGHT_SMALL;
 
				}
 
				break;
 
			}
 

	
 
			case WID_MTS_LIST_RIGHT: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK);
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				for (MusicSystem::Playlist::const_iterator song = _music.active_playlist.begin(); song != _music.active_playlist.end(); ++song) {
 
					SetDParam(0, song->tracknr);
 
					SetDParam(1, 2);
 
					SetDParamStr(2, song->songname);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_PLAYLIST_TRACK_NAME);
 
					y += FONT_HEIGHT_SMALL;
 
					DrawString(tr, STR_PLAYLIST_TRACK_NAME);
 
					tr.top += FONT_HEIGHT_SMALL;
 
				}
 
				break;
 
			}
 
@@ -712,7 +712,7 @@ struct MusicWindow : public Window {
 
	{
 
		switch (widget) {
 
			case WID_M_TRACK_NR: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK);
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, 0, WD_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.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str);
 
				DrawString(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM), str);
 
				break;
 
			}
 

	
 
			case WID_M_TRACK_NAME: {
 
				GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, PC_BLACK);
 
				GfxFillRect(r.Shrink(0, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_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.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM), str, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
src/network/network_content_gui.cpp
Show inline comments
 
@@ -616,17 +616,15 @@ public:
 
	 */
 
	void DrawMatrix(const Rect &r) const
 
	{
 
		const NWidgetBase *nwi_checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
 
		const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NCL_NAME);
 
		const NWidgetBase *nwi_type = this->GetWidget<NWidgetBase>(WID_NCL_TYPE);
 

	
 
		int line_height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL);
 
		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 type = this->GetWidget<NWidgetBase>(WID_NCL_TYPE)->GetCurrentRect();
 

	
 
		/* Fill the matrix with the information */
 
		int sprite_y_offset = WD_MATRIX_TOP + (line_height - this->checkbox_size.height) / 2 - 1;
 
		int text_y_offset = WD_MATRIX_TOP + (line_height - FONT_HEIGHT_NORMAL) / 2;
 
		uint y = r.top;
 
		int sprite_y_offset = (this->resize.step_height - this->checkbox_size.height) / 2;
 
		int text_y_offset   = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2;
 

	
 
		Rect mr = r.WithHeight(this->resize.step_height);
 
		auto iter = this->content.begin() + this->vscroll->GetPosition();
 
		size_t last = this->vscroll->GetPosition() + this->vscroll->GetCapacity();
 
		auto end = (last < this->content.size()) ? this->content.begin() + last : this->content.end();
 
@@ -634,7 +632,7 @@ public:
 
		for (/**/; iter != end; iter++) {
 
			const ContentInfo *ci = *iter;
 

	
 
			if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY);
 
			if (ci == this->selected) GfxFillRect(mr.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_GREY);
 

	
 
			SpriteID sprite;
 
			SpriteID pal = PAL_NONE;
 
@@ -646,13 +644,13 @@ public:
 
				case ContentInfo::DOES_NOT_EXIST: sprite = SPR_BLOT; pal = PALETTE_TO_RED;   break;
 
				default: NOT_REACHED();
 
			}
 
			DrawSprite(sprite, pal, nwi_checkbox->pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
 
			DrawSprite(sprite, pal, checkbox.left + (sprite == SPR_BLOT ? 3 : 2), mr.top + sprite_y_offset + (sprite == SPR_BLOT ? 0 : 1));
 

	
 
			StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS;
 
			DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK, SA_HOR_CENTER);
 
			DrawString(type.left, type.right, mr.top + text_y_offset, str, TC_BLACK, SA_HOR_CENTER);
 

	
 
			DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + text_y_offset, ci->name, TC_BLACK);
 
			y += this->resize.step_height;
 
			DrawString(name.left, name.right, mr.top + text_y_offset, ci->name, TC_BLACK);
 
			mr = mr.Translate(0, this->resize.step_height);
 
		}
 
	}
 

	
 
@@ -662,60 +660,59 @@ public:
 
	 */
 
	void DrawDetails(const Rect &r) const
 
	{
 
		static const int DETAIL_LEFT         =  5; ///< Number of pixels at the left
 
		static const int DETAIL_RIGHT        =  5; ///< Number of pixels at the right
 
		static const int DETAIL_TOP          =  5; ///< Number of pixels at the top
 
		/* Height for the title banner */
 
		int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 

	
 
		/* Height for the title banner */
 
		int DETAIL_TITLE_HEIGHT = 5 * FONT_HEIGHT_NORMAL;
 
		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);
 
		tr.top += HEADER_HEIGHT;
 

	
 
		/* Create the nice grayish rectangle at the details top */
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + DETAIL_TITLE_HEIGHT, PC_DARK_BLUE);
 
		DrawString(r.left + WD_INSET_LEFT, r.right - WD_INSET_RIGHT, r.top + FONT_HEIGHT_NORMAL + WD_INSET_TOP, STR_CONTENT_DETAIL_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
 
		GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_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 */
 
		SetDParam(0, this->filesize_sum);
 
		DrawString(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, r.bottom - FONT_HEIGHT_NORMAL - WD_PAR_VSEP_NORMAL, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
 
		DrawString(tr.left, tr.right, tr.bottom - FONT_HEIGHT_NORMAL + 1, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
 

	
 
		if (this->selected == nullptr) return;
 

	
 
		/* And fill the rest of the details when there's information to place there */
 
		DrawStringMultiLine(r.left + WD_INSET_LEFT, r.right - WD_INSET_RIGHT, r.top + DETAIL_TITLE_HEIGHT / 2, r.top + DETAIL_TITLE_HEIGHT, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER);
 
		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 */
 
		const uint max_y = r.bottom - FONT_HEIGHT_NORMAL - WD_PAR_VSEP_WIDE;
 
		int y = r.top + DETAIL_TITLE_HEIGHT + DETAIL_TOP;
 
		tr.bottom -= FONT_HEIGHT_NORMAL + WD_PAR_VSEP_WIDE;
 

	
 
		if (this->selected->upgrade) {
 
			SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
 
			y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_UPDATE);
 
			y += WD_PAR_VSEP_WIDE;
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_UPDATE);
 
			tr.top += WD_PAR_VSEP_WIDE;
 
		}
 

	
 
		SetDParamStr(0, this->selected->name);
 
		y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_NAME);
 
		tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_NAME);
 

	
 
		if (!this->selected->version.empty()) {
 
			SetDParamStr(0, this->selected->version);
 
			y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_VERSION);
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_VERSION);
 
		}
 

	
 
		if (!this->selected->description.empty()) {
 
			SetDParamStr(0, this->selected->description);
 
			y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DESCRIPTION);
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_DESCRIPTION);
 
		}
 

	
 
		if (!this->selected->url.empty()) {
 
			SetDParamStr(0, this->selected->url);
 
			y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_URL);
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_URL);
 
		}
 

	
 
		SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
 
		y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TYPE);
 
		tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_TYPE);
 

	
 
		y += WD_PAR_VSEP_WIDE;
 
		tr.top += WD_PAR_VSEP_WIDE;
 
		SetDParam(0, this->selected->filesize);
 
		y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_FILESIZE);
 
		tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_FILESIZE);
 

	
 
		if (!this->selected->dependencies.empty()) {
 
			/* List dependencies */
 
@@ -733,7 +730,7 @@ public:
 
				}
 
			}
 
			SetDParamStr(0, buf);
 
			y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES);
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_DEPENDENCIES);
 
		}
 

	
 
		if (!this->selected->tags.empty()) {
 
@@ -744,7 +741,7 @@ public:
 
				p += seprintf(p, lastof(buf), p == buf ? "%s" : ", %s", tag.c_str());
 
			}
 
			SetDParamStr(0, buf);
 
			y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TAGS);
 
			tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_TAGS);
 
		}
 

	
 
		if (this->selected->IsSelected()) {
 
@@ -761,7 +758,7 @@ public:
 
			}
 
			if (p != buf) {
 
				SetDParamStr(0, buf);
 
				y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
 
				tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
 
			}
 
		}
 
	}
src/network/network_gui.cpp
Show inline comments
 
@@ -633,15 +633,19 @@ public:
 
	{
 
		NetworkGameList *sel = this->server;
 

	
 
		const int detail_height = 6 + 8 + 6 + 3 * FONT_HEIGHT_NORMAL;
 
		/* Height for the title banner */
 
		int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM;
 

	
 
		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);
 
		tr.top += HEADER_HEIGHT;
 

	
 
		/* Draw the right menu */
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + detail_height - 1, PC_DARK_BLUE);
 
		/* 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);
 
		if (sel == nullptr) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 
			DrawString(hr.left, hr.right, hr.top, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 
		} else if (sel->status != NGLS_ONLINE) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
 

	
 
			StringID message = INVALID_STRING_ID;
 
			switch (sel->status) {
 
				case NGLS_OFFLINE: message = STR_NETWORK_SERVER_LIST_SERVER_OFFLINE; break;
 
@@ -652,63 +656,63 @@ public:
 
				/* Handled by the if-case above. */
 
				case NGLS_ONLINE: NOT_REACHED();
 
			}
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + detail_height + 4, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline
 

	
 
			DrawString(hr.left, hr.right, hr.top, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline
 
			DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
 
			DrawString(tr.left, tr.right, tr.top, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline
 
		} else { // show game info
 

	
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
 

	
 
			uint16 y = r.top + detail_height + 4;
 
			DrawString(hr.left, hr.right, hr.top, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 
			DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
 

	
 
			SetDParam(0, sel->info.clients_on);
 
			SetDParam(1, sel->info.clients_max);
 
			SetDParam(2, sel->info.companies_on);
 
			SetDParam(3, sel->info.companies_max);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CLIENTS);
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_CLIENTS);
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + sel->info.landscape);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParam(0, sel->info.map_width);
 
			SetDParam(1, sel->info.map_height);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_MAP_SIZE); // map size
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE); // map size
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParamStr(0, sel->info.server_revision);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParamStr(0, sel->connection_string);
 
			StringID invite_or_address = StrStartsWith(sel->connection_string, "+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS;
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, invite_or_address); // server address / invite code
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, invite_or_address); // server address / invite code
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParam(0, sel->info.start_date);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_START_DATE); // start date
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE); // start date
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParam(0, sel->info.game_date);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
 
			tr.top += FONT_HEIGHT_NORMAL;
 

	
 
			if (sel->info.gamescript_version != -1) {
 
				SetDParamStr(0, sel->info.gamescript_name);
 
				SetDParam(1, sel->info.gamescript_version);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_GAMESCRIPT); // gamescript name and version
 
				y += FONT_HEIGHT_NORMAL;
 
				tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_GAMESCRIPT); // gamescript name and version
 
			}
 

	
 
			y += WD_PAR_VSEP_NORMAL;
 
			tr.top += WD_PAR_VSEP_WIDE;
 

	
 
			if (!sel->info.compatible) {
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, sel->info.version_compatible ? STR_NETWORK_SERVER_LIST_GRF_MISMATCH : STR_NETWORK_SERVER_LIST_VERSION_MISMATCH, TC_FROMSTRING, SA_HOR_CENTER); // server mismatch
 
				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
 
			} else if (sel->info.clients_on == sel->info.clients_max) {
 
				/* Show: server full, when clients_on == max_clients */
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_FULL, TC_FROMSTRING, SA_HOR_CENTER); // server full
 
				DrawString(tr, STR_NETWORK_SERVER_LIST_SERVER_FULL, TC_FROMSTRING, SA_HOR_CENTER); // server full
 
			} else if (sel->info.use_password) {
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_HOR_CENTER); // password warning
 
				DrawString(tr, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_HOR_CENTER); // password warning
 
			}
 
		}
 
	}
 
@@ -2088,8 +2092,8 @@ public:
 
				uint line = 0;
 

	
 
				if (this->hover_index >= 0) {
 
					uint offset = this->hover_index * this->line_height;
 
					GfxFillRect(r.left + 2, r.top + offset, r.right - 1, r.top + offset + this->line_height - 2, GREY_SCALE(9));
 
					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));
 
				}
 

	
 
				NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
 
@@ -2314,8 +2318,7 @@ struct NetworkCompanyPasswordWindow : pu
 
	{
 
		if (widget != WID_NCP_WARNING) return;
 

	
 
		DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT,
 
			r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
 
		DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM),
 
			STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
@@ -2415,7 +2418,7 @@ struct NetworkAskRelayWindow : public Wi
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget == WID_NAR_TEXT) {
 
			DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMETEXT_BOTTOM, STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM), STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -428,7 +428,8 @@ struct NewGRFInspectWindow : Window {
 
					if (u == v) sel_end = total_width;
 
				}
 

	
 
				int width = r.Width() - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
 
				Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				int width = br.Width();
 
				int skip = 0;
 
				if (total_width > width) {
 
					int sel_center = (sel_start + sel_end) / 2;
 
@@ -437,8 +438,8 @@ struct NewGRFInspectWindow : Window {
 

	
 
				GrfSpecFeature f = GetFeatureNum(this->window_number);
 
				int h = GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height;
 
				int y = CenterBounds(r.top, r.bottom, h);
 
				DrawVehicleImage(v->First(), r.left + WD_BEVEL_LEFT, r.right - WD_BEVEL_RIGHT, y + 1, INVALID_VEHICLE, EIT_IN_DETAILS, skip);
 
				int y = CenterBounds(br.top, br.bottom, h);
 
				DrawVehicleImage(v->First(), br.left, br.right, y + 1, INVALID_VEHICLE, EIT_IN_DETAILS, skip);
 

	
 
				/* Highlight the articulated part (this is different to the whole-vehicle highlighting of DrawVehicleImage */
 
				if (_current_text_dir == TD_RTL) {
 
@@ -878,13 +879,12 @@ struct SpriteAlignerWindow : Window {
 
			case WID_SA_SPRITE: {
 
				/* Center the sprite ourselves */
 
				const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
 
				int width  = r.Width()  - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
 
				int height = r.Height() - WD_BEVEL_TOP - WD_BEVEL_BOTTOM;
 
				int x = -UnScaleGUI(spr->x_offs) + (width  - UnScaleGUI(spr->width) ) / 2;
 
				int y = -UnScaleGUI(spr->y_offs) + (height - UnScaleGUI(spr->height)) / 2;
 
				Rect ir = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				int x = -UnScaleGUI(spr->x_offs) + (ir.Width()  - UnScaleGUI(spr->width) ) / 2;
 
				int y = -UnScaleGUI(spr->y_offs) + (ir.Height() - UnScaleGUI(spr->height)) / 2;
 

	
 
				DrawPixelInfo new_dpi;
 
				if (!FillDrawPixelInfo(&new_dpi, r.left + WD_BEVEL_LEFT, r.top + WD_BEVEL_TOP, width, height)) break;
 
				if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) break;
 
				DrawPixelInfo *old_dpi = _cur_dpi;
 
				_cur_dpi = &new_dpi;
 

	
 
@@ -902,11 +902,11 @@ 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());
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect ir = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				for (int i = this->vscroll->GetPosition(); i < max; i++) {
 
					SetDParam(0, list[i]);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
 
					y += step_size;
 
					DrawString(ir, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
 
					ir.top += step_size;
 
				}
 
				break;
 
			}
src/newgrf_gui.cpp
Show inline comments
 
@@ -66,8 +66,9 @@ void ShowNewGRFError()
 
	}
 
}
 

	
 
static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params)
 
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);
 
	if (c->error != nullptr) {
 
		char message[512];
 
		SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages
 
@@ -79,34 +80,34 @@ static void ShowNewGRFInfo(const GRFConf
 
		GetString(message, c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message));
 

	
 
		SetDParamStr(0, message);
 
		y = DrawStringMultiLine(x, right, y, bottom, c->error->severity);
 
		tr.top = DrawStringMultiLine(tr, c->error->severity);
 
	}
 

	
 
	/* Draw filename or not if it is not known (GRF sent over internet) */
 
	if (c->filename != nullptr) {
 
		SetDParamStr(0, c->filename);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_FILENAME);
 
		tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_FILENAME);
 
	}
 

	
 
	/* Prepare and draw GRF ID */
 
	char buff[256];
 
	seprintf(buff, lastof(buff), "%08X", BSWAP32(c->ident.grfid));
 
	SetDParamStr(0, buff);
 
	y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_GRF_ID);
 
	tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_GRF_ID);
 

	
 
	if ((_settings_client.gui.newgrf_developer_tools || _settings_client.gui.newgrf_show_old_versions) && c->version != 0) {
 
		SetDParam(0, c->version);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_VERSION);
 
		tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_VERSION);
 
	}
 
	if ((_settings_client.gui.newgrf_developer_tools || _settings_client.gui.newgrf_show_old_versions) && c->min_loadable_version != 0) {
 
		SetDParam(0, c->min_loadable_version);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MIN_VERSION);
 
		tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_MIN_VERSION);
 
	}
 

	
 
	/* Prepare and draw MD5 sum */
 
	md5sumToString(buff, lastof(buff), c->ident.md5sum);
 
	SetDParamStr(0, buff);
 
	y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MD5SUM);
 
	tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_MD5SUM);
 

	
 
	/* Show GRF parameter list */
 
	if (show_params) {
 
@@ -117,7 +118,7 @@ static void ShowNewGRFInfo(const GRFConf
 
		} else {
 
			SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
 
		}
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PARAMETER);
 
		tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_PARAMETER);
 

	
 
		/* Draw the palette of the NewGRF */
 
		if (c->palette & GRFP_BLT_32BPP) {
 
@@ -125,21 +126,21 @@ static void ShowNewGRFInfo(const GRFConf
 
		} else {
 
			SetDParam(0, (c->palette & GRFP_USE_WINDOWS) ? STR_NEWGRF_SETTINGS_PALETTE_LEGACY : STR_NEWGRF_SETTINGS_PALETTE_DEFAULT);
 
		}
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PALETTE);
 
		tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_PALETTE);
 
	}
 

	
 
	/* Show flags */
 
	if (c->status == GCS_NOT_FOUND)       y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NOT_FOUND);
 
	if (c->status == GCS_DISABLED)        y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_DISABLED);
 
	if (HasBit(c->flags, GCF_INVALID))    y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_INCOMPATIBLE);
 
	if (HasBit(c->flags, GCF_COMPATIBLE)) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_COMPATIBLE_LOADED);
 
	if (c->status == GCS_NOT_FOUND)       tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_NOT_FOUND);
 
	if (c->status == GCS_DISABLED)        tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_DISABLED);
 
	if (HasBit(c->flags, GCF_INVALID))    tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_INCOMPATIBLE);
 
	if (HasBit(c->flags, GCF_COMPATIBLE)) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_COMPATIBLE_LOADED);
 

	
 
	/* Draw GRF info if it exists */
 
	if (!StrEmpty(c->GetDescription())) {
 
		SetDParamStr(0, c->GetDescription());
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_BLACK_RAW_STRING);
 
		tr.top = DrawStringMultiLine(tr, STR_BLACK_RAW_STRING);
 
	} else {
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NO_INFO);
 
		tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_NO_INFO);
 
	}
 
}
 

	
 
@@ -252,18 +253,17 @@ struct NewGRFParametersWindow : public W
 
			if (par_info == nullptr) return;
 
			const char *desc = GetGRFStringFromGRFText(par_info->desc);
 
			if (desc == nullptr) return;
 
			DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_TEXTPANEL_TOP, r.bottom - WD_TEXTPANEL_BOTTOM, desc, TC_BLACK);
 
			DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT, WD_TEXTPANEL_TOP, WD_FRAMERECT_RIGHT, WD_TEXTPANEL_BOTTOM), desc, TC_BLACK);
 
			return;
 
		} else if (widget != WID_NP_BACKGROUND) {
 
			return;
 
		}
 

	
 
		Rect ir = r.Shrink(WD_FRAMERECT_LEFT, 0, WD_FRAMERECT_RIGHT, 0);
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
 
		uint text_right   = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
 
		uint buttons_left = rtl ? ir.right - SETTING_BUTTON_WIDTH - 3 : ir.left + 4;
 
		Rect tr = r.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
 

	
 
		int y = r.top;
 
		int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 
		for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
 
@@ -273,13 +273,13 @@ struct NewGRFParametersWindow : public W
 
			bool selected = (i == this->clicked_row);
 

	
 
			if (par_info->type == PTYPE_BOOL) {
 
				DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
 
				DrawBoolButton(buttons_left, ir.top + button_y_offset, current_value != 0, this->editable);
 
				SetDParam(2, par_info->GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
 
			} else if (par_info->type == PTYPE_UINT_ENUM) {
 
				if (par_info->complete_labels) {
 
					DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
 
					DrawDropDownButton(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
 
				} else {
 
					DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
 
					DrawArrowButtons(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
 
				}
 
				SetDParam(2, STR_JUST_INT);
 
				SetDParam(3, current_value);
 
@@ -301,8 +301,8 @@ struct NewGRFParametersWindow : public W
 
				SetDParam(1, i + 1);
 
			}
 

	
 
			DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
 
			y += this->line_height;
 
			DrawString(tr.left, tr.right, ir.top + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
 
			ir.top += this->line_height;
 
		}
 
	}
 

	
 
@@ -833,10 +833,11 @@ struct NewGRFWindow : public Window, New
 
	{
 
		switch (widget) {
 
			case WID_NS_FILE_LIST: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_NS_FILE_LIST)->resize_y;
 
				uint y = r.top + WD_FRAMERECT_TOP;
 
				Dimension square = GetSpriteSize(SPR_SQUARE);
 
				Dimension warning = GetSpriteSize(SPR_WARNING_SIGN);
 
				int square_offset_y = (step_height - square.height) / 2;
 
@@ -844,10 +845,10 @@ struct NewGRFWindow : public Window, New
 
				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 

	
 
				bool rtl = _current_text_dir == TD_RTL;
 
				uint text_left    = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + square.width + 15;
 
				uint text_right   = rtl ? r.right - square.width - 15 : r.right - WD_FRAMERECT_RIGHT;
 
				uint square_left  = rtl ? r.right - square.width - 5 : r.left + 5;
 
				uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
 
				uint text_left    = rtl ? tr.left : tr.left + square.width + 13;
 
				uint text_right   = rtl ? tr.right - square.width - 13 : tr.right;
 
				uint square_left  = rtl ? tr.right - square.width - 3 : tr.left + 3;
 
				uint warning_left = rtl ? tr.right - square.width - warning.width - 8 : tr.left + square.width + 8;
 

	
 
				int i = 0;
 
				for (const GRFConfig *c = this->actives; c != nullptr; c = c->next, i++) {
 
@@ -857,35 +858,36 @@ struct NewGRFWindow : public Window, New
 
						PaletteID pal = this->GetPalette(c);
 

	
 
						if (h) {
 
							GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, PC_DARK_BLUE);
 
							GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE);
 
						} else if (i == this->active_over) {
 
							/* Get index of current selection. */
 
							int active_sel_pos = 0;
 
							for (GRFConfig *c = this->actives; c != nullptr && c != this->active_sel; c = c->next, active_sel_pos++) {}
 
							if (active_sel_pos != this->active_over) {
 
								uint top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
 
								GfxFillRect(r.left + WD_FRAMERECT_LEFT, top - 1, r.right - WD_FRAMERECT_RIGHT, top + 1, PC_GREY);
 
								uint top = this->active_over < active_sel_pos ? tr.top + 1 : tr.top + step_height - 2;
 
								GfxFillRect(tr.left, top - 1, tr.right, top + 1, PC_GREY);
 
							}
 
						}
 
						DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
 
						if (c->error != nullptr) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
 
						DrawSprite(SPR_SQUARE, pal, square_left, tr.top + square_offset_y);
 
						if (c->error != nullptr) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, tr.top + warning_offset_y);
 
						uint txtoffset = c->error == nullptr ? 0 : warning.width;
 
						DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
 
						y += step_height;
 
						DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), tr.top + offset_y, text, h ? TC_WHITE : TC_ORANGE);
 
						tr.top += step_height;
 
					}
 
				}
 
				if (i == this->active_over && this->vscroll->IsVisible(i)) { // Highlight is after the last GRF entry.
 
					GfxFillRect(r.left + WD_FRAMERECT_LEFT, y, r.right - WD_FRAMERECT_RIGHT, y + 2, PC_GREY);
 
					GfxFillRect(tr.left, tr.top, tr.right, tr.top + 2, PC_GREY);
 
				}
 
				break;
 
			}
 

	
 
			case WID_NS_AVAIL_LIST: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK);
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				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);
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y;
 
				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 
				uint y = r.top + WD_FRAMERECT_TOP;
 
				uint min_index = this->vscroll2->GetPosition();
 
				uint max_index = std::min(min_index + this->vscroll2->GetCapacity(), (uint)this->avails.size());
 

	
 
@@ -894,16 +896,16 @@ struct NewGRFWindow : public Window, New
 
					bool h = (c == this->avail_sel);
 
					const char *text = c->GetName();
 

	
 
					if (h) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, PC_DARK_BLUE);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y + offset_y, text, h ? TC_WHITE : TC_SILVER);
 
					y += step_height;
 
					if (h) GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE);
 
					DrawString(tr.left, tr.right, tr.top + offset_y, text, h ? TC_WHITE : TC_SILVER);
 
					tr.top += step_height;
 
				}
 
				break;
 
			}
 

	
 
			case WID_NS_NEWGRF_INFO_TITLE:
 
				/* Create the nice grayish rectangle at the details top. */
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_DARK_BLUE);
 
				GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), 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;
 

	
 
@@ -911,7 +913,7 @@ struct NewGRFWindow : public Window, New
 
				const GRFConfig *selected = this->active_sel;
 
				if (selected == nullptr) selected = this->avail_sel;
 
				if (selected != nullptr) {
 
					ShowNewGRFInfo(selected, r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, r.right - WD_FRAMERECT_RIGHT, r.bottom - WD_FRAMERECT_BOTTOM, this->show_params);
 
					ShowNewGRFInfo(selected, r, this->show_params);
 
				}
 
				break;
 
			}
 
@@ -2091,20 +2093,21 @@ struct SavePresetWindow : public Window 
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 
				const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
				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;
 
				uint y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				uint min_index = this->vscroll->GetPosition();
 
				uint max_index = std::min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size());
 

	
 
				for (uint i = min_index; i < max_index; i++) {
 
					if ((int)i == this->selected) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 2, PC_DARK_BLUE);
 
					if ((int)i == this->selected) GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE);
 

	
 
					const char *text = this->presets[i].c_str();
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y + offset_y, text, ((int)i == this->selected) ? TC_WHITE : TC_SILVER);
 
					y += step_height;
 
					DrawString(tr.left, tr.right, tr.top + offset_y, text, ((int)i == this->selected) ? TC_WHITE : TC_SILVER);
 
					tr.top += step_height;
 
				}
 
				break;
 
			}
src/news_gui.cpp
Show inline comments
 
@@ -1135,9 +1135,6 @@ static void DrawNewsString(uint left, ui
 
}
 

	
 
struct MessageHistoryWindow : Window {
 
	static const int top_spacing;    ///< Additional spacing at the top of the #WID_MH_BACKGROUND widget.
 
	static const int bottom_spacing; ///< Additional spacing at the bottom of the #WID_MH_BACKGROUND widget.
 

	
 
	int line_height; /// < Height of a single line in the news history window including spacing.
 
	int date_width;  /// < Width needed for the date part.
 

	
 
@@ -1154,7 +1151,7 @@ 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 + 2;
 
			this->line_height = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			resize->height = this->line_height;
 

	
 
			/* Months are off-by-one, so it's actually 8. Not using
 
@@ -1162,7 +1159,7 @@ struct MessageHistoryWindow : Window {
 
			SetDParam(0, ConvertYMDToDate(ORIGINAL_MAX_YEAR, 7, 30));
 
			this->date_width = GetStringBoundingBox(STR_SHORT_DATE).width;
 

	
 
			size->height = 4 * resize->height + this->top_spacing + this->bottom_spacing; // At least 4 lines are visible.
 
			size->height = 4 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; // At least 4 lines are visible.
 
			size->width = std::max(200u, size->width); // At least 200 pixels wide.
 
		}
 
	}
 
@@ -1185,17 +1182,15 @@ struct MessageHistoryWindow : Window {
 
		}
 

	
 
		/* Fill the widget with news items. */
 
		int y = r.top + this->top_spacing;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint date_left  = rtl ? r.right - WD_FRAMERECT_RIGHT - this->date_width : r.left + WD_FRAMERECT_LEFT;
 
		uint date_right = rtl ? r.right - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT + this->date_width;
 
		uint news_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->date_width + WD_FRAMERECT_RIGHT + ScaleFontTrad(5);
 
		uint news_right = rtl ? r.right - WD_FRAMERECT_RIGHT - this->date_width - WD_FRAMERECT_RIGHT - ScaleFontTrad(5) : r.right - WD_FRAMERECT_RIGHT;
 
		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);
 
		int y = news.top;
 
		for (int n = this->vscroll->GetCapacity(); n > 0; n--) {
 
			SetDParam(0, ni->date);
 
			DrawString(date_left, date_right, y, STR_SHORT_DATE);
 
			DrawString(date.left, date.right, y, STR_SHORT_DATE);
 

	
 
			DrawNewsString(news_left, news_right, y, TC_WHITE, ni);
 
			DrawNewsString(news.left, news.right, y, TC_WHITE, ni);
 
			y += this->line_height;
 

	
 
			ni = ni->prev;
 
@@ -1235,9 +1230,6 @@ struct MessageHistoryWindow : Window {
 
	}
 
};
 

	
 
const int MessageHistoryWindow::top_spacing = WD_FRAMERECT_TOP + 4;
 
const int MessageHistoryWindow::bottom_spacing = WD_FRAMERECT_BOTTOM;
 

	
 
static const NWidgetPart _nested_message_history[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
src/object_gui.cpp
Show inline comments
 
@@ -313,8 +313,8 @@ public:
 
				break;
 

	
 
			case WID_BO_SELECT_IMAGE:
 
				size->width  = ScaleGUITrad(64) + 2;
 
				size->height = ScaleGUITrad(58) + 2;
 
				size->width  = ScaleGUITrad(64) + WD_BEVEL_LEFT + WD_BEVEL_RIGHT;
 
				size->height = ScaleGUITrad(58) + WD_BEVEL_TOP + WD_BEVEL_BOTTOM;
 
				break;
 

	
 
			default: break;
 
@@ -325,15 +325,15 @@ public:
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BO_CLASS_LIST: {
 
				int y = r.top;
 
				Rect mr = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				uint pos = 0;
 
				for (auto object_class_id : this->object_classes) {
 
					ObjectClass *objclass = ObjectClass::Get(object_class_id);
 
					if (objclass->GetUISpecCount() == 0) continue;
 
					if (!this->vscroll->IsVisible(pos++)) continue;
 
					DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, objclass->name,
 
					DrawString(mr, objclass->name,
 
							(object_class_id == _selected_object_class) ? TC_WHITE : TC_BLACK);
 
					y += this->line_height;
 
					mr.top += this->line_height;
 
				}
 
				break;
 
			}
 
@@ -360,9 +360,9 @@ public:
 
					if (spec->grf_prop.grffile == nullptr) {
 
						extern const DrawTileSprites _objects[];
 
						const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
 
						DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
						DrawOrigTileSeqInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec, GB(widget, 16, 16));
 
						DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec, GB(widget, 16, 16));
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
@@ -377,19 +377,19 @@ public:
 
				if (spec == nullptr) break;
 

	
 
				if (!spec->IsAvailable()) {
 
					GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK, FILLRECT_CHECKER);
 
				}
 
				DrawPixelInfo tmp_dpi;
 
				/* Set up a clipping area for the preview. */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left + 1, r.top, (r.right - 1) - (r.left + 1) + 1, r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					if (spec->grf_prop.grffile == nullptr) {
 
						extern const DrawTileSprites _objects[];
 
						const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
 
						DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
						DrawOrigTileSeqInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec,
 
						DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec,
 
								std::min<int>(_selected_object_view, spec->views - 1));
 
					}
 
					_cur_dpi = old_dpi;
src/order_gui.cpp
Show inline comments
 
@@ -1074,12 +1074,13 @@ public:
 
	{
 
		if (widget != WID_O_ORDER_LIST) return;
 

	
 
		Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		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 middle = rtl ? r.right - WD_FRAMETEXT_RIGHT - index_column_width : r.left + WD_FRAMETEXT_LEFT + index_column_width;
 
		int middle = rtl ? ir.right - index_column_width : ir.left + index_column_width;
 

	
 
		int y = r.top + WD_FRAMERECT_TOP;
 
		int y = ir.top;
 
		int line_height = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST)->resize_y;
 

	
 
		int i = this->vscroll->GetPosition();
 
@@ -1093,9 +1094,9 @@ 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 bottom = std::min(top + 2, r.bottom - WD_FRAMERECT_BOTTOM);
 
					top = std::max(top - 3, r.top + WD_FRAMERECT_TOP);
 
					GfxFillRect(r.left + WD_FRAMETEXT_LEFT, top, r.right - WD_FRAMETEXT_RIGHT, bottom, _colour_gradient[COLOUR_GREY][7]);
 
					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]);
 
					break;
 
				}
 
				y += line_height;
 
@@ -1105,7 +1106,7 @@ public:
 
			}
 

	
 
			/* Reset counters for drawing the orders. */
 
			y = r.top + WD_FRAMERECT_TOP;
 
			y = ir.top;
 
			i = this->vscroll->GetPosition();
 
			order = this->vehicle->GetOrder(i);
 
		}
 
@@ -1115,7 +1116,7 @@ public:
 
			/* Don't draw anything if it extends past the end of the window. */
 
			if (!this->vscroll->IsVisible(i)) break;
 

	
 
			DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, r.left + WD_FRAMETEXT_LEFT, middle, r.right - WD_FRAMETEXT_RIGHT);
 
			DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, ir.left, middle, ir.right);
 
			y += line_height;
 

	
 
			i++;
 
@@ -1124,7 +1125,7 @@ public:
 

	
 
		if (this->vscroll->IsVisible(i)) {
 
			StringID str = this->vehicle->IsOrderListShared() ? STR_ORDERS_END_OF_SHARED_ORDERS : STR_ORDERS_END_OF_ORDERS;
 
			DrawString(rtl ? r.left + WD_FRAMETEXT_LEFT : middle, rtl ? middle : r.right - WD_FRAMETEXT_RIGHT, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
 
			DrawString(rtl ? ir.left : middle, rtl ? middle : ir.right, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
 
		}
 
	}
 

	
src/rail_gui.cpp
Show inline comments
 
@@ -1281,14 +1281,14 @@ public:
 
				break;
 

	
 
			case WID_BRAS_NEWST_LIST: {
 
				Rect ir = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM);
 
				uint statclass = 0;
 
				uint row = 0;
 
				for (auto station_class : this->station_classes) {
 
					if (this->vscroll->IsVisible(statclass)) {
 
						DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, row * this->line_height + r.top + WD_MATRIX_TOP,
 
						DrawString(ir,
 
								StationClass::Get(station_class)->name,
 
								station_class == _railstation.station_class ? TC_WHITE : TC_BLACK);
 
						row++;
 
						ir.top += this->line_height;
 
					}
 
					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.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK, FILLRECT_CHECKER);
 
				}
 

	
 
				/* Set up a clipping area for the station preview. */
 
@@ -2043,7 +2043,7 @@ struct BuildRailWaypointWindow : PickerW
 
				DrawWaypointSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), type, _cur_railtype);
 

	
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_BLACK, FILLRECT_CHECKER);
 
				}
 
			}
 
		}
src/signs_gui.cpp
Show inline comments
 
@@ -194,30 +194,29 @@ struct SignListWindow : Window, SignList
 
	{
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				uint y = r.top + WD_FRAMERECT_TOP; // Offset from top of widget.
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				uint text_offset_y = (this->resize.step_height - FONT_HEIGHT_NORMAL + 1) / 2;
 
				/* No signs? */
 
				if (this->vscroll->GetCount() == 0) {
 
					DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y + text_offset_y, STR_STATION_LIST_NONE);
 
					DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_STATION_LIST_NONE);
 
					return;
 
				}
 

	
 
				Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
 
				bool rtl = _current_text_dir == TD_RTL;
 
				int sprite_offset_y = (this->resize.step_height - d.height + 1) / 2;
 
				uint icon_left  = 4 + (rtl ? r.right - this->text_offset : r.left);
 
				uint text_left  = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
 
				uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
 
				uint icon_left = rtl ? tr.right - this->text_offset : tr.left;
 
				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++) {
 
					const Sign *si = this->signs[i];
 

	
 
					if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + sprite_offset_y);
 
					if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, tr.top + sprite_offset_y);
 

	
 
					SetDParam(0, si->index);
 
					DrawString(text_left, text_right, y + text_offset_y, STR_SIGN_NAME, TC_YELLOW);
 
					y += this->resize.step_height;
 
					DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_SIGN_NAME, TC_YELLOW);
 
					tr.top += this->resize.step_height;
 
				}
 
				break;
 
			}
src/smallmap_gui.cpp
Show inline comments
 
@@ -1214,8 +1214,9 @@ 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);
 
			DrawPixelInfo new_dpi;
 
			if (!FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.Width(), r.Height())) return;
 
			if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
			this->DrawSmallMap(&new_dpi);
 
			break;
 
		}
 
@@ -1224,17 +1225,13 @@ void SmallMapWindow::RebuildColourIndexI
 
			uint columns = this->GetNumberColumnsLegend(r.Width());
 
			uint number_of_rows = this->GetNumberRowsLegend(columns);
 
			bool rtl = _current_text_dir == TD_RTL;
 
			uint y_org = r.top + WD_FRAMERECT_TOP;
 
			uint x = rtl ? r.right - this->column_width - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT;
 
			uint y = y_org;
 
			uint i = 0; // Row counter for industry legend.
 
			uint row_height = FONT_HEIGHT_SMALL;
 
			int padding = ScaleFontTrad(1);
 

	
 
			uint text_left  = rtl ? 0 : this->legend_width + WD_FRAMERECT_LEFT;
 
			uint text_right = this->column_width - padding - (rtl ? this->legend_width + WD_FRAMERECT_RIGHT : 0);
 
			uint blob_left  = rtl ? this->column_width - padding - this->legend_width : 0;
 
			uint blob_right = rtl ? this->column_width - padding : this->legend_width;
 
			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 icon = origin.WithWidth(this->legend_width, rtl).Shrink(0, padding, 0, 0);
 

	
 
			StringID string = STR_NULL;
 
			switch (this->map_type) {
 
@@ -1255,8 +1252,10 @@ void SmallMapWindow::RebuildColourIndexI
 
				if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
 
					/* Column break needed, continue at top, COLUMN_WIDTH pixels
 
					 * (one "row") to the right. */
 
					x += rtl ? -(int)this->column_width : this->column_width;
 
					y = y_org;
 
					int x = rtl ? -(int)this->column_width : this->column_width;
 
					int y = origin.top - text.top;
 
					text = text.Translate(x, y);
 
					icon = icon.Translate(x, y);
 
					i = 1;
 
				}
 

	
 
@@ -1283,10 +1282,10 @@ void SmallMapWindow::RebuildColourIndexI
 
							if (!tbl->show_on_map) {
 
								/* Simply draw the string, not the black border of the legend colour.
 
								 * This will enforce the idea of the disabled item */
 
								DrawString(x + text_left, x + text_right, y, string, TC_GREY);
 
								DrawString(text, string, TC_GREY);
 
							} else {
 
								DrawString(x + text_left, x + text_right, y, string, TC_BLACK);
 
								GfxFillRect(x + blob_left, y + padding, x + blob_right, y + row_height - 1, PC_BLACK); // Outer border of the legend colour
 
								DrawString(text, string, TC_BLACK);
 
								GfxFillRect(icon, PC_BLACK); // Outer border of the legend colour
 
							}
 
							break;
 
						}
 
@@ -1295,13 +1294,14 @@ void SmallMapWindow::RebuildColourIndexI
 
					default:
 
						if (this->map_type == SMT_CONTOUR) SetDParam(0, tbl->height * TILE_HEIGHT_STEP);
 
						/* Anything that is not an industry or a company is using normal process */
 
						GfxFillRect(x + blob_left, y + padding, x + blob_right, y + row_height - 1, PC_BLACK);
 
						DrawString(x + text_left, x + text_right, y, tbl->legend);
 
						GfxFillRect(icon, PC_BLACK);
 
						DrawString(text, tbl->legend);
 
						break;
 
				}
 
				GfxFillRect(x + blob_left + 1, y + padding + 1, x + blob_right - 1, y + row_height - 2, legend_colour); // Legend colour
 
				GfxFillRect(icon.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), legend_colour); // Legend colour
 

	
 
				y += row_height;
 
				text = text.Translate(0, row_height);
 
				icon = icon.Translate(0, row_height);
 
			}
 
		}
 
	}
src/station_gui.cpp
Show inline comments
 
@@ -433,7 +433,7 @@ public:
 
			case WID_STL_LIST: {
 
				bool rtl = _current_text_dir == TD_RTL;
 
				int max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				uint line_height = this->GetWidget<NWidgetBase>(widget)->resize_y;
 
				/* Spacing between station name and first rating graph. */
 
				int text_spacing = ScaleFontTrad(5);
 
@@ -450,7 +450,7 @@ public:
 

	
 
					SetDParam(0, st->index);
 
					SetDParam(1, st->facilities);
 
					int x = DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_STATION);
 
					int x = DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_STATION);
 
					x += rtl ? -text_spacing : text_spacing;
 

	
 
					/* show cargo waiting and station ratings */
 
@@ -463,20 +463,20 @@ public:
 
							 * the space. */
 
							if (rtl) {
 
								x -= rating_width + rating_spacing;
 
								if (x < r.left + WD_FRAMERECT_LEFT) break;
 
								if (x < tr.left) break;
 
							}
 
							StationsWndShowStationRating(x, x + rating_width, y, cid, st->goods[cid].cargo.TotalCount(), st->goods[cid].rating);
 
							StationsWndShowStationRating(x, x + rating_width, tr.top, cid, st->goods[cid].cargo.TotalCount(), st->goods[cid].rating);
 
							if (!rtl) {
 
								x += rating_width + rating_spacing;
 
								if (x > r.right - WD_FRAMERECT_RIGHT) break;
 
								if (x > tr.right) break;
 
							}
 
						}
 
					}
 
					y += line_height;
 
					tr.top += line_height;
 
				}
 

	
 
				if (this->vscroll->GetCount() == 0) { // company has no stations
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_LIST_NONE);
 
					DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_NONE);
 
					return;
 
				}
 
				break;
 
@@ -484,11 +484,13 @@ public:
 

	
 
			default:
 
				if (widget >= WID_STL_CARGOSTART) {
 
					Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
					const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART];
 
					int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 1 : 0;
 
					GfxFillRect(r.left + cg_ofst + 1, r.top + cg_ofst + 1, r.right - 1 + cg_ofst, r.bottom - 1 + cg_ofst, cs->rating_colour);
 
					br = br.Translate(cg_ofst, cg_ofst);
 
					GfxFillRect(br, cs->rating_colour);
 
					TextColour tc = GetContrastColour(cs->rating_colour);
 
					DrawString(r.left + cg_ofst, r.right + cg_ofst, CenterBounds(r.top, r.bottom, FONT_HEIGHT_SMALL) + cg_ofst, cs->abbrev, tc, SA_HOR_CENTER);
 
					DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cs->abbrev, tc, SA_HOR_CENTER);
 
				}
 
				break;
 
		}
 
@@ -1367,7 +1369,7 @@ struct StationViewWindow : public Window
 
			case WID_SV_WAITING:
 
				resize->height = FONT_HEIGHT_NORMAL;
 
				size->height = WD_FRAMERECT_TOP + 4 * resize->height + WD_FRAMERECT_BOTTOM;
 
				this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width);
 
				break;
 

	
 
			case WID_SV_ACCEPT_RATING_LIST:
 
@@ -1439,7 +1441,7 @@ struct StationViewWindow : public Window
 

	
 
			/* Draw waiting cargo. */
 
			NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_SV_WAITING);
 
			Rect waiting_rect = nwi->GetCurrentRect();
 
			Rect waiting_rect = nwi->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
			this->DrawEntries(&cargo, waiting_rect, pos, maxrows, 0);
 
			scroll_to_row = INT_MAX;
 
		}
 
@@ -1711,7 +1713,7 @@ struct StationViewWindow : public Window
 
	 * @param cargo Current cargo being drawn (if cargo column has been passed).
 
	 * @return row (in "pos" counting) after the one we have last drawn to.
 
	 */
 
	int DrawEntries(CargoDataEntry *entry, Rect &r, int pos, int maxrows, int column, CargoID cargo = CT_INVALID)
 
	int DrawEntries(CargoDataEntry *entry, const Rect &r, int pos, int maxrows, int column, CargoID cargo = CT_INVALID)
 
	{
 
		if (this->sortings[column] == ST_AS_GROUPING) {
 
			if (this->groupings[column] != GR_CARGO) {
 
@@ -1729,13 +1731,13 @@ struct StationViewWindow : public Window
 

	
 
			if (pos > -maxrows && pos <= 0) {
 
				StringID str = STR_EMPTY;
 
				int y = r.top + WD_FRAMERECT_TOP - pos * FONT_HEIGHT_NORMAL;
 
				int y = r.top - pos * FONT_HEIGHT_NORMAL;
 
				SetDParam(0, cargo);
 
				SetDParam(1, cd->GetCount());
 

	
 
				if (this->groupings[column] == GR_CARGO) {
 
					str = STR_STATION_VIEW_WAITING_CARGO;
 
					DrawCargoIcons(cd->GetCargo(), cd->GetCount(), r.left + WD_FRAMERECT_LEFT + this->expand_shrink_width, r.right - WD_FRAMERECT_RIGHT - this->expand_shrink_width, y);
 
					DrawCargoIcons(cd->GetCargo(), cd->GetCount(), r.left + this->expand_shrink_width, r.right - this->expand_shrink_width, y);
 
				} else {
 
					if (!auto_distributed) grouping = GR_SOURCE;
 
					StationID station = cd->GetStation();
 
@@ -1760,12 +1762,10 @@ struct StationViewWindow : public Window
 
				}
 

	
 
				bool rtl = _current_text_dir == TD_RTL;
 
				int text_left    = rtl ? r.left + this->expand_shrink_width : r.left + WD_FRAMERECT_LEFT + column * this->expand_shrink_width;
 
				int text_right   = rtl ? r.right - WD_FRAMERECT_LEFT - column * this->expand_shrink_width : r.right - this->expand_shrink_width;
 
				int shrink_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - this->expand_shrink_width + WD_FRAMERECT_LEFT;
 
				int shrink_right = rtl ? r.left + this->expand_shrink_width - WD_FRAMERECT_RIGHT : r.right - WD_FRAMERECT_RIGHT;
 
				Rect text = r.Indent(column * this->expand_shrink_width, rtl).Indent(this->expand_shrink_width, !rtl);
 
				Rect shrink = r.WithWidth(this->expand_shrink_width, !rtl);
 

	
 
				DrawString(text_left, text_right, y, str);
 
				DrawString(text.left, text.right, y, str);
 

	
 
				if (column < NUM_COLUMNS - 1) {
 
					const char *sym = nullptr;
 
@@ -1780,7 +1780,7 @@ struct StationViewWindow : public Window
 
							sym = "+";
 
						}
 
					}
 
					if (sym) DrawString(shrink_left, shrink_right, y, sym, TC_YELLOW);
 
					if (sym != nullptr) DrawString(shrink.left, shrink.right, y, sym, TC_YELLOW);
 
				}
 
				this->SetDisplayedRow(cd);
 
			}
 
@@ -1800,13 +1800,14 @@ struct StationViewWindow : public Window
 
	int DrawAcceptedCargo(const Rect &r) const
 
	{
 
		const Station *st = Station::Get(this->window_number);
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		CargoTypes cargo_mask = 0;
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i);
 
		}
 
		SetDParam(0, cargo_mask);
 
		int bottom = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
 
		int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
 
		return CeilDiv(bottom - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
 
	}
 

	
 
@@ -1818,16 +1819,17 @@ struct StationViewWindow : public Window
 
	int DrawCargoRatings(const Rect &r) const
 
	{
 
		const Station *st = Station::Get(this->window_number);
 
		int y = r.top + WD_FRAMERECT_TOP;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		if (st->town->exclusive_counter > 0) {
 
			SetDParam(0, st->town->exclusivity);
 
			y = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, st->town->exclusivity == st->owner ? STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF : STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY);
 
			y += WD_PAR_VSEP_WIDE;
 
			tr.top = DrawStringMultiLine(tr, st->town->exclusivity == st->owner ? STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF : STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY);
 
			tr.top += WD_PAR_VSEP_WIDE;
 
		}
 

	
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE);
 
		y += FONT_HEIGHT_NORMAL;
 
		DrawString(tr, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE);
 
		tr.top += FONT_HEIGHT_NORMAL;
 

	
 
		for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
 
			const GoodsEntry *ge = &st->goods[cs->Index()];
 
@@ -1838,10 +1840,10 @@ struct StationViewWindow : public Window
 
			SetDParam(1, lg != nullptr ? lg->Monthly((*lg)[ge->node].Supply()) : 0);
 
			SetDParam(2, STR_CARGO_RATING_APPALLING + (ge->rating >> 5));
 
			SetDParam(3, ToPercent8(ge->rating));
 
			DrawString(r.left + WD_FRAMERECT_LEFT + 6, r.right - WD_FRAMERECT_RIGHT - 6, y, STR_STATION_VIEW_CARGO_SUPPLY_RATING);
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(tr.Indent(6, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
		}
 
		return CeilDiv(y - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
 
		return CeilDiv(tr.top - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
 
	}
 

	
 
	/**
 
@@ -2287,20 +2289,20 @@ struct SelectStationWindow : Window {
 
	{
 
		if (widget != WID_JS_PANEL) return;
 

	
 
		uint y = r.top + WD_FRAMERECT_TOP;
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
		if (this->vscroll->GetPosition() == 0) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
 
			y += this->resize.step_height;
 
			DrawString(tr, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
 
			tr.top += this->resize.step_height;
 
		}
 

	
 
		for (uint i = std::max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, y += this->resize.step_height) {
 
		for (uint i = std::max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, tr.top += this->resize.step_height) {
 
			/* Don't draw anything if it extends past the end of the window. */
 
			if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
 

	
 
			const T *st = T::Get(_stations_nearby_list[i - 1]);
 
			SetDParam(0, st->index);
 
			SetDParam(1, st->facilities);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
 
			DrawString(tr, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
 
		}
 
	}
 

	
src/statusbar_gui.cpp
Show inline comments
 
@@ -137,24 +137,24 @@ struct StatusBarWindow : Window {
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		int text_offset = std::max(0, (r.Height() - FONT_HEIGHT_NORMAL) / 2); // Offset for rendering the text vertically centered
 
		int text_top = r.top + text_offset;
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, 0, WD_FRAMERECT_RIGHT, 0);
 
		tr.top = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
 
		switch (widget) {
 
			case WID_S_LEFT:
 
				/* Draw the date */
 
				SetDParam(0, _date);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_WHITE_DATE_LONG, TC_FROMSTRING, SA_HOR_CENTER);
 
				DrawString(tr, STR_WHITE_DATE_LONG, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 

	
 
			case WID_S_RIGHT: {
 
				if (_local_company == COMPANY_SPECTATOR) {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_STATUSBAR_SPECTATOR, TC_FROMSTRING, SA_HOR_CENTER);
 
					DrawString(tr, STR_STATUSBAR_SPECTATOR, TC_FROMSTRING, SA_HOR_CENTER);
 
				} else {
 
					/* Draw company money, if any */
 
					const Company *c = Company::GetIfValid(_local_company);
 
					if (c != nullptr) {
 
						SetDParam(0, c->money);
 
						DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_COMPANY_MONEY, TC_FROMSTRING, SA_HOR_CENTER);
 
						DrawString(tr, STR_COMPANY_MONEY, TC_FROMSTRING, SA_HOR_CENTER);
 
					}
 
				}
 
				break;
 
@@ -163,12 +163,12 @@ struct StatusBarWindow : Window {
 
			case WID_S_MIDDLE:
 
				/* Draw status bar */
 
				if (this->saving) { // true when saving is active
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_STATUSBAR_SAVING_GAME, TC_FROMSTRING, SA_HOR_CENTER | SA_VERT_CENTER);
 
					DrawString(tr, STR_STATUSBAR_SAVING_GAME, TC_FROMSTRING, SA_HOR_CENTER | SA_VERT_CENTER);
 
				} else if (_do_autosave) {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_STATUSBAR_AUTOSAVE, TC_FROMSTRING, SA_HOR_CENTER);
 
					DrawString(tr, STR_STATUSBAR_AUTOSAVE, TC_FROMSTRING, SA_HOR_CENTER);
 
				} else if (_pause_mode != PM_UNPAUSED) {
 
					StringID msg = (_pause_mode & PM_PAUSED_LINK_GRAPH) ? STR_STATUSBAR_PAUSED_LINK_GRAPH : STR_STATUSBAR_PAUSED;
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, msg, TC_FROMSTRING, SA_HOR_CENTER);
 
					DrawString(tr, msg, TC_FROMSTRING, SA_HOR_CENTER);
 
				} else if (this->ticker_scroll < TICKER_STOP && _statusbar_news_item != nullptr && _statusbar_news_item->string_id != 0) {
 
					/* Draw the scrolling news text */
 
					if (!DrawScrollingStatusText(_statusbar_news_item, ScaleGUITrad(this->ticker_scroll), r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom)) {
 
@@ -176,20 +176,20 @@ struct StatusBarWindow : Window {
 
						if (Company::IsValidID(_local_company)) {
 
							/* This is the default text */
 
							SetDParam(0, _local_company);
 
							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_STATUSBAR_COMPANY_NAME, TC_FROMSTRING, SA_HOR_CENTER);
 
							DrawString(tr, STR_STATUSBAR_COMPANY_NAME, TC_FROMSTRING, SA_HOR_CENTER);
 
						}
 
					}
 
				} else {
 
					if (Company::IsValidID(_local_company)) {
 
						/* This is the default text */
 
						SetDParam(0, _local_company);
 
						DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, text_top, STR_STATUSBAR_COMPANY_NAME, TC_FROMSTRING, SA_HOR_CENTER);
 
						DrawString(tr, STR_STATUSBAR_COMPANY_NAME, TC_FROMSTRING, SA_HOR_CENTER);
 
					}
 
				}
 

	
 
				if (!this->reminder_timeout.HasElapsed()) {
 
					Dimension icon_size = GetSpriteSize(SPR_UNREAD_NEWS);
 
					DrawSprite(SPR_UNREAD_NEWS, PAL_NONE, r.right - WD_FRAMERECT_RIGHT - icon_size.width, CenterBounds(r.top, r.bottom, icon_size.height));
 
					DrawSprite(SPR_UNREAD_NEWS, PAL_NONE, tr.right - icon_size.width, CenterBounds(r.top, r.bottom, icon_size.height));
 
				}
 
				break;
 
		}
src/story_gui.cpp
Show inline comments
 
@@ -692,19 +692,17 @@ public:
 
		StoryPage *page = this->GetSelPage();
 
		if (page == nullptr) return;
 

	
 
		const int x = r.left + WD_FRAMETEXT_LEFT;
 
		const int y = r.top + WD_FRAMETEXT_TOP;
 
		const int right = r.right - WD_FRAMETEXT_RIGHT;
 
		const int bottom = r.bottom - WD_FRAMETEXT_BOTTOM;
 
		Rect fr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 

	
 
		/* Set up a clipping region for the panel. */
 
		DrawPixelInfo tmp_dpi;
 
		if (!FillDrawPixelInfo(&tmp_dpi, x, y, right - x + 1, bottom - y + 1)) return;
 
		if (!FillDrawPixelInfo(&tmp_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
 

	
 
		DrawPixelInfo *old_dpi = _cur_dpi;
 
		_cur_dpi = &tmp_dpi;
 

	
 
		/* Draw content (now coordinates given to Draw** are local to the new clipping region). */
 
		fr = fr.Translate(-fr.left, -fr.top);
 
		int line_height = FONT_HEIGHT_NORMAL;
 
		const int scrollpos = this->vscroll->GetPosition();
 
		int y_offset = -scrollpos;
 
@@ -712,13 +710,13 @@ public:
 
		/* Date */
 
		if (page->date != INVALID_DATE) {
 
			SetDParam(0, page->date);
 
			DrawString(0, right - x, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
 
			DrawString(0, fr.right, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
 
		}
 
		y_offset += line_height;
 

	
 
		/* Title */
 
		SetDParamStr(0, page->title != nullptr ? page->title : this->selected_generic_title);
 
		y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, STR_STORY_BOOK_TITLE, TC_BLACK, SA_TOP | SA_HOR_CENTER);
 
		y_offset = DrawStringMultiLine(0, fr.right, y_offset, fr.bottom, STR_STORY_BOOK_TITLE, TC_BLACK, SA_TOP | SA_HOR_CENTER);
 

	
 
		/* Page elements */
 
		this->EnsureStoryPageElementLayout();
src/subsidy_gui.cpp
Show inline comments
 
@@ -145,15 +145,13 @@ struct SubsidyListWindow : Window {
 
		YearMonthDay ymd;
 
		ConvertDateToYMD(_date, &ymd);
 

	
 
		int right = r.right - WD_FRAMERECT_RIGHT;
 
		int y = r.top + WD_FRAMERECT_TOP;
 
		int x = r.left + WD_FRAMERECT_LEFT;
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		int pos = -this->vscroll->GetPosition();
 
		const int cap = this->vscroll->GetCapacity();
 

	
 
		/* Section for drawing the offered subsidies */
 
		if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_TITLE);
 
		if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_TITLE);
 
		pos++;
 

	
 
		uint num = 0;
 
@@ -163,7 +161,7 @@ struct SubsidyListWindow : Window {
 
					/* Displays the two offered towns */
 
					SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui);
 
					SetDParam(7, _date - ymd.day + s->remaining * 32);
 
					DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_FROM_TO);
 
					DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_FROM_TO);
 
				}
 
				pos++;
 
				num++;
 
@@ -171,13 +169,13 @@ struct SubsidyListWindow : Window {
 
		}
 

	
 
		if (num == 0) {
 
			if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
 
			if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
 
			pos++;
 
		}
 

	
 
		/* Section for drawing the already granted subsidies */
 
		pos++;
 
		if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_TITLE);
 
		if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_TITLE);
 
		pos++;
 
		num = 0;
 

	
 
@@ -189,7 +187,7 @@ struct SubsidyListWindow : Window {
 
					SetDParam(8, _date - ymd.day + s->remaining * 32);
 

	
 
					/* Displays the two connected stations */
 
					DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_FROM_TO);
 
					DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_FROM_TO);
 
				}
 
				pos++;
 
				num++;
 
@@ -197,7 +195,7 @@ struct SubsidyListWindow : Window {
 
		}
 

	
 
		if (num == 0) {
 
			if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
 
			if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
 
			pos++;
 
		}
 
	}
src/textfile_gui.cpp
Show inline comments
 
@@ -148,17 +148,15 @@ void TextfileWindow::SetupScrollbars(boo
 
{
 
	if (widget != WID_TF_BACKGROUND) return;
 

	
 
	const int x = r.left + WD_FRAMETEXT_LEFT;
 
	const int y = r.top + WD_FRAMETEXT_TOP;
 
	const int right = r.right - WD_FRAMETEXT_RIGHT;
 
	const int bottom = r.bottom - WD_FRAMETEXT_BOTTOM;
 
	Rect fr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
 

	
 
	DrawPixelInfo new_dpi;
 
	if (!FillDrawPixelInfo(&new_dpi, x, y, right - x + 1, bottom - y + 1)) return;
 
	if (!FillDrawPixelInfo(&new_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
 
	DrawPixelInfo *old_dpi = _cur_dpi;
 
	_cur_dpi = &new_dpi;
 

	
 
	/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
 
	fr = fr.Translate(-fr.left, -fr.top);
 
	int line_height = FONT_HEIGHT_MONO;
 
	int pos = this->vscroll->GetPosition();
 
	int cap = this->vscroll->GetCapacity();
 
@@ -169,9 +167,9 @@ void TextfileWindow::SetupScrollbars(boo
 

	
 
		int y_offset = (line.top - pos) * line_height;
 
		if (IsWidgetLowered(WID_TF_WRAPTEXT)) {
 
			DrawStringMultiLine(0, right - x, y_offset, bottom - y, line.text, TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
 
			DrawStringMultiLine(0, fr.right, y_offset, fr.bottom, line.text, TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
 
		} else {
 
			DrawString(-this->hscroll->GetPosition(), right - x, y_offset, line.text, TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
 
			DrawString(-this->hscroll->GetPosition(), fr.right, y_offset, line.text, TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
 
		}
 
	}
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -356,7 +356,7 @@ struct TimetableWindow : Window {
 

	
 
		switch (widget) {
 
			case WID_VT_TIMETABLE_PANEL: {
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				int i = this->vscroll->GetPosition();
 
				VehicleOrderID order_id = (i + 1) / 2;
 
				bool final_order = false;
 
@@ -364,7 +364,7 @@ struct TimetableWindow : Window {
 
				bool rtl = _current_text_dir == TD_RTL;
 
				SetDParamMaxValue(0, v->GetNumOrders(), 2);
 
				int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
 
				int middle = rtl ? r.right - WD_FRAMERECT_RIGHT - index_column_width : r.left + WD_FRAMERECT_LEFT + index_column_width;
 
				int middle = rtl ? tr.right - index_column_width : tr.left + index_column_width;
 

	
 
				const Order *order = v->GetOrder(order_id);
 
				while (order != nullptr) {
 
@@ -372,7 +372,7 @@ struct TimetableWindow : Window {
 
					if (!this->vscroll->IsVisible(i)) break;
 

	
 
					if (i % 2 == 0) {
 
						DrawOrderString(v, order, order_id, y, i == selected, true, r.left + WD_FRAMERECT_LEFT, middle, r.right - WD_FRAMERECT_RIGHT);
 
						DrawOrderString(v, order, order_id, tr.top, i == selected, true, tr.left, middle, tr.right);
 

	
 
						order_id++;
 

	
 
@@ -408,13 +408,13 @@ struct TimetableWindow : Window {
 
						}
 
						SetDParam(2, order->GetMaxSpeed());
 

	
 
						DrawString(rtl ? r.left + WD_FRAMERECT_LEFT : middle, rtl ? middle : r.right - WD_FRAMERECT_LEFT, y, string, colour);
 
						DrawString(rtl ? tr.left : middle, rtl ? middle : tr.right, tr.top, string, colour);
 

	
 
						if (final_order) break;
 
					}
 

	
 
					i++;
 
					y += FONT_HEIGHT_NORMAL;
 
					tr.top += FONT_HEIGHT_NORMAL;
 
				}
 
				break;
 
			}
 
@@ -432,16 +432,13 @@ struct TimetableWindow : Window {
 

	
 
				VehicleOrderID earlyID = BuildArrivalDepartureList(v, arr_dep) ? cur_order : (VehicleOrderID)INVALID_VEH_ORDER_ID;
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 

	
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				bool show_late = this->show_expected && v->lateness_counter > DAY_TICKS;
 
				Ticks offset = show_late ? 0 : -v->lateness_counter;
 

	
 
				bool rtl = _current_text_dir == TD_RTL;
 
				int abbr_left  = rtl ? r.right - WD_FRAMERECT_RIGHT - this->deparr_abbr_width : r.left + WD_FRAMERECT_LEFT;
 
				int abbr_right = rtl ? r.right - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT + this->deparr_abbr_width;
 
				int time_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_RIGHT - this->deparr_time_width;
 
				int time_right = rtl ? r.left + WD_FRAMERECT_LEFT + this->deparr_time_width : r.right - WD_FRAMERECT_RIGHT;
 
				Rect abbr = tr.WithWidth(this->deparr_abbr_width, rtl);
 
				Rect time = tr.WithWidth(this->deparr_time_width, !rtl);
 

	
 
				for (int i = this->vscroll->GetPosition(); i / 2 < v->GetNumOrders(); ++i) { // note: i is also incremented in the loop
 
					/* Don't draw anything if it extends past the end of the window. */
 
@@ -449,54 +446,54 @@ struct TimetableWindow : Window {
 

	
 
					if (i % 2 == 0) {
 
						if (arr_dep[i / 2].arrival != INVALID_TICKS) {
 
							DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
							DrawString(abbr.left, abbr.right, tr.top, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
							if (this->show_expected && i / 2 == earlyID) {
 
								SetDParam(0, _date + arr_dep[i / 2].arrival / DAY_TICKS);
 
								DrawString(time_left, time_right, y, STR_JUST_DATE_TINY, TC_GREEN);
 
								DrawString(time.left, time.right, tr.top, STR_JUST_DATE_TINY, TC_GREEN);
 
							} else {
 
								SetDParam(0, _date + (arr_dep[i / 2].arrival + offset) / DAY_TICKS);
 
								DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
 
								DrawString(time.left, time.right, tr.top, STR_JUST_DATE_TINY,
 
										show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
 
							}
 
						}
 
					} else {
 
						if (arr_dep[i / 2].departure != INVALID_TICKS) {
 
							DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
							DrawString(abbr.left, abbr.right, tr.top, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
							SetDParam(0, _date + (arr_dep[i/2].departure + offset) / DAY_TICKS);
 
							DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
 
							DrawString(time.left, time.right, tr.top, STR_JUST_DATE_TINY,
 
									show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
 
						}
 
					}
 
					y += FONT_HEIGHT_NORMAL;
 
					tr.top += FONT_HEIGHT_NORMAL;
 
				}
 
				break;
 
			}
 

	
 
			case WID_VT_SUMMARY_PANEL: {
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
				Ticks total_time = v->orders != nullptr ? v->orders->GetTimetableDurationIncomplete() : 0;
 
				if (total_time != 0) {
 
					SetTimetableParams(0, 1, total_time);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, v->orders->IsCompleteTimetable() ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE);
 
					DrawString(tr, v->orders->IsCompleteTimetable() ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE);
 
				}
 
				y += FONT_HEIGHT_NORMAL;
 
				tr.top += FONT_HEIGHT_NORMAL;
 

	
 
				if (v->timetable_start != 0) {
 
					/* We are running towards the first station so we can start the
 
					 * timetable at the given time. */
 
					SetDParam(0, STR_JUST_DATE_TINY);
 
					SetDParam(1, v->timetable_start);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_START_AT);
 
					DrawString(tr, STR_TIMETABLE_STATUS_START_AT);
 
				} else if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) {
 
					/* We aren't running on a timetable yet, so how can we be "on time"
 
					 * when we aren't even "on service"/"on duty"? */
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_NOT_STARTED);
 
					DrawString(tr, STR_TIMETABLE_STATUS_NOT_STARTED);
 
				} else if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_ON_TIME);
 
					DrawString(tr, STR_TIMETABLE_STATUS_ON_TIME);
 
				} else {
 
					SetTimetableParams(0, 1, abs(v->lateness_counter));
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE);
 
					DrawString(tr, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE);
 
				}
 
				break;
 
			}
src/toolbar_gui.cpp
Show inline comments
 
@@ -106,10 +106,11 @@ public:
 
	void Draw(const Rect &r, bool sel, Colours bg_colour) const override
 
	{
 
		bool rtl = _current_text_dir == TD_RTL;
 
		Rect tr = r.Shrink(WD_DROPDOWNTEXT_LEFT, 0, WD_DROPDOWNTEXT_RIGHT, 0);
 
		if (this->checked) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
 
			DrawString(tr, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
 
		}
 
		DrawString(r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : this->checkmark_width), r.right - WD_FRAMERECT_RIGHT - (rtl ? this->checkmark_width : 0), r.top, this->String(), sel ? TC_WHITE : TC_BLACK);
 
		DrawString(tr.Indent(this->checkmark_width, rtl), this->String(), sel ? TC_WHITE : TC_BLACK);
 
	}
 
};
 

	
 
@@ -138,12 +139,12 @@ public:
 
		CompanyID company = (CompanyID)this->result;
 
		SetDParam(0, company);
 
		SetDParam(1, company);
 
		return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
 
		return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT + 6;
 
	}
 

	
 
	uint Height(uint width) const override
 
	{
 
		return std::max(std::max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
 
		return std::max(std::max(this->icon_size.height, this->lock_size.height) + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM, (uint)FONT_HEIGHT_NORMAL);
 
	}
 

	
 
	void Draw(const Rect &r, bool sel, Colours bg_colour) const override
 
@@ -154,13 +155,14 @@ public:
 
		/* It's possible the company is deleted while the dropdown is open */
 
		if (!Company::IsValidID(company)) return;
 

	
 
		Rect tr = r.Shrink(WD_DROPDOWNTEXT_LEFT, 0, WD_DROPDOWNTEXT_RIGHT, 0);
 
		int icon_y = CenterBounds(r.top, r.bottom, icon_size.height);
 
		int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
 
		int lock_y = CenterBounds(r.top, r.bottom, lock_size.height);
 

	
 
		DrawCompanyIcon(company, rtl ? r.right - this->icon_size.width - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT, icon_y);
 
		DrawCompanyIcon(company, tr.WithWidth(this->icon_size.width, rtl).left, icon_y);
 
		if (NetworkCompanyIsPassworded(company)) {
 
			DrawSprite(SPR_LOCK, PAL_NONE, rtl ? r.left + WD_FRAMERECT_LEFT : r.right - this->lock_size.width - WD_FRAMERECT_RIGHT, lock_y);
 
			DrawSprite(SPR_LOCK, PAL_NONE, tr.WithWidth(this->lock_size.width, !rtl).left, lock_y);
 
		}
 

	
 
		SetDParam(0, company);
 
@@ -171,7 +173,8 @@ public:
 
		} else {
 
			col = sel ? TC_WHITE : TC_BLACK;
 
		}
 
		DrawString(r.left + WD_FRAMERECT_LEFT + (rtl ? 3 + this->lock_size.width : 3 + this->icon_size.width), r.right - WD_FRAMERECT_RIGHT - (rtl ? 3 + this->icon_size.width : 3 + this->lock_size.width), text_y, STR_COMPANY_NAME_COMPANY_NUM, col);
 
		tr = tr.Indent(this->icon_size.width + 3, rtl).Indent(this->lock_size.width + 3, !rtl);
 
		DrawString(tr.left, tr.right, text_y, STR_COMPANY_NAME_COMPANY_NUM, col);
 
	}
 
};
 

	
 
@@ -2355,10 +2358,10 @@ struct ScenarioEditorToolbarWindow : Win
 
	{
 
		switch (widget) {
 
			case WID_TE_SPACER: {
 
				int height = r.bottom - r.top;
 
				int height = r.Height();
 
				if (height > 2 * FONT_HEIGHT_NORMAL) {
 
					DrawString(r.left, r.right, (height + 1) / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
 
					DrawString(r.left, r.right, (height + 1) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
 
					DrawString(r.left, r.right, height / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
 
					DrawString(r.left, r.right, height / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
 
				} else {
 
					DrawString(r.left, r.right, (height - FONT_HEIGHT_NORMAL) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
 
				}
src/town_gui.cpp
Show inline comments
 
@@ -137,14 +137,10 @@ public:
 
	/** Draw the contents of the ratings panel. May request a resize of the window if the contents does not fit. */
 
	void DrawRatings()
 
	{
 
		NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO);
 
		uint left = nwid->pos_x + WD_FRAMERECT_LEFT;
 
		uint right = nwid->pos_x + nwid->current_x - 1 - WD_FRAMERECT_RIGHT;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO)->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		uint y = nwid->pos_y + WD_FRAMERECT_TOP;
 

	
 
		DrawString(left, right, y, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
 
		y += FONT_HEIGHT_NORMAL;
 
		DrawString(r, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
 
		r.top += FONT_HEIGHT_NORMAL;
 

	
 
		Dimension icon_size = GetSpriteSize(SPR_COMPANY_ICON);
 
		int icon_width      = icon_size.width;
 
@@ -155,56 +151,52 @@ public:
 
		int exclusive_y_offset   = (FONT_HEIGHT_NORMAL - exclusive_size.height) / 2;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint text_left      = left  + (rtl ? 0 : icon_width + exclusive_width + 4);
 
		uint text_right     = right - (rtl ? icon_width + exclusive_width + 4 : 0);
 
		uint icon_left      = rtl ? right - icon_width : left;
 
		uint exclusive_left = rtl ? right - icon_width - exclusive_width - 2 : left + icon_width + 2;
 
		Rect text = r.Indent(icon_width + exclusive_width + 4, rtl);
 
		uint icon_left = r.WithWidth(icon_width, rtl).left;
 
		uint exclusive_left = r.Indent(icon_width + 2, rtl).WithWidth(exclusive_width, rtl).left;
 

	
 
		/* Draw list of companies */
 
		for (const Company *c : Company::Iterate()) {
 
			if ((HasBit(this->town->have_ratings, c->index) || this->town->exclusivity == c->index)) {
 
				DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
 
				DrawCompanyIcon(c->index, icon_left, text.top + icon_y_offset);
 

	
 
				SetDParam(0, c->index);
 
				SetDParam(1, c->index);
 

	
 
				int r = this->town->ratings[c->index];
 
				int rating = this->town->ratings[c->index];
 
				StringID str = STR_CARGO_RATING_APPALLING;
 
				if (r > RATING_APPALLING) str++;
 
				if (r > RATING_VERYPOOR)  str++;
 
				if (r > RATING_POOR)      str++;
 
				if (r > RATING_MEDIOCRE)  str++;
 
				if (r > RATING_GOOD)      str++;
 
				if (r > RATING_VERYGOOD)  str++;
 
				if (r > RATING_EXCELLENT) str++;
 
				if (rating > RATING_APPALLING) str++;
 
				if (rating > RATING_VERYPOOR)  str++;
 
				if (rating > RATING_POOR)      str++;
 
				if (rating > RATING_MEDIOCRE)  str++;
 
				if (rating > RATING_GOOD)      str++;
 
				if (rating > RATING_VERYGOOD)  str++;
 
				if (rating > RATING_EXCELLENT) str++;
 

	
 
				SetDParam(2, str);
 
				if (this->town->exclusivity == c->index) {
 
					DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, y + exclusive_y_offset);
 
					DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, r.top + exclusive_y_offset);
 
				}
 

	
 
				DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING);
 
				y += FONT_HEIGHT_NORMAL;
 
				DrawString(text, STR_LOCAL_AUTHORITY_COMPANY_RATING);
 
				text.top += FONT_HEIGHT_NORMAL;
 
			}
 
		}
 

	
 
		y = y + WD_FRAMERECT_BOTTOM - nwid->pos_y; // Compute needed size of the widget.
 
		if (y > nwid->current_y) {
 
		text.bottom = text.top - 1;
 
		if (text.bottom > r.bottom) {
 
			/* If the company list is too big to fit, mark ourself dirty and draw again. */
 
			ResizeWindow(this, 0, y - nwid->current_y, false);
 
			ResizeWindow(this, 0, text.bottom - r.bottom, false);
 
		}
 
	}
 

	
 
	/** Draws the contents of the actions panel. May re-initialise window to resize panel, if the list does not fit. */
 
	void DrawActions()
 
	{
 
		NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST);
 
		uint left = nwid->pos_x + WD_FRAMERECT_LEFT;
 
		uint right = nwid->pos_x + nwid->current_x - 1 - WD_FRAMERECT_RIGHT;
 
		uint y = nwid->pos_y + WD_FRAMERECT_TOP;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
 
		y += FONT_HEIGHT_NORMAL;
 
		DrawString(r, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
 
		r.top += FONT_HEIGHT_NORMAL;
 

	
 
		/* Draw list of actions */
 
		for (int i = 0; i < TACT_COUNT; i++) {
 
@@ -216,8 +208,8 @@ public:
 
			if (HasBit(this->available_actions, i)) action_colour = TC_ORANGE;
 
			if (this->sel_index == i) action_colour = TC_WHITE;
 

	
 
			DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, action_colour);
 
			y += FONT_HEIGHT_NORMAL;
 
			DrawString(r, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, action_colour);
 
			r.top += FONT_HEIGHT_NORMAL;
 
		}
 
	}
 

	
 
@@ -235,7 +227,7 @@ public:
 
					bool affordable = action_cost < Company::GetIfValid(_local_company)->money;
 

	
 
					SetDParam(0, action_cost);
 
					DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
 
					DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM),
 
						STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index,
 
						affordable ? TC_YELLOW : TC_RED);
 
				}
 
@@ -389,21 +381,24 @@ public:
 
	{
 
		if (widget != WID_TV_INFO) return;
 

	
 
		uint y = r.top + WD_FRAMERECT_TOP;
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
		SetDParam(0, this->town->cache.population);
 
		SetDParam(1, this->town->cache.num_houses);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_VIEW_POPULATION_HOUSES);
 
		DrawString(tr, STR_TOWN_VIEW_POPULATION_HOUSES);
 
		tr.top += FONT_HEIGHT_NORMAL;
 

	
 
		SetDParam(0, 1 << CT_PASSENGERS);
 
		SetDParam(1, this->town->supplied[CT_PASSENGERS].old_act);
 
		SetDParam(2, this->town->supplied[CT_PASSENGERS].old_max);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
 
		DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
 
		tr.top += FONT_HEIGHT_NORMAL;
 

	
 
		SetDParam(0, 1 << CT_MAIL);
 
		SetDParam(1, this->town->supplied[CT_MAIL].old_act);
 
		SetDParam(2, this->town->supplied[CT_MAIL].old_max);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
 
		DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
 
		tr.top += FONT_HEIGHT_NORMAL;
 

	
 
		bool first = true;
 
		for (int i = TE_BEGIN; i < TE_END; i++) {
 
@@ -412,13 +407,12 @@ public:
 
			if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
 

	
 
			if (first) {
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
 
				DrawString(tr, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
 
				tr.top += FONT_HEIGHT_NORMAL;
 
				first = false;
 
			}
 

	
 
			bool rtl = _current_text_dir == TD_RTL;
 
			uint cargo_text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : 20);
 
			uint cargo_text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? 20 : 0);
 

	
 
			const CargoSpec *cargo = FindFirstCargoWithTownEffect((TownEffect)i);
 
			assert(cargo != nullptr);
 
@@ -448,26 +442,30 @@ public:
 
				SetDParam(2, cargo->Index());
 
				SetDParam(3, this->town->goal[i]);
 
			}
 
			DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, string);
 
			DrawString(tr.Indent(20, rtl), string);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		if (HasBit(this->town->flags, TOWN_IS_GROWING)) {
 
			SetDParam(0, RoundDivSU(this->town->growth_rate + 1, DAY_TICKS));
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
 
			DrawString(tr, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
		} else {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
 
			DrawString(tr, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		/* only show the town noise, if the noise option is activated. */
 
		if (_settings_game.economy.station_noise_level) {
 
			SetDParam(0, this->town->noise_reached);
 
			SetDParam(1, this->town->MaxTownNoise());
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_NOISE_IN_TOWN);
 
			DrawString(tr, STR_TOWN_VIEW_NOISE_IN_TOWN);
 
			tr.top += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		if (!this->town->text.empty()) {
 
			SetDParamStr(0, this->town->text);
 
			DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y += FONT_HEIGHT_NORMAL, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
 
			tr.top = DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_BLACK);
 
		}
 
	}
 

	
 
@@ -821,18 +819,17 @@ public:
 

	
 
			case WID_TD_LIST: {
 
				int n = 0;
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				if (this->towns.size() == 0) { // No towns available.
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
 
					DrawString(tr, STR_TOWN_DIRECTORY_NONE);
 
					break;
 
				}
 

	
 
				/* At least one town available. */
 
				bool rtl = _current_text_dir == TD_RTL;
 
				Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
 
				int text_left  = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : icon_size.width + 2);
 
				int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
 
				int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
 
				int icon_x = tr.WithWidth(icon_size.width, rtl).left;
 
				tr = tr.Indent(icon_size.width + 2, rtl);
 

	
 
				for (uint i = this->vscroll->GetPosition(); i < this->towns.size(); i++) {
 
					const Town *t = this->towns[i];
 
@@ -840,19 +837,19 @@ public:
 

	
 
					/* Draw rating icon. */
 
					if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) {
 
						DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
 
						DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, tr.top + (this->resize.step_height - icon_size.height) / 2);
 
					} else {
 
						SpriteID icon = SPR_TOWN_RATING_APALLING;
 
						if (t->ratings[_local_company] > RATING_VERYPOOR) icon = SPR_TOWN_RATING_MEDIOCRE;
 
						if (t->ratings[_local_company] > RATING_GOOD)     icon = SPR_TOWN_RATING_GOOD;
 
						DrawSprite(icon, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
 
						DrawSprite(icon, PAL_NONE, icon_x, tr.top + (this->resize.step_height - icon_size.height) / 2);
 
					}
 

	
 
					SetDParam(0, t->index);
 
					SetDParam(1, t->cache.population);
 
					DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
 
					DrawString(tr.left, tr.right, tr.top + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
 

	
 
					y += this->resize.step_height;
 
					tr.top += this->resize.step_height;
 
					if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
 
				}
 
				break;
src/transparency_gui.cpp
Show inline comments
 
@@ -52,18 +52,20 @@ public:
 
			case WID_TT_CATENARY:
 
			case WID_TT_LOADING: {
 
				uint i = widget - WID_TT_BEGIN;
 
				if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + 1, r.top + 1);
 
				if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + WD_BEVEL_LEFT, r.top + WD_BEVEL_TOP);
 
				break;
 
			}
 
			case WID_TT_BUTTONS:
 
			case WID_TT_BUTTONS: {
 
				const Rect fr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) {
 
					if (i == WID_TT_LOADING) continue; // Do not draw button for invisible loading indicators.
 

	
 
					const NWidgetBase *wi = this->GetWidget<NWidgetBase>(i);
 
					DrawFrameRect(wi->pos_x + 1, r.top + 2, wi->pos_x + wi->current_x - 2, r.bottom - 2, COLOUR_PALE_GREEN,
 
					const Rect wr = this->GetWidget<NWidgetBase>(i)->GetCurrentRect().Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
 
					DrawFrameRect(wr.left, fr.top, wr.right, fr.bottom, COLOUR_PALE_GREEN,
 
							HasBit(_invisibility_opt, i - WID_TT_BEGIN) ? FR_LOWERED : FR_NONE);
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
src/tree_gui.cpp
Show inline comments
 
@@ -169,7 +169,7 @@ public:
 
		if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
 
			const int index = widget - WID_BT_TYPE_BUTTON_FIRST;
 
			/* Trees "grow" in the centre on the bottom line of the buttons */
 
			DrawSprite(tree_sprites[index].sprite, tree_sprites[index].pal, CenterBounds(r.left, r.right, 0) + WD_FRAMERECT_LEFT, r.bottom - ScaleGUITrad(BUTTON_BOTTOM_OFFSET));
 
			DrawSprite(tree_sprites[index].sprite, tree_sprites[index].pal, CenterBounds(r.left, r.right, 0), r.bottom - ScaleGUITrad(BUTTON_BOTTOM_OFFSET));
 
		}
 
	}
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -539,7 +539,7 @@ typedef std::vector<RefitOption> Subtype
 
 */
 
static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int sel[2], uint pos, uint rows, uint delta, const Rect &r)
 
{
 
	uint y = r.top + WD_MATRIX_TOP;
 
	Rect ir = r.Shrink(WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_LEFT);
 
	uint current = 0;
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -547,12 +547,11 @@ static void DrawVehicleRefitWindow(const
 
	uint iconheight = GetSpriteSize(SPR_CIRCLE_FOLDED).height;
 
	int linecolour = _colour_gradient[COLOUR_ORANGE][4];
 

	
 
	int iconleft   = rtl ? r.right - WD_MATRIX_RIGHT - iconwidth     : r.left + WD_MATRIX_LEFT;
 
	int iconcenter = rtl ? r.right - WD_MATRIX_RIGHT - iconwidth / 2 : r.left + WD_MATRIX_LEFT + iconwidth / 2;
 
	int iconinner  = rtl ? r.right - WD_MATRIX_RIGHT - iconwidth     : r.left + WD_MATRIX_LEFT + iconwidth;
 

	
 
	int textleft   = r.left  + WD_MATRIX_LEFT  + (rtl ? 0 : iconwidth + 4);
 
	int textright  = r.right - WD_MATRIX_RIGHT - (rtl ? iconwidth + 4 : 0);
 
	int iconleft   = rtl ? ir.right - iconwidth     : ir.left;
 
	int iconcenter = rtl ? ir.right - iconwidth / 2 : ir.left + iconwidth / 2;
 
	int iconinner  = rtl ? ir.right - iconwidth     : ir.left + iconwidth;
 

	
 
	Rect tr = ir.Indent(iconwidth + 4, rtl);
 

	
 
	/* Draw the list of subtypes for each cargo, and find the selected refit option (by its position). */
 
	for (uint i = 0; current < pos + rows && i < NUM_CARGO; i++) {
 
@@ -571,12 +570,12 @@ static void DrawVehicleRefitWindow(const
 
			if (list[i].size() > 1) {
 
				if (refit.subtype != 0xFF) {
 
					/* Draw tree lines */
 
					int ycenter = y + FONT_HEIGHT_NORMAL / 2;
 
					GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
 
					int ycenter = tr.top + FONT_HEIGHT_NORMAL / 2;
 
					GfxDrawLine(iconcenter, tr.top - WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : tr.top - WD_MATRIX_TOP + delta - 1, linecolour);
 
					GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
 
				} else {
 
					/* Draw expand/collapse icon */
 
					DrawSprite(sel[0] == (int)i ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, y + (FONT_HEIGHT_NORMAL - iconheight) / 2);
 
					DrawSprite(sel[0] == (int)i ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, tr.top + (FONT_HEIGHT_NORMAL - iconheight) / 2);
 
				}
 
			}
 

	
 
@@ -584,9 +583,9 @@ static void DrawVehicleRefitWindow(const
 
			/* Get the cargo name. */
 
			SetDParam(0, CargoSpec::Get(refit.cargo)->name);
 
			SetDParam(1, refit.string);
 
			DrawString(textleft, textright, y, STR_JUST_STRING_STRING, colour);
 

	
 
			y += delta;
 
			DrawString(tr, STR_JUST_STRING_STRING, colour);
 

	
 
			tr.top += delta;
 
			current++;
 
		}
 
	}
 
@@ -999,8 +998,7 @@ struct RefitWindow : public Window {
 
				if (this->cargo != nullptr) {
 
					StringID string = this->GetCapacityString(this->cargo);
 
					if (string != INVALID_STRING_ID) {
 
						DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT,
 
								r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM, string);
 
						DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM), string);
 
					}
 
				}
 
				break;
 
@@ -1637,25 +1635,22 @@ uint GetVehicleListHeight(VehicleType ty
 
 */
 
void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
 
{
 
	int left = r.left + WD_MATRIX_LEFT;
 
	int right = r.right - WD_MATRIX_RIGHT;
 
	int width = right - left;
 
	Rect ir = r.WithHeight(line_height).Shrink(WD_MATRIX_LEFT, 0, WD_MATRIX_RIGHT, 0);
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	int text_offset = std::max<int>(GetSpriteSize(SPR_PROFIT_LOT).width, GetDigitWidth() * this->unitnumber_digits) + WD_FRAMERECT_RIGHT;
 
	int text_left  = left  + (rtl ?           0 : text_offset);
 
	int text_right = right - (rtl ? text_offset :           0);
 
	Dimension profit = GetSpriteSize(SPR_PROFIT_LOT);
 
	int text_offset = std::max<int>(profit.width, GetDigitWidth() * this->unitnumber_digits) + WD_FRAMERECT_RIGHT;
 
	Rect tr = ir.Indent(text_offset, rtl);
 

	
 
	bool show_orderlist = this->vli.vtype >= VEH_SHIP;
 
	int orderlist_left  = left  + (rtl ? 0 : std::max(ScaleGUITrad(100) + text_offset, width / 2));
 
	int orderlist_right = right - (rtl ? std::max(ScaleGUITrad(100) + text_offset, width / 2) : 0);
 

	
 
	int image_left  = (rtl && show_orderlist) ? orderlist_right : text_left;
 
	int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
 

	
 
	int vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left;
 

	
 
	int y = r.top;
 
	Rect olr = ir.Indent(std::max(ScaleGUITrad(100) + text_offset, ir.Width() / 2), rtl);
 

	
 
	int image_left  = (rtl && show_orderlist) ? olr.right : tr.left;
 
	int image_right = (!rtl && show_orderlist) ? olr.left : tr.right;
 
	int image_height = ScaleGUITrad(GetVehicleHeight(this->vli.vtype));
 

	
 
	int vehicle_button_x = rtl ? ir.right - profit.width : ir.left;
 

	
 
	uint max = static_cast<uint>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
 
	for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 

	
 
@@ -1663,31 +1658,31 @@ void BaseVehicleListWindow::DrawVehicleL
 

	
 
		SetDParam(0, vehgroup.GetDisplayProfitThisYear());
 
		SetDParam(1, vehgroup.GetDisplayProfitLastYear());
 
		DrawString(text_left, text_right, y + line_height - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
 

	
 
		DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, y + FONT_HEIGHT_NORMAL + 3);
 
		DrawString(tr.left, tr.right, ir.bottom - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
 

	
 
		DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, ir.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL);
 

	
 
		switch (this->grouping) {
 
			case GB_NONE: {
 
				const Vehicle *v = vehgroup.GetSingleVehicle();
 

	
 
				if (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) {
 
					DrawSprite(SPR_WARNING_SIGN, PAL_NONE, vehicle_button_x, y + FONT_HEIGHT_NORMAL + 3 + GetSpriteSize(SPR_PROFIT_LOT).height);
 
					DrawSprite(SPR_WARNING_SIGN, PAL_NONE, vehicle_button_x, ir.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL + profit.height);
 
				}
 

	
 
				DrawVehicleImage(v, image_left, image_right, y + FONT_HEIGHT_SMALL - 1, selected_vehicle, EIT_IN_LIST, 0);
 
				DrawVehicleImage(v, image_left, image_right, CenterBounds(ir.top, ir.bottom, image_height), selected_vehicle, EIT_IN_LIST, 0);
 

	
 
				if (!v->name.empty()) {
 
					/* The vehicle got a name so we will print it */
 
					SetDParam(0, v->index);
 
					DrawString(text_left, text_right, y, STR_TINY_BLACK_VEHICLE);
 
					DrawString(tr.left, tr.right, ir.top, STR_TINY_BLACK_VEHICLE);
 
				} else if (v->group_id != DEFAULT_GROUP) {
 
					/* The vehicle has no name, but is member of a group, so print group name */
 
					SetDParam(0, v->group_id);
 
					DrawString(text_left, text_right, y, STR_TINY_GROUP, TC_BLACK);
 
					DrawString(tr.left, tr.right, ir.top, STR_TINY_GROUP, TC_BLACK);
 
				}
 

	
 
				if (show_orderlist) DrawSmallOrderList(v, orderlist_left, orderlist_right, y, this->order_arrow_width, v->cur_real_order_index);
 
				if (show_orderlist) DrawSmallOrderList(v, olr.left, olr.right, ir.top, this->order_arrow_width, v->cur_real_order_index);
 

	
 
				StringID str;
 
				if (v->IsChainInDepot()) {
 
@@ -1697,7 +1692,7 @@ void BaseVehicleListWindow::DrawVehicleL
 
				}
 

	
 
				SetDParam(0, v->unitnumber);
 
				DrawString(left, right, y + 2, str);
 
				DrawString(ir.left, ir.right, ir.top + WD_FRAMERECT_TOP, str);
 
				break;
 
			}
 

	
 
@@ -1706,20 +1701,20 @@ void BaseVehicleListWindow::DrawVehicleL
 

	
 
				for (int i = 0; i < static_cast<int>(vehgroup.NumVehicles()); ++i) {
 
					if (image_left + 8 * i >= image_right) break; // Break if there is no more space to draw any more vehicles anyway.
 
					DrawVehicleImage(vehgroup.vehicles_begin[i], image_left + 8 * i, image_right, y + FONT_HEIGHT_SMALL - 1, selected_vehicle, EIT_IN_LIST, 0);
 
					DrawVehicleImage(vehgroup.vehicles_begin[i], image_left + 8 * i, image_right, CenterBounds(ir.top, ir.bottom, image_height), selected_vehicle, EIT_IN_LIST, 0);
 
				}
 

	
 
				if (show_orderlist) DrawSmallOrderList((vehgroup.vehicles_begin[0])->GetFirstOrder(), orderlist_left, orderlist_right, y, this->order_arrow_width);
 
				if (show_orderlist) DrawSmallOrderList((vehgroup.vehicles_begin[0])->GetFirstOrder(), olr.left, olr.right, ir.top, this->order_arrow_width);
 

	
 
				SetDParam(0, vehgroup.NumVehicles());
 
				DrawString(left, right, y + 2, STR_BLACK_COMMA);
 
				DrawString(ir.left, ir.right, ir.top + WD_FRAMERECT_TOP, STR_BLACK_COMMA);
 
				break;
 

	
 
			default:
 
				NOT_REACHED();
 
		}
 

	
 
		y += line_height;
 
		ir = ir.Translate(0, line_height);
 
	}
 
}
 

	
 
@@ -2434,15 +2429,15 @@ struct VehicleDetailsWindow : Window {
 

	
 
		switch (widget) {
 
			case WID_VD_TOP_DETAILS: {
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
				/* Draw running cost */
 
				SetDParam(1, v->age / DAYS_IN_LEAP_YEAR);
 
				SetDParam(0, (v->age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
 
				SetDParam(2, v->max_age / DAYS_IN_LEAP_YEAR);
 
				SetDParam(3, v->GetDisplayRunningCost());
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_AGE_RUNNING_COST_YR);
 
				y += FONT_HEIGHT_NORMAL;
 
				DrawString(tr, STR_VEHICLE_INFO_AGE_RUNNING_COST_YR);
 
				tr.top += FONT_HEIGHT_NORMAL;
 

	
 
				/* Draw max speed */
 
				StringID string;
 
@@ -2473,24 +2468,24 @@ struct VehicleDetailsWindow : Window {
 
						string = STR_VEHICLE_INFO_MAX_SPEED;
 
					}
 
				}
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, string);
 
				y += FONT_HEIGHT_NORMAL;
 
				DrawString(tr, string);
 
				tr.top += FONT_HEIGHT_NORMAL;
 

	
 
				/* Draw profit */
 
				SetDParam(0, v->GetDisplayProfitThisYear());
 
				SetDParam(1, v->GetDisplayProfitLastYear());
 
				if (v->IsGroundVehicle()) {
 
					SetDParam(2, v->GetDisplayMinPowerToWeight());
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR_MIN_PERFORMANCE);
 
					DrawString(tr, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR_MIN_PERFORMANCE);
 
				} else {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR);
 
					DrawString(tr, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR);
 
				}
 
				y += FONT_HEIGHT_NORMAL;
 
				tr.top += FONT_HEIGHT_NORMAL;
 

	
 
				/* Draw breakdown & reliability */
 
				SetDParam(0, ToPercent16(v->reliability));
 
				SetDParam(1, v->breakdowns_since_last_service);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS);
 
				DrawString(tr, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS);
 
				break;
 
			}
 

	
 
@@ -3032,16 +3027,13 @@ public:
 

	
 
		/* Draw the flag plus orders. */
 
		bool rtl = (_current_text_dir == TD_RTL);
 
		uint text_offset = std::max({GetSpriteSize(SPR_WARNING_SIGN).width, GetSpriteSize(SPR_FLAG_VEH_STOPPED).width, GetSpriteSize(SPR_FLAG_VEH_RUNNING).width}) + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT;
 
		int text_left = r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : text_offset);
 
		int text_right = r.right - (rtl ? text_offset : (uint)WD_FRAMERECT_RIGHT);
 
		int text_top = CenterBounds(r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM, FONT_HEIGHT_NORMAL);
 
		int image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) ? SPR_WARNING_SIGN : SPR_FLAG_VEH_RUNNING;
 
		int image_left = (rtl ? text_right + 1 : r.left) + WD_IMGBTN_LEFT;
 
		int image_top = CenterBounds(r.top + WD_IMGBTN_TOP, r.bottom - WD_IMGBTN_BOTTOM, GetSpriteSize(image).height);
 
		int lowered = this->IsWidgetLowered(WID_VV_START_STOP) ? 1 : 0;
 
		DrawSprite(image, PAL_NONE, image_left + lowered, image_top + lowered);
 
		DrawString(text_left + lowered, text_right + lowered, text_top + lowered, str, text_colour, SA_HOR_CENTER);
 
		uint icon_width = std::max({GetSpriteSize(SPR_WARNING_SIGN).width, GetSpriteSize(SPR_FLAG_VEH_STOPPED).width, GetSpriteSize(SPR_FLAG_VEH_RUNNING).width});
 
		int lowered = this->IsWidgetLowered(widget) ? 1 : 0;
 
		Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM).Translate(lowered, lowered);
 
		SpriteID image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) ? SPR_WARNING_SIGN : SPR_FLAG_VEH_RUNNING;
 
		DrawSprite(image, PAL_NONE, tr.WithWidth(icon_width, rtl).left, CenterBounds(tr.top, tr.bottom, GetSpriteSize(image).height));
 
		tr = tr.Indent(icon_width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT, rtl);
 
		DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), str, text_colour, SA_HOR_CENTER);
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
src/widgets/dropdown.cpp
Show inline comments
 
@@ -88,8 +88,10 @@ uint DropDownListIconItem::Width() const
 
void DropDownListIconItem::Draw(const Rect &r, bool sel, Colours bg_colour) const
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 
	DrawSprite(this->sprite, this->pal, rtl ? r.right - this->dim.width - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT, CenterBounds(r.top, r.bottom, this->sprite_y));
 
	DrawString(r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : (this->dim.width + WD_FRAMERECT_LEFT)), r.right - WD_FRAMERECT_RIGHT - (rtl ? (this->dim.width + WD_FRAMERECT_RIGHT) : 0), CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK);
 
	Rect ir = r.Shrink(WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_LEFT);
 
	Rect tr = ir.Indent(this->dim.width + WD_FRAMERECT_LEFT, rtl);
 
	DrawSprite(this->sprite, this->pal, ir.WithWidth(this->dim.width, rtl).left, CenterBounds(r.top, r.bottom, this->sprite_y));
 
	DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK);
 
}
 

	
 
void DropDownListIconItem::SetDimension(Dimension d)
0 comments (0 inline, 0 general)