Changeset - r21763:903f53f3d380
[Not reviewed]
master
0 5 0
peter1138 - 10 years ago 2014-09-22 08:01:25
peter1138@openttd.org
(svn r26906) -Codechange: Scale depot and station picker buttons by GUI zoom level.
5 files changed with 74 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/dock_gui.cpp
Show inline comments
 
@@ -26,6 +26,7 @@
 
#include "company_base.h"
 
#include "hotkeys.h"
 
#include "gui.h"
 
#include "zoom_func.h"
 

	
 
#include "widgets/dock_widget.h"
 

	
 
@@ -498,14 +499,30 @@ public:
 
		UpdateDocksDirection();
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case WID_BDD_X:
 
			case WID_BDD_Y:
 
				size->width  = UnScaleByZoom(96 * 4, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 

	
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_x + 64, this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_y + 18, AXIS_X, DEPOT_PART_NORTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_x + 32, this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_y + 34, AXIS_X, DEPOT_PART_SOUTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + 32, this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_y + 18, AXIS_Y, DEPOT_PART_NORTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + 64, this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_y + 34, AXIS_Y, DEPOT_PART_SOUTH);
 
		int x1 = UnScaleByZoom(63 * 4, ZOOM_LVL_GUI) + 1;
 
		int x2 = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
		int y1 = UnScaleByZoom(17 * 4, ZOOM_LVL_GUI) + 1;
 
		int y2 = UnScaleByZoom(33 * 4, ZOOM_LVL_GUI) + 1;
 

	
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_x + x1, this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_y + y1, AXIS_X, DEPOT_PART_NORTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_x + x2, this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_y + y2, AXIS_X, DEPOT_PART_SOUTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + x2, this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_y + y1, AXIS_Y, DEPOT_PART_NORTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + x1, this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_y + y2, AXIS_Y, DEPOT_PART_SOUTH);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
src/rail_cmd.cpp
Show inline comments
 
@@ -2443,9 +2443,6 @@ void DrawTrainDepotSprite(int x, int y, 
 
	SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite;
 
	uint32 offset = rti->GetRailtypeSpriteOffset();
 

	
 
	x += 33;
 
	y += 17;
 

	
 
	if (image != SPR_FLAT_GRASS_TILE) image += offset;
 
	PaletteID palette = COMPANY_SPRITE_COLOUR(_local_company);
 

	
src/rail_gui.cpp
Show inline comments
 
@@ -1072,6 +1072,13 @@ public:
 
				break;
 
			}
 

	
 
			case WID_BRAS_PLATFORM_DIR_X:
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
			case WID_BRAS_IMAGE:
 
				size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(58 * 4, ZOOM_LVL_GUI) + 2;
 
				break;
 

	
 
			case WID_BRAS_COVERAGE_TEXTS:
 
				size->height = this->coverage_height;
 
				break;
 
@@ -1093,8 +1100,10 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					if (!DrawStationTile(32, 28, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
 
						StationPickerDrawSprite(32, 28, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
 
					int x = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
					int y = r.bottom - r.top - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI);
 
					if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
@@ -1105,8 +1114,10 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					if (!DrawStationTile(32, 28, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
 
						StationPickerDrawSprite(32, 28, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
 
					int x = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
					int y = r.bottom - r.top - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI);
 
					if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
@@ -1141,8 +1152,10 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					if (!DrawStationTile(32, 28, _cur_railtype, _railstation.orientation, _railstation.station_class, type)) {
 
						StationPickerDrawSprite(32, 28, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
 
					int x = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
					int y = r.bottom - r.top - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI);
 
					if (!DrawStationTile(x, y, _cur_railtype, _railstation.orientation, _railstation.station_class, type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
@@ -1676,11 +1689,19 @@ struct BuildRailDepotWindow : public Pic
 
		this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
		size->height = UnScaleByZoom(48 * 4, ZOOM_LVL_GUI) + 2;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		DrawTrainDepotSprite(r.left - 1, r.top, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
 
		DrawTrainDepotSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
@@ -1768,6 +1789,11 @@ struct BuildRailWaypointWindow : PickerW
 
				/* Resizing in X direction only at blob size, but at pixel level in Y. */
 
				resize->height = 1;
 
				break;
 

	
 
			case WID_BRW_WAYPOINT:
 
				size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(58 * 4, ZOOM_LVL_GUI) + 2;
 
				break;
 
		}
 
	}
 

	
 
@@ -1777,7 +1803,7 @@ struct BuildRailWaypointWindow : PickerW
 
			case WID_BRW_WAYPOINT: {
 
				byte type = GB(widget, 16, 16);
 
				const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
 
				DrawWaypointSprite(r.left + TILE_PIXELS, r.bottom - TILE_PIXELS, type, _cur_railtype);
 
				DrawWaypointSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), type, _cur_railtype);
 

	
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
src/road_cmd.cpp
Show inline comments
 
@@ -1415,9 +1415,6 @@ void DrawRoadDepotSprite(int x, int y, D
 
	PaletteID palette = COMPANY_SPRITE_COLOUR(_local_company);
 
	const DrawTileSprites *dts = (rt == ROADTYPE_TRAM) ? &_tram_depot[dir] : &_road_depot[dir];
 

	
 
	x += 33;
 
	y += 17;
 

	
 
	DrawSprite(dts->ground.sprite, PAL_NONE, x, y);
 
	DrawOrigTileSeqInGUI(x, y, dts, palette);
 
}
src/road_gui.cpp
Show inline comments
 
@@ -28,6 +28,7 @@
 
#include "company_base.h"
 
#include "hotkeys.h"
 
#include "road_gui.h"
 
#include "zoom_func.h"
 

	
 
#include "widgets/road_widget.h"
 

	
 
@@ -862,11 +863,19 @@ struct BuildRoadDepotWindow : public Pic
 
		this->FinishInitNested(TRANSPORT_ROAD);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
		size->height = UnScaleByZoom(48 * 4, ZOOM_LVL_GUI) + 2;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		DrawRoadDepotSprite(r.left - 1, r.top, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
 
		DrawRoadDepotSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
@@ -990,12 +999,20 @@ struct BuildRoadStationWindow : public P
 
		}
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
 

	
 
		size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
		size->height = UnScaleByZoom(48 * 4, ZOOM_LVL_GUI) + 2;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
 

	
 
		StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
 
		StationPickerDrawSprite(r.left + TILE_PIXELS, r.bottom - TILE_PIXELS, st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE);
 
		StationPickerDrawSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
0 comments (0 inline, 0 general)