openttd updated to 1.5.0-beta2
--HG-- branch : openttd
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Id: rail_gui.cpp 26375 2014-02-24 19:57:18Z frosch $ */
|
||||
/* $Id: rail_gui.cpp 27163 2015-02-22 15:26:27Z frosch $ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
@@ -40,6 +40,8 @@
|
||||
|
||||
#include "widgets/rail_widget.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
|
||||
static RailType _cur_railtype; ///< Rail type of the current build-rail toolbar.
|
||||
static bool _remove_button_clicked; ///< Flag whether 'remove' toggle-button is currently enabled
|
||||
@@ -86,7 +88,7 @@ static bool IsStationAvailable(const StationSpec *statspec)
|
||||
|
||||
void CcPlaySound1E(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
|
||||
}
|
||||
|
||||
static void GenericPlaceRail(TileIndex tile, int cmd)
|
||||
@@ -133,7 +135,7 @@ void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
|
||||
|
||||
DiagDirection dir = (DiagDirection)p2;
|
||||
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
|
||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||
|
||||
tile += TileOffsByDiagDir(dir);
|
||||
@@ -171,7 +173,7 @@ void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
|
||||
/* Only close the station builder window if the default station and non persistent building is chosen. */
|
||||
if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||
}
|
||||
@@ -272,7 +274,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w)
|
||||
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (result.Succeeded()) {
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
|
||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||
} else {
|
||||
SetRedErrorSquare(_build_tunnel_endtile);
|
||||
@@ -432,6 +434,18 @@ struct BuildRailToolbarWindow : Window {
|
||||
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some data on this window has become invalid.
|
||||
* @param data Information about the changed data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) delete this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the rail toolbar for railtype given
|
||||
* @param railtype the railtype to display
|
||||
@@ -1038,8 +1052,7 @@ public:
|
||||
Dimension d = {0, 0};
|
||||
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
|
||||
if (i == STAT_CLASS_WAYP) continue;
|
||||
SetDParam(0, StationClass::Get((StationClassID)i)->name);
|
||||
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
|
||||
d = maxdim(d, GetStringBoundingBox(StationClass::Get((StationClassID)i)->name));
|
||||
}
|
||||
size->width = max(size->width, d.width + padding.width);
|
||||
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
|
||||
@@ -1071,6 +1084,13 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_BRAS_PLATFORM_DIR_X:
|
||||
case WID_BRAS_PLATFORM_DIR_Y:
|
||||
case WID_BRAS_IMAGE:
|
||||
size->width = ScaleGUITrad(64) + 2;
|
||||
size->height = ScaleGUITrad(58) + 2;
|
||||
break;
|
||||
|
||||
case WID_BRAS_COVERAGE_TEXTS:
|
||||
size->height = this->coverage_height;
|
||||
break;
|
||||
@@ -1092,8 +1112,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 = ScaleGUITrad(31) + 1;
|
||||
int y = r.bottom - r.top - ScaleGUITrad(31);
|
||||
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;
|
||||
}
|
||||
@@ -1104,8 +1126,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 = ScaleGUITrad(31) + 1;
|
||||
int y = r.bottom - r.top - ScaleGUITrad(31);
|
||||
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;
|
||||
}
|
||||
@@ -1117,8 +1141,8 @@ public:
|
||||
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
|
||||
if (i == STAT_CLASS_WAYP) continue;
|
||||
if (this->vscroll->IsVisible(statclass)) {
|
||||
SetDParam(0, StationClass::Get((StationClassID)i)->name);
|
||||
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, row * this->line_height + r.top + WD_MATRIX_TOP, STR_JUST_STRING,
|
||||
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, row * this->line_height + r.top + WD_MATRIX_TOP,
|
||||
StationClass::Get((StationClassID)i)->name,
|
||||
(StationClassID)i == _railstation.station_class ? TC_WHITE : TC_BLACK);
|
||||
row++;
|
||||
}
|
||||
@@ -1140,8 +1164,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 = ScaleGUITrad(31) + 1;
|
||||
int y = r.bottom - r.top - ScaleGUITrad(31);
|
||||
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;
|
||||
}
|
||||
@@ -1675,11 +1701,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 = ScaleGUITrad(64) + 2;
|
||||
size->height = ScaleGUITrad(48) + 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 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
@@ -1767,6 +1801,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 = ScaleGUITrad(64) + 2;
|
||||
size->height = ScaleGUITrad(58) + 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1776,7 +1815,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 + 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);
|
||||
|
||||
Reference in New Issue
Block a user