diff options
author | peter1138 <peter1138@openttd.org> | 2014-09-22 08:01:25 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2014-09-22 08:01:25 +0000 |
commit | 51fe741987da095274cd3782ff62371a1126ddb8 (patch) | |
tree | b6b85bfe28aeff152bbb373d07d615641fc65690 | |
parent | 26239c3d89327d2b94210097f90ae3c6dba3dbc7 (diff) | |
download | openttd-51fe741987da095274cd3782ff62371a1126ddb8.tar.xz |
(svn r26906) -Codechange: Scale depot and station picker buttons by GUI zoom level.
-rw-r--r-- | src/dock_gui.cpp | 25 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 3 | ||||
-rw-r--r-- | src/rail_gui.cpp | 42 | ||||
-rw-r--r-- | src/road_cmd.cpp | 3 | ||||
-rw-r--r-- | src/road_gui.cpp | 21 |
5 files changed, 74 insertions, 20 deletions
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 94b735573..cd994bc0b 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -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) diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 2ba00d790..d3093aa7b 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -2443,9 +2443,6 @@ void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype) 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); diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 1907c6617..ff330b035 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -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 PickerWindowBase { 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 : PickerWindowBase { /* 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 : PickerWindowBase { 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); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 46a074968..cdcedf460 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1415,9 +1415,6 @@ void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt) 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); } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index c0594e1f8..7824f1f29 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -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 PickerWindowBase { 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 PickerWindowBase { } } + 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) |