OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
OpenXcom::Globe Class Reference

Interactive globe view of the world. More...

#include <Globe.h>

Inheritance diagram for OpenXcom::Globe:
OpenXcom::InteractiveSurface OpenXcom::Surface

Public Member Functions

 Globe (Game *game, int cenX, int cenY, int width, int height, int x=0, int y=0)
 Creates a new globe at the specified position and size. More...
 
 ~Globe ()
 Cleans up the globe. More...
 
void polarToCart (double lon, double lat, Sint16 *x, Sint16 *y) const
 Converts polar coordinates to cartesian coordinates. More...
 
void polarToCart (double lon, double lat, double *x, double *y) const
 Converts polar coordinates to cartesian coordinates.
 
void cartToPolar (Sint16 x, Sint16 y, double *lon, double *lat) const
 Converts cartesian coordinates to polar coordinates. More...
 
void setTexture (SurfaceSet *texture)
 Sets the texture set for the globe's polygons.
 
void rotateLeft ()
 Starts rotating the globe left. More...
 
void rotateRight ()
 Starts rotating the globe right. More...
 
void rotateUp ()
 Starts rotating the globe up. More...
 
void rotateDown ()
 Starts rotating the globe down. More...
 
void rotateStop ()
 Stops rotating the globe. More...
 
void rotateStopLon ()
 Stops longitude rotation of the globe. More...
 
void rotateStopLat ()
 Stops latitude rotation of the globe. More...
 
void zoomIn ()
 Zooms the globe in. More...
 
void zoomOut ()
 Zooms the globe out. More...
 
void zoomMin ()
 Zooms the globe minimum. More...
 
void zoomMax ()
 Zooms the globe maximum. More...
 
void saveZoomDogfight ()
 Saves the zoom level for dogfights. More...
 
bool zoomDogfightIn ()
 Zooms the globe in for dogfights. More...
 
bool zoomDogfightOut ()
 Zooms the globe out for dogfights. More...
 
size_t getZoom () const
 Gets the current zoom. More...
 
void center (double lon, double lat)
 Centers the globe on a point. More...
 
bool insideLand (double lon, double lat) const
 Checks if a point is inside land. More...
 
void toggleDetail ()
 Turns on/off the globe detail. More...
 
std::vector< Target * > getTargets (int x, int y, bool craft) const
 Gets all the targets near a point on the globe. More...
 
void cachePolygons ()
 Caches visible globe polygons. More...
 
void setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256)
 Sets the palette of the globe. More...
 
void think ()
 Handles the timers. More...
 
void blink ()
 Blinks the markers. More...
 
void rotate ()
 Rotates the globe. More...
 
void draw ()
 Draws the whole globe. More...
 
void drawOcean ()
 Draws the ocean of the globe. More...
 
void drawLand ()
 Draws the land of the globe. More...
 
void drawShadow ()
 Draws the shadow.
 
void drawRadars ()
 Draws the radar ranges of the globe. More...
 
void drawFlights ()
 Draws the flight paths of the globe. More...
 
void drawDetail ()
 Draws the country details of the globe. More...
 
void drawMarkers ()
 Draws all the markers over the globe. More...
 
void blit (Surface *surface)
 Blits the globe onto another surface. More...
 
void mouseOver (Action *action, State *state)
 Special handling for mouse hover. More...
 
void mousePress (Action *action, State *state)
 Special handling for mouse presses. More...
 
void mouseRelease (Action *action, State *state)
 Special handling for mouse releases. More...
 
void mouseClick (Action *action, State *state)
 Special handling for mouse clicks. More...
 
void keyboardPress (Action *action, State *state)
 Special handling for key presses. More...
 
void getPolygonTextureAndShade (double lon, double lat, int *texture, int *shade) const
 Get the polygons texture and shade at the given point. More...
 
const LocalizedTexttr (const std::string &id) const
 Get the localized text.
 
LocalizedText tr (const std::string &id, unsigned n) const
 Get the localized text.
 
void setNewBaseHoverPos (double lon, double lat)
 Sets hover base position.
 
void setNewBaseHover (void)
 Turns on new base hover mode.
 
