📄 oasisconsolesystem.h
字号:
/******************************************************************************
* This source file is part of Bad Camel Gaming
* Copyright (C) 2003 Zephie Greyvenstein
* See Readme.html for acknowledgements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/******************************************************************************
* FILENAME : oasisConsoleSystem.h
* DESCRIPTION : The console system
* AUTHOR : Zephie Greyvenstein
*****************************************************************************/
/// Avoid double inclusion
#ifndef __CONSOLESYSTEM_H__
#define __CONSOLESYSTEM_H__
/// Include the common headers
#include "oasisCommon.h"
#include "oasisFrameListener.h"
#include "oasisKeyListener.h"
#include "oasisSystem.h"
#include "oasisSingleton.h"
//////////////////////// Forward declare Ogre stuff
namespace Ogre {
class Overlay;
class GuiElement;
class TextAreaGuiElement;
};
namespace Oasis {
/// The console system for in-game scripting
class _oasisExport consoleSystem : public frameListener,
public keyListener,
public system,
public singleton< consoleSystem > {
public:
/// The console states
enum ConsoleState {
/// Open state
CS_OPEN = 0,
/// Opening state
CS_OPENING = 1,
/// Closed state
CS_CLOSED = 2,
/// Closing state
CS_CLOSING =3
};
/// Constructor
consoleSystem( );
/// Deconstructor
virtual ~consoleSystem( );
/// Get singleton
static consoleSystem &get( void );
/// Get singleton pointer
static consoleSystem *getPtr( void );
/// Reset this system
void reset( void );
/// Update this system
void update( real time );
/// Clear the console
void clear( void );
/// Get the lines count
const uint8 getLineCount( void ) const;
/// Open console
void open( void );
/// Close console
void close( void );
/// Set a line's text
void setLineText( uint8 line, const string &text );
/// Get a line's text
const string &getLineText( uint8 line ) const;
/// Write something on the console
void write( const string &text );
private:
/// Handle to the console overlay
Ogre::Overlay *consoleOverlay;
/// State of the console
ConsoleState state;
/// Cursor position
uint8 cursorPos;
/// Listener event for frame started
bool frameStarted( real time );
/// When the console is open, it processes key events
void keyClicked( KeyCode key, char keyChar ) {}
/// When the console is open, it processes key events
void keyPressed( KeyCode key, char keyChar );
/// When the console is open, it processes key events
void keyReleased( KeyCode key, char keyChar );
/// Bump text up one line
void _bumpText( void );
/// The command string
string command;
/// The last command string
string lastCommand;
/// Records if we are using the buffer
bool pressedUp;
/// A vector of textarea's
typedef std::vector< Ogre::TextAreaGuiElement* > textAreaVector;
/// The text lines
textAreaVector textLines;
/// !!! Hack until I've written gui system
Ogre::Overlay *_getOverlay( const string &overlay );
/// !!! Hack until I've written gui system
Ogre::TextAreaGuiElement *_createTextArea( const string &name );
/// !!! Hack until I've written gui system
void _addGuiElement( const string &parent, Ogre::GuiElement *child );
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -