_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
CViewport Class Reference

#include <viewport.h>

Public Member Functions

const PixelPosGetTopLeftPos () const
 
const PixelPosGetBottomRightPos () const
 

Public Attributes

PixelPos TopLeftPos
 
PixelPos BottomRightPos
 Screen pixel top-left corner. More...
 
Vec2i MapPos
 Screen pixel bottom-right corner. More...
 
PixelDiff Offset
 Map tile left-upper corner. More...
 
int MapWidth
 Offset within MapX, MapY. More...
 
int MapHeight
 Width in map tiles. More...
 
CUnitUnit
 Height in map tiles. More...
 

map_draw.cpp - The map drawing.

 CViewport ()
 
 ~CViewport ()
 
bool IsInsideMapArea (const PixelPos &screenPixelPos) const
 Check if pos pixels are within map area. More...
 
PixelPos ScreenToMapPixelPos (const PixelPos &screenPixelPos) const
 Convert screen coordinates into map pixel coordinates. More...
 
PixelPos MapToScreenPixelPos (const PixelPos &mapPixelPos) const
 
Vec2i ScreenToTilePos (const PixelPos &screenPixelPos) const
 convert screen coordinate into tilepos More...
 
PixelPos TilePosToScreen_TopLeft (const Vec2i &tilePos) const
 convert tilepos coordonates into screen (take the top left of the tile) More...
 
PixelPos TilePosToScreen_Center (const Vec2i &tilePos) const
 convert tilepos coordonates into screen (take the center of the tile) More...
 
void Set (const Vec2i &tilePos, const PixelDiff &offset)
 Set the current map view to x,y(upper,left corner) More...
 
void Center (const PixelPos &mapPixelPos)
 Center map on point in viewport. More...
 
void SetClipping () const
 
void Draw () const
 Draw the full Viewport. More...
 
void DrawBorder () const
 
bool AnyMapAreaVisibleInViewport (const Vec2i &boxmin, const Vec2i &boxmax) const
 Check if any part of an area is visible in viewport. More...
 
bool Contains (const PixelPos &screenPos) const
 
void Restrict (int &screenPosX, int &screenPosY) const
 
PixelSize GetPixelSize () const
 

Detailed Description

A map viewport.

A part of the map displayed on screen.

CViewport::TopLeftPos CViewport::BottomRightPos

upper left corner of this viewport is located at pixel coordinates (TopLeftPosTopLeftPos) with respect to upper left corner of stratagus's window, similarly lower right corner of this viewport is (BottomRightPos) pixels away from the UL corner of stratagus's window.

CViewport::MapX CViewport::MapY CViewport::MapWidth CViewport::MapHeight

Tile coordinates of UL corner of this viewport with respect to UL corner of the whole map.

CViewport::Unit

Viewport is bound to a unit. If the unit moves the viewport changes the position together with the unit.

Constructor & Destructor Documentation

CViewport::CViewport ( )
CViewport::~CViewport ( )

Member Function Documentation

bool CViewport::AnyMapAreaVisibleInViewport ( const Vec2i boxmin,
const Vec2i boxmax 
) const

Check if any part of an area is visible in viewport.

Check if any part of an area is visible in a viewport.

Parameters
boxminmap tile position of area in map to be checked.
boxmaxmap tile position of area in map to be checked.
Returns
True if any part of area is visible, false otherwise
void CViewport::Center ( const PixelPos mapPixelPos)

Center map on point in viewport.

Center map viewport v on map tile (pos).

Parameters
mapPixelPosmap pixel position.
bool CViewport::Contains ( const PixelPos screenPos) const
void CViewport::Draw ( ) const

Draw the full Viewport.

Draw a map viewport.

void CViewport::DrawBorder ( ) const

Draw border around the viewport

const PixelPos& CViewport::GetBottomRightPos ( ) const
inline
PixelSize CViewport::GetPixelSize ( ) const
const PixelPos& CViewport::GetTopLeftPos ( ) const
inline
bool CViewport::IsInsideMapArea ( const PixelPos screenPixelPos) const

Check if pos pixels are within map area.

PixelPos CViewport::MapToScreenPixelPos ( const PixelPos mapPixelPos) const
void CViewport::Restrict ( int &  screenPosX,
int &  screenPosY 
) const
PixelPos CViewport::ScreenToMapPixelPos ( const PixelPos screenPixelPos) const

Convert screen coordinates into map pixel coordinates.

Vec2i CViewport::ScreenToTilePos ( const PixelPos screenPixelPos) const

convert screen coordinate into tilepos

void CViewport::Set ( const Vec2i tilePos,
const PixelDiff offset 
)

Set the current map view to x,y(upper,left corner)

Change viewpoint of map viewport v to tilePos.

Parameters
tilePosmap tile position.
offsetoffset in tile.
void CViewport::SetClipping ( ) const
PixelPos CViewport::TilePosToScreen_Center ( const Vec2i tilePos) const

convert tilepos coordonates into screen (take the center of the tile)

PixelPos CViewport::TilePosToScreen_TopLeft ( const Vec2i tilePos) const

convert tilepos coordonates into screen (take the top left of the tile)

Member Data Documentation

PixelPos CViewport::BottomRightPos

Screen pixel top-left corner.

int CViewport::MapHeight

Width in map tiles.

Vec2i CViewport::MapPos

Screen pixel bottom-right corner.

int CViewport::MapWidth

Offset within MapX, MapY.

PixelDiff CViewport::Offset

Map tile left-upper corner.

PixelPos CViewport::TopLeftPos
CUnit* CViewport::Unit

Height in map tiles.


The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.