载入中...
搜索中...
未找到
GameplayTagPicker.cpp
浏览该文件的文档.
2
3#include <algorithm>
4
5namespace eve::editor {
6
8 if (!root.empty() && !tags::isValidGameplayTagName(root))
10 Diagnostic::error(DiagnosticCode::InvalidArgument, "Invalid gameplay-tag picker root", "root"));
11 root_ = std::move(root);
13}
14
16 if (!registry_.contains(name))
18 Diagnostic::error(DiagnosticCode::NotFound, "Cannot select an unregistered gameplay tag", name));
19 selected_ = std::move(name);
21}
22
23std::vector<GameplayTagPickerEntry> GameplayTagPicker::entries() const {
24 const auto definitions = registry_.search(filter_, root_);
25 std::vector<GameplayTagPickerEntry> result;
26 result.reserve(definitions.size());
27 for (const auto& definition : definitions) {
28 const std::size_t depth =
29 static_cast<std::size_t>(std::count(definition.name.begin(), definition.name.end(), '.'));
30 const bool hasChildren = std::any_of(definitions.begin(), definitions.end(), [&](const auto& candidate) {
31 return candidate.name != definition.name &&
32 tags::gameplayTagMatches(candidate.name, definition.name,
33 tags::GameplayTagMatch::IncludeDescendants);
34 });
35 result.push_back({definition.id, definition.name, definition.description, depth, hasChildren});
36 }
37 return result;
38}
39
40} // namespace eve::editor
int root
Definition AnimSmr.cpp:119
UI-neutral gameplay-tag picker projection.
std::string name
std::uint32_t depth
const std::map< std::string, Value > & definitions
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Result< void > select(std::string name)
Select an exact registered definition.
Result< void > setRoot(std::string root)
Restrict results to a tag root and its descendants; empty clears the root.
std::vector< GameplayTagPickerEntry > entries() const
Build deterministic owning entries for the current root and filter.
std::vector< GameplayTagDefinition > search(std::string_view text, std::string_view root={}) const
Return definitions matching a root and case-insensitive text filter.
bool contains(std::string_view name) const
Return whether an exact definition exists.
bool isValidGameplayTagName(std::string_view name) noexcept
Returns whether a name is a canonical dot-separated gameplay tag.