Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/sound5/src/libraries/core/IOConsole.h @ 9358

Last change on this file since 9358 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
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 *      Oliver Scheuss
24 *      Reto Grieder
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30#ifndef _IOConsole_H__
31#define _IOConsole_H__
32
33#include "CorePrereqs.h"
34
35#include <sstream>
36#include <string>
37#include <vector>
38#include "util/Singleton.h"
39#include "core/Shell.h"
40
41#ifdef ORXONOX_PLATFORM_UNIX
42struct termios;
43#elif defined(ORXONOX_PLATFORM_WINDOWS)
44#define WIN32_LEAN_AND_MEAN
45#ifndef NOMINMAX
46#define NOMINMAX
47#endif
48#include <windows.h>
49#endif
50
51namespace orxonox
52{
53    class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener
54    {
55        friend class Singleton<IOConsole>;
56
57    public:
58        IOConsole();
59        ~IOConsole();
60
61        void preUpdate(const Clock& time);
62
63    private:
64        void setTerminalMode();
65        void getTerminalSize();
66        void printStatusLines();
67        static int extractLogLevel(std::string* text);
68
69        // Methods from ShellListener
70        void linesChanged();
71        void onlyLastLineChanged();
72        void lineAdded();
73        void inputChanged();
74        void cursorChanged();
75        void executed();
76        void exit();
77
78        Shell*                  shell_;
79        InputBuffer*            buffer_;
80        std::ostream            cout_;
81        std::ostringstream      origCout_;
82        int                     terminalWidth_;
83        int                     terminalHeight_;
84        int                     lastTerminalWidth_;
85        int                     lastTerminalHeight_;
86        const std::string       promptString_;
87
88#ifdef ORXONOX_PLATFORM_UNIX
89        bool willPrintStatusLines();
90        void printInputLine();
91        void printOutputLine(const std::string& line, Shell::LineType type);
92        static void resetTerminalMode();
93
94        bool                    bPrintStatusLine_;
95        bool                    bStatusPrinted_;
96        std::vector<int>        statusLineWidths_;
97        int                     statusLineMaxWidth_;
98        static const int        minOutputLines_ = 3;
99        termios*                originalTerminalSettings_;
100
101#elif defined(ORXONOX_PLATFORM_WINDOWS)
102        void resetTerminalMode();
103        void moveCursor(int dx, int dy);
104        void writeText(const std::string& text, const COORD& pos, WORD attributes = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
105        void createNewOutputLines(int lines);
106        void printOutputLine(const std::string& line, Shell::LineType type, const COORD& pos);
107
108        static inline COORD makeCOORD(int x, int y)
109        {
110            COORD val = {x, y};
111            return val;
112        }
113
114        DWORD                   originalTerminalSettings_;
115        HANDLE                  stdInHandle_;
116        HANDLE                  stdOutHandle_;
117        int                     inputLineRow_;
118        int                     inputLineHeight_;
119        const int               statusLines_;
120        int                     lastOutputLineHeight_;
121        uint64_t                lastRefreshTime_;
122#endif
123
124        static IOConsole* singletonPtr_s;
125    };
126}
127
128#endif /* _IOConsole_H__ */
Note: See TracBrowser for help on using the repository browser.