XPMP2
X-Plane multiplayer library 2 - using instancing
Namespaces | Macros | Functions | Variables
Map.cpp File Reference

Implementation for creating the map layer. More...

#include "XPMP2.h"

Namespaces

 XPMP2
 

Macros

#define INFO_MAP_ENABLED   "Map drawing has been %s"
 
#define ERR_MAP_LAYER_FAILED   "Creating a map layer failed for map '%s'"
 
#define ERR_UNABLE_NO_ICONS   "Cannot enable map drawing due to missing map icons file"
 
#define DEBUG_MAP_LAYER_CREATED   "Created a map layer for map '%s'"
 

Functions

bool XPMP2::IsInRect (float x, float y, const float bounds_ltrb[4])
 Tests if x/y lies within the rect, given as a float[4] array. More...
 
void XPMP2::MapPrepareCacheCB (XPLMMapLayerID, const float *inTotalMapBoundsLeftTopRightBottom, XPLMMapProjectionID projection, void *)
 Prepare map drawing information. More...
 
void XPMP2::MapIconDrawingCB (XPLMMapLayerID inLayer, const float *inMapBoundsLeftTopRightBottom, float, float mapUnitsPerUserInterfaceUnit, XPLMMapStyle, XPLMMapProjectionID projection, void *refcon)
 Actually draw the icons into the map. More...
 
void XPMP2::MapLabelDrawingCB (XPLMMapLayerID inLayer, const float *inMapBoundsLeftTopRightBottom, float, float mapUnitsPerUserInterfaceUnit, XPLMMapStyle, XPLMMapProjectionID projection, void *refcon)
 Actually draw the labels into th emap. More...
 
void XPMP2::MapDeleteCB (XPLMMapLayerID inLayer, void *)
 Called when a map is about to be deleted. More...
 
void XPMP2::MapLayerCreate (const char *mapIdentifier)
 Create our map layer for the given map. More...
 
void XPMP2::MapCreateAll ()
 Loop all existing maps and create our map layer for them. More...
 
void XPMP2::MapDestroyAll ()
 Remove all our map layers. More...
 
void XPMP2::MapCreateCB (const char *mapIdentifier, void *)
 Callback called when a map is created. We then need to add our layer to it. More...
 
void XPMP2::MapInit ()
 Initialize the module. More...
 
void XPMP2::MapCleanup ()
 Grace cleanup. More...
 
void XPMPEnableMap (bool _bEnable, bool _bLabels)
 Enable or disable the drawing of aircraft icons on X-Plane's map. More...
 

Variables

constexpr int XPMP2::MAP_ICON_WIDTH = 3
 Dimenson of MapIcon.png. More...
 
constexpr int XPMP2::MAP_ICON_HEIGHT = 3
 Dimenson of MapIcon.png. More...
 
constexpr int XPMP2::MAP_MIN_ICON_SIZE = 40
 Minimum icon size in map in UI units. More...
 
constexpr float XPMP2::MAP_AC_SIZE = 30.0f
 Assumed size of an aircraft in m. More...
 
std::array< const char *, 2 > XPMP2::ALL_MAPS
 The list of known maps, which are hard-coded by X-Plane's SDK. More...
 

Detailed Description

Implementation for creating the map layer.

Draws aircraft icons on X-Plane's maps in positions where our aircraft are. Aircraft icons are provided in a PNG icon sheet.

See also
https://developer.x-plane.com/sdk/XPLMMap/
Author
Birger Hoppe

Macro Definition Documentation

◆ DEBUG_MAP_LAYER_CREATED

#define DEBUG_MAP_LAYER_CREATED   "Created a map layer for map '%s'"

◆ ERR_MAP_LAYER_FAILED

#define ERR_MAP_LAYER_FAILED   "Creating a map layer failed for map '%s'"

◆ ERR_UNABLE_NO_ICONS

#define ERR_UNABLE_NO_ICONS   "Cannot enable map drawing due to missing map icons file"

◆ INFO_MAP_ENABLED

#define INFO_MAP_ENABLED   "Map drawing has been %s"

Function Documentation

◆ XPMPEnableMap()

void XPMPEnableMap ( bool  _bEnable,
bool  _bLabels = true 
)

Enable or disable the drawing of aircraft icons on X-Plane's map.

Parameters
_bEnableEnable or disable entire map functionality
_bLabelsIf map is enabled, shall also labels be drawn?

XPMP2 creates a separate Map Layer named after the plugin for this purposes. By default, the map functionality is enabled including label writing.