mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
Add road stop flags to only show in the road or tram build menus
This commit is contained in:
parent
6f963a1268
commit
8020f6d481
@ -84,6 +84,10 @@
|
||||
<span class="indent">Only allow drive-through stops (not bay stops). (This only takes effect from <span class="code">road_stops</span> version 2).</span></p>
|
||||
<p><b>RST_GENERAL_FLAG_NO_AUTO_ROAD_CONNECTION</b><br />
|
||||
<span class="indent">Do not automatically build connecting road pieces. (This only takes effect from <span class="code">road_stops</span> version 3).</span></p>
|
||||
<p><b>RST_GENERAL_FLAG_BUILD_MENU_ROAD_ONLY</b><br />
|
||||
<span class="indent">Only show in the road build menu (not tram). (This only takes effect from <span class="code">road_stops</span> version 4).</span></p>
|
||||
<p><b>RST_GENERAL_FLAG_BUILD_MENU_TRAM_ONLY</b><br />
|
||||
<span class="indent">Only show in the tram build menu (not road). (This only takes effect from <span class="code">road_stops</span> version 4).</span></p>
|
||||
</td></tr>
|
||||
<tr><td>minimum_bridge_height</td><td>Array of 6 items [0..255, ...]</td><td>Minimum clearances required for a bridge for each of the <a href="#roadstop_views">6 views/rotations</a> (or 0 to not allow any bridge). Values are given in height level units (1 level == 8px).</td></tr>
|
||||
<tr><td>disallowed_bridge_pillars</td><td>Array of 6 items [bitmask(RST_BRIDGE_PILLAR_FLAG_, ...), ...]</td><td>
|
||||
|
@ -153,6 +153,8 @@
|
||||
<tr><td>2</td><td>4</td><td>Do not show catenary graphics.</br>This requires <font face="monospace">road_stops</font>, version 2.</td></tr>
|
||||
<tr><td>3</td><td>8</td><td>Only allow drive-through stops (not bay stops).</br>This requires <font face="monospace">road_stops</font>, version 2.</td></tr>
|
||||
<tr><td>4</td><td>10</td><td>Do not automatically build connecting road pieces.</br>This requires <font face="monospace">road_stops</font>, version 3.</td></tr>
|
||||
<tr><td>5</td><td>20</td><td>Only show in the road build menu (not tram).</br>This requires <font face="monospace">road_stops</font>, version 4.</td></tr>
|
||||
<tr><td>6</td><td>40</td><td>Only show in the tram build menu (not road).</br>This requires <font face="monospace">road_stops</font>, version 4.</td></tr>
|
||||
</table>
|
||||
The default value is 0 (no flags enabled).
|
||||
</p>
|
||||
|
@ -54,7 +54,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
|
||||
GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
|
||||
GRFFeatureInfo("action0_object_flood_resistant", 1),
|
||||
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
|
||||
GRFFeatureInfo("road_stops", 3),
|
||||
GRFFeatureInfo("road_stops", 4),
|
||||
GRFFeatureInfo("new_landscape", 1),
|
||||
GRFFeatureInfo(),
|
||||
};
|
||||
|
@ -477,17 +477,18 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri
|
||||
|
||||
/**
|
||||
* Checks if there's any new stations by a specific RoadStopType
|
||||
* @param rs the RoadStopType to check for.
|
||||
* @return true if there was any new RoadStopSpec's found for the given RoadStopType, else false.
|
||||
* @param rs the RoadStopType to check.
|
||||
* @param roadtype the RoadType to check.
|
||||
* @return true if there was any new RoadStopSpec's found for the given RoadStopType and RoadType, else false.
|
||||
*/
|
||||
bool GetIfNewStopsByType(RoadStopType rs)
|
||||
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype)
|
||||
{
|
||||
if (!(RoadStopClass::GetClassCount() > 1 || RoadStopClass::Get(ROADSTOP_CLASS_DFLT)->GetSpecCount() > 1)) return false;
|
||||
for (uint i = 0; i < RoadStopClass::GetClassCount(); i++) {
|
||||
// We don't want to check the default or waypoint classes. These classes are always available.
|
||||
if (i == ROADSTOP_CLASS_DFLT || i == ROADSTOP_CLASS_WAYP) continue;
|
||||
RoadStopClass *roadstopclass = RoadStopClass::Get((RoadStopClassID)i);
|
||||
if (GetIfClassHasNewStopsByType(roadstopclass, rs)) return true;
|
||||
if (GetIfClassHasNewStopsByType(roadstopclass, rs, roadtype)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -495,13 +496,14 @@ bool GetIfNewStopsByType(RoadStopType rs)
|
||||
/**
|
||||
* Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopType.
|
||||
* @param roadstopclass the RoadStopClass to check.
|
||||
* @param rs the RoadStopType to check by.
|
||||
* @return true if the roadstopclass has any specs compatible with the given RoadStopType.
|
||||
* @param rs the RoadStopType to check.
|
||||
* @param roadtype the RoadType to check.
|
||||
* @return true if the RoadStopSpec has any specs compatible with the given RoadStopType and RoadType.
|
||||
*/
|
||||
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs)
|
||||
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype)
|
||||
{
|
||||
for (uint j = 0; j < roadstopclass->GetSpecCount(); j++) {
|
||||
if (GetIfStopIsForType(roadstopclass->GetSpec(j), rs)) return true;
|
||||
if (GetIfStopIsForType(roadstopclass->GetSpec(j), rs, roadtype)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -509,13 +511,18 @@ bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs)
|
||||
/**
|
||||
* Checks if the given RoadStopSpec is compatible with the given RoadStopType.
|
||||
* @param roadstopspec the RoadStopSpec to check.
|
||||
* @param rs the RoadStopType to check by.
|
||||
* @return true if the roadstopspec is compatible with the given RoadStopType.
|
||||
* @param rs the RoadStopType to check.
|
||||
* @param roadtype the RoadType to check.
|
||||
* @return true if the RoadStopSpec is compatible with the given RoadStopType and RoadType.
|
||||
*/
|
||||
bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs)
|
||||
bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype)
|
||||
{
|
||||
// The roadstopspec is nullptr, must be the default station, always return true.
|
||||
if (roadstopspec == nullptr) return true;
|
||||
|
||||
if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(roadtype)) return false;
|
||||
if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(roadtype)) return false;
|
||||
|
||||
if (roadstopspec->stop_type == ROADSTOPTYPE_ALL) return true;
|
||||
|
||||
switch (rs) {
|
||||
|
@ -69,6 +69,8 @@ enum RoadStopSpecFlags {
|
||||
RSF_NO_CATENARY, ///< Do not show catenary.
|
||||
RSF_DRIVE_THROUGH_ONLY, ///< Stop is drive-through only.
|
||||
RSF_NO_AUTO_ROAD_CONNECTION, ///< No auto road connection.
|
||||
RSF_BUILD_MENU_ROAD_ONLY, ///< Only show in the road build menu (not tram).
|
||||
RSF_BUILD_MENU_TRAM_ONLY, ///< Only show in the tram build menu (not road).
|
||||
};
|
||||
|
||||
enum RoadStopSpecIntlFlags {
|
||||
@ -181,9 +183,9 @@ uint8 GetRoadStopTileAnimationSpeed(TileIndex tile);
|
||||
void TriggerRoadStopAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
|
||||
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type = CT_INVALID);
|
||||
|
||||
bool GetIfNewStopsByType(RoadStopType rs);
|
||||
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs);
|
||||
bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs);
|
||||
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype);
|
||||
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype);
|
||||
bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype);
|
||||
|
||||
uint GetCountOfCompatibleStopsByType(RoadStopClass *roadstopclass, RoadStopType rs);
|
||||
|
||||
|
@ -95,7 +95,12 @@ static RoadType _cur_roadtype;
|
||||
*/
|
||||
static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType type)
|
||||
{
|
||||
if (roadstopspec == nullptr || !HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true;
|
||||
if (roadstopspec == nullptr) return true;
|
||||
|
||||
if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) return false;
|
||||
if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)) return false;
|
||||
|
||||
if (!HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true;
|
||||
|
||||
uint16 cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, _cur_roadtype, type, 0);
|
||||
if (cb_res == CALLBACK_FAILED) return true;
|
||||
@ -788,7 +793,7 @@ struct BuildRoadToolbarWindow : Window {
|
||||
|
||||
case DDSP_BUILD_BUSSTOP:
|
||||
case DDSP_REMOVE_BUSSTOP:
|
||||
if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_BUS)) {
|
||||
if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_BUS, _cur_roadtype)) {
|
||||
if (_remove_button_clicked) {
|
||||
TileArea ta(start_tile, end_tile);
|
||||
DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_CONSTRUCTION_OTHER);
|
||||
@ -800,7 +805,7 @@ struct BuildRoadToolbarWindow : Window {
|
||||
|
||||
case DDSP_BUILD_TRUCKSTOP:
|
||||
case DDSP_REMOVE_TRUCKSTOP:
|
||||
if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_TRUCK)) {
|
||||
if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_TRUCK, _cur_roadtype)) {
|
||||
if (_remove_button_clicked) {
|
||||
TileArea ta(start_tile, end_tile);
|
||||
DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_CONSTRUCTION_OTHER);
|
||||
@ -1245,7 +1250,7 @@ public:
|
||||
this->vscrollList = nullptr;
|
||||
this->vscrollMatrix = nullptr;
|
||||
this->roadStopType = rs;
|
||||
bool newstops = GetIfNewStopsByType(rs);
|
||||
bool newstops = GetIfNewStopsByType(rs, _cur_roadtype);
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
||||
@ -1302,7 +1307,7 @@ public:
|
||||
}
|
||||
if (newstops) {
|
||||
/* The currently selected class doesn't have any stops for this RoadStopType, reset the selection. */
|
||||
if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), rs)) {
|
||||
if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), rs, _cur_roadtype)) {
|
||||
_roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
|
||||
_roadstop_gui_settings.roadstop_type = 0;
|
||||
}
|
||||
@ -1310,7 +1315,7 @@ public:
|
||||
_roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, _roadstop_gui_settings.roadstop_count - 1);
|
||||
|
||||
/* Reset back to default class if the previously selected class is not available for this road stop type. */
|
||||
if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), roadStopType)) {
|
||||
if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), roadStopType, _cur_roadtype)) {
|
||||
_roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
|
||||
}
|
||||
|
||||
@ -1364,7 +1369,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
RoadStopClass *rs_class = RoadStopClass::Get(rs_id);
|
||||
if (GetIfClassHasNewStopsByType(rs_class, this->roadStopType)) this->roadstop_classes.push_back(rs_id);
|
||||
if (GetIfClassHasNewStopsByType(rs_class, this->roadStopType, _cur_roadtype)) this->roadstop_classes.push_back(rs_id);
|
||||
}
|
||||
|
||||
if (this->ShowNewStops()) {
|
||||
@ -1614,7 +1619,7 @@ public:
|
||||
int y = this->vscrollList->GetScrolledRowFromWidget(pt.y, this, WID_BROS_NEWST_LIST);
|
||||
if (y >= (int)this->roadstop_classes.size()) return;
|
||||
RoadStopClassID class_id = this->roadstop_classes[y];
|
||||
if (_roadstop_gui_settings.roadstop_class != class_id && GetIfClassHasNewStopsByType(RoadStopClass::Get(class_id), roadStopType)) {
|
||||
if (_roadstop_gui_settings.roadstop_class != class_id && GetIfClassHasNewStopsByType(RoadStopClass::Get(class_id), roadStopType, _cur_roadtype)) {
|
||||
_roadstop_gui_settings.roadstop_class = class_id;
|
||||
RoadStopClass *rsclass = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
|
||||
_roadstop_gui_settings.roadstop_count = rsclass->GetSpecCount();
|
||||
|
Loading…
Reference in New Issue
Block a user