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

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CViewport Class Reference

#include <viewport.h>

Public Member Functions

SDL_Surface * GetFogSurface ()
 
const PixelPosGetTopLeftPos () const
 
const PixelPosGetBottomRightPos () const
 

Static Public Member Functions

static bool isGridEnabled ()
 
static void EnableGrid (const bool value)
 

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 ()
 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
 

map_fog.cpp - The map fog of war handling.

void Clean ()
 

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()

CViewport::~CViewport ( )

Member Function Documentation

◆ AnyMapAreaVisibleInViewport()

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

◆ Center()

void CViewport::Center ( const PixelPos mapPixelPos)

Center map on point in viewport.

Center map viewport v on map tile (pos).

Parameters
mapPixelPosmap pixel position.

◆ Clean()

void CViewport::Clean ( )

◆ Contains()

bool CViewport::Contains ( const PixelPos screenPos) const

◆ Draw()

void CViewport::Draw ( )

Draw the full Viewport.

Draw a map viewport.

Draw Fog of War

◆ DrawBorder()

void CViewport::DrawBorder ( ) const

Draw border around the viewport

◆ EnableGrid()

static void CViewport::EnableGrid ( const bool  value)
inlinestatic

◆ GetBottomRightPos()

const PixelPos& CViewport::GetBottomRightPos ( ) const
inline

◆ GetFogSurface()

SDL_Surface* CViewport::GetFogSurface ( )
inline

◆ GetPixelSize()

PixelSize CViewport::GetPixelSize ( ) const

◆ GetTopLeftPos()

const PixelPos& CViewport::GetTopLeftPos ( ) const
inline

◆ isGridEnabled()

static bool CViewport::isGridEnabled ( )
inlinestatic

◆ IsInsideMapArea()

bool CViewport::IsInsideMapArea ( const PixelPos screenPixelPos) const

Check if pos pixels are within map area.

◆ MapToScreenPixelPos()

PixelPos CViewport::MapToScreenPixelPos ( const PixelPos mapPixelPos) const

◆ Restrict()

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

◆ ScreenToMapPixelPos()

PixelPos CViewport::ScreenToMapPixelPos ( const PixelPos screenPixelPos) const

Convert screen coordinates into map pixel coordinates.

◆ ScreenToTilePos()

Vec2i CViewport::ScreenToTilePos ( const PixelPos screenPixelPos) const

convert screen coordinate into tilepos

◆ Set()

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.

◆ SetClipping()

void CViewport::SetClipping ( ) const

◆ TilePosToScreen_Center()

PixelPos CViewport::TilePosToScreen_Center ( const Vec2i tilePos) const

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

◆ TilePosToScreen_TopLeft()

PixelPos CViewport::TilePosToScreen_TopLeft ( const Vec2i tilePos) const

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

Member Data Documentation

◆ BottomRightPos

PixelPos CViewport::BottomRightPos

Screen pixel top-left corner.

◆ MapHeight

int CViewport::MapHeight

Width in map tiles.

◆ MapPos

Vec2i CViewport::MapPos

Screen pixel bottom-right corner.

◆ MapWidth

int CViewport::MapWidth

Offset within MapX, MapY.

◆ Offset

PixelDiff CViewport::Offset

Map tile left-upper corner.

◆ TopLeftPos

PixelPos CViewport::TopLeftPos

◆ Unit

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.