22 #include "../Engine/InteractiveSurface.h" 23 #include "../Engine/FastLineClip.h" 46 static const int NUM_LANDSHADES = 48;
47 static const int NUM_SEASHADES = 72;
48 static const int NEAR_RADIUS = 25;
49 static const size_t DOGFIGHT_ZOOM = 3;
50 static const int CITY_MARKER = 8;
51 static const double ROTATE_LONGITUDE;
52 static const double ROTATE_LATITUDE;
56 double _cenLon, _cenLat, _rotLon, _rotLat, _hoverLon, _hoverLat;
57 double _craftLon, _craftLat, _craftRange;
58 size_t _zoom, _zoomOld, _zoomTexture;
61 Surface *_markers, *_countries, *_radars;
64 Timer *_blinkTimer, *_rotTimer;
65 std::list<Polygon*> _cacheLand;
67 double _radius, _radiusStep;
69 std::vector<std::vector<Cord> > _earthData;
71 std::vector<Sint16> _randomNoiseData;
73 std::vector<double> _zoomRadius;
75 bool _isMouseScrolling, _isMouseScrolled;
76 int _xBeforeMouseScrolling, _yBeforeMouseScrolling;
77 double _lonBeforeMouseScrolling, _latBeforeMouseScrolling;
78 Uint32 _mouseScrollingStartTime;
79 int _totalMouseMoveX, _totalMouseMoveY;
80 bool _mouseMovedOverThreshold;
83 void setZoom(
size_t zoom);
85 bool pointBack(
double lon,
double lat)
const;
87 double lastVisibleLat(
double lon)
const;
89 Polygon* getPolygonFromLonLat(
double lon,
double lat)
const;
91 bool targetNear(
Target* target,
int x,
int y)
const;
93 void cache(std::list<Polygon*> *polygons, std::list<Polygon*> *cache);
95 Cord getSunDirection(
double lon,
double lat)
const;
97 void drawGlobeCircle(
double lat,
double lon,
double radius,
int segments,
int frac = 1);
99 void XuLine(
Surface* surface,
Surface* src,
double x1,
double y1,
double x2,
double y2,
int shade);
101 void drawVHLine(
Surface *surface,
double lon1,
double lat1,
double lon2,
double lat2, Uint8 color);
103 void drawPath(
Surface *surface,
double lon1,
double lat1,
double lon2,
double lat2);
107 void setupRadii(
int width,
int height);
109 static Uint8 OCEAN_COLOR;
110 static bool OCEAN_SHADING;
111 static Uint8 COUNTRY_LABEL_COLOR;
112 static Uint8 LINE_COLOR;
113 static Uint8 CITY_LABEL_COLOR;
114 static Uint8 BASE_LABEL_COLOR;
117 Globe(
Game* game,
int cenX,
int cenY,
int width,
int height,
int x = 0,
int y = 0);
121 void polarToCart(
double lon,
double lat, Sint16 *x, Sint16 *y)
const;
123 void polarToCart(
double lon,
double lat,
double *x,
double *y)
const;
125 void cartToPolar(Sint16 x, Sint16 y,
double *lon,
double *lat)
const;
157 void center(
double lon,
double lat);
159 bool insideLand(
double lon,
double lat)
const;
163 std::vector<Target*>
getTargets(
int x,
int y,
bool craft)
const;
167 void setPalette(SDL_Color *colors,
int firstcolor = 0,
int ncolors = 256);
bool zoomDogfightIn()
Zooms the globe in for dogfights.
Definition: Globe.cpp:589
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void setNewBaseHoverPos(double lon, double lat)
Sets hover base position.
Definition: Globe.cpp:1187
void rotateUp()
Starts rotating the globe up.
Definition: Globe.cpp:465
A game state that receives user input and reacts accordingly.
Definition: State.h:44
void drawMarkers()
Draws all the markers over the globe.
Definition: Globe.cpp:1533
void drawFlights()
Draws the flight paths of the globe.
Definition: Globe.cpp:1467
Timer used to run code in fixed intervals.
Definition: Timer.h:35
std::vector< Target * > getTargets(int x, int y, bool craft) const
Gets all the targets near a point on the globe.
Definition: Globe.cpp:699
Surface that the user can interact with.
Definition: InteractiveSurface.h:37
void drawDetail()
Draws the country details of the globe.
Definition: Globe.cpp:1238
void mouseRelease(Action *action, State *state)
Special handling for mouse releases.
Definition: Globe.cpp:1706
void blit(Surface *surface)
Blits the globe onto another surface.
Definition: Globe.cpp:1581
Interactive globe view of the world.
Definition: Globe.h:43
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.
Definition: Globe.cpp:260
void mousePress(Action *action, State *state)
Special handling for mouse presses.
Definition: Globe.cpp:1678
void cartToPolar(Sint16 x, Sint16 y, double *lon, double *lat) const
Converts cartesian coordinates to polar coordinates.
Definition: Globe.cpp:346
void rotateStopLon()
Stops longitude rotation of the globe.
Definition: Globe.cpp:493
void toggleDetail()
Turns on/off the globe detail.
Definition: Globe.cpp:665
void keyboardPress(Action *action, State *state)
Special handling for key presses.
Definition: Globe.cpp:1799
void drawLand()
Draws the land of the globe.
Definition: Globe.cpp:916
void drawOcean()
Draws the ocean of the globe.
Definition: Globe.cpp:901
bool zoomDogfightOut()
Zooms the globe out for dogfights.
Definition: Globe.cpp:614
void toggleRadarLines()
set the _radarLines variable
Definition: Globe.cpp:1844
void center(double lon, double lat)
Centers the globe on a point.
Definition: Globe.cpp:641
void rotateLeft()
Starts rotating the globe left.
Definition: Globe.cpp:447
Container of a set of surfaces.
Definition: SurfaceSet.h:35
void draw()
Draws the whole globe.
Definition: Globe.cpp:881
void polarToCart(double lon, double lat, Sint16 *x, Sint16 *y) const
Converts polar coordinates to cartesian coordinates.
Definition: Globe.cpp:323
void zoomIn()
Zooms the globe in.
Definition: Globe.cpp:536
Fast line clip.
Definition: FastLineClip.h:25
void mouseClick(Action *action, State *state)
Special handling for mouse clicks.
Definition: Globe.cpp:1727
void drawRadars()
Draws the radar ranges of the globe.
Definition: Globe.cpp:1069
bool insideLand(double lon, double lat) const
Checks if a point is inside land.
Definition: Globe.cpp:656
void rotateDown()
Starts rotating the globe down.
Definition: Globe.cpp:474
~Globe()
Cleans up the globe.
Definition: Globe.cpp:298
Represents a polygon in the world map.
Definition: Polygon.h:31
void mouseOver(Action *action, State *state)
Special handling for mouse hover.
Definition: Globe.cpp:1594
void cachePolygons()
Caches visible globe polygons.
Definition: Globe.cpp:769
void rotateStop()
Stops rotating the globe.
Definition: Globe.cpp:483
void zoomOut()
Zooms the globe out.
Definition: Globe.cpp:547
void zoomMin()
Zooms the globe minimum.
Definition: Globe.cpp:558
Represents the contents of the Geoscape globe, such as world polygons, polylines, etc...
Definition: RuleGlobe.h:36
void drawShadow()
Draws the shadow.
Definition: Globe.cpp:990
void stopScrolling(Action *action)
Move the mouse back to where it started after we finish drag scrolling.
Definition: Globe.cpp:1910
void rotateStopLat()
Stops latitude rotation of the globe.
Definition: Globe.cpp:505
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the palette of the globe.
Definition: Globe.cpp:827
void rotateRight()
Starts rotating the globe right.
Definition: Globe.cpp:456
void blink()
Blinks the markers.
Definition: Globe.cpp:851
The core of the game engine, manages the game's entire contents and structure.
Definition: Game.h:41
size_t getZoom() const
Gets the current zoom.
Definition: Globe.cpp:1836
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
void rotate()
Rotates the globe.
Definition: Globe.cpp:869
void getPolygonTextureAndShade(double lon, double lat, int *texture, int *shade) const
Get the polygons texture and shade at the given point.
Definition: Globe.cpp:1819
void think()
Handles the timers.
Definition: Globe.cpp:842
void saveZoomDogfight()
Saves the zoom level for dogfights.
Definition: Globe.cpp:580
void resize()
Update the resolution settings, we just resized the window.
Definition: Globe.cpp:1853
Definition: BaseInfoState.cpp:40
void zoomMax()
Zooms the globe maximum.
Definition: Globe.cpp:569
void setCraftRange(double lon, double lat, double range)
Sets craft range mode.
Definition: Globe.cpp:1916
void setNewBaseHover(bool hover)
Turns on new base hover mode.
Definition: Globe.cpp:1182