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::MinimapWidget Class Reference

Singleton that maintains normalised minimap state. More...

#include <MinimapWidget.h>

+ Collaboration diagram for Olympe::MinimapWidget:

Public Member Functions

void UpdateNodes (const std::vector< MinimapNode > &nodes, float graphMinX, float graphMinY, float graphMaxX, float graphMaxY)
 Recomputes normalised node positions from graph-space coordinates.
 
void UpdateViewport (float viewX, float viewY, float viewW, float viewH, float graphMinX, float graphMinY, float graphMaxX, float graphMaxY)
 Recomputes the normalised viewport rectangle.
 
const std::vector< MinimapNode > & GetMinimapNodes () const
 Returns the last computed set of normalised minimap node positions.
 
const MinimapViewportGetViewport () const
 Returns the last computed normalised viewport rectangle.
 
void OnDrag (float deltaX, float deltaY, float graphW, float graphH, float &outGraphDeltaX, float &outGraphDeltaY)
 Converts a drag delta on the minimap into a graph-space delta.
 

Static Public Member Functions

static MinimapWidgetGet ()
 Returns the single shared instance.
 

Static Public Attributes

static constexpr float WIDTH = 200.0f
 Width of the minimap panel in screen pixels.
 
static constexpr float HEIGHT = 150.0f
 Height of the minimap panel in screen pixels.
 

Private Member Functions

 MinimapWidget ()
 

Private Attributes

std::vector< MinimapNodem_MinimapNodes
 
MinimapViewport m_Viewport
 

Detailed Description

Singleton that maintains normalised minimap state.

Typical usage:

mm.UpdateNodes(graphNodes, minX, minY, maxX, maxY);
mm.UpdateViewport(scrollX, scrollY, viewW, viewH, minX, minY, maxX, maxY);
const auto& pts = mm.GetMinimapNodes();
const auto& vp = mm.GetViewport();
// ... render pts and vp rectangle ...
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static MinimapWidget & Get()
Returns the single shared instance.

Definition at line 68 of file MinimapWidget.h.

Constructor & Destructor Documentation

◆ MinimapWidget()

Olympe::MinimapWidget::MinimapWidget ( )
private

Member Function Documentation

◆ Get()

MinimapWidget & Olympe::MinimapWidget::Get ( )
static

Returns the single shared instance.

Definition at line 18 of file MinimapWidget.cpp.

◆ GetMinimapNodes()

const std::vector< MinimapNode > & Olympe::MinimapWidget::GetMinimapNodes ( ) const

Returns the last computed set of normalised minimap node positions.

Definition at line 103 of file MinimapWidget.cpp.

References m_MinimapNodes.

◆ GetViewport()

const MinimapViewport & Olympe::MinimapWidget::GetViewport ( ) const

Returns the last computed normalised viewport rectangle.

Definition at line 108 of file MinimapWidget.cpp.

References m_Viewport.

◆ OnDrag()

void Olympe::MinimapWidget::OnDrag ( float  deltaX,
float  deltaY,
float  graphW,
float  graphH,
float outGraphDeltaX,
float outGraphDeltaY 
)

Converts a drag delta on the minimap into a graph-space delta.

Parameters
deltaXDrag delta in minimap pixel space (x).
deltaYDrag delta in minimap pixel space (y).
graphWFull graph width in graph space.
graphHFull graph height in graph space.
outGraphDeltaXResulting graph-space x delta.
outGraphDeltaYResulting graph-space y delta.

Definition at line 117 of file MinimapWidget.cpp.

References GetComponentTypeID_Static(), HEIGHT, and WIDTH.

+ Here is the call graph for this function:

◆ UpdateNodes()

void Olympe::MinimapWidget::UpdateNodes ( const std::vector< MinimapNode > &  nodes,
float  graphMinX,
float  graphMinY,
float  graphMaxX,
float  graphMaxY 
)

Recomputes normalised node positions from graph-space coordinates.

Parameters
nodesNodes to display (absolute graph-space positions).
graphMinXLeftmost graph boundary.
graphMinYTopmost graph boundary.
graphMaxXRightmost graph boundary.
graphMaxYBottommost graph boundary.

Definition at line 60 of file MinimapWidget.cpp.

References GetComponentTypeID_Static(), Olympe::MinimapNode::id, and m_MinimapNodes.

+ Here is the call graph for this function:

◆ UpdateViewport()

void Olympe::MinimapWidget::UpdateViewport ( float  viewX,
float  viewY,
float  viewW,
float  viewH,
float  graphMinX,
float  graphMinY,
float  graphMaxX,
float  graphMaxY 
)

Recomputes the normalised viewport rectangle.

Parameters
viewXCurrent scroll / pan X in graph space.
viewYCurrent scroll / pan Y in graph space.
viewWViewport width in graph space.
viewHViewport height in graph space.
graphMinXLeftmost graph boundary.
graphMinYTopmost graph boundary.
graphMaxXRightmost graph boundary.
graphMaxYBottommost graph boundary.

Definition at line 81 of file MinimapWidget.cpp.

References GetComponentTypeID_Static(), Olympe::MinimapViewport::h, m_Viewport, Olympe::MinimapViewport::w, Olympe::MinimapViewport::x, and Olympe::MinimapViewport::y.

+ Here is the call graph for this function:

Member Data Documentation

◆ HEIGHT

constexpr float Olympe::MinimapWidget::HEIGHT = 150.0f
staticconstexpr

Height of the minimap panel in screen pixels.

Definition at line 74 of file MinimapWidget.h.

Referenced by OnDrag().

◆ m_MinimapNodes

std::vector<MinimapNode> Olympe::MinimapWidget::m_MinimapNodes
private

Definition at line 155 of file MinimapWidget.h.

Referenced by GetMinimapNodes(), and UpdateNodes().

◆ m_Viewport

MinimapViewport Olympe::MinimapWidget::m_Viewport
private

Definition at line 156 of file MinimapWidget.h.

Referenced by GetViewport(), MinimapWidget(), and UpdateViewport().

◆ WIDTH

constexpr float Olympe::MinimapWidget::WIDTH = 200.0f
staticconstexpr

Width of the minimap panel in screen pixels.

Definition at line 72 of file MinimapWidget.h.

Referenced by OnDrag().


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