____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"#include <ui.h>
Public Member Functions | |
| 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 Y pixel to map tile. | |
| int | Viewport2MapY (int y) const |
| Convert map tile to screen X pixel. | |
| int | Map2ViewportX (int x) const |
| Convert map tile to screen Y pixel. | |
| int | Map2ViewportY (int y) const |
| Convert map pixel coordinates into viewport coordinates. | |
| void | MapPixel2Viewport (int &x, int &y) const |
| Set the current map view to x,y(upper,left corner). | |
| void | Set (int x, int y, int offsetx, int offsety) |
| Center map on point in viewport. | |
| void | Center (int x, int y, int offsetx, int offsety) |
| void | Draw () const |
| < Draw the full Viewport. | |
| void | DrawBorder () const |
| Check if any part of an area is visible in viewport. | |
| bool | AnyMapAreaVisibleInViewport (int sx, int sy, int ex, int ey) const |
Public Attributes | |
| int | X |
| Screen pixel left corner x coordinate. | |
| int | Y |
| Screen pixel upper corner y coordinate. | |
| int | EndX |
| Screen pixel right x coordinate. | |
| int | EndY |
| Screen pixel bottom y coordinate. | |
| int | MapX |
| Map tile left corner x coordinate. | |
| int | MapY |
| Map tile upper corner y coordinate. | |
| int | OffsetX |
| X Offset within MapX. | |
| int | OffsetY |
| Y Offset within MapY. | |
| int | MapWidth |
| Width in map tiles. | |
| int | MapHeight |
| Height in map tiles. | |
| CUnit * | Unit |
| Bound to this unit. | |
Protected Member Functions | |
| void | DrawMapBackgroundInViewport () const |
| < Draw the map background | |
| void | DrawMapFogOfWar () const |
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.
Viewport is bound to a unit. If the unit moves the viewport changes the position together with the unit.
Definition at line 148 of file ui.h.
| bool CViewport::IsInsideMapArea | ( | int | x, | |
| int | y | |||
| ) | const |
Check if X and Y pixels are within map area.
Convert screen X pixel to map tile
Definition at line 79 of file map_draw.cpp.
References CMap::Info, Map, CMapInfo::MapHeight, CMapInfo::MapWidth, MapX, MapY, OffsetX, OffsetY, TileSizeX, TileSizeY, X, and Y.
Referenced by UIHandleButtonDown(), UIHandleMouseMove(), and UISelectStateButtonDown().
| int CViewport::Viewport2MapX | ( | int | x | ) | const |
Convert screen Y pixel to map tile.
Convert viewport x coordinate to map tile x coordinate.
| x | X coordinate into this viewport (in pixels, relative to origin of Stratagus's window - not the viewport itself!). |
Definition at line 110 of file map_draw.cpp.
References CMap::Info, Map, CMapInfo::MapWidth, MapX, OffsetX, TileSizeX, and X.
Referenced by DrawBuildingCursor(), DrawMapCursor(), EditorCallbackButtonDown(), EditorCallbackKeyDown(), EditorCallbackMouse(), UIHandleButtonDown(), UIHandleButtonUp(), and UIHandleMouseMove().
| int CViewport::Viewport2MapY | ( | int | y | ) | const |
Convert map tile to screen X pixel.
Convert viewport y coordinate to map tile y coordinate.
| y | Y coordinate into this viewport (in pixels, relative to origin of Stratagus's window - not the viewport itself!). |
Definition at line 125 of file map_draw.cpp.
References CMap::Info, Map, CMapInfo::MapHeight, MapY, OffsetY, TileSizeY, and Y.
Referenced by DrawBuildingCursor(), DrawMapCursor(), EditorCallbackButtonDown(), EditorCallbackKeyDown(), EditorCallbackMouse(), UIHandleButtonDown(), UIHandleButtonUp(), and UIHandleMouseMove().
| int CViewport::Map2ViewportX | ( | int | x | ) | const |
Convert map tile to screen Y pixel.
Convert a map tile X coordinate into a viewport x pixel coordinate.
| x | The map tile's X coordinate. |
Definition at line 139 of file map_draw.cpp.
References MapX, OffsetX, TileSizeX, and X.
Referenced by CUnit::Draw(), DrawMapCursor(), DrawUnitSelection(), GetOrderPosition(), ShowOrder(), and ShowSingleOrder().
| int CViewport::Map2ViewportY | ( | int | y | ) | const |
Convert map pixel coordinates into viewport coordinates.
Convert a map tile Y coordinate into a viewport y pixel coordinate.
| y | The map tile's Y coordinate. |
Definition at line 152 of file map_draw.cpp.
References MapY, OffsetY, TileSizeY, and Y.
Referenced by CUnit::Draw(), DrawMapCursor(), DrawUnitSelection(), GetOrderPosition(), ShowOrder(), and ShowSingleOrder().
| void CViewport::MapPixel2Viewport | ( | int & | x, | |
| int & | y | |||
| ) | const |
| void CViewport::Set | ( | int | x, | |
| int | y, | |||
| int | offsetx, | |||
| int | offsety | |||
| ) |
Center map on point in viewport.
Change viewpoint of map viewport v to x,y.
| x | X map tile position. | |
| y | Y map tile position. | |
| offsetx | X offset in tile. | |
| offsety | Y offset in tile. |
Definition at line 174 of file map_draw.cpp.
References EndX, EndY, CMap::Info, Map, CUserInterface::MapArea, MapHeight, CMapInfo::MapHeight, MapWidth, CMapInfo::MapWidth, MapX, MapY, OffsetX, OffsetY, CMapArea::ScrollPaddingBottom, CMapArea::ScrollPaddingLeft, CMapArea::ScrollPaddingRight, CMapArea::ScrollPaddingTop, TileSizeX, TileSizeY, UI, X, and Y.
Referenced by Center(), DoScrollArea(), EditorCallbackButtonDown(), EditorCallbackMouse(), FinishViewportModeConfiguration(), MouseScrollMap(), and UiRecallMapPosition().
| void CViewport::Center | ( | int | x, | |
| int | y, | |||
| int | offsetx, | |||
| int | offsety | |||
| ) |
Center map viewport v on map tile (x,y).
| x | X map tile position. | |
| y | Y map tile position. | |
| offsetx | X offset in tile. | |
| offsety | Y offset in tile. |
Definition at line 220 of file map_draw.cpp.
References EndX, EndY, Set(), TileSizeX, TileSizeY, X, and Y.
Referenced by CclCenterMap(), CenterOnMessage(), CreateGame(), UiCenterOnGroup(), UiCenterOnSelected(), UiFindIdleWorker(), UIHandleButtonDown(), UIHandleMouseMove(), and UISelectStateButtonDown().
| void CViewport::DrawMapBackgroundInViewport | ( | ) | const [protected] |
< Draw the map background
Draw the map fog of war
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)
Definition at line 252 of file map_draw.cpp.
References CGraphic::DrawClip(), CVideo::DrawRectangleClip(), Editor, CPatchType::getGraphic(), CPatchManager::getPatches(), CPatchType::getTileHeight(), CPatchType::getTileWidth(), CPatch::getType(), CPatch::getX(), CPatch::getY(), Map, MapX, MapY, OffsetX, OffsetY, CMap::PatchManager, CEditor::PatchOutlineColor, CEditor::Running, CEditor::ShowPatchOutlines, TileSizeX, TileSizeY, Video, X, Y, and y.
Referenced by Draw().
| void CViewport::DrawMapFogOfWar | ( | ) | const [protected] |
Draw the map fog of war.
Definition at line 498 of file map_fog.cpp.
References ColorBlack, DrawFogOfWarTile(), EndX, EndY, CVideo::FillRectangleClip(), CPlayer::Index, CMap::Info, CMap::IsTileVisible(), Map, CMapInfo::MapHeight, MapHeight, CMapInfo::MapWidth, MapWidth, MapX, MapY, OffsetX, OffsetY, ReplayRevealMap, ThisPlayer, TileSizeX, TileSizeY, Video, VisibleTable, X, and Y.
Referenced by Draw().
| void CViewport::Draw | ( | ) | const |
< Draw the full Viewport.
Draw a map viewport.
Definition at line 275 of file map_draw.cpp.
References CurrentViewport, CParticleManager::draw(), CUnit::Draw(), DrawBorder(), MissileType::DrawLevel, DrawMapBackgroundInViewport(), DrawMapFogOfWar(), Missile::DrawMissile(), EndX, EndY, FindAndSortMissiles(), FindAndSortUnits(), GameCycle, KeyModifiers, MAX_MISSILES, ModifierShift, NumSelected, ParticleManager, PopClipping(), Preference, PushClipping(), Selected, SetClipping(), ShowOrder(), CPreference::ShowOrders, ShowOrdersCount, Missile::Type, UnitMax, X, and Y.
| void CViewport::DrawBorder | ( | ) | const |
Check if any part of an area is visible in viewport.
Draw border around the viewport
Definition at line 336 of file map_draw.cpp.
References ColorBlack, ColorOrange, CVideo::DrawRectangle(), EndX, EndY, CUserInterface::NumViewports, CUserInterface::SelectedViewport, UI, Video, X, and Y.
Referenced by Draw().
| bool CViewport::AnyMapAreaVisibleInViewport | ( | int | sx, | |
| int | sy, | |||
| int | ex, | |||
| int | ey | |||
| ) | const |
Check if any part of an area is visible in a viewport.
| 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. |
Definition at line 70 of file map_draw.cpp.
References MapHeight, MapWidth, MapX, and MapY.
Referenced by MissileVisibleInViewport().
| int CViewport::X |
Screen pixel left corner x coordinate.
Definition at line 182 of file ui.h.
Referenced by Center(), ClipViewport(), Draw(), DrawBorder(), DrawBuildingCursor(), DrawCursor(), DrawMapBackgroundInViewport(), DrawMapCursor(), DrawMapFogOfWar(), Missile::DrawMissile(), DrawPieMenu(), DrawVisibleRectangleCursor(), EditorCallbackMouse(), FinishViewportModeConfiguration(), GetViewport(), IsInsideMapArea(), CUnit::IsVisibleInViewport(), Map2ViewportX(), MapPixel2Viewport(), RestrictCursorToViewport(), Set(), SetViewportModeQuad(), SetViewportModeSingle(), SetViewportModeSplitHoriz(), SetViewportModeSplitHoriz3(), SetViewportModeSplitVert(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UISelectStateButtonDown(), and Viewport2MapX().
| int CViewport::Y |
Screen pixel upper corner y coordinate.
Definition at line 183 of file ui.h.
Referenced by Center(), ClipViewport(), Draw(), DrawBorder(), DrawBuildingCursor(), DrawCursor(), DrawMapBackgroundInViewport(), DrawMapCursor(), DrawMapFogOfWar(), Missile::DrawMissile(), DrawPieMenu(), DrawVisibleRectangleCursor(), EditorCallbackMouse(), FinishViewportModeConfiguration(), GetViewport(), IsInsideMapArea(), CUnit::IsVisibleInViewport(), Map2ViewportY(), MapPixel2Viewport(), RestrictCursorToViewport(), Set(), SetViewportModeQuad(), SetViewportModeSingle(), SetViewportModeSplitHoriz(), SetViewportModeSplitHoriz3(), SetViewportModeSplitVert(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UISelectStateButtonDown(), and Viewport2MapY().
| int CViewport::EndX |
Screen pixel right x coordinate.
Definition at line 184 of file ui.h.
Referenced by Center(), ClipViewport(), Draw(), DrawBorder(), DrawBuildingCursor(), DrawMapCursor(), DrawMapFogOfWar(), DrawPieMenu(), DrawVisibleRectangleCursor(), EditorCallbackMouse(), FinishViewportModeConfiguration(), CUnit::IsVisibleInViewport(), RestrictCursorToViewport(), Set(), SetViewportModeQuad(), SetViewportModeSplitHoriz3(), SetViewportModeSplitVert(), and UIHandleMouseMove().
| int CViewport::EndY |
Screen pixel bottom y coordinate.
Definition at line 185 of file ui.h.
Referenced by Center(), ClipViewport(), Draw(), DrawBorder(), DrawBuildingCursor(), DrawMapCursor(), DrawMapFogOfWar(), DrawPieMenu(), DrawVisibleRectangleCursor(), EditorCallbackMouse(), FinishViewportModeConfiguration(), CUnit::IsVisibleInViewport(), RestrictCursorToViewport(), Set(), SetViewportModeQuad(), SetViewportModeSplitHoriz(), SetViewportModeSplitHoriz3(), and UIHandleMouseMove().
| int CViewport::MapX |
Map tile left corner x coordinate.
Definition at line 187 of file ui.h.
Referenced by AnyMapAreaVisibleInViewport(), CalculateStereo(), CclDefineViewports(), DoScrollArea(), DrawBuildingCursor(), DrawCursor(), DrawMapBackgroundInViewport(), DrawMapFogOfWar(), Missile::DrawMissile(), EditorCallbackMouse(), EditorUpdateDisplay(), FindAndSortUnits(), FinishViewportModeConfiguration(), IsInsideMapArea(), CUnit::IsVisibleInViewport(), Map2ViewportX(), MapPixel2Viewport(), MouseScrollMap(), PlayMissileSound(), SaveViewports(), SelectUnitsByType(), Set(), ToggleUnitsByType(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UiSaveMapPosition(), UISelectStateButtonDown(), UpdateDisplay(), ViewPointDistance(), ViewPointDistanceToUnit(), and Viewport2MapX().
| int CViewport::MapY |
Map tile upper corner y coordinate.
Definition at line 188 of file ui.h.
Referenced by AnyMapAreaVisibleInViewport(), CclDefineViewports(), DoScrollArea(), DrawBuildingCursor(), DrawCursor(), DrawMapBackgroundInViewport(), DrawMapFogOfWar(), Missile::DrawMissile(), EditorCallbackMouse(), EditorUpdateDisplay(), FindAndSortUnits(), FinishViewportModeConfiguration(), IsInsideMapArea(), CUnit::IsVisibleInViewport(), Map2ViewportY(), MapPixel2Viewport(), MouseScrollMap(), SaveViewports(), SelectUnitsByType(), Set(), ToggleUnitsByType(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UiSaveMapPosition(), UISelectStateButtonDown(), UpdateDisplay(), ViewPointDistance(), ViewPointDistanceToUnit(), and Viewport2MapY().
X Offset within MapX.
Definition at line 189 of file ui.h.
Referenced by DoScrollArea(), DrawBuildingCursor(), DrawCursor(), DrawMapBackgroundInViewport(), DrawMapFogOfWar(), Missile::DrawMissile(), EditorCallbackMouse(), FinishViewportModeConfiguration(), IsInsideMapArea(), CUnit::IsVisibleInViewport(), Map2ViewportX(), MapPixel2Viewport(), MouseScrollMap(), Set(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UISelectStateButtonDown(), and Viewport2MapX().
Y Offset within MapY.
Definition at line 190 of file ui.h.
Referenced by DoScrollArea(), DrawBuildingCursor(), DrawCursor(), DrawMapBackgroundInViewport(), DrawMapFogOfWar(), Missile::DrawMissile(), EditorCallbackMouse(), FinishViewportModeConfiguration(), IsInsideMapArea(), CUnit::IsVisibleInViewport(), Map2ViewportY(), MapPixel2Viewport(), MouseScrollMap(), Set(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UISelectStateButtonDown(), and Viewport2MapY().
Width in map tiles.
Definition at line 191 of file ui.h.
Referenced by AnyMapAreaVisibleInViewport(), CalculateStereo(), DoScrollArea(), DrawBuildingCursor(), CMinimap::DrawCursor(), DrawMapFogOfWar(), EditorCallbackButtonDown(), EditorCallbackMouse(), FindAndSortUnits(), PlayMissileSound(), SelectUnitsByType(), Set(), ToggleUnitsByType(), ViewPointDistance(), and ViewPointDistanceToUnit().
Height in map tiles.
Definition at line 192 of file ui.h.
Referenced by AnyMapAreaVisibleInViewport(), DoScrollArea(), DrawBuildingCursor(), CMinimap::DrawCursor(), DrawMapFogOfWar(), EditorCallbackButtonDown(), EditorCallbackMouse(), FindAndSortUnits(), SelectUnitsByType(), Set(), ToggleUnitsByType(), ViewPointDistance(), and ViewPointDistanceToUnit().
Bound to this unit.
Definition at line 194 of file ui.h.
Referenced by CclDefineViewports(), SaveViewports(), UIHandleButtonDown(), and UiTrackUnit().
1.5.6