void unsetNewBaseHover (void)
 Turns off new base hover mode.
 
bool getNewBaseHover (void)
 Gets state of base hover mode.
 
bool getShowRadar (void)
 Gets _detail variable.
 
void toggleRadarLines ()
 set the _radarLines variable
 
void resize ()
 Update the resolution settings, we just resized the window.
 
void setupRadii (int width, int height)
 Set up the radius of earth and stuff.
 
void stopScrolling (Action *action)
 Move the mouse back to where it started after we finish drag scrolling. More...
 
- Public Member Functions inherited from OpenXcom::InteractiveSurface
 InteractiveSurface (int width, int height, int x=0, int y=0)
 Creates a new interactive surface with the specified size and position. More...
 
virtual ~InteractiveSurface ()
 Cleans up the interactive surface.
 
void setVisible (bool visible)
 Sets the surface's visibility. More...
 
virtual void handle (Action *action, State *state)
 Processes any pending events. More...
 
virtual void setFocus (bool focus)
 Sets the focus of this surface. More...
 
bool isFocused () const
 Gets the focus of this surface. More...
 
virtual void unpress (State *state)
 Unpresses the surface. More...
 
void onMouseClick (ActionHandler handler, Uint8 button=SDL_BUTTON_LEFT)
 Hooks an action handler to a mouse click on the surface. More...
 
void onMousePress (ActionHandler handler, Uint8 button=0)
 Hooks an action handler to a mouse press over the surface. More...
 
void onMouseRelease (ActionHandler handler, Uint8 button=0)
 Hooks an action handler to a mouse release over the surface. More...
 
void onMouseIn (ActionHandler handler)
 Hooks an action handler to moving the mouse into the surface. More...
 
void onMouseOver (ActionHandler handler)
 Hooks an action handler to moving the mouse over the surface. More...
 
void onMouseOut (ActionHandler handler)
 Hooks an action handler to moving the mouse out of the surface. More...
 
void onKeyboardPress (ActionHandler handler, SDLKey key=SDLK_ANY)
 Hooks an action handler to pressing a key when the surface is focused. More...
 
void onKeyboardRelease (ActionHandler handler, SDLKey key=SDLK_ANY)
 Hooks an action handler to releasing a key when the surface is focused. More...
 
virtual void mouseIn (Action *action, State *state)
 Processes a mouse hover in event. More...
 
virtual void mouseOut (Action *action, State *state)
 Processes a mouse hover out event. More...
 
virtual void keyboardRelease (Action *action, State *state)
 Processes a keyboard key release event. More...
 
void setListButton ()
 Check this surface to see if it's a textlist button. More...
 
- Public Member Functions inherited from OpenXcom::Surface
 Surface (int width, int height, int x=0, int y=0, int bpp=8)
 Creates a new surface with the specified size and position. More...
 
 Surface (const Surface &other)
 Creates a new surface from an existing one. More...
 
virtual ~Surface ()
 Cleans up the surface. More...
 
void loadScr (const std::string &filename)
 Loads an X-Com SCR graphic. More...
 
void loadSpk (const std::string &filename)
 Loads an X-Com SPK graphic. More...
 
void loadBdy (const std::string &filename)
 Loads a TFTD BDY graphic. More...
 
void loadImage (const std::string &filename)
 Loads a general image file. More...
 
void clear ()
 Clears the surface's contents. More...
 
void offset (int off, int min=-1, int max=-1, int mul=1)
 Offsets the surface's colors by a set amount. More...
 
void invert (Uint8 mid)
 Inverts the surface's colors. More...
 
virtual void initText (Font *, Font *, Language *)
 Initializes the surface's various text resources.
 
void copy (Surface *surface)
 Copies a portion of another surface into this one. More...
 
void drawRect (SDL_Rect *rect, Uint8 color)
 Draws a filled rectangle on the surface. More...
 
void drawRect (Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 color)
 Draws a filled rectangle on the surface. More...
 
void drawLine (Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color)
 Draws a line on the surface. More...
 
void drawCircle (Sint16 x, Sint16 y, Sint16 r, Uint8 color)
 Draws a filled circle on the surface. More...
 
