1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom.  If not, see <http:///www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_GEOSCAPESTATE_H
20 #define OPENXCOM_GEOSCAPESTATE_H
21 
22 #include "../Engine/State.h"
23 #include <list>
24 
25 namespace OpenXcom
26 {
27 
28 class Surface;
29 class Globe;
30 class TextButton;
31 class InteractiveSurface;
32 class Text;
33 class Timer;
34 class DogfightState;
35 class Ufo;
36 class TerrorSite;
37 class Base;
38 
39 /**
40  * Geoscape screen which shows an overview of
41  * the world and lets the player manage the game.
42  */
43 class GeoscapeState : public State
44 {
45 private:
46 	Surface *_bg, *_sideLine, *_sidebar;
47 	Globe *_globe;
48 	TextButton *_btnIntercept, *_btnBases, *_btnGraphs, *_btnUfopaedia, *_btnOptions, *_btnFunding;
49 	TextButton *_timeSpeed;
50 	TextButton *_btn5Secs, *_btn1Min, *_btn5Mins, *_btn30Mins, *_btn1Hour, *_btn1Day;
51 	TextButton *_sideTop, *_sideBottom;
52 	InteractiveSurface *_btnRotateLeft, *_btnRotateRight, *_btnRotateUp, *_btnRotateDown, *_btnZoomIn, *_btnZoomOut;
53 	Text *_txtFunds, *_txtHour, *_txtHourSep, *_txtMin, *_txtMinSep, *_txtSec, *_txtWeekday, *_txtDay, *_txtMonth, *_txtYear;
54 	Timer *_gameTimer, *_zoomInEffectTimer, *_zoomOutEffectTimer, *_dogfightStartTimer;
55 	bool _pause, _zoomInEffectDone, _zoomOutEffectDone;
56 	Text *_txtDebug;
57 	std::list<State*> _popups;
58 	std::list<DogfightState*> _dogfights, _dogfightsToBeStarted;
59 	size_t _minimizedDogfights;
60 public:
61 	/// Creates the Geoscape state.
62 	GeoscapeState(Game *game);
63 	/// Cleans up the Geoscape state.
64 	~GeoscapeState();
65 	/// Handle keypresses.
66 	void handle(Action *action);
67 	/// Updates the palette and timer.
68 	void init();
69 	/// Runs the timer.
70 	void think();
71 	/// Displays the game time/date. (+Funds)
72 	void timeDisplay();
73 	/// Advances the game timer.
74 	void timeAdvance();
75 	/// Trigger whenever 5 seconds pass.
76 	void time5Seconds();
77 	/// Trigger whenever 10 minutes pass.
78 	void time10Minutes();
79 	/// Trigger whenever 30 minutes pass.
80 	void time30Minutes();
81 	/// Trigger whenever 1 hour passes.
82 	void time1Hour();
83 	/// Trigger whenever 1 day passes.
84 	void time1Day();
85 	/// Trigger whenever 1 month passes.
86 	void time1Month();
87 	/// Resets the timer to minimum speed.
88 	void timerReset();
89 	/// Displays a popup window.
90 	void popup(State *state);
91 	/// Gets the Geoscape globe.
92 	Globe *getGlobe() const;
93 	/// Handler for clicking the globe.
94 	void globeClick(Action *action);
95 	/// Handler for clicking the Intercept button.
96 	void btnInterceptClick(Action *action);
97 	/// Handler for clicking the Bases button.
98 	void btnBasesClick(Action *action);
99 	/// Handler for clicking the Graph button.
100 	void btnGraphsClick(Action *action);
101 	/// Handler for clicking the Ufopaedia button.
102 	void btnUfopaediaClick(Action *action);
103 	/// Handler for clicking the Options button.
104 	void btnOptionsClick(Action *action);
105 	/// Handler for clicking the Funding button.
106 	void btnFundingClick(Action *action);
107 	/// Handler for pressing the Rotate Left arrow.
108 	void btnRotateLeftPress(Action *action);
109 	/// Handler for releasing the Rotate Left arrow.
110 	void btnRotateLeftRelease(Action *action);
111 	/// Handler for pressing the Rotate Right arrow.
112 	void btnRotateRightPress(Action *action);
113 	/// Handler for releasing the Rotate Right arrow.
114 	void btnRotateRightRelease(Action *action);
115 	/// Handler for pressing the Rotate Up arrow.
116 	void btnRotateUpPress(Action *action);
117 	/// Handler for releasing the Rotate Up arrow.
118 	void btnRotateUpRelease(Action *action);
119 	/// Handler for pressing the Rotate Down arrow.
120 	void btnRotateDownPress(Action *action);
121 	/// Handler for releasing the Rotate Down arrow.
122 	void btnRotateDownRelease(Action *action);
123 	/// Handler for left-clicking the Zoom In icon.
124 	void btnZoomInLeftClick(Action *action);
125 	/// Handler for right-clicking the Zoom In icon.
126 	void btnZoomInRightClick(Action *action);
127 	/// Handler for left-clicking the Zoom Out icon.
128 	void btnZoomOutLeftClick(Action *action);
129 	/// Handler for right-clicking the Zoom Out icon.
130 	void btnZoomOutRightClick(Action *action);
131 	/// Blit method - renders the state and dogfights.
132 	void blit();
133 	/// Globe zoom in effect for dogfights.
134 	void zoomInEffect();
135 	/// Globe zoom out effect for dogfights.
136 	void zoomOutEffect();
137 	/// Multi-dogfights logic handling.
138 	void handleDogfights();
139 	/// Gets the number of minimized dogfights.
140 	int minimizedDogfightsCount();
141 	/// Starts a new dogfight.
142 	void startDogfight();
143 	/// Get first free dogfight slot.
144 	int getFirstFreeDogfightSlot();
145 	/// Handler for clicking the timer button.
146 	void btnTimerClick(Action *action);
147 	/// Process a terror site
148 	bool processTerrorSite(TerrorSite *ts) const;
149 	/// Handles base defense
150 	void handleBaseDefense(Base *base, Ufo *ufo);
151 	/// Update the resolution settings, we just resized the window.
152 	void resize(int &dX, int &dY);
153 private:
154 	/// Handle alien mission generation.
155 	void determineAlienMissions(bool atGameStart = false);
156 	/// Handle Terror mission generation.
157 	void setupTerrorMission();
158 };
159 
160 }
161 
162 #endif
163