Changeset - r26410:4eb5b6f65264
[Not reviewed]
master
0 6 0
Peter Nelson - 4 years ago 2021-05-04 11:35:27
peter1138@openttd.org
Codechange: Draw station acceptance text in its own widget.
6 files changed with 37 insertions and 47 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include "command_func.h"
 
#include "airport_cmd.h"
 
#include "station_cmd.h"
 
#include "zoom_func.h"
 

	
 
#include "widgets/airport_widget.h"
 

	
 
@@ -423,11 +424,8 @@ public:
 
	{
 
		this->DrawWidgets();
 

	
 
		uint16 top = this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->pos_y + this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL;
 
		NWidgetBase *panel_nwi = this->GetWidget<NWidgetBase>(WID_AP_BOTTOMPANEL);
 

	
 
		int right = panel_nwi->pos_x +  panel_nwi->current_x;
 
		int bottom = panel_nwi->pos_y +  panel_nwi->current_y;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_AP_ACCEPTANCE)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 

	
 
		if (_selected_airport_index != -1) {
 
			const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
 
@@ -437,20 +435,20 @@ public:
 
			if (_settings_game.economy.station_noise_level) {
 
				/* show the noise of the selected airport */
 
				SetDParam(0, as->noise_level);
 
				DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE);
 
				top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
				DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE);
 
				top += FONT_HEIGHT_NORMAL + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
			}
 

	
 
			/* strings such as 'Size' and 'Coverage Area' */
 
			top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
			top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
			top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
			top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		}
 

	
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
		if (top > bottom) {
 
			ResizeWindow(this, 0, top - bottom, false);
 
		if (top > r.bottom) {
 
			ResizeWindow(this, 0, top - r.bottom, false);
 
		}
 
	}
 

	
 
@@ -608,7 +606,7 @@ static const NWidgetPart _nested_build_a
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), SetFill(1, 0),
 
	EndContainer(),
 
};
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -416,6 +416,7 @@ enum BuildDockStationWidgets {
 
	BDSW_LT_OFF,     ///< 'Off' button of coverage high light.
 
	BDSW_LT_ON,      ///< 'On' button of coverage high light.
 
	BDSW_INFO,       ///< 'Coverage highlight' label.
 
	BDSW_ACCEPTANCE, ///< Acceptance info.
 
};
 

	
 
struct BuildDocksStationWindow : public PickerWindowBase {
 
@@ -445,17 +446,15 @@ public:
 
		}
 

	
 
		/* strings such as 'Size' and 'Coverage Area' */
 
		int top = this->GetWidget<NWidgetBase>(BDSW_LT_OFF)->pos_y + this->GetWidget<NWidgetBase>(BDSW_LT_OFF)->current_y + WD_PAR_VSEP_NORMAL;
 
		NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(BDSW_BACKGROUND);
 
		int right  = back_nwi->pos_x + back_nwi->current_x;
 
		int bottom = back_nwi->pos_y + back_nwi->current_y;
 
		top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		Rect r = this->GetWidget<NWidgetBase>(BDSW_ACCEPTANCE)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
		if (top > bottom) {
 
			ResizeWindow(this, 0, top - bottom, false);
 
		if (top > r.bottom) {
 
			ResizeWindow(this, 0, top - r.bottom, false);
 
		}
 
	}
 

	
 
@@ -493,7 +492,7 @@ static const NWidgetPart _nested_build_d
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 20), SetResize(0, 1),
 
		NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1),
 
	EndContainer(),
 
};
 

	
src/rail_gui.cpp
Show inline comments
 
@@ -1179,18 +1179,15 @@ public:
 

	
 
		if (this->IsShaded()) return;
 
		/* 'Accepts' and 'Supplies' texts. */
 
		NWidgetBase *cov = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS);
 
		int top = cov->pos_y + WD_PAR_VSEP_NORMAL;
 
		int left = cov->pos_x + WD_FRAMERECT_LEFT;
 
		int right = cov->pos_x + cov->current_x - WD_FRAMERECT_RIGHT;
 
		int bottom = cov->pos_y + cov->current_y;
 
		top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
		if (top > bottom) {
 
			this->coverage_height += top - bottom;
 
		if (top > r.bottom) {
 
			this->coverage_height += top - r.bottom;
 
			this->ReInit();
 
		}
 
	}
 
@@ -1637,7 +1634,7 @@ static const NWidgetPart _nested_station
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(2, 5, 0, 1), SetFill(1, 1), SetResize(1, 0),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetFill(1, 1), SetResize(1, 0),
 
			NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_RESIZE),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
src/road_gui.cpp
Show inline comments
 
@@ -1090,17 +1090,15 @@ struct BuildRoadStationWindow : public P
 

	
 
		/* 'Accepts' and 'Supplies' texts. */
 
		StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
 
		int top = this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->pos_y + this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->current_y + WD_PAR_VSEP_NORMAL;
 
		NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(WID_BROS_BACKGROUND);
 
		int right = back_nwi->pos_x +  back_nwi->current_x;
 
		int bottom = back_nwi->pos_y +  back_nwi->current_y;
 
		top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, true) + WD_PAR_VSEP_NORMAL;
 
		Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
 
		int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL);
 
		/* Resize background if the window is too small.
 
		 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
		if (top > bottom) {
 
			ResizeWindow(this, 0, top - bottom, false);
 
		if (top > r.bottom) {
 
			ResizeWindow(this, 0, top - r.bottom, false);
 
		}
 
	}
 

	
 
@@ -1194,7 +1192,7 @@ static const NWidgetPart _nested_road_st
 
											SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1),
 
	EndContainer(),
 
};
 

	
 
@@ -1219,11 +1217,7 @@ static const NWidgetPart _nested_tram_st
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y),  SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 1),
 
		NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
 
			NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
 
@@ -1232,7 +1226,7 @@ static const NWidgetPart _nested_tram_st
 
											SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
 
		NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1),
 
	EndContainer(),
 
};
 

	
src/widgets/airport_widget.h
Show inline comments
 
@@ -30,6 +30,7 @@ enum AirportPickerWidgets {
 
	WID_AP_COVERAGE_LABEL,  ///< Label if you want to see the coverage.
 
	WID_AP_BTN_DONTHILIGHT, ///< Don't show the coverage button.
 
	WID_AP_BTN_DOHILIGHT,   ///< Show the coverage button.
 
	WID_AP_ACCEPTANCE,      ///< Acceptance info.
 
};
 

	
 
#endif /* WIDGETS_AIRPORT_WIDGET_H */
src/widgets/road_widget.h
Show inline comments
 
@@ -51,7 +51,8 @@ enum BuildRoadStationWidgets {
 
	WID_BROS_STATION_Y,     ///< Drive-through station in y-direction.
 
	WID_BROS_LT_OFF,        ///< Turn off area highlight.
 
	WID_BROS_LT_ON,         ///< Turn on area highlight.
 
	WID_BROS_INFO,          ///< Station acceptance info.
 
	WID_BROS_INFO,          ///< Station acceptance toggle.
 
	WID_BROS_ACCEPTANCE,    ///< Station acceptance.
 
};
 

	
 
#endif /* WIDGETS_ROAD_WIDGET_H */
0 comments (0 inline, 0 general)