Changeset - r12355:15ed6906d629
[Not reviewed]
master
0 6 0
yexo - 15 years ago 2009-07-10 22:03:09
yexo@openttd.org
(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.
6 files changed with 31 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -233,13 +233,13 @@ public:
 
		if (_settings_game.economy.station_noise_level) {
 
			/* show the noise of the selected airport */
 
			SetDParam(0, airport->noise_level);
 
			DrawString(WD_FRAMERECT_LEFT, this->width - WD_FRAMERECT_RIGHT, top, STR_STATION_NOISE);
 
			DrawString(this->widget[BAW_BOTTOMPANEL].left + WD_FRAMERECT_LEFT, this->widget[BAW_BOTTOMPANEL].right - WD_FRAMERECT_RIGHT, top, STR_STATION_NOISE);
 
			top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
		}
 

	
 
		/* strings such as 'Size' and 'Coverage Area' */
 
		top = DrawStationCoverageAreaText(WD_FRAMERECT_LEFT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(WD_FRAMERECT_LEFT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(this->widget[BAW_BOTTOMPANEL].left + WD_FRAMERECT_LEFT, this->widget[BAW_BOTTOMPANEL].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(this->widget[BAW_BOTTOMPANEL].left + WD_FRAMERECT_LEFT, this->widget[BAW_BOTTOMPANEL].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		if (top != this->widget[BAW_BOTTOMPANEL].bottom) {
 
			this->SetDirty();
 
			ResizeWindowForWidget(this, BAW_BOTTOMPANEL, 0, top - this->widget[BAW_BOTTOMPANEL].bottom);
src/dock_gui.cpp
Show inline comments
 
@@ -402,11 +402,13 @@ public:
 
			SetTileSelectSize(1, 1);
 
		}
 

	
 
		int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false);
 
		text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4;
 
		if (text_end != this->widget[BDSW_BACKGROUND].bottom) {
 
		/* strings such as 'Size' and 'Coverage Area' */
 
		int top = this->widget[BDSW_LT_OFF].bottom + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(this->widget[BDSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BDSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(this->widget[BDSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BDSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		if (top != this->widget[BDSW_BACKGROUND].bottom) {
 
			this->SetDirty();
 
			ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom);
 
			ResizeWindowForWidget(this, BDSW_BACKGROUND, 0, top - this->widget[BDSW_BACKGROUND].bottom);
 
			this->SetDirty();
 
		}
 
	}
src/misc_gui.cpp
Show inline comments
 
@@ -811,7 +811,7 @@ void GuiShowTooltips(StringID str, uint 
 

	
 

	
 
static int DrawStationCoverageText(const CargoArray &cargos,
 
	int str_x, int str_y, StationCoverageType sct, bool supplies)
 
	int left, int right, int top, StationCoverageType sct, bool supplies)
 
{
 
	bool first = true;
 

	
 
@@ -847,19 +847,20 @@ static int DrawStationCoverageText(const
 
	assert(b < endof(string));
 

	
 
	SetDParamStr(0, string);
 
	return DrawStringMultiLine(str_x, str_x + 144, str_y, INT32_MAX, STR_JUST_RAW_STRING);
 
	return DrawStringMultiLine(left, right, top, INT32_MAX, STR_JUST_RAW_STRING);
 
}
 

	
 
/**
 
 * Calculates and draws the accepted or supplied cargo around the selected tile(s)
 
 * @param sx x position where the string is to be drawn
 
 * @param sy y position where the string is to be drawn
 
 * @param left x position where the string is to be drawn
 
 * @param right the right most position to draw on
 
 * @param top y position where the string is to be drawn
 
 * @param sct which type of cargo is to be displayed (passengers/non-passengers)
 
 * @param rad radius around selected tile(s) to be searched
 
 * @param supplies if supplied cargos should be drawn, else accepted cargos
 
 * @return Returns the y value below the string that was drawn
 
 */
 
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
 
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
 
{
 
	TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
 
	if (tile < MapSize()) {
 
@@ -869,10 +870,10 @@ int DrawStationCoverageAreaText(int sx, 
 
		} else {
 
			cargos = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad);
 
		}
 
		return DrawStationCoverageText(cargos, sx, sy, sct, supplies);
 
		return DrawStationCoverageText(cargos, left, right, top, sct, supplies);
 
	}
 

	
 
	return sy;
 
	return top;
 
}
 

	
 
void CheckRedrawStationCoverage(const Window *w)
src/rail_gui.cpp
Show inline comments
 
@@ -1063,11 +1063,13 @@ public:
 
		DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 101 + y_offset, STR_STATION_BUILD_PLATFORM_LENGTH, TC_FROMSTRING, SA_CENTER);
 
		DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 141 + y_offset, STR_STATION_BUILD_COVERAGE_AREA_TITLE, TC_FROMSTRING, SA_CENTER);
 

	
 
		int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false);
 
		text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
 
		if (text_end != this->widget[BRSW_BACKGROUND].bottom) {
 
		/* strings such as 'Size' and 'Coverage Area' */
 
		int top = 166 + y_offset;
 
		top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		if (top != this->widget[BRSW_BACKGROUND].bottom) {
 
			this->SetDirty();
 
			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom);
 
			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, top - this->widget[BRSW_BACKGROUND].bottom);
 
			this->SetDirty();
 
		}
 

	
src/road_gui.cpp
Show inline comments
 
@@ -955,15 +955,14 @@ struct BuildRoadStationWindow : public P
 
		StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
 
		StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
 

	
 
		int text_end = DrawStationCoverageAreaText(2, 147,
 
			(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
 
			rad, false);
 
		text_end = DrawStationCoverageAreaText(2, text_end + 4,
 
			(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
 
			rad, true) + 4;
 
		if (text_end > this->widget[BRSW_BACKGROUND].bottom) {
 
		/* strings such as 'Size' and 'Coverage Area' */
 
		StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
 
		int top = 147;
 
		top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, sct, rad, false) + WD_PAR_VSEP_NORMAL;
 
		top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, sct, rad, true) + WD_PAR_VSEP_NORMAL;
 
		if (top != this->widget[BRSW_BACKGROUND].bottom) {
 
			this->SetDirty();
 
			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom);
 
			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, top - this->widget[BRSW_BACKGROUND].bottom);
 
			this->SetDirty();
 
		}
 
	}
src/station_gui.h
Show inline comments
 
@@ -33,7 +33,7 @@ enum StationCoverageType {
 
	SCT_ALL
 
};
 

	
 
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies);
 
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies);
 
void CheckRedrawStationCoverage(const Window *w);
 

	
 
void ShowSelectStationIfNeeded(CommandContainer cmd, int w, int h);
0 comments (0 inline, 0 general)