Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Olympe::MiniMapPanel Class Reference

Singleton mini-map providing normalised graph overview data. More...

#include <MiniMapPanel.h>

Public Member Functions

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.
 
void UpdateNodePositions (const std::vector< std::pair< int, std::pair< float, float > > > &rawPositions)
 Updates the normalised node positions from raw (id, x, y) triples.
 
const std::vector< MiniMapNodeEntry > & GetNodes () const
 Returns the normalised node positions for rendering.
 
void GetViewportRect (float &outX, float &outY, float &outW, float &outH) const
 Returns the normalised viewport rectangle.
 
bool IsVisible () const
 Returns true when the mini-map has valid data to display.
 
bool HandleClick (float clickNX, float clickNY, float &outScrollX, float &outScrollY) const
 Converts a click on the mini-map into a graph-scroll target.
 

Static Public Member Functions

static MiniMapPanelGet ()
 Returns the single shared instance.
 

Static Public Attributes

static constexpr float PANEL_WIDTH = 200.0f
 Default panel width in screen px.
 
static constexpr float PANEL_HEIGHT = 150.0f
 Default panel height in screen px.
 

Private Member Functions

 MiniMapPanel ()
 
float Normalise (float value, float minVal, float maxVal) const
 

Private Attributes

float m_GraphMinX
 
float m_GraphMaxX
 
float m_GraphMinY
 
float m_GraphMaxY
 
float m_ViewMinX
 
float m_ViewMaxX
 
float m_ViewMinY
 
float m_ViewMaxY
 
std::vector< MiniMapNodeEntrym_Nodes
 
bool m_IsVisible
 

Detailed Description

Singleton mini-map providing normalised graph overview data.

Typical usage:

mm.SetGraphBounds(minX, maxX, minY, maxY);
mm.UpdateNodePositions(rawPositions);
// Render thumbnail using GetNodes() and GetViewportRect()
auto [vpX, vpY, vpW, vpH] = mm.GetViewportRect(); // C++14: use structured float4
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static MiniMapPanel & Get()
Returns the single shared instance.

Definition at line 57 of file MiniMapPanel.h.

Constructor & Destructor Documentation

◆ MiniMapPanel()

Olympe::MiniMapPanel::MiniMapPanel ( )
private

Definition at line 24 of file MiniMapPanel.cpp.

Member Function Documentation

◆ Get()

MiniMapPanel & Olympe::MiniMapPanel::Get ( )
static

Returns the single shared instance.

Definition at line 18 of file MiniMapPanel.cpp.

◆ GetNodes()

const std::vector< MiniMapNodeEntry > & Olympe::MiniMapPanel::GetNodes ( ) const

Returns the normalised node positions for rendering.

Definition at line 90 of file MiniMapPanel.cpp.

References m_Nodes.

◆ GetViewportRect()

void Olympe::MiniMapPanel::GetViewportRect ( float outX,
float outY,
float outW,
float outH 
) const

Returns the normalised viewport rectangle.

Parameters
outXLeft edge [0..1]
outYTop edge [0..1]
outWWidth [0..1]
outHHeight [0..1]

Definition at line 95 of file MiniMapPanel.cpp.

References GetComponentTypeID_Static(), m_GraphMaxX, m_GraphMaxY, m_GraphMinX, m_GraphMinY, m_ViewMaxX, m_ViewMaxY, m_ViewMinX, m_ViewMinY, and Normalise().

+ Here is the call graph for this function:

◆ HandleClick()

bool Olympe::MiniMapPanel::HandleClick ( float  clickNX,
float  clickNY,
float outScrollX,
float outScrollY 
) const

Converts a click on the mini-map into a graph-scroll target.

Parameters
clickNXNormalised X of the click on the mini-map [0..1].
clickNYNormalised Y of the click on the mini-map [0..1].
outScrollXTarget scroll X in graph space.
outScrollYTarget scroll Y in graph space.

Definition at line 120 of file MiniMapPanel.cpp.

References GetComponentTypeID_Static(), m_GraphMaxX, m_GraphMaxY, m_GraphMinX, and m_GraphMinY.

+ Here is the call graph for this function:

◆ IsVisible()

bool Olympe::MiniMapPanel::IsVisible ( ) const

Returns true when the mini-map has valid data to display.

Definition at line 111 of file MiniMapPanel.cpp.

References m_IsVisible.

◆ Normalise()

float Olympe::MiniMapPanel::Normalise ( float  value,
float  minVal,
float  maxVal 
) const
private

Definition at line 37 of file MiniMapPanel.cpp.

References GetComponentTypeID_Static().

Referenced by GetViewportRect(), and UpdateNodePositions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetGraphBounds()

void Olympe::MiniMapPanel::SetGraphBounds ( float  minX,
float  maxX,
float  minY,
float  maxY 
)

Sets the full bounds of the graph in graph space.

Definition at line 52 of file MiniMapPanel.cpp.

References GetComponentTypeID_Static(), m_GraphMaxX, m_GraphMaxY, m_GraphMinX, and m_GraphMinY.

+ Here is the call graph for this function:

◆ SetViewport()

void Olympe::MiniMapPanel::SetViewport ( float  minX,
float  maxX,
float  minY,
float  maxY 
)

Sets the currently visible viewport in graph space.

Definition at line 60 of file MiniMapPanel.cpp.

References GetComponentTypeID_Static(), m_ViewMaxX, m_ViewMaxY, m_ViewMinX, and m_ViewMinY.

+ Here is the call graph for this function:

◆ UpdateNodePositions()

void Olympe::MiniMapPanel::UpdateNodePositions ( const std::vector< std::pair< int, std::pair< float, float > > > &  rawPositions)

Updates the normalised node positions from raw (id, x, y) triples.

Parameters
rawPositionsEach entry: (nodeId, graphX, graphY).

Definition at line 68 of file MiniMapPanel.cpp.

References GetComponentTypeID_Static(), Olympe::MiniMapNodeEntry::id, m_GraphMaxX, m_GraphMaxY, m_GraphMinX, m_GraphMinY, m_IsVisible, m_Nodes, and Normalise().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_GraphMaxX

float Olympe::MiniMapPanel::m_GraphMaxX
private

Definition at line 131 of file MiniMapPanel.h.

Referenced by GetViewportRect(), HandleClick(), SetGraphBounds(), and UpdateNodePositions().

◆ m_GraphMaxY

float Olympe::MiniMapPanel::m_GraphMaxY
private

Definition at line 133 of file MiniMapPanel.h.

Referenced by GetViewportRect(), HandleClick(), SetGraphBounds(), and UpdateNodePositions().

◆ m_GraphMinX

float Olympe::MiniMapPanel::m_GraphMinX
private

Definition at line 130 of file MiniMapPanel.h.

Referenced by GetViewportRect(), HandleClick(), SetGraphBounds(), and UpdateNodePositions().

◆ m_GraphMinY

float Olympe::MiniMapPanel::m_GraphMinY
private

Definition at line 132 of file MiniMapPanel.h.

Referenced by GetViewportRect(), HandleClick(), SetGraphBounds(), and UpdateNodePositions().

◆ m_IsVisible

bool Olympe::MiniMapPanel::m_IsVisible
private

Definition at line 141 of file MiniMapPanel.h.

Referenced by IsVisible(), and UpdateNodePositions().

◆ m_Nodes

std::vector<MiniMapNodeEntry> Olympe::MiniMapPanel::m_Nodes
private

Definition at line 140 of file MiniMapPanel.h.

Referenced by GetNodes(), and UpdateNodePositions().

◆ m_ViewMaxX

float Olympe::MiniMapPanel::m_ViewMaxX
private

Definition at line 136 of file MiniMapPanel.h.

Referenced by GetViewportRect(), and SetViewport().

◆ m_ViewMaxY

float Olympe::MiniMapPanel::m_ViewMaxY
private

Definition at line 138 of file MiniMapPanel.h.

Referenced by GetViewportRect(), and SetViewport().

◆ m_ViewMinX

float Olympe::MiniMapPanel::m_ViewMinX
private

Definition at line 135 of file MiniMapPanel.h.

Referenced by GetViewportRect(), and SetViewport().

◆ m_ViewMinY

float Olympe::MiniMapPanel::m_ViewMinY
private

Definition at line 137 of file MiniMapPanel.h.

Referenced by GetViewportRect(), and SetViewport().

◆ PANEL_HEIGHT

constexpr float Olympe::MiniMapPanel::PANEL_HEIGHT = 150.0f
staticconstexpr

Default panel height in screen px.

Definition at line 122 of file MiniMapPanel.h.

◆ PANEL_WIDTH

constexpr float Olympe::MiniMapPanel::PANEL_WIDTH = 200.0f
staticconstexpr

Default panel width in screen px.

Definition at line 121 of file MiniMapPanel.h.


The documentation for this class was generated from the following files: