1 /*=============================================================================
2 Blobby Volley 2
3 Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de)
4 Copyright (C) 2006 Daniel Knobe (daniel-knobe@web.de)
5 
6 This program 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 2 of the License, or
9 (at your option) any later version.
10 
11 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 =============================================================================*/
20 
21 #pragma once
22 
23 #include "State.h"
24 
25 /*! \class GameState
26 	\brief base class for any game related state (Local, Network, Replay)
27 */
28 
29 class GameState : public State
30 {
31 public:
32 	GameState(DuelMatch* match = nullptr);
33 	virtual ~GameState();
34 
35 	// step function defines the steps actual work
36 	virtual void step_impl() = 0;
37 
38 protected:
39 
40 	/// static protected helper function that
41 	/// draws the game. It is in State because
42 	/// this functionality is shared by
43 	/// LocalGameState, NetworkGameState and ReplayState
44 	void presentGame();
45 
46 	/// this draws the ui in the game, i.e. clock, score and player names
47 	void presentGameUI();
48 
49 	// ui helpers
50 	/// this function draws the save replay ui
51 	/// it returns true if the player clicks on the OK button
52 	bool displaySaveReplayPrompt();
53 
54 	/// this function draws the error message box
55 	/// it returns true if the player clicks on the OK button
56 	bool displayErrorMessageBox();
57 
58 	/// this function draws the winning player screen
59 	/// does not display any buttons because they depend on the game type
60 	bool displayWinningPlayerScreen(PlayerSide winner);
61 
62 
63 	/// calculates the default name for a replay file
64 	void setDefaultReplayName(const std::string& left, const std::string& right);
65 
66 	/// saves the replay to the desired file
67 	void saveReplay(ReplayRecorder& recorder);
68 
69 
70 	boost::scoped_ptr<DuelMatch> mMatch;
71 
72 	// ui helper variable for storing a filename
73 	bool mSaveReplay;
74 
75 	std::string mErrorMessage;
76 private:
77 	std::string mFilename;
78 };
79