1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D 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 //    Scorched3D 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 along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(AFX_ConsoleImpl_H__516D85F7_420B_43EB_B0BE_563DCBE1B143__INCLUDED_)
22 #define AFX_ConsoleImpl_H__516D85F7_420B_43EB_B0BE_563DCBE1B143__INCLUDED_
23 
24 #include <common/LoggerI.h>
25 #include <engine/GameStateI.h>
26 #include <GLEXT/GLFont2d.h>
27 #include <console/Console.h>
28 #include <console/ConsoleMethods.h>
29 #include <console/ConsoleLines.h>
30 #include <console/ConsoleRules.h>
31 
32 class ConsoleImpl : public GameStateI, public LoggerI, public Console
33 {
34 public:
35 	ConsoleImpl();
36 	virtual ~ConsoleImpl();
37 
38 	virtual void init();
39 
addRule(ConsoleRule * rule)40 	virtual void addRule(ConsoleRule *rule) { rules_.addRule(rule); }
removeRule(ConsoleRule * rule)41 	virtual void removeRule(ConsoleRule *rule) { rules_.removeRule(rule); }
42 
43 	virtual void addLine(bool parse, const std::string &line);
clear()44 	virtual void clear() { lines_.clear(); }
45 	virtual void help();
46 
getLines()47 	std::deque<ConsoleLine *> &getLines() { return lines_.getLines(); }
48 
49 	// Inherited from GameStateI
50 	virtual void simulate(const unsigned state, float frameTime);
51 	virtual void draw(const unsigned state);
52 	virtual void keyboardCheck(const unsigned state, float frameTime,
53 							   char *buffer, unsigned int keyState,
54 							   KeyboardHistory::HistoryElement *history, int hisCount,
55 							   bool &skipRest);
56 
57 	// Inherited from LoggerI
58 	virtual void logMessage(LoggerInfo &info);
59 
60 protected:
61 	float height_;
62 	bool opening_;
63 	bool showCursor_;
64 	GLFont2d *font_;
65 	ConsoleLines lines_;
66 	ConsoleRules rules_;
67 	ConsoleMethods methods_;
68 	std::string currentLine_;
69 	int historyPosition_;
70 	std::deque<std::string> history_;
71 
72 	void resetPositions();
73 	void drawBackdrop(float width, float top);
74 	void drawText(float width, float top);
75 };
76 
77 #endif // !defined(AFX_ConsoleImpl_H__516D85F7_420B_43EB_B0BE_563DCBE1B143__INCLUDED_)
78