mirror of https://github.com/OpenTTD/OpenTTD
(svn r9897) -Codechange: prepare the toolbar for more road types.
parent
0646d307bd
commit
b7748a686e
|
@ -46,7 +46,7 @@ void ShowTrainViewWindow(const Vehicle *v);
|
||||||
void ShowOrdersWindow(const Vehicle *v);
|
void ShowOrdersWindow(const Vehicle *v);
|
||||||
|
|
||||||
/* road_gui.cpp */
|
/* road_gui.cpp */
|
||||||
void ShowBuildRoadToolbar();
|
void ShowBuildRoadToolbar(RoadType roadtype);
|
||||||
void ShowBuildRoadScenToolbar();
|
void ShowBuildRoadScenToolbar();
|
||||||
void ShowRoadVehViewWindow(const Vehicle *v);
|
void ShowRoadVehViewWindow(const Vehicle *v);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ static int _rename_what = -1;
|
||||||
|
|
||||||
static byte _terraform_size = 1;
|
static byte _terraform_size = 1;
|
||||||
RailType _last_built_railtype;
|
RailType _last_built_railtype;
|
||||||
|
RoadType _last_built_roadtype;
|
||||||
static int _scengen_town_size = 1; // depress medium-sized towns per default
|
static int _scengen_town_size = 1; // depress medium-sized towns per default
|
||||||
|
|
||||||
extern void GenerateIndustries();
|
extern void GenerateIndustries();
|
||||||
|
@ -310,7 +311,8 @@ static void MenuClickBuildRail(int index)
|
||||||
|
|
||||||
static void MenuClickBuildRoad(int index)
|
static void MenuClickBuildRoad(int index)
|
||||||
{
|
{
|
||||||
ShowBuildRoadToolbar();
|
_last_built_roadtype = (RoadType)index;
|
||||||
|
ShowBuildRoadToolbar(_last_built_roadtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuClickBuildWater(int index)
|
static void MenuClickBuildWater(int index)
|
||||||
|
@ -930,12 +932,13 @@ static void ToolbarBuildRailClick(Window *w)
|
||||||
const Player *p = GetPlayer(_local_player);
|
const Player *p = GetPlayer(_local_player);
|
||||||
Window *w2;
|
Window *w2;
|
||||||
w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
|
w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
|
||||||
WP(w2,menu_d).sel_index = _last_built_railtype;
|
WP(w2, menu_d).sel_index = _last_built_railtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ToolbarBuildRoadClick(Window *w)
|
static void ToolbarBuildRoadClick(Window *w)
|
||||||
{
|
{
|
||||||
PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 1, 0);
|
Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 1, 0);
|
||||||
|
WP(w2, menu_d).sel_index = _last_built_roadtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ToolbarBuildWaterClick(Window *w)
|
static void ToolbarBuildWaterClick(Window *w)
|
||||||
|
@ -1873,7 +1876,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
|
||||||
case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
|
case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
|
||||||
case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
|
case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
|
||||||
case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype, -1); break;
|
case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype, -1); break;
|
||||||
case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(); break;
|
case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
|
||||||
case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
|
case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
|
||||||
case WKC_SHIFT | WKC_F10:ShowBuildAirToolbar(); break;
|
case WKC_SHIFT | WKC_F10:ShowBuildAirToolbar(); break;
|
||||||
case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
|
case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
|
||||||
|
@ -2514,6 +2517,7 @@ void InitializeMainGui()
|
||||||
{
|
{
|
||||||
/* Clean old GUI values */
|
/* Clean old GUI values */
|
||||||
_last_built_railtype = RAILTYPE_RAIL;
|
_last_built_railtype = RAILTYPE_RAIL;
|
||||||
|
_last_built_roadtype = ROADTYPE_ROAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -845,7 +845,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||||
DrawBridgeMiddle(ti);
|
DrawBridgeMiddle(ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawRoadDepotSprite(int x, int y, DiagDirection dir)
|
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
|
||||||
{
|
{
|
||||||
SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
|
SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
|
||||||
const DrawTileSprites* dts = &_road_depot[dir];
|
const DrawTileSprites* dts = &_road_depot[dir];
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
|
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
|
|
||||||
void DrawRoadDepotSprite(int x, int y, DiagDirection dir);
|
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt);
|
||||||
|
|
||||||
#endif /* ROAD_CMD_H */
|
#endif /* ROAD_CMD_H */
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "road_cmd.h"
|
|
||||||
#include "road_map.h"
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
@ -18,6 +16,9 @@
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "road.h"
|
||||||
|
#include "road_cmd.h"
|
||||||
|
#include "road_map.h"
|
||||||
#include "station_map.h"
|
#include "station_map.h"
|
||||||
//needed for catchments
|
//needed for catchments
|
||||||
#include "station.h"
|
#include "station.h"
|
||||||
|
@ -31,6 +32,8 @@ static bool _remove_button_clicked;
|
||||||
|
|
||||||
static byte _place_road_flag;
|
static byte _place_road_flag;
|
||||||
|
|
||||||
|
static RoadType _cur_roadtype;
|
||||||
|
|
||||||
static DiagDirection _road_depot_orientation;
|
static DiagDirection _road_depot_orientation;
|
||||||
static DiagDirection _road_station_picker_orientation;
|
static DiagDirection _road_station_picker_orientation;
|
||||||
|
|
||||||
|
@ -69,7 +72,7 @@ void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
static void PlaceRoad_Tunnel(TileIndex tile)
|
static void PlaceRoad_Tunnel(TileIndex tile)
|
||||||
{
|
{
|
||||||
DoCommandP(tile, 0x200 | ROADTYPES_ROAD, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
|
DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
|
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
|
||||||
|
@ -77,7 +80,9 @@ static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
|
||||||
tile += TileOffsByDiagDir(direction);
|
tile += TileOffsByDiagDir(direction);
|
||||||
// if there is a roadpiece just outside of the station entrance, build a connecting route
|
// if there is a roadpiece just outside of the station entrance, build a connecting route
|
||||||
if (IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
|
if (IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
|
||||||
DoCommandP(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
|
if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
|
||||||
|
DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +100,7 @@ void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
static void PlaceRoad_Depot(TileIndex tile)
|
static void PlaceRoad_Depot(TileIndex tile)
|
||||||
{
|
{
|
||||||
DoCommandP(tile, _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE));
|
DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
|
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
|
||||||
|
@ -298,9 +303,9 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
if (e->we.place.userdata == 0) {
|
if (e->we.place.userdata == 0) {
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | ROADTYPES_ROAD);
|
ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
|
||||||
} else if (e->we.place.userdata != 4) {
|
} else if (e->we.place.userdata != 4) {
|
||||||
DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
|
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D,
|
||||||
_remove_button_clicked ?
|
_remove_button_clicked ?
|
||||||
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
|
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
|
||||||
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
|
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
|
||||||
|
@ -313,7 +318,7 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
|
||||||
case WE_PLACE_PRESIZE: {
|
case WE_PLACE_PRESIZE: {
|
||||||
TileIndex tile = e->we.place.tile;
|
TileIndex tile = e->we.place.tile;
|
||||||
|
|
||||||
DoCommand(tile, 0x200 | ROADTYPES_ROAD, 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
DoCommand(tile, 0x200 | _cur_roadtype, 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||||
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -349,9 +354,10 @@ static const WindowDesc _build_road_desc = {
|
||||||
BuildRoadToolbWndProc
|
BuildRoadToolbWndProc
|
||||||
};
|
};
|
||||||
|
|
||||||
void ShowBuildRoadToolbar()
|
void ShowBuildRoadToolbar(RoadType roadtype)
|
||||||
{
|
{
|
||||||
if (!IsValidPlayer(_current_player)) return;
|
if (!IsValidPlayer(_current_player)) return;
|
||||||
|
_cur_roadtype = roadtype;
|
||||||
|
|
||||||
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
||||||
Window *w = AllocateWindowDesc(&_build_road_desc);
|
Window *w = AllocateWindowDesc(&_build_road_desc);
|
||||||
|
@ -396,10 +402,10 @@ static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
|
||||||
case WE_PAINT:
|
case WE_PAINT:
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
DrawRoadDepotSprite(70, 17, DIAGDIR_NE);
|
DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
|
||||||
DrawRoadDepotSprite(70, 69, DIAGDIR_SE);
|
DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
|
||||||
DrawRoadDepotSprite( 2, 69, DIAGDIR_SW);
|
DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
|
||||||
DrawRoadDepotSprite( 2, 17, DIAGDIR_NW);
|
DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_CLICK: {
|
case WE_CLICK: {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "order.h"
|
#include "order.h"
|
||||||
#include "rail.h"
|
#include "rail.h"
|
||||||
|
#include "road.h"
|
||||||
#include "airport.h"
|
#include "airport.h"
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
|
|
||||||
|
@ -328,6 +329,7 @@ struct buildvehicle_d {
|
||||||
union {
|
union {
|
||||||
RailTypeByte railtype;
|
RailTypeByte railtype;
|
||||||
AirportFTAClass::Flags flags;
|
AirportFTAClass::Flags flags;
|
||||||
|
RoadTypes roadtypes;
|
||||||
} filter;
|
} filter;
|
||||||
byte sel_index; ///< deprecated value, used for 'unified' ship and road
|
byte sel_index; ///< deprecated value, used for 'unified' ship and road
|
||||||
bool descending_sort_order;
|
bool descending_sort_order;
|
||||||
|
|
Loading…
Reference in New Issue