Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
MiniMapPanel.cpp
Go to the documentation of this file.
1/**
2 * @file MiniMapPanel.cpp
3 * @brief MiniMapPanel implementation (Phase 9).
4 * @author Olympe Engine
5 * @date 2026-03-09
6 */
7
8#include "MiniMapPanel.h"
9
10#include <cstddef>
11
12namespace Olympe {
13
14// ============================================================================
15// Singleton
16// ============================================================================
17
19{
20 static MiniMapPanel s_Instance;
21 return s_Instance;
22}
23
25 : m_GraphMinX(0.0f), m_GraphMaxX(1000.0f)
26 , m_GraphMinY(0.0f), m_GraphMaxY(1000.0f)
27 , m_ViewMinX(0.0f), m_ViewMaxX(800.0f)
28 , m_ViewMinY(0.0f), m_ViewMaxY(600.0f)
29 , m_IsVisible(false)
30{
31}
32
33// ============================================================================
34// Helpers
35// ============================================================================
36
37float MiniMapPanel::Normalise(float value, float minVal, float maxVal) const
38{
39 float range = maxVal - minVal;
40 if (range <= 0.0f)
41 return 0.0f;
42 float n = (value - minVal) / range;
43 if (n < 0.0f) n = 0.0f;
44 if (n > 1.0f) n = 1.0f;
45 return n;
46}
47
48// ============================================================================
49// Configuration
50// ============================================================================
51
52void MiniMapPanel::SetGraphBounds(float minX, float maxX, float minY, float maxY)
53{
58}
59
60void MiniMapPanel::SetViewport(float minX, float maxX, float minY, float maxY)
61{
66}
67
69 const std::vector<std::pair<int, std::pair<float, float>>>& rawPositions)
70{
71 m_Nodes.clear();
72 m_Nodes.reserve(rawPositions.size());
73
74 for (size_t i = 0; i < rawPositions.size(); ++i)
75 {
77 entry.id = rawPositions[i].first;
80 m_Nodes.push_back(entry);
81 }
82
83 m_IsVisible = !m_Nodes.empty();
84}
85
86// ============================================================================
87// Accessors
88// ============================================================================
89
90const std::vector<MiniMapNodeEntry>& MiniMapPanel::GetNodes() const
91{
92 return m_Nodes;
93}
94
96 float& outW, float& outH) const
97{
100
103
104 outW = (graphW > 0.0f) ? ((m_ViewMaxX - m_ViewMinX) / graphW) : 1.0f;
105 outH = (graphH > 0.0f) ? ((m_ViewMaxY - m_ViewMinY) / graphH) : 1.0f;
106
107 if (outW > 1.0f) outW = 1.0f;
108 if (outH > 1.0f) outH = 1.0f;
109}
110
112{
113 return m_IsVisible;
114}
115
116// ============================================================================
117// Interaction
118// ============================================================================
119
121 float& outScrollX, float& outScrollY) const
122{
124 return false;
125
128
131 return true;
132}
133
134} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Navigation mini-map panel for the VS graph editor (Phase 9).
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.
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.
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).
int id
Graph node ID.