Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/core/OutputBuffer.h @ 1402

Last change on this file since 1402 was 1322, checked in by landauf, 17 years ago

The InGameConsole is now using the new Shell. There's a clear separation between the two classes: InGameConsole implements all graphical parts of the console (and has a tick), while Shell handles the internal actions (like listening on input and output changes). That's why InGameConsole has no longer it's own InputBuffer and doesn't care about command-executing or anything else.

There are currently three new features:

  • Every output through COUT(level) is now visible in the InGameConsole, provided the configured output-level for the shell matches. default: 1 (only forced output and errors)
  • The cursor in the input-line is movable with the left and right arrow keys (home and end works too)
  • You can scroll through all output-lines by pressing page up and page down

There's another feature to come, providing a command history, accessible with up and down arrow keys, but I couldn't finish it yet, because there's still a bug, causing Orxonox to scroll through the entire memory - that's maybe a bit too much history ;)

File size: 2.9 KB
RevLine 
[1312]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _OutputBuffer_H__
30#define _OutputBuffer_H__
31
[1313]32#include <list>
[1312]33#include <sstream>
[1322]34#include <iostream>
[1312]35
36#include "CorePrereqs.h"
37
38namespace orxonox
39{
[1313]40    class _CoreExport OutputBufferListener
[1312]41    {
42        friend class OutputBuffer;
[1313]43
[1312]44        virtual void outputChanged() = 0;
45    };
46
47    class _CoreExport OutputBuffer
48    {
49        public:
[1313]50            OutputBuffer() {}
51            ~OutputBuffer() {}
[1312]52
53            template <class T>
54            inline OutputBuffer& operator<<(T object)
55            {
56                this->stream_ << object;
57                this->callListeners();
[1313]58                return *this;
[1312]59            }
60
[1322]61            OutputBuffer& operator<<(std::ostream& (*manipulator)(std::ostream&));
62            OutputBuffer& operator<<(std::ios& (*manipulator)(std::ios&));
63            OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
64
[1312]65            template <class T>
66            inline void add(T object)
67            {
68                this->stream_ << object;
69                this->callListeners();
70            }
71
72            template <class T>
73            inline void addLine(T object)
74            {
75                this->stream_ << object << std::endl;
76                this->callListeners();
77            }
78
79            inline void newline()
80            {
81                this->stream_ << std::endl;
82                this->callListeners();
83            }
84
85            inline void flush()
86            {
87                this->stream_.flush();
88            }
89
90            bool getLine(std::string* output);
91
92            void registerListener(OutputBufferListener* listener);
93            void unregisterListener(OutputBufferListener* listener);
94
95        private:
96            void callListeners();
97
98            std::stringstream stream_;
[1313]99            std::list<OutputBufferListener*> listeners_;
[1312]100    };
101}
102
103#endif /* _OutputBuffer_H__ */
Note: See TracBrowser for help on using the repository browser.