![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Singleton fuzzy-search panel for adding nodes to the graph. More...
#include <NodeSearchPanel.h>
Public Member Functions | |
| void | OpenSearch (float posX, float posY) |
| Opens the search panel at the given graph-space position. | |
| void | CloseSearch () |
| Closes the search panel and clears the query. | |
| bool | IsOpen () const |
| Returns true if the panel is currently visible. | |
| void | UpdateQuery (const std::string &query) |
| Recomputes the result list for the given query string. | |
| const std::vector< NodeSearchResult > & | GetResults () const |
| Returns the current result list sorted by relevance (best first). | |
| void | ConfirmSelection (int index) |
Fires the OnNodeAdd callback for the result at index and closes the panel. | |
| int | GetSelectedIndex () const |
| Returns the index of the currently highlighted result (-1 = none). | |
| void | SelectPrevious () |
| Moves the selection up by one step (wraps around). | |
| void | SelectNext () |
| Moves the selection down by one step (wraps around). | |
| void | SetNodeAddCallback (std::function< void(const std::string &, float, float)> callback) |
| Registers the callback that fires when the user confirms a node. | |
| float | GetSpawnX () const |
| Returns the X coordinate where the new node should be spawned. | |
| float | GetSpawnY () const |
| Returns the Y coordinate where the new node should be spawned. | |
Static Public Member Functions | |
| static NodeSearchPanel & | Get () |
| Returns the single shared instance. | |
Private Member Functions | |
| NodeSearchPanel () | |
| void | InitNodeCatalogue () |
Static Private Member Functions | |
| static float | ComputeScore (const std::string &query, const std::string &candidate) |
| Compute a [0..1] relevance score; returns 0 if there is no match. | |
Private Attributes | |
| bool | m_IsOpen |
| float | m_SpawnPosX |
| float | m_SpawnPosY |
| std::vector< NodeSearchResult > | m_Catalogue |
| Full unfiltered catalogue. | |
| std::vector< NodeSearchResult > | m_Results |
| Current filtered/sorted results. | |
| int | m_SelectedIndex |
| std::function< void(const std::string &, float, float)> | m_OnNodeAdd |
Singleton fuzzy-search panel for adding nodes to the graph.
Typical usage:
Definition at line 71 of file NodeSearchPanel.h.
|
private |
Definition at line 43 of file NodeSearchPanel.cpp.
References InitNodeCatalogue().
Here is the call graph for this function:| void Olympe::NodeSearchPanel::CloseSearch | ( | ) |
Closes the search panel and clears the query.
Definition at line 117 of file NodeSearchPanel.cpp.
References m_IsOpen, m_Results, and m_SelectedIndex.
Referenced by ConfirmSelection().
Here is the caller graph for this function:
|
staticprivate |
Compute a [0..1] relevance score; returns 0 if there is no match.
Definition at line 133 of file NodeSearchPanel.cpp.
References GetComponentTypeID_Static().
Referenced by UpdateQuery().
Here is the call graph for this function:
Here is the caller graph for this function:Fires the OnNodeAdd callback for the result at index and closes the panel.
No-op if index is out of range.
Definition at line 221 of file NodeSearchPanel.cpp.
References CloseSearch(), GetComponentTypeID_Static(), m_OnNodeAdd, m_Results, m_SpawnPosX, and m_SpawnPosY.
Here is the call graph for this function:
|
static |
Returns the single shared instance.
Definition at line 37 of file NodeSearchPanel.cpp.
| const std::vector< NodeSearchResult > & Olympe::NodeSearchPanel::GetResults | ( | ) | const |
Returns the current result list sorted by relevance (best first).
Definition at line 212 of file NodeSearchPanel.cpp.
References m_Results.
| int Olympe::NodeSearchPanel::GetSelectedIndex | ( | ) | const |
Returns the index of the currently highlighted result (-1 = none).
Definition at line 233 of file NodeSearchPanel.cpp.
References m_SelectedIndex.
| float Olympe::NodeSearchPanel::GetSpawnX | ( | ) | const |
Returns the X coordinate where the new node should be spawned.
Definition at line 268 of file NodeSearchPanel.cpp.
References m_SpawnPosX.
| float Olympe::NodeSearchPanel::GetSpawnY | ( | ) | const |
Returns the Y coordinate where the new node should be spawned.
Definition at line 269 of file NodeSearchPanel.cpp.
References m_SpawnPosY.
|
private |
Definition at line 56 of file NodeSearchPanel.cpp.
References GetComponentTypeID_Static(), m_Catalogue, Olympe::NodeSearchResult::nodeType, and SYSTEM_LOG.
Referenced by NodeSearchPanel().
Here is the call graph for this function:
Here is the caller graph for this function:| bool Olympe::NodeSearchPanel::IsOpen | ( | ) | const |
Returns true if the panel is currently visible.
Definition at line 124 of file NodeSearchPanel.cpp.
References m_IsOpen.
Opens the search panel at the given graph-space position.
| posX | Spawn X for the new node (graph space). |
| posY | Spawn Y for the new node (graph space). |
Definition at line 105 of file NodeSearchPanel.cpp.
References m_IsOpen, m_Results, m_SelectedIndex, m_SpawnPosX, m_SpawnPosY, and UpdateQuery().
Here is the call graph for this function:| void Olympe::NodeSearchPanel::SelectNext | ( | ) |
Moves the selection down by one step (wraps around).
Definition at line 246 of file NodeSearchPanel.cpp.
References GetComponentTypeID_Static(), m_Results, and m_SelectedIndex.
Here is the call graph for this function:| void Olympe::NodeSearchPanel::SelectPrevious | ( | ) |
Moves the selection up by one step (wraps around).
Definition at line 238 of file NodeSearchPanel.cpp.
References GetComponentTypeID_Static(), m_Results, and m_SelectedIndex.
Here is the call graph for this function:| void Olympe::NodeSearchPanel::SetNodeAddCallback | ( | std::function< void(const std::string &, float, float)> | callback | ) |
Registers the callback that fires when the user confirms a node.
| callback | Signature: void(nodeType, spawnX, spawnY) |
Definition at line 258 of file NodeSearchPanel.cpp.
References GetComponentTypeID_Static(), and m_OnNodeAdd.
Here is the call graph for this function:Recomputes the result list for the given query string.
Call this every frame (or whenever the query changes).
Definition at line 176 of file NodeSearchPanel.cpp.
References ComputeScore(), GetComponentTypeID_Static(), m_Catalogue, m_Results, m_SelectedIndex, and Olympe::NodeSearchResult::relevanceScore.
Referenced by OpenSearch().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Full unfiltered catalogue.
Definition at line 172 of file NodeSearchPanel.h.
Referenced by InitNodeCatalogue(), and UpdateQuery().
|
private |
Definition at line 169 of file NodeSearchPanel.h.
Referenced by CloseSearch(), IsOpen(), and OpenSearch().
Definition at line 175 of file NodeSearchPanel.h.
Referenced by ConfirmSelection(), and SetNodeAddCallback().
|
private |
Current filtered/sorted results.
Definition at line 173 of file NodeSearchPanel.h.
Referenced by CloseSearch(), ConfirmSelection(), GetResults(), OpenSearch(), SelectNext(), SelectPrevious(), and UpdateQuery().
|
private |
Definition at line 174 of file NodeSearchPanel.h.
Referenced by CloseSearch(), GetSelectedIndex(), OpenSearch(), SelectNext(), SelectPrevious(), and UpdateQuery().
|
private |
Definition at line 170 of file NodeSearchPanel.h.
Referenced by ConfirmSelection(), GetSpawnX(), and OpenSearch().
|
private |
Definition at line 171 of file NodeSearchPanel.h.
Referenced by ConfirmSelection(), GetSpawnY(), and OpenSearch().