(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.

This commit is contained in:
tron 2005-10-14 08:11:18 +00:00
parent 1667628659
commit f97d1274bc
4 changed files with 62 additions and 15 deletions

11
rail.h
View File

@ -171,6 +171,17 @@ typedef struct RailtypeInfo {
SpriteID convert_rail; ///< button for converting rail SpriteID convert_rail; ///< button for converting rail
} gui_sprites; } gui_sprites;
struct {
CursorID rail_ns;
CursorID rail_swne;
CursorID rail_ew;
CursorID rail_nwse;
CursorID autorail;
CursorID depot;
CursorID tunnel;
CursorID convert;
} cursor;
struct { struct {
StringID toolbar_caption; StringID toolbar_caption;
} strings; } strings;

View File

@ -220,27 +220,27 @@ static void PlaceRail_AutoSignals(TileIndex tile)
static void BuildRailClick_N(Window *w) static void BuildRailClick_N(Window *w)
{ {
HandlePlacePushButton(w, 4, _cur_railtype*4 + SPR_CURSOR_NS_TRACK, 1, PlaceRail_N); HandlePlacePushButton(w, 4, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N);
} }
static void BuildRailClick_NE(Window *w) static void BuildRailClick_NE(Window *w)
{ {
HandlePlacePushButton(w, 5, _cur_railtype*4 + SPR_CURSOR_SWNE_TRACK, 1, PlaceRail_NE); HandlePlacePushButton(w, 5, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE);
} }
static void BuildRailClick_E(Window *w) static void BuildRailClick_E(Window *w)
{ {
HandlePlacePushButton(w, 6, _cur_railtype*4 + SPR_CURSOR_EW_TRACK, 1, PlaceRail_E); HandlePlacePushButton(w, 6, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E);
} }
static void BuildRailClick_NW(Window *w) static void BuildRailClick_NW(Window *w)
{ {
HandlePlacePushButton(w, 7, _cur_railtype*4 + SPR_CURSOR_NWSE_TRACK, 1, PlaceRail_NW); HandlePlacePushButton(w, 7, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW);
} }
static void BuildRailClick_AutoRail(Window *w) static void BuildRailClick_AutoRail(Window *w)
{ {
HandlePlacePushButton(w, 8, SPR_CURSOR_AUTORAIL + _cur_railtype, VHM_RAIL, PlaceRail_AutoRail); HandlePlacePushButton(w, 8, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail);
} }
static void BuildRailClick_Demolish(Window *w) static void BuildRailClick_Demolish(Window *w)
@ -248,15 +248,11 @@ static void BuildRailClick_Demolish(Window *w)
HandlePlacePushButton(w, 9, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); HandlePlacePushButton(w, 9, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
} }
static const CursorID _depot_cursors[] = {
SPR_CURSOR_RAIL_DEPOT,
SPR_CURSOR_MONO_DEPOT,
SPR_CURSOR_MAGLEV_DEPOT,
};
static void BuildRailClick_Depot(Window *w) static void BuildRailClick_Depot(Window *w)
{ {
if (HandlePlacePushButton(w, 10, _depot_cursors[_cur_railtype], 1, PlaceRail_Depot)) ShowBuildTrainDepotPicker(); if (HandlePlacePushButton(w, 10, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) {
ShowBuildTrainDepotPicker();
}
} }
static void BuildRailClick_Waypoint(Window *w) static void BuildRailClick_Waypoint(Window *w)
@ -284,7 +280,7 @@ static void BuildRailClick_Bridge(Window *w)
static void BuildRailClick_Tunnel(Window *w) static void BuildRailClick_Tunnel(Window *w)
{ {
HandlePlacePushButton(w, 15, SPR_CURSOR_TUNNEL_RAIL + _cur_railtype, 3, PlaceRail_Tunnel); HandlePlacePushButton(w, 15, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel);
} }
static void BuildRailClick_Remove(Window *w) static void BuildRailClick_Remove(Window *w)
@ -310,7 +306,7 @@ static void BuildRailClick_Remove(Window *w)
static void BuildRailClick_Convert(Window *w) static void BuildRailClick_Convert(Window *w)
{ {
HandlePlacePushButton(w, 17, SPR_CURSOR_CONVERT_RAIL + _cur_railtype * 2, 1, PlaceRail_ConvertRail); HandlePlacePushButton(w, 17, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail);
} }
static void BuildRailClick_Landscaping(Window *w) static void BuildRailClick_Landscaping(Window *w)

View File

@ -6,7 +6,7 @@
/** Global Railtype definition /** Global Railtype definition
*/ */
const RailtypeInfo _railtypes[RAILTYPE_END] = { const RailtypeInfo _railtypes[] = {
/** Railway */ /** Railway */
{ /* Main Sprites */ { /* Main Sprites */
{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X, { SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
@ -19,6 +19,17 @@ const RailtypeInfo _railtypes[RAILTYPE_END] = {
{ 0x4E3, 0x4E4, 0x4E5, 0x4E6, { 0x4E3, 0x4E4, 0x4E5, 0x4E6,
SPR_OPENTTD_BASE + 0, 0x50E, 0x97E, SPR_OPENTTD_BASE + 25 }, SPR_OPENTTD_BASE + 0, 0x50E, 0x97E, SPR_OPENTTD_BASE + 25 },
{
SPR_CURSOR_NS_TRACK,
SPR_CURSOR_SWNE_TRACK,
SPR_CURSOR_EW_TRACK,
SPR_CURSOR_NWSE_TRACK,
SPR_CURSOR_AUTORAIL,
SPR_CURSOR_RAIL_DEPOT,
SPR_CURSOR_TUNNEL_RAIL,
SPR_CURSOR_CONVERT_RAIL
},
/* strings */ /* strings */
{ STR_100A_RAILROAD_CONSTRUCTION }, { STR_100A_RAILROAD_CONSTRUCTION },
@ -44,6 +55,17 @@ const RailtypeInfo _railtypes[RAILTYPE_END] = {
{ 0x4E7, 0x4E8, 0x4E9, 0x4EA, { 0x4E7, 0x4E8, 0x4E9, 0x4EA,
SPR_OPENTTD_BASE + 1, SPR_OPENTTD_BASE + 12, 0x97F, SPR_OPENTTD_BASE + 27 }, SPR_OPENTTD_BASE + 1, SPR_OPENTTD_BASE + 12, 0x97F, SPR_OPENTTD_BASE + 27 },
{
SPR_CURSOR_NS_MONO,
SPR_CURSOR_SWNE_MONO,
SPR_CURSOR_EW_MONO,
SPR_CURSOR_NWSE_MONO,
SPR_CURSOR_AUTOMONO,
SPR_CURSOR_MONO_DEPOT,
SPR_CURSOR_TUNNEL_MONO,
SPR_CURSOR_CONVERT_MONO
},
/* strings */ /* strings */
{ STR_100B_MONORAIL_CONSTRUCTION }, { STR_100B_MONORAIL_CONSTRUCTION },
@ -69,6 +91,17 @@ const RailtypeInfo _railtypes[RAILTYPE_END] = {
{ 0x4EB, 0x4EC, 0x4EE, 0x4ED, { 0x4EB, 0x4EC, 0x4EE, 0x4ED,
SPR_OPENTTD_BASE + 2, SPR_OPENTTD_BASE + 13, 0x980, SPR_OPENTTD_BASE + 29 }, SPR_OPENTTD_BASE + 2, SPR_OPENTTD_BASE + 13, 0x980, SPR_OPENTTD_BASE + 29 },
{
SPR_CURSOR_NS_MAGLEV,
SPR_CURSOR_SWNE_MAGLEV,
SPR_CURSOR_EW_MAGLEV,
SPR_CURSOR_NWSE_MAGLEV,
SPR_CURSOR_AUTOMAGLEV,
SPR_CURSOR_MAGLEV_DEPOT,
SPR_CURSOR_TUNNEL_MAGLEV,
SPR_CURSOR_CONVERT_MAGLEV
},
/* strings */ /* strings */
{ STR_100C_MAGLEV_CONSTRUCTION }, { STR_100C_MAGLEV_CONSTRUCTION },

View File

@ -936,15 +936,22 @@ typedef enum CursorSprites {
SPR_CURSOR_RAIL_DEPOT = 1296, SPR_CURSOR_RAIL_DEPOT = 1296,
SPR_CURSOR_RAIL_STATION = 1300, SPR_CURSOR_RAIL_STATION = 1300,
SPR_CURSOR_TUNNEL_RAIL = 2434, SPR_CURSOR_TUNNEL_RAIL = 2434,
SPR_CURSOR_TUNNEL_MONO = 2435, SPR_CURSOR_TUNNEL_MONO = 2435,
SPR_CURSOR_TUNNEL_MAGLEV = 2436, SPR_CURSOR_TUNNEL_MAGLEV = 2436,
SPR_CURSOR_AUTORAIL = SPR_OPENTTD_BASE + 4, SPR_CURSOR_AUTORAIL = SPR_OPENTTD_BASE + 4,
SPR_CURSOR_AUTOMONO = SPR_OPENTTD_BASE + 5,
SPR_CURSOR_AUTOMAGLEV = SPR_OPENTTD_BASE + 6,
SPR_CURSOR_WAYPOINT = SPR_OPENTTD_BASE + 7, SPR_CURSOR_WAYPOINT = SPR_OPENTTD_BASE + 7,
SPR_CURSOR_MONO_DEPOT = SPR_OPENTTD_BASE + 14, SPR_CURSOR_MONO_DEPOT = SPR_OPENTTD_BASE + 14,
SPR_CURSOR_MAGLEV_DEPOT = SPR_OPENTTD_BASE + 15, SPR_CURSOR_MAGLEV_DEPOT = SPR_OPENTTD_BASE + 15,
SPR_CURSOR_CONVERT_RAIL = SPR_OPENTTD_BASE + 26, SPR_CURSOR_CONVERT_RAIL = SPR_OPENTTD_BASE + 26,
SPR_CURSOR_CONVERT_MONO = SPR_OPENTTD_BASE + 28,
SPR_CURSOR_CONVERT_MAGLEV = SPR_OPENTTD_BASE + 30,
/* road cursors */ /* road cursors */
SPR_CURSOR_ROAD_NESW = 1311, SPR_CURSOR_ROAD_NESW = 1311,