OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::Camera Class Reference

Class handling camera movement, either by mouse or by events on the battlescape. More...

#include <Camera.h>

Public Member Functions

 Camera (int spriteWidth, int spriteHeight, int mapsize_x, int mapsize_y, int mapsize_z, Map *map, int visibleMapHeight)
 Creates a new camera. More...
 
 ~Camera ()
 Cleans up the camera. More...
 
void setScrollTimer (Timer *mouse, Timer *key)
 Sets the camera's scroll timers. More...
 
void mousePress (Action *action, State *state)
 Special handling for mouse press. More...
 
void mouseRelease (Action *action, State *state)
 Special handling for mouse release. More...
 
void mouseOver (Action *action, State *state)
 Special handling for mouse over. More...
 
void keyboardPress (Action *action, State *state)
 Special handling for key presses. More...
 
void keyboardRelease (Action *action, State *state)
 Special handling for key releases. More...
 
void scrollMouse ()
 Scrolls the view for mouse-scrolling. More...
 
void scrollKey ()
 Scrolls the view for keyboard-scrolling. More...
 
void scrollXY (int x, int y, bool redraw)
 Scrolls the view a certain amount. More...
 
void jumpXY (int x, int y)
 Jumps the view (when projectile in motion). More...
 
void up ()
 Moves map layer up. More...
 
void down ()
 Move map layer down. More...
 
void setViewLevel (int viewlevel)
 Sets the view level. More...
 
void convertMapToScreen (const Position &mapPos, Position *screenPos) const
 Converts map coordinates to screen coordinates. More...
 
void convertVoxelToScreen (const Position &voxelPos, Position *screenPos) const
 Converts voxel coordinates to screen coordinates. More...
 
void convertScreenToMap (int screenX, int screenY, int *mapX, int *mapY) const
 Converts screen coordinates to map coordinates. More...
 
void centerOnPosition (const Position &pos, bool redraw=true)
 Center map on a position. More...
 
Position getCenterPosition ()
 Gets map's center position. More...
 
int getViewLevel () const
 Gets the map displayed level. More...
 
int getMapSizeX () const
 Gets the map size x. More...
 
int getMapSizeY () const
 Gets the map size y. More...
 
Position getMapOffset ()
 Get the map x/y screen offset. More...
 
void setMapOffset (Position pos)
 Sets the map x/y screen offset. More...
 
int toggleShowAllLayers ()
 Toggles showing all map layers. More...
 
bool getShowAllLayers () const
 Checks if the camera is showing all map layers. More...
 
bool isOnScreen (const Position &mapPos, const bool unitWalking) const
 Checks if map coordinates X,Y,Z are on screen. More...
 
void resize ()
 Resize the viewable area. More...
 
void stopMouseScrolling ()
 stop mouse scrolling.
 

Detailed Description

Class handling camera movement, either by mouse or by events on the battlescape.

Constructor & Destructor Documentation

OpenXcom::Camera::Camera ( int  spriteWidth,
int  spriteHeight,
int  mapsize_x,
int  mapsize_y,
int  mapsize_z,
Map map,
int  visibleMapHeight 
)

Creates a new camera.

Sets up a camera.

Parameters
spriteWidthWidth of map sprite.
spriteHeightHeight of map sprite.
mapsize_xCurrent map size in X axis.
mapsize_yCurrent map size in Y axis.
mapsize_zCurrent map size in Z axis.
mapPointer to map surface.
visibleMapHeightCurrent height the view is at.
OpenXcom::Camera::~Camera ( )

Cleans up the camera.

Deletes the Camera.

Member Function Documentation

void OpenXcom::Camera::centerOnPosition ( const Position mapPos,
bool  redraw = true 
)

Center map on a position.

Centers map on a certain position.

Parameters
mapPosPosition to center on.
redrawRedraw map or not.
void OpenXcom::Camera::convertMapToScreen ( const Position mapPos,
Position screenPos 
) const

Converts map coordinates to screen coordinates.

Converts map coordinates X,Y,Z to screen positions X, Y.

Parameters
mapPosX,Y,Z coordinates on the map.
screenPosScreen position.
void OpenXcom::Camera::convertScreenToMap ( int  screenX,
int  screenY,
int *  mapX,
int *  mapY 
) const

Converts screen coordinates to map coordinates.

Parameters
screenXScreen x position.
screenYScreen y position.
mapXMap x position.
mapYMap y position.
void OpenXcom::Camera::convertVoxelToScreen ( const Position voxelPos,
Position screenPos 
) const

Converts voxel coordinates to screen coordinates.

Converts voxel coordinates X,Y,Z to screen positions X, Y.

Parameters
voxelPosX,Y,Z coordinates of the voxel.
screenPosScreen position.
void OpenXcom::Camera::down ( )

Move map layer down.

Goes one level down.

Position OpenXcom::Camera::getCenterPosition ( )

Gets map's center position.

Returns
Map's center position.
Position OpenXcom::Camera::getMapOffset ( )

Get the map x/y screen offset.

Gets the map offset.

Returns
The map offset.
int OpenXcom::Camera::getMapSizeX ( ) const

Gets the map size x.

Returns
The map size x.
int OpenXcom::Camera::getMapSizeY ( ) const

Gets the map size y.

Returns
The map size y.
bool OpenXcom::Camera::getShowAllLayers ( ) const

Checks if the camera is showing all map layers.

Returns
Current layer setting.
int OpenXcom::Camera::getViewLevel ( ) const

Gets the map displayed level.

Gets the displayed level.

Returns
The displayed layer.
bool OpenXcom::Camera::isOnScreen ( const Position mapPos,
const bool  unitWalking 
) const

Checks if map coordinates X,Y,Z are on screen.

Parameters
mapPosCoordinates to check.
unitWalkingTrue to offset coordinates for a unit walking.
Returns
True if the map coordinates are on screen.
void OpenXcom::Camera::jumpXY ( int  x,
int  y 
)

Jumps the view (when projectile in motion).

Handles jumping with given deviation.

Parameters
xX deviation.
yY deviation.
void OpenXcom::Camera::keyboardPress ( Action action,
State state 
)

Special handling for key presses.

Handles camera keyboard shortcuts.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.
void OpenXcom::Camera::keyboardRelease ( Action action,
State state 
)

Special handling for key releases.

Handles camera keyboard shortcuts.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.
void OpenXcom::Camera::mouseOver ( Action action,
State state 
)

Special handling for mouse over.

Handles mouse over events.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.
void OpenXcom::Camera::mousePress ( Action action,
State state 
)

Special handling for mouse press.

Handles camera mouse shortcuts.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.
void OpenXcom::Camera::mouseRelease ( Action action,
State state 
)

Special handling for mouse release.

Handles camera mouse shortcuts.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.
void OpenXcom::Camera::resize ( )

Resize the viewable area.

Resizes the viewable window of the camera.

void OpenXcom::Camera::scrollKey ( )

Scrolls the view for keyboard-scrolling.

Handles keyboard-scrolling.

void OpenXcom::Camera::scrollMouse ( )

Scrolls the view for mouse-scrolling.

Handles mouse-scrolling.

void OpenXcom::Camera::scrollXY ( int  x,
int  y,
bool  redraw 
)

Scrolls the view a certain amount.

Handles scrolling with given deviation.

Parameters
xX deviation.
yY deviation.
redrawRedraw map or not.
void OpenXcom::Camera::setMapOffset ( Position  pos)

Sets the map x/y screen offset.

Sets the map offset.

Parameters
posThe map offset.
void OpenXcom::Camera::setScrollTimer ( Timer mouse,
Timer key 
)

Sets the camera's scroll timers.

Sets the camera's scrolling timer.

Parameters
mousePointer to mouse timer.
keyPointer to key timer.
void OpenXcom::Camera::setViewLevel ( int  viewlevel)

Sets the view level.

Parameters
viewlevelNew view level.
int OpenXcom::Camera::toggleShowAllLayers ( )

Toggles showing all map layers.

Returns
New layer setting.
void OpenXcom::Camera::up ( )

Moves map layer up.

Goes one level up.


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