1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 01:12:39 +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:
Peter Nelson
2024-05-07 12:13:49 +01:00
committed by Peter Nelson
parent b76517816e
commit fde3b35a24
7 changed files with 130 additions and 4 deletions

View File

@@ -9,11 +9,13 @@
#include "stdafx.h"
#include "command_func.h"
#include "company_func.h"
#include "hotkeys.h"
#include "newgrf.h"
#include "newgrf_object.h"
#include "newgrf_text.h"
#include "object.h"
#include "object_base.h"
#include "picker_gui.h"
#include "sound_func.h"
#include "strings_func.h"
@@ -91,6 +93,16 @@ public:
}
}
void FillUsedItems(std::set<PickerItem> &items) override
{
for (const Object *o : Object::Iterate()) {
if (GetTileOwner(o->location.tile) != _current_company) continue;
const ObjectSpec *spec = ObjectSpec::Get(o->type);
if (spec == nullptr || spec->class_index == INVALID_OBJECT_CLASS || !spec->IsEverAvailable()) continue;
items.insert(GetPickerItem(spec));
}
}
static ObjectPickerCallbacks instance;
};
/* static */ ObjectPickerCallbacks ObjectPickerCallbacks::instance;