mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-26 13:44:16 +01:00
Feature: New filter to show only used types in build-pickers.
This filters the build-picker type lists to only show types that have already been placed in the current game, making it simpler to get to build matching features.
This commit is contained in:
committed by
Peter Nelson
parent
b76517816e
commit
fde3b35a24
@@ -30,6 +30,7 @@
|
||||
#include "dropdown_type.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "engine_base.h"
|
||||
#include "station_base.h"
|
||||
#include "strings_func.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "station_cmd.h"
|
||||
@@ -1160,6 +1161,22 @@ public:
|
||||
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, (uint8_t)orientation);
|
||||
}
|
||||
}
|
||||
|
||||
void FillUsedItems(std::set<PickerItem> &items) override
|
||||
{
|
||||
for (const Station *st : Station::Iterate()) {
|
||||
if (st->owner != _local_company) continue;
|
||||
if (roadstoptype == ROADSTOP_TRUCK && !(st->facilities & FACIL_TRUCK_STOP)) continue;
|
||||
if (roadstoptype == ROADSTOP_BUS && !(st->facilities & FACIL_BUS_STOP)) continue;
|
||||
items.insert({0, 0, ROADSTOP_CLASS_DFLT, 0}); // We would need to scan the map to find out if default is used.
|
||||
for (const auto &sm : st->roadstop_speclist) {
|
||||
if (sm.spec == nullptr) continue;
|
||||
if (roadstoptype == ROADSTOP_TRUCK && sm.spec->stop_type != ROADSTOPTYPE_FREIGHT && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
||||
if (roadstoptype == ROADSTOP_BUS && sm.spec->stop_type != ROADSTOPTYPE_PASSENGER && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
||||
items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_BUS_CLASS_TOOLTIP; }
|
||||
|
||||
Reference in New Issue
Block a user