void drawPolygon (Sint16 *x, Sint16 *y, int n, Uint8 color)
 Draws a filled polygon on the surface. More...
 
void drawTexturedPolygon (Sint16 *x, Sint16 *y, int n, Surface *texture, int dx, int dy)
 Draws a textured polygon on the surface. More...
 
void drawString (Sint16 x, Sint16 y, const char *s, Uint8 color)
 Draws a string on the surface. More...
 
SDL_Color * getPalette () const
 Returns the surface's 8bpp palette. More...
 
virtual void setX (int x)
 Sets the X position of the surface. More...
 
int getX () const
 Returns the position of the surface in the X axis. More...
 
virtual void setY (int y)
 Sets the Y position of the surface. More...
 
int getY () const
 Returns the position of the surface in the Y axis. More...
 
void setVisible (bool visible)
 Sets the surface's visibility. More...
 
bool getVisible () const
 Gets the surface's visibility. More...
 
void resetCrop ()
 Resets the cropping rectangle for the surface. More...
 
SDL_Rect * getCrop ()
 Gets the cropping rectangle for the surface. More...
 
void setPixel (int x, int y, Uint8 pixel)
 Changes the color of a pixel in the surface, relative to the top-left corner of the surface. More...
 
void setPixelIterative (int *x, int *y, Uint8 pixel)
 Changes the color of a pixel in the surface and returns the next pixel position. More...
 
Uint8 getPixel (int x, int y) const
 Returns the color of a specified pixel in the surface. More...
 
SDL_Surface * getSurface () const
 Returns the internal SDL_Surface for SDL calls. More...
 
int getWidth () const
 Returns the width of the surface. More...
 
virtual void setWidth (int width)
 Sets the width of the surface. More...
 
int getHeight () const
 Returns the height of the surface. More...
 
virtual void setHeight (int height)
 Sets the height of the surface. More...
 
void setHidden (bool hidden)
 Sets the surface's special hidden flag. More...
 
void lock ()
 Locks the surface. More...
 
void unlock ()
 Unlocks the surface. More...
 
void blitNShade (Surface *surface, int x, int y, int off, bool half=false, int newBaseColor=0)
 Specific blit function to blit battlescape terrain data in different shades in a fast way. More...
 
void invalidate ()
 Invalidate the surface: force it to be redrawn. More...
 
std::string getTooltip () const
 Gets the tooltip of the surface. More...
 
void setTooltip (const std::string &tooltip)
 Sets the tooltip of the surface. More...
 

Static Public Member Functions

static void loadDat (const std::string &filename, std::list< Polygon * > *polygons)
 Loads a set of polygons from a DAT file. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OpenXcom::InteractiveSurface
bool isButtonPressed (Uint8 button=0)
 Is this mouse button pressed?
 
virtual bool isButtonHandled (Uint8 button=0)
 Is this mouse button event handled?
 
void setButtonPressed (Uint8 button, bool pressed)
 Set a mouse button's internal state.
 
- Protected Member Functions inherited from OpenXcom::Surface
void resize (int width, int height)
 Recreates the surface with a new size. More...
 

Detailed Description

Interactive globe view of the world.

Takes a flat world map made out of land polygons with polar coordinates and renders it as a 3D-looking globe with cartesian coordinates that the player can interact with.

Constructor & Destructor Documentation

OpenXcom::Globe::Globe ( Game game,
int  cenX,
int  cenY,
int  width,
int  height,
int  x = 0,
int  y = 0 
)

Creates a new globe at the specified position and size.

Sets up a globe with the specified size and position.

Parameters
gamePointer to core game.
cenXX position of the center of the globe.
cenYY position of the center of the globe.
widthWidth in pixels.
heightHeight in pixels.
xX position in pixels.
yY position in pixels.
OpenXcom::Globe::~Globe ( )

Cleans up the globe.

Deletes the contained surfaces.

Member Function Documentation

void OpenXcom::Globe::blink ( )

Blinks the markers.

Makes the globe markers blink.

void OpenXcom::Globe::blit ( Surface surface)
virtual

Blits the globe onto another surface.

Parameters
surfacePointer to another surface.

Reimplemented from OpenXcom::Surface.

void OpenXcom::Globe::cachePolygons ( )

Caches visible globe polygons.

Takes care of pre-calculating all the polygons currently visible on the globe and caching them so they only need to be recalculated when the globe is actually moved.

void OpenXcom::Globe::cartToPolar ( Sint16  x,
Sint16  y,
double *  lon,
double *  lat 
) const

Converts cartesian coordinates to polar coordinates.

Converts a cartesian point into a polar point for mapping a globe click onto the flat world map.

Parameters
xX position of the cartesian point.
yY position of the cartesian point.
lonPointer to the output longitude.
latPointer to the output latitude.
void OpenXcom::Globe::center ( double  lon,
double  lat 
)

Centers the globe on a point.

Rotates the globe to center on a certain polar point on the world map.

Parameters
lonLongitude of the point.
latLatitude of the point.
void OpenXcom::Globe::draw ( )
virtual

Draws the whole globe.

Draws the whole globe, part by part.

Reimplemented from OpenXcom::Surface.

void OpenXcom::Globe::drawDetail ( )

Draws the country details of the globe.

Draws the details of the countries on the globe, based on the current zoom level.

void OpenXcom::Globe::drawFlights ( )

Draws the flight paths of the globe.

Draws the flight paths of player craft flying on the globe.

void OpenXcom::Globe::drawLand ( )

Draws the land of the globe.

Renders the land, taking all the visible world polygons and texturing and shading them accordingly.

void OpenXcom::Globe::drawMarkers ( )

Draws all the markers over the globe.

Draws the markers of all the various things going on around the world on top of the globe.

void OpenXcom::Globe::drawOcean ( )

Draws the ocean of the globe.

Renders the ocean, shading it according to the time of day.

void OpenXcom::Globe::drawRadars ( )

Draws the radar ranges of the globe.

Draws the radar ranges of player bases on the globe.

void OpenXcom::Globe::getPolygonTextureAndShade ( double  lon,
double  lat,
int *  texture,
int *  shade 
) const

Get the polygons texture and shade at the given point.

Get the polygons texture at a given point.

Parameters
lonLongitude of the point.
latLatitude of the point.
texturepointer to texture ID returns -1 when polygon not found
shadepointer to shade

this is shade conversion from 0..31 levels of geoscape to battlescape levels 0..15

std::vector< Target * > OpenXcom::Globe::getTargets ( int  x,
int  y,
bool  craft 
) const

Gets all the targets near a point on the globe.

Returns a list of all the targets currently near a certain cartesian point over the globe.

Parameters
xX coordinate of point.
yY coordinate of point.
craftOnly get craft targets.
Returns
List of pointers to targets.
size_t OpenXcom::Globe::getZoom ( ) const

Gets the current zoom.

Checks if the globe is zoomed in to it's maximum.

Returns
Returns true if globe is at max zoom, otherwise returns false.
bool OpenXcom::Globe::insideLand ( double  lon,
double  lat 
) const

Checks if a point is inside land.

Checks if a polar point is inside the globe's landmass.

Parameters
lonLongitude of the point.
latLatitude of the point.
Returns
True if it's inside, False if it's outside.
void OpenXcom::Globe::keyboardPress ( Action action,
State state 
)
virtual

Special handling for key presses.

Handles globe keyboard shortcuts.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.

Reimplemented from OpenXcom::InteractiveSurface.

void OpenXcom::Globe::loadDat ( const std::string &  filename,
std::list< Polygon * > *  polygons 
)
static

Loads a set of polygons from a DAT file.

Loads a series of map polar coordinates in X-Com format, converts them and stores them in a set of polygons.

Parameters
filenameFilename of the DAT file.
polygonsPointer to the polygon set.
See also
http://www.ufopaedia.org/index.php?title=WORLD.DAT
void OpenXcom::Globe::mouseClick ( Action action,
State state 
)
virtual

Special handling for mouse clicks.

Ignores any mouse clicks that are outside the globe and handles globe rotation and zooming.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.

Reimplemented from OpenXcom::InteractiveSurface.

void OpenXcom::Globe::mouseOver ( Action action,
State state 
)
virtual

Special handling for mouse hover.

Ignores any mouse hovers that are outside the globe.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.

Reimplemented from OpenXcom::InteractiveSurface.

void OpenXcom::Globe::mousePress ( Action action,
State state 
)
virtual

Special handling for mouse presses.

Ignores any mouse clicks that are outside the globe.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.

Reimplemented from OpenXcom::InteractiveSurface.

void OpenXcom::Globe::mouseRelease ( Action action,
State state 
)
virtual

Special handling for mouse releases.

Ignores any mouse clicks that are outside the globe.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.

Reimplemented from OpenXcom::InteractiveSurface.

void OpenXcom::Globe::polarToCart ( double  lon,
double  lat,
Sint16 *  x,
Sint16 *  y 
) const

Converts polar coordinates to cartesian coordinates.

Converts a polar point into a cartesian point for mapping a polygon onto the 3D-looking globe.

Parameters
lonLongitude of the polar point.
latLatitude of the polar point.
xPointer to the output X position.
yPointer to the output Y position.
void OpenXcom::Globe::rotate ( )

Rotates the globe.

Rotates the globe by a set amount.

Necessary since the globe keeps rotating while a button is pressed down.

void OpenXcom::Globe::rotateDown ( )

Starts rotating the globe down.

Sets a downwards rotation speed and starts the timer.

void OpenXcom::Globe::rotateLeft ( )

Starts rotating the globe left.

Sets a leftwards rotation speed and starts the timer.

void OpenXcom::Globe::rotateRight ( )

Starts rotating the globe right.

Sets a rightwards rotation speed and starts the timer.

void OpenXcom::Globe::rotateStop ( )

Stops rotating the globe.

Resets the rotation speed and timer.

void OpenXcom::Globe::rotateStopLat ( )

Stops latitude rotation of the globe.

Resets latitude rotation speed and timer.

void OpenXcom::Globe::rotateStopLon ( )

Stops longitude rotation of the globe.

Resets longitude rotation speed and timer.

void OpenXcom::Globe::rotateUp ( )

Starts rotating the globe up.

Sets a upwards rotation speed and starts the timer.

void OpenXcom::Globe::saveZoomDogfight ( )

Saves the zoom level for dogfights.

Stores the zoom used before a dogfight.

void OpenXcom::Globe::setPalette ( SDL_Color *  colors,
int  firstcolor = 0,
int  ncolors = 256 
)
virtual

Sets the palette of the globe.

Replaces a certain amount of colors in the palette of the globe.

Parameters
colorsPointer to the set of colors.
firstcolorOffset of the first color to replace.
ncolorsAmount of colors to replace.

Reimplemented from OpenXcom::Surface.

void OpenXcom::Globe::stopScrolling ( Action action)

Move the mouse back to where it started after we finish drag scrolling.

Parameters
actionPointer to an action.
void OpenXcom::Globe::think ( )
virtual

Handles the timers.

Keeps the animation timers running.

Reimplemented from OpenXcom::Surface.

void OpenXcom::Globe::toggleDetail ( )

Turns on/off the globe detail.

Switches the amount of detail shown on the globe.

With detail on, country and city details are shown when zoomed in.

bool OpenXcom::Globe::zoomDogfightIn ( )

Zooms the globe in for dogfights.

Zooms the globe smoothly into dogfight level.

Returns
Is the globe already zoomed in?
bool OpenXcom::Globe::zoomDogfightOut ( )

Zooms the globe out for dogfights.

Zooms the globe smoothly out of dogfight level.

Returns
Is the globe already zoomed out?
void OpenXcom::Globe::zoomIn ( )

Zooms the globe in.

Increases the zoom level on the globe.

void OpenXcom::Globe::zoomMax ( )

Zooms the globe maximum.

Zooms the globe in as close as possible.

void OpenXcom::Globe::zoomMin ( )

Zooms the globe minimum.

Zooms the globe out as far as possible.

void OpenXcom::Globe::zoomOut ( )

Zooms the globe out.

Decreases the zoom level on the globe.


The documentation for this class was generated from the following files: