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

CViewport Class Reference

#include <viewport.h>

List of all members.


map_draw.cpp - The map drawing.

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

Public Member Functions

const PixelPosGetTopLeftPos () const
const PixelPosGetBottomRightPos () const

Public Attributes

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

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::IsInsideMapArea ( const PixelPos screenPixelPos  )  const

Check if pos pixels are within map area.

PixelPos CViewport::ScreenToMapPixelPos ( const PixelPos screenPixelPos  )  const

Convert screen coordinates into map pixel coordinates.

PixelPos CViewport::MapToScreenPixelPos ( const PixelPos mapPixelPos  )  const

Vec2i CViewport::ScreenToTilePos ( const PixelPos screenPixelPos  )  const

convert screen coordinate into tilepos

PixelPos CViewport::TilePosToScreen_TopLeft ( const Vec2i tilePos  )  const

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

PixelPos CViewport::TilePosToScreen_Center ( const Vec2i tilePos  )  const

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

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:
tilePos map tile position.
offset offset in tile.

void CViewport::Center ( const PixelPos mapPixelPos  ) 

Center map on point in viewport.

Center map viewport v on map tile (pos).

Parameters:
mapPixelPos map pixel position.

void CViewport::SetClipping (  )  const

void CViewport::Draw (  )  const

Draw the full Viewport.

Draw a map viewport.

void CViewport::DrawBorder (  )  const

Draw border around the viewport

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:
boxmin map tile position of area in map to be checked.
boxmax map tile position of area in map to be checked.
Returns:
True if any part of area is visible, false otherwise

bool CViewport::Contains ( const PixelPos screenPos  )  const

void CViewport::Restrict ( int &  screenPosX,
int &  screenPosY 
) const

PixelSize CViewport::GetPixelSize (  )  const

const PixelPos& CViewport::GetTopLeftPos (  )  const [inline]

const PixelPos& CViewport::GetBottomRightPos (  )  const [inline]


Member Data Documentation

Screen pixel top-left corner.

Screen pixel bottom-right corner.

Map tile left-upper corner.

Offset within MapX, MapY.

Width in map tiles.

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.