$treeview $search $mathjax
Stratagus  2.2.6
$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 <ui.h>

List of all members.


map_draw.cpp - The map drawing.

 ~CViewport ()
bool IsInsideMapArea (int x, int y) const
 Check if X and Y pixels are within map area.
int Viewport2MapX (int x) const
 Convert screen X pixel to map tile.
int Viewport2MapY (int y) const
 Convert screen Y pixel to map tile.
int Map2ViewportX (int x) const
 Convert map tile to screen X pixel.
int Map2ViewportY (int y) const
 Convert map tile to screen Y pixel.
void MapPixel2Viewport (int &x, int &y) const
 Convert map pixel coordinates into viewport coordinates.
void Set (int x, int y, int offsetx, int offsety)
 Set the current map view to x,y(upper,left corner).
void Center (const Vec2i &pos, const PixelPos &offset)
 Center map on point in viewport.
void UpdateUnits ()
void Draw () const
 Draw the full Viewport.
void DrawBorder () const
bool AnyMapAreaVisibleInViewport (int sx, int sy, int ex, int ey) const
 Check if any part of an area is visible in viewport.
void DrawMapBackgroundInViewport () const
 Draw the map background.

Public Member Functions

 CViewport ()

Public Attributes

int X
int Y
 Screen pixel left corner x coordinate.
int EndX
 Screen pixel upper corner y coordinate.
int EndY
 Screen pixel right x coordinate.
int MapX
 Screen pixel bottom y coordinate.
int MapY
 Map tile left corner x coordinate.
int OffsetX
 Map tile upper corner y coordinate.
int OffsetY
 X Offset within MapX.
int MapWidth
 Y Offset within MapY.
int MapHeight
 Width in map tiles.
CUnitUnit
 Height in map tiles.
CDrawProxyProxy
 Bound to this unit.

Protected Member Functions

map_fog.cpp - The map fog of war handling.
void DrawMapFogOfWar () const
 Draw the map fog of war.

Detailed Description

A map viewport.

A part of the map displayed on sceen.

CViewport::X CViewport::Y CViewport::EndX CViewport::EndY

upper left corner of this viewport is located at pixel coordinates (X, Y) with respect to upper left corner of stratagus's window, similarly lower right corner of this viewport is (EndX, EndY) 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.

Todo:
binding to a group.

Constructor & Destructor Documentation

CViewport::CViewport (  )  [inline]

CViewport::~CViewport (  ) 


Member Function Documentation

bool CViewport::IsInsideMapArea ( int  x,
int  y 
) const

Check if X and Y pixels are within map area.

int CViewport::Viewport2MapX ( int  x  )  const

Convert screen X pixel to map tile.

Convert viewport x coordinate to map tile x coordinate.

Parameters:
x X coordinate into this viewport (in pixels, relative to origin of Stratagus's window - not the viewport itself!).
Returns:
X map tile coordinate.

int CViewport::Viewport2MapY ( int  y  )  const

Convert screen Y pixel to map tile.

Convert viewport y coordinate to map tile y coordinate.

Parameters:
y Y coordinate into this viewport (in pixels, relative to origin of Stratagus's window - not the viewport itself!).
Returns:
Y map tile coordinate.

int CViewport::Map2ViewportX ( int  x  )  const

Convert map tile to screen X pixel.

Convert a map tile X coordinate into a viewport x pixel coordinate.

Parameters:
x The map tile's X coordinate.
Returns:
X screen coordinate in pixels (relative to origin of Stratagus's window).

int CViewport::Map2ViewportY ( int  y  )  const

Convert map tile to screen Y pixel.

Convert a map tile Y coordinate into a viewport y pixel coordinate.

Parameters:
y The map tile's Y coordinate.
Returns:
Y screen coordinate in pixels (relative to origin of Stratagus's window).

void CViewport::MapPixel2Viewport ( int &  x,
int &  y 
) const

Convert map pixel coordinates into viewport coordinates.

Convert map pixel coordinates into viewport coordinates.

void CViewport::Set ( int  x,
int  y,
int  offsetx,
int  offsety 
)

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

Change viewpoint of map viewport v to x,y.

Parameters:
x X map tile position.
y Y map tile position.
offsetx X offset in tile.
offsety Y offset in tile.

void CViewport::Center ( const Vec2i pos,
const PixelPos offset 
)

Center map on point in viewport.

Center map viewport v on map tile (pos).

Parameters:
pos map tile position.
offset offset in tile.

void CViewport::DrawMapBackgroundInViewport (  )  const [protected]

Draw the map background.

Draw the map backgrounds.

StephanR: variables explained below for screen:

 *---------------------------------------*
 |                                       |
 |        *-----------------------*      |<-TheUi.MapY,dy (in pixels)
 |        |   |   |   |   |   |   |      |        |
 |        |   |   |   |   |   |   |      |        |
 |        |---+---+---+---+---+---|      |        |
 |        |   |   |   |   |   |   |      |        |MapHeight (in tiles)
 |        |   |   |   |   |   |   |      |        |
 |        |---+---+---+---+---+---|      |        |
 |        |   |   |   |   |   |   |      |        |
 |        |   |   |   |   |   |   |      |        |
 |        *-----------------------*      |<-ey,UI.MapEndY (in pixels)
 |                                       |
 |                                       |
 *---------------------------------------*
          ^                       ^
        dx|-----------------------|ex,UI.MapEndX (in pixels)
            UI.MapX MapWidth (in tiles)
 (in pixels)
 

void CViewport::DrawMapFogOfWar (  )  const [protected]

Draw the map fog of war.

Draw the map fog of war.

void CViewport::UpdateUnits (  ) 

void CViewport::Draw (  )  const

Draw the full Viewport.

Draw a map viewport.

void CViewport::DrawBorder (  )  const

Draw border around the viewport

bool CViewport::AnyMapAreaVisibleInViewport ( int  sx,
int  sy,
int  ex,
int  ey 
) 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:
sx X map tile position of area in map to be checked.
sy Y map tile position of area in map to be checked.
ex X map tile position of area in map to be checked.
ey Y map tile position of area in map to be checked.
Returns:
True if any part of area is visible, false otherwise


Member Data Documentation

Screen pixel left corner x coordinate.

Screen pixel upper corner y coordinate.

Screen pixel right x coordinate.

Screen pixel bottom y coordinate.

Map tile left corner x coordinate.

Map tile upper corner y coordinate.

X Offset within MapX.

Y Offset within MapY.

Width in map tiles.

Height in map tiles.

Bound to this unit.


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