1 /***************************************************************************
2  *      Mechanized Assault and Exploration Reloaded Projectfile            *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19 
20 #ifndef ui_graphical_menu_windows_windowlandingpositionselection_windowlandingpositionselectionH
21 #define ui_graphical_menu_windows_windowlandingpositionselection_windowlandingpositionselectionH
22 
23 #include <memory>
24 
25 #include "ui/graphical/window.h"
26 #include "utility/signal/signalconnectionmanager.h"
27 #include "utility/signal/signal.h"
28 #include "game/logic/landingpositionstate.h"
29 
30 class cPushButton;
31 class cImage;
32 class cLabel;
33 class cPosition;
34 class cLandingPositionSelectionMap;
35 class cStaticMap;
36 class cAnimationTimer;
37 template<typename, typename> class cChatBox;
38 class cChatBoxLandingPlayerListViewItem;
39 class cLobbyChatBoxListViewItem;
40 
41 struct sTerrain;
42 
43 
44 class cWindowLandingPositionSelection : public cWindow
45 {
46 public:
47 	cWindowLandingPositionSelection (std::shared_ptr<cStaticMap> staticMap, bool withChatBox);
48 	~cWindowLandingPositionSelection();
49 
50 	const cPosition& getSelectedPosition() const;
51 
52 	void applyReselectionState (eLandingPositionState state);
53 
54 	void setInfoMessage (const std::string& message);
55 
56 	cChatBox<cLobbyChatBoxListViewItem, cChatBoxLandingPlayerListViewItem>* getChatBox();
57 
58 	void allowSelection();
59 	void disallowSelection();
60 
61 	void lockBack();
62 	void unlockBack();
63 
64 	cSignal<void (const cPosition&)> selectedPosition;
65 	cSignal<void ()> canceled;
66 
67 	virtual void handleActivated (cApplication& application, bool firstTime) MAXR_OVERRIDE_FUNCTION;
68 	virtual void handleDeactivated (cApplication& application, bool removed) MAXR_OVERRIDE_FUNCTION;
69 
70 	virtual bool handleMouseMoved (cApplication& application, cMouse& mouse, const cPosition& offset) MAXR_OVERRIDE_FUNCTION;
71 
72 	mutable cSignal<void ()> opened;
73 	mutable cSignal<void ()> closed;
74 private:
75 	cSignalConnectionManager signalConnectionManager;
76 	cSignalConnectionManager circleAnimationConnectionManager;
77 
78 	std::shared_ptr<cStaticMap> staticMap;
79 
80 	std::shared_ptr<cAnimationTimer> animationTimer;
81 
82 	bool selectionAllowed;
83 
84 	eLandingPositionState reselectionState;
85 
86 	cPushButton* backButton;
87 	cLabel* infoLabel;
88 	cImage* circlesImage;
89 	cChatBox<cLobbyChatBoxListViewItem, cChatBoxLandingPlayerListViewItem>* chatBox;
90 
91 	float circleAnimationState;
92 
93 	cLandingPositionSelectionMap* mapWidget;
94 
95 	cPosition lastSelectedPosition;
96 
97 	AutoSurface createHudSurface();
98 
99 	void backClicked();
100 	void mapClicked (const cPosition& tilePosition);
101 	void updateLandingPositionCircles (const cPosition& tilePosition, float radiusFactor);
102 
103 	void startCircleAnimation (const cPosition& tilePosition);
104 	void runCircleAnimation (const cPosition& tilePosition);
105 };
106 
107 #endif // ui_graphical_menu_windows_windowlandingpositionselection_windowlandingpositionselectionH
108