Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
MiniMapPanel.h
Go to the documentation of this file.
1/**
2 * @file MiniMapPanel.h
3 * @brief Navigation mini-map panel for the VS graph editor (Phase 9).
4 * @author Olympe Engine
5 * @date 2026-03-09
6 *
7 * @details
8 * MiniMapPanel tracks the full graph bounds and the current viewport, and
9 * exposes normalised (0..1) coordinates for rendering a thumbnail overview.
10 * It also converts click/drag events on the mini-map into graph-scroll deltas.
11 *
12 * No ImGui dependency — UI code reads the data and renders however it likes.
13 *
14 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
15 */
16
17#pragma once
18
19#include <utility>
20#include <vector>
21
22namespace Olympe {
23
24// ============================================================================
25// Supporting types
26// ============================================================================
27
28/**
29 * @struct MiniMapNodeEntry
30 * @brief A node represented in the mini-map (normalised coords).
31 */
33 int id; ///< Graph node ID
34 float nx; ///< Normalised X [0..1]
35 float ny; ///< Normalised Y [0..1]
36};
37
38// ============================================================================
39// MiniMapPanel
40// ============================================================================
41
42/**
43 * @class MiniMapPanel
44 * @brief Singleton mini-map providing normalised graph overview data.
45 *
46 * Typical usage:
47 * @code
48 * auto& mm = MiniMapPanel::Get();
49 * mm.SetGraphBounds(minX, maxX, minY, maxY);
50 * mm.SetViewport(viewMinX, viewMaxX, viewMinY, viewMaxY);
51 * mm.UpdateNodePositions(rawPositions);
52 *
53 * // Render thumbnail using GetNodes() and GetViewportRect()
54 * auto [vpX, vpY, vpW, vpH] = mm.GetViewportRect(); // C++14: use structured float4
55 * @endcode
56 */
58public:
59
60 // -----------------------------------------------------------------------
61 // Singleton access
62 // -----------------------------------------------------------------------
63
64 /** @brief Returns the single shared instance. */
65 static MiniMapPanel& Get();
66
67 // -----------------------------------------------------------------------
68 // Configuration
69 // -----------------------------------------------------------------------
70
71 /**
72 * @brief Sets the full bounds of the graph in graph space.
73 */
74 void SetGraphBounds(float minX, float maxX, float minY, float maxY);
75
76 /**
77 * @brief Sets the currently visible viewport in graph space.
78 */
79 void SetViewport(float minX, float maxX, float minY, float maxY);
80
81 /**
82 * @brief Updates the normalised node positions from raw (id, x, y) triples.
83 * @param rawPositions Each entry: (nodeId, graphX, graphY).
84 */
85 void UpdateNodePositions(const std::vector<std::pair<int, std::pair<float, float>>>& rawPositions);
86
87 // -----------------------------------------------------------------------
88 // Accessors
89 // -----------------------------------------------------------------------
90
91 /** @brief Returns the normalised node positions for rendering. */
92 const std::vector<MiniMapNodeEntry>& GetNodes() const;
93
94 /**
95 * @brief Returns the normalised viewport rectangle.
96 * @param outX Left edge [0..1]
97 * @param outY Top edge [0..1]
98 * @param outW Width [0..1]
99 * @param outH Height [0..1]
100 */
101 void GetViewportRect(float& outX, float& outY, float& outW, float& outH) const;
102
103 /** @brief Returns true when the mini-map has valid data to display. */
104 bool IsVisible() const;
105
106 // -----------------------------------------------------------------------
107 // Interaction
108 // -----------------------------------------------------------------------
109
110 /**
111 * @brief Converts a click on the mini-map into a graph-scroll target.
112 *
113 * @param clickNX Normalised X of the click on the mini-map [0..1].
114 * @param clickNY Normalised Y of the click on the mini-map [0..1].
115 * @param outScrollX Target scroll X in graph space.
116 * @param outScrollY Target scroll Y in graph space.
117 */
118 bool HandleClick(float clickNX, float clickNY,
119 float& outScrollX, float& outScrollY) const;
120
121 static constexpr float PANEL_WIDTH = 200.0f; ///< Default panel width in screen px
122 static constexpr float PANEL_HEIGHT = 150.0f; ///< Default panel height in screen px
123
124private:
125
126 MiniMapPanel();
127
128 float Normalise(float value, float minVal, float maxVal) const;
129
134
139
140 std::vector<MiniMapNodeEntry> m_Nodes;
142};
143
144} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton mini-map providing normalised graph overview data.
const std::vector< MiniMapNodeEntry > & GetNodes() const
Returns the normalised node positions for rendering.
std::vector< MiniMapNodeEntry > m_Nodes
bool HandleClick(float clickNX, float clickNY, float &outScrollX, float &outScrollY) const
Converts a click on the mini-map into a graph-scroll target.
static MiniMapPanel & Get()
Returns the single shared instance.
static constexpr float PANEL_HEIGHT
Default panel height in screen px.
void GetViewportRect(float &outX, float &outY, float &outW, float &outH) const
Returns the normalised viewport rectangle.
void SetGraphBounds(float minX, float maxX, float minY, float maxY)
Sets the full bounds of the graph in graph space.
static constexpr float PANEL_WIDTH
Default panel width in screen px.
void SetViewport(float minX, float maxX, float minY, float maxY)
Sets the currently visible viewport in graph space.
bool IsVisible() const
Returns true when the mini-map has valid data to display.
void UpdateNodePositions(const std::vector< std::pair< int, std::pair< float, float > > > &rawPositions)
Updates the normalised node positions from raw (id, x, y) triples.
float Normalise(float value, float minVal, float maxVal) const
< Provides AssetID and INVALID_ASSET_ID
A node represented in the mini-map (normalised coords).
float nx
Normalised X [0..1].
float ny
Normalised Y [0..1].
int id
Graph node ID.