13#include "../system/system_utils.h"
26 for (
size_t i = 0;
i <
out.size(); ++
i)
27 out[
i] =
static_cast<char>(std::tolower(
static_cast<unsigned char>(
out[
i])));
60 auto add = [
this](
const std::string& type,
61 const std::string& name,
62 const std::string& category,
63 const std::string&
desc)
68 r.category = category;
70 r.relevanceScore = 0.0f;
75 add(
"EntryPoint",
"Entry Point",
"ControlFlow",
"Graph execution start node.");
76 add(
"Sequence",
"Sequence",
"ControlFlow",
"Executes children left-to-right.");
77 add(
"Selector",
"Selector",
"ControlFlow",
"Executes children until one succeeds.");
78 add(
"Branch",
"Branch",
"ControlFlow",
"Conditional fork (true/false).");
79 add(
"Repeat",
"Repeat",
"ControlFlow",
"Loops a subgraph N times.");
80 add(
"Wait",
"Wait",
"ControlFlow",
"Pauses execution for a duration.");
81 add(
"SubGraph",
"Sub Graph",
"ControlFlow",
"Delegates execution to an external graph.");
84 add(
"MoveToLocation",
"Move To Location",
"Actions",
"Moves an entity to a target position.");
85 add(
"Attack",
"Attack",
"Actions",
"Triggers an attack on a target.");
86 add(
"Flee",
"Flee",
"Actions",
"Makes the entity flee from a threat.");
87 add(
"Patrol",
"Patrol",
"Actions",
"Cycles through patrol waypoints.");
88 add(
"SetVariable",
"Set Variable",
"Actions",
"Writes a value to the blackboard.");
89 add(
"LogMessage",
"Log Message",
"Actions",
"Emits a debug message.");
92 add(
"Variable",
"Variable",
"Data",
"Data pure node - reads a blackboard variable.");
93 add(
"MathOp",
"Math Operation",
"Data",
"Data pure node - computes arithmetic operation.");
94 add(
"GetBBValue",
"Get BB Value",
"Data",
"Reads a value from the blackboard.");
95 add(
"SetBBValue",
"Set BB Value",
"Data",
"Writes a value to the blackboard.");
97 SYSTEM_LOG <<
"[NodeSearchPanel] Catalogue initialised with "
98 <<
static_cast<int>(
m_Catalogue.size()) <<
" entries." << std::endl;
139 const std::string
q = ToLowerNSP(
query);
150 if (
c.size() >=
q.size() &&
c.substr(0,
q.size()) ==
q)
154 if (
c.find(
q) != std::string::npos)
160 for (
size_t ci = 0;
ci <
c.size() &&
qi <
q.size(); ++
ci)
169 float score = 0.4f -
static_cast<float>(
gaps) * 0.01f;
170 return (score > 0.01f) ? score : 0.01f;
203 if (a.relevanceScore != b.relevanceScore)
204 return a.relevanceScore > b.relevanceScore;
205 return a.name < b.name;
226 const std::string& type =
m_Results[
static_cast<size_t>(
index)].nodeType;
259 std::function<
void(
const std::string&,
float,
float)>
callback)
ComponentTypeID GetComponentTypeID_Static()
Quick node-add search panel with fuzzy matching (Phase 9).
Singleton fuzzy-search panel for adding nodes to the graph.
int GetSelectedIndex() const
Returns the index of the currently highlighted result (-1 = none).
void SelectNext()
Moves the selection down by one step (wraps around).
void UpdateQuery(const std::string &query)
Recomputes the result list for the given query string.
bool IsOpen() const
Returns true if the panel is currently visible.
void SelectPrevious()
Moves the selection up by one step (wraps around).
std::vector< NodeSearchResult > m_Results
Current filtered/sorted results.
float GetSpawnX() const
Returns the X coordinate where the new node should be spawned.
std::function< void(const std::string &, float, float)> m_OnNodeAdd
void ConfirmSelection(int index)
Fires the OnNodeAdd callback for the result at index and closes the panel.
const std::vector< NodeSearchResult > & GetResults() const
Returns the current result list sorted by relevance (best first).
void OpenSearch(float posX, float posY)
Opens the search panel at the given graph-space position.
std::vector< NodeSearchResult > m_Catalogue
Full unfiltered catalogue.
void CloseSearch()
Closes the search panel and clears the query.
float GetSpawnY() const
Returns the Y coordinate where the new node should be spawned.
static float ComputeScore(const std::string &query, const std::string &candidate)
Compute a [0..1] relevance score; returns 0 if there is no match.
static NodeSearchPanel & Get()
Returns the single shared instance.
void SetNodeAddCallback(std::function< void(const std::string &, float, float)> callback)
Registers the callback that fires when the user confirms a node.
std::string ToLowerNSP(const std::string &s)
< Provides AssetID and INVALID_ASSET_ID
A single match returned by NodeSearchPalette::FuzzySearch().
std::string nodeType
Internal type key (e.g. "Sequence")
float relevanceScore
Higher = better match.