Preview station layout exactly as it's going to be built
This commit is contained in:
@@ -120,7 +120,7 @@ std::multimap<TileIndex, ObjectTileHighlight> Blueprint::GetTiles(TileIndex tile
|
|||||||
add_tile(otile, ObjectTileHighlight::make_rail_depot(o.u.rail.depot.ddir));
|
add_tile(otile, ObjectTileHighlight::make_rail_depot(o.u.rail.depot.ddir));
|
||||||
break;
|
break;
|
||||||
case Item::Type::RAIL_STATION_PART:
|
case Item::Type::RAIL_STATION_PART:
|
||||||
add_tile(otile, ObjectTileHighlight::make_rail_station(o.u.rail.station_part.axis));
|
add_tile(otile, ObjectTileHighlight::make_rail_station(o.u.rail.station_part.axis, 0));
|
||||||
break;
|
break;
|
||||||
case Item::Type::RAIL_SIGNAL:
|
case Item::Type::RAIL_SIGNAL:
|
||||||
add_tile(otile, ObjectTileHighlight::make_rail_signal(o.u.rail.signal.pos, o.u.rail.signal.type, o.u.rail.signal.variant));
|
add_tile(otile, ObjectTileHighlight::make_rail_signal(o.u.rail.signal.pos, o.u.rail.signal.type, o.u.rail.signal.variant));
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ extern RailType _cur_railtype;
|
|||||||
RoadBits FindRailsToConnect(TileIndex tile);
|
RoadBits FindRailsToConnect(TileIndex tile);
|
||||||
extern DiagDirection _build_depot_direction; ///< Currently selected depot direction
|
extern DiagDirection _build_depot_direction; ///< Currently selected depot direction
|
||||||
extern uint32 _realtime_tick;
|
extern uint32 _realtime_tick;
|
||||||
|
extern void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec);
|
||||||
|
|
||||||
struct RailStationGUISettings {
|
struct RailStationGUISettings {
|
||||||
Axis orientation; ///< Currently selected rail station orientation
|
Axis orientation; ///< Currently selected rail station orientation
|
||||||
@@ -98,9 +99,10 @@ ObjectTileHighlight ObjectTileHighlight::make_rail_track(Track track) {
|
|||||||
return oh;
|
return oh;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectTileHighlight ObjectTileHighlight::make_rail_station(Axis axis) {
|
ObjectTileHighlight ObjectTileHighlight::make_rail_station(Axis axis, byte section) {
|
||||||
auto oh = ObjectTileHighlight(Type::RAIL_STATION);
|
auto oh = ObjectTileHighlight(Type::RAIL_STATION);
|
||||||
oh.u.rail.station.axis = axis;
|
oh.u.rail.station.axis = axis;
|
||||||
|
oh.u.rail.station.section = section;
|
||||||
return oh;
|
return oh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +200,9 @@ static const DiagDirection _place_depot_extra_dir[12] = {
|
|||||||
void ObjectHighlight::UpdateTiles() {
|
void ObjectHighlight::UpdateTiles() {
|
||||||
this->tiles.clear();
|
this->tiles.clear();
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
|
case Type::NONE:
|
||||||
|
break;
|
||||||
|
|
||||||
case Type::RAIL_DEPOT: {
|
case Type::RAIL_DEPOT: {
|
||||||
auto dir = this->ddir;
|
auto dir = this->ddir;
|
||||||
this->tiles.insert(std::make_pair(this->tile, ObjectTileHighlight::make_rail_depot(dir)));
|
this->tiles.insert(std::make_pair(this->tile, ObjectTileHighlight::make_rail_depot(dir)));
|
||||||
@@ -211,9 +216,26 @@ void ObjectHighlight::UpdateTiles() {
|
|||||||
}
|
}
|
||||||
case Type::RAIL_STATION: {
|
case Type::RAIL_STATION: {
|
||||||
auto ta = OrthogonalTileArea(this->tile, this->end_tile);
|
auto ta = OrthogonalTileArea(this->tile, this->end_tile);
|
||||||
TILE_AREA_LOOP(tile, ta) {
|
auto numtracks = ta.w;
|
||||||
this->tiles.insert({tile, ObjectTileHighlight::make_rail_station(this->axis)});
|
auto plat_len = ta.h;
|
||||||
}
|
if (this->axis == AXIS_X) Swap(numtracks, plat_len);
|
||||||
|
|
||||||
|
auto layout_ptr = AllocaM(byte, numtracks * plat_len);
|
||||||
|
GetStationLayout(layout_ptr, numtracks, plat_len, nullptr); // TODO statspec
|
||||||
|
|
||||||
|
auto tile_delta = (this->axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
|
TileIndex tile_track = this->tile;
|
||||||
|
do {
|
||||||
|
TileIndex tile = tile_track;
|
||||||
|
int w = plat_len;
|
||||||
|
do {
|
||||||
|
byte layout = *layout_ptr++;
|
||||||
|
this->tiles.insert({tile, ObjectTileHighlight::make_rail_station(this->axis, layout & ~1)});
|
||||||
|
tile += tile_delta;
|
||||||
|
} while (--w);
|
||||||
|
tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
|
||||||
|
} while (--numtracks);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::BLUEPRINT:
|
case Type::BLUEPRINT:
|
||||||
@@ -221,7 +243,7 @@ void ObjectHighlight::UpdateTiles() {
|
|||||||
this->tiles = this->blueprint->GetTiles(this->tile);
|
this->tiles = this->blueprint->GetTiles(this->tile);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,10 +287,10 @@ void DrawTrainDepotSprite(const TileInfo *ti, RailType railtype, DiagDirection d
|
|||||||
DrawRailTileSeq(ti, dts, TO_INVALID, offset, 0, PALETTE_TINT_WHITE);
|
DrawRailTileSeq(ti, dts, TO_INVALID, offset, 0, PALETTE_TINT_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTrainStationSprite(const TileInfo *ti, RailType railtype, Axis axis) {
|
void DrawTrainStationSprite(const TileInfo *ti, RailType railtype, Axis axis, byte section) {
|
||||||
int32 total_offset = 0;
|
int32 total_offset = 0;
|
||||||
PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company);
|
PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company);
|
||||||
const DrawTileSprites *t = GetStationTileLayout(STATION_RAIL, (axis == AXIS_X ? 0 : 1));
|
const DrawTileSprites *t = GetStationTileLayout(STATION_RAIL, section + (axis == AXIS_X ? 0 : 1));
|
||||||
const RailtypeInfo *rti = nullptr;
|
const RailtypeInfo *rti = nullptr;
|
||||||
|
|
||||||
if (railtype != INVALID_RAILTYPE) {
|
if (railtype != INVALID_RAILTYPE) {
|
||||||
@@ -451,7 +473,7 @@ void ObjectHighlight::Draw(const TileInfo *ti) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ObjectTileHighlight::Type::RAIL_STATION:
|
case ObjectTileHighlight::Type::RAIL_STATION:
|
||||||
DrawTrainStationSprite(ti, _cur_railtype, oth.u.rail.station.axis);
|
DrawTrainStationSprite(ti, _cur_railtype, oth.u.rail.station.axis, oth.u.rail.station.section);
|
||||||
break;
|
break;
|
||||||
case ObjectTileHighlight::Type::RAIL_SIGNAL:
|
case ObjectTileHighlight::Type::RAIL_SIGNAL:
|
||||||
DrawSignal(ti, _cur_railtype, oth.u.rail.signal.pos, oth.u.rail.signal.type, oth.u.rail.signal.variant);
|
DrawSignal(ti, _cur_railtype, oth.u.rail.signal.pos, oth.u.rail.signal.type, oth.u.rail.signal.variant);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
Track track;
|
Track track;
|
||||||
struct {
|
struct {
|
||||||
Axis axis;
|
Axis axis;
|
||||||
|
byte section;
|
||||||
} station;
|
} station;
|
||||||
struct {
|
struct {
|
||||||
uint pos;
|
uint pos;
|
||||||
@@ -59,7 +60,7 @@ public:
|
|||||||
ObjectTileHighlight(Type type): type{type} {}
|
ObjectTileHighlight(Type type): type{type} {}
|
||||||
static ObjectTileHighlight make_rail_depot(DiagDirection ddir);
|
static ObjectTileHighlight make_rail_depot(DiagDirection ddir);
|
||||||
static ObjectTileHighlight make_rail_track(Track track);
|
static ObjectTileHighlight make_rail_track(Track track);
|
||||||
static ObjectTileHighlight make_rail_station(Axis axis);
|
static ObjectTileHighlight make_rail_station(Axis axis, byte section);
|
||||||
static ObjectTileHighlight make_rail_signal(uint pos, SignalType type, SignalVariant variant);
|
static ObjectTileHighlight make_rail_signal(uint pos, SignalType type, SignalVariant variant);
|
||||||
static ObjectTileHighlight make_rail_bridge_head(DiagDirection ddir, BridgeType type);
|
static ObjectTileHighlight make_rail_bridge_head(DiagDirection ddir, BridgeType type);
|
||||||
static ObjectTileHighlight make_rail_tunnel_head(DiagDirection ddir);
|
static ObjectTileHighlight make_rail_tunnel_head(DiagDirection ddir);
|
||||||
|
|||||||
Reference in New Issue
Block a user