|
@@ -1,10 +1,9 @@
|
|
|
-#include "core/Console.h"
|
|
|
|
|
-
|
|
|
|
|
#include <OgreRenderWindow.h>
|
|
#include <OgreRenderWindow.h>
|
|
|
|
|
|
|
|
#include "common/QGearsApplication.h"
|
|
#include "common/QGearsApplication.h"
|
|
|
#include "core/ConfigCmdManager.h"
|
|
#include "core/ConfigCmdManager.h"
|
|
|
#include "core/ConfigVarManager.h"
|
|
#include "core/ConfigVarManager.h"
|
|
|
|
|
+#include "core/Console.h"
|
|
|
#include "core/DebugDraw.h"
|
|
#include "core/DebugDraw.h"
|
|
|
#include "core/Logger.h"
|
|
#include "core/Logger.h"
|
|
|
#include "core/ScriptManager.h"
|
|
#include "core/ScriptManager.h"
|
|
@@ -13,67 +12,61 @@
|
|
|
#include <OgreFontManager.h>
|
|
#include <OgreFontManager.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
-template<>Console *Ogre::Singleton< Console >::msSingleton = NULL;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-ConfigVar cv_console_notification( "console_notification", "Draw console strings even when console is hided", "false" );
|
|
|
|
|
-
|
|
|
|
|
|
|
+template<>Console *Ogre::Singleton<Console>::msSingleton = nullptr;
|
|
|
|
|
+ConfigVar cv_console_notification("console_notification", "Draw console strings even when console is hided", "false");
|
|
|
|
|
|
|
|
|
|
|
|
|
Console::Console():
|
|
Console::Console():
|
|
|
- m_ToVisible( false ),
|
|
|
|
|
- m_Visible( false ),
|
|
|
|
|
- m_Height( 0 ),
|
|
|
|
|
|
|
+ m_ToVisible(false),
|
|
|
|
|
+ m_Visible(false),
|
|
|
|
|
+ m_Height(0),
|
|
|
|
|
|
|
|
- m_MaxOutputLine( 128 ),
|
|
|
|
|
- m_DisplayLine( 0 ),
|
|
|
|
|
- m_InputLine( "" ),
|
|
|
|
|
- m_CursorPosition( 0 ),
|
|
|
|
|
- m_CursorBlinkTime( 0 ),
|
|
|
|
|
|
|
+ m_MaxOutputLine(128),
|
|
|
|
|
+ m_DisplayLine(0),
|
|
|
|
|
+ m_InputLine(""),
|
|
|
|
|
+ m_CursorPosition(0),
|
|
|
|
|
+ m_CursorBlinkTime(0),
|
|
|
|
|
|
|
|
- m_HistoryLine( -1 ),
|
|
|
|
|
- m_HistorySize( 32 ),
|
|
|
|
|
|
|
+ m_HistoryLine(-1),
|
|
|
|
|
+ m_HistorySize(32),
|
|
|
|
|
|
|
|
- m_AutoCompletitionLine( 0 )
|
|
|
|
|
|
|
+ m_AutoCompletitionLine(0)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- Ogre::FontPtr font = Ogre::FontManager::getSingleton().getByName( "CourierNew" );
|
|
|
|
|
- if( font.isNull() == false )
|
|
|
|
|
|
|
+ Ogre::FontPtr font = Ogre::FontManager::getSingleton().getByName("CourierNew");
|
|
|
|
|
+ if(font.isNull() == false)
|
|
|
{
|
|
{
|
|
|
- m_LetterWidth = static_cast<int>(font->getGlyphAspectRatio( '_' ) * 16);
|
|
|
|
|
|
|
+ m_LetterWidth = static_cast<int>(font->getGlyphAspectRatio('_') * 16);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- LOG_ERROR( "Console::frameStarted: Font for console not found." );
|
|
|
|
|
|
|
+ LOG_ERROR("Console::frameStarted: Font for console not found.");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// calculate width and height of console depending on size of application
|
|
// calculate width and height of console depending on size of application
|
|
|
- Ogre::RenderTarget *render_target( QGears::Application::getSingleton().getRenderWindow() );
|
|
|
|
|
|
|
+ Ogre::RenderTarget *render_target(QGears::Application::getSingleton().getRenderWindow());
|
|
|
m_ConsoleWidth = render_target->getWidth();
|
|
m_ConsoleWidth = render_target->getWidth();
|
|
|
m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
|
|
m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
|
|
|
- m_LineWidth = ( m_ConsoleWidth - 20 ) / 8;
|
|
|
|
|
|
|
+ m_LineWidth = (m_ConsoleWidth - 20) / 8;
|
|
|
|
|
|
|
|
- LOG_TRIVIAL( "Created console width " + Ogre::StringConverter::toString( m_ConsoleWidth ) + ", height " + Ogre::StringConverter::toString( m_ConsoleHeight ) );
|
|
|
|
|
|
|
+ LOG_TRIVIAL("Created console width " + Ogre::StringConverter::toString(m_ConsoleWidth) + ", height " + Ogre::StringConverter::toString(m_ConsoleHeight));
|
|
|
|
|
|
|
|
// add as frame and log listner
|
|
// add as frame and log listner
|
|
|
- Ogre::LogManager::getSingleton().getDefaultLog()->addListener( this );
|
|
|
|
|
|
|
+ Ogre::LogManager::getSingleton().getDefaultLog()->addListener(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
Console::~Console()
|
|
Console::~Console()
|
|
|
{
|
|
{
|
|
|
// remove as listner
|
|
// remove as listner
|
|
|
- Ogre::LogManager::getSingleton().getDefaultLog()->removeListener( this );
|
|
|
|
|
|
|
+ Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::Input(const QGears::Event& event)
|
|
Console::Input(const QGears::Event& event)
|
|
|
{
|
|
{
|
|
|
- if( m_Visible != true )
|
|
|
|
|
|
|
+ if(m_Visible != true)
|
|
|
{
|
|
{
|
|
|
// add console
|
|
// add console
|
|
|
if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
|
|
if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
|
|
@@ -87,23 +80,23 @@ Console::Input(const QGears::Event& event)
|
|
|
// input command
|
|
// input command
|
|
|
else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_RETURN && m_InputLine.size())
|
|
else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_RETURN && m_InputLine.size())
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
|
|
|
|
|
|
|
+ m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- AddTextToOutput( m_InputLine );
|
|
|
|
|
|
|
+ AddTextToOutput(m_InputLine);
|
|
|
AddInputToHistory();
|
|
AddInputToHistory();
|
|
|
|
|
|
|
|
// backslashed text are console commands, otherwise - script commands
|
|
// backslashed text are console commands, otherwise - script commands
|
|
|
- if( '\\' == m_InputLine[ 0 ] || '/' == m_InputLine[ 0 ] )
|
|
|
|
|
|
|
+ if('\\' == m_InputLine[0] || '/' == m_InputLine[0])
|
|
|
{
|
|
{
|
|
|
- if( m_InputLine.size() > 1 )
|
|
|
|
|
|
|
+ if(m_InputLine.size() > 1)
|
|
|
{
|
|
{
|
|
|
// remove backslash
|
|
// remove backslash
|
|
|
- m_InputLine.erase( 0, 1 );
|
|
|
|
|
|
|
+ m_InputLine.erase(0, 1);
|
|
|
|
|
|
|
|
- ExecuteCommand( m_InputLine );
|
|
|
|
|
|
|
+ ExecuteCommand(m_InputLine);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -127,7 +120,7 @@ Console::Input(const QGears::Event& event)
|
|
|
// history up
|
|
// history up
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_UP)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_UP)
|
|
|
{
|
|
{
|
|
|
- if( m_HistoryLine < ( int )m_History.size() - 1 )
|
|
|
|
|
|
|
+ if(m_HistoryLine < (int)m_History.size() - 1)
|
|
|
{
|
|
{
|
|
|
++m_HistoryLine;
|
|
++m_HistoryLine;
|
|
|
SetInputLineFromHistory();
|
|
SetInputLineFromHistory();
|
|
@@ -136,7 +129,7 @@ Console::Input(const QGears::Event& event)
|
|
|
// history down
|
|
// history down
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_DOWN)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_DOWN)
|
|
|
{
|
|
{
|
|
|
- if( m_HistoryLine > 0 )
|
|
|
|
|
|
|
+ if(m_HistoryLine > 0)
|
|
|
{
|
|
{
|
|
|
--m_HistoryLine;
|
|
--m_HistoryLine;
|
|
|
SetInputLineFromHistory();
|
|
SetInputLineFromHistory();
|
|
@@ -145,7 +138,7 @@ Console::Input(const QGears::Event& event)
|
|
|
// scroll display to previous row
|
|
// scroll display to previous row
|
|
|
else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 > 0)
|
|
else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 > 0)
|
|
|
{
|
|
{
|
|
|
- if( m_DisplayLine > 0 )
|
|
|
|
|
|
|
+ if(m_DisplayLine > 0)
|
|
|
{
|
|
{
|
|
|
m_DisplayLine -= 1;
|
|
m_DisplayLine -= 1;
|
|
|
}
|
|
}
|
|
@@ -153,7 +146,7 @@ Console::Input(const QGears::Event& event)
|
|
|
// scroll display to next row
|
|
// scroll display to next row
|
|
|
else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 < 0)
|
|
else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 < 0)
|
|
|
{
|
|
{
|
|
|
- if( m_DisplayLine < m_OutputLine.size() )
|
|
|
|
|
|
|
+ if(m_DisplayLine < m_OutputLine.size())
|
|
|
{
|
|
{
|
|
|
m_DisplayLine += 1;
|
|
m_DisplayLine += 1;
|
|
|
}
|
|
}
|
|
@@ -162,7 +155,7 @@ Console::Input(const QGears::Event& event)
|
|
|
// scroll display to previous row
|
|
// scroll display to previous row
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_PGUP)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_PGUP)
|
|
|
{
|
|
{
|
|
|
- if( m_DisplayLine > 0 )
|
|
|
|
|
|
|
+ if(m_DisplayLine > 0)
|
|
|
{
|
|
{
|
|
|
m_DisplayLine -= 1;
|
|
m_DisplayLine -= 1;
|
|
|
}
|
|
}
|
|
@@ -170,7 +163,7 @@ Console::Input(const QGears::Event& event)
|
|
|
// scroll display to next row
|
|
// scroll display to next row
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_PGDOWN)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_PGDOWN)
|
|
|
{
|
|
{
|
|
|
- if( m_DisplayLine < m_OutputLine.size() )
|
|
|
|
|
|
|
+ if(m_DisplayLine < m_OutputLine.size())
|
|
|
{
|
|
{
|
|
|
m_DisplayLine += 1;
|
|
m_DisplayLine += 1;
|
|
|
}
|
|
}
|
|
@@ -178,30 +171,30 @@ Console::Input(const QGears::Event& event)
|
|
|
// delete character after cursor
|
|
// delete character after cursor
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_DELETE)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_DELETE)
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- if( m_InputLine.size() > 0 && m_CursorPosition < m_InputLine.size() )
|
|
|
|
|
|
|
+ if(m_InputLine.size() > 0 && m_CursorPosition < m_InputLine.size())
|
|
|
{
|
|
{
|
|
|
- m_InputLine.erase( m_CursorPosition, 1 );
|
|
|
|
|
|
|
+ m_InputLine.erase(m_CursorPosition, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// delete character before cursor
|
|
// delete character before cursor
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_BACK)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_BACK)
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- if( m_CursorPosition > 0 )
|
|
|
|
|
|
|
+ if(m_CursorPosition > 0)
|
|
|
{
|
|
{
|
|
|
- m_InputLine.erase( m_CursorPosition - 1, 1 );
|
|
|
|
|
|
|
+ m_InputLine.erase(m_CursorPosition - 1, 1);
|
|
|
--m_CursorPosition;
|
|
--m_CursorPosition;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -209,13 +202,13 @@ Console::Input(const QGears::Event& event)
|
|
|
// move cursor to left
|
|
// move cursor to left
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_LEFT)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_LEFT)
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
|
|
|
|
|
|
|
+ m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( m_CursorPosition > 0 )
|
|
|
|
|
|
|
+ if(m_CursorPosition > 0)
|
|
|
{
|
|
{
|
|
|
--m_CursorPosition;
|
|
--m_CursorPosition;
|
|
|
}
|
|
}
|
|
@@ -223,13 +216,13 @@ Console::Input(const QGears::Event& event)
|
|
|
// move cursor to right
|
|
// move cursor to right
|
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_RIGHT)
|
|
else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_RIGHT)
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
|
|
|
|
|
|
|
+ m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( m_CursorPosition < m_InputLine.size() )
|
|
|
|
|
|
|
+ if(m_CursorPosition < m_InputLine.size())
|
|
|
{
|
|
{
|
|
|
++m_CursorPosition;
|
|
++m_CursorPosition;
|
|
|
}
|
|
}
|
|
@@ -245,18 +238,18 @@ Console::Input(const QGears::Event& event)
|
|
|
{
|
|
{
|
|
|
m_CursorPosition = 0;
|
|
m_CursorPosition = 0;
|
|
|
|
|
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
|
|
|
|
|
|
|
+ m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// move cursor to end of string
|
|
// move cursor to end of string
|
|
|
else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_END)
|
|
else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_END)
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
|
|
|
|
|
|
|
+ m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -267,12 +260,12 @@ Console::Input(const QGears::Event& event)
|
|
|
{
|
|
{
|
|
|
char legalchars[] = "ABCDEFGHIJKLMNOPQRSTUVWXUZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_=+?{[]}|\\;:'\"<>,./? ";
|
|
char legalchars[] = "ABCDEFGHIJKLMNOPQRSTUVWXUZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_=+?{[]}|\\;:'\"<>,./? ";
|
|
|
char txt = static_cast<char>(event.param2);
|
|
char txt = static_cast<char>(event.param2);
|
|
|
- for( unsigned int c = 0; c < sizeof( legalchars ) - 1; ++c )
|
|
|
|
|
|
|
+ for(unsigned int c = 0; c < sizeof(legalchars ) - 1; ++c)
|
|
|
{
|
|
{
|
|
|
- if( legalchars[ c ] == txt )
|
|
|
|
|
|
|
+ if(legalchars[c] == txt)
|
|
|
{
|
|
{
|
|
|
std::string::iterator i = m_InputLine.begin() + m_CursorPosition;
|
|
std::string::iterator i = m_InputLine.begin() + m_CursorPosition;
|
|
|
- m_InputLine.insert( i, txt );
|
|
|
|
|
|
|
+ m_InputLine.insert(i, txt);
|
|
|
++m_CursorPosition;
|
|
++m_CursorPosition;
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
break;
|
|
break;
|
|
@@ -282,138 +275,134 @@ Console::Input(const QGears::Event& event)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::Update()
|
|
Console::Update()
|
|
|
{
|
|
{
|
|
|
float delta_time = Timer::getSingleton().GetSystemTimeDelta();
|
|
float delta_time = Timer::getSingleton().GetSystemTimeDelta();
|
|
|
|
|
|
|
|
- if( m_ToVisible == true && m_Height < m_ConsoleHeight )
|
|
|
|
|
|
|
+ if(m_ToVisible == true && m_Height < m_ConsoleHeight)
|
|
|
{
|
|
{
|
|
|
|
|
+ // TODO: Convert this to a constant.
|
|
|
m_Height += delta_time * 1500;
|
|
m_Height += delta_time * 1500;
|
|
|
|
|
|
|
|
- if( m_Height >= m_ConsoleHeight )
|
|
|
|
|
|
|
+ if(m_Height >= m_ConsoleHeight)
|
|
|
{
|
|
{
|
|
|
m_Height = static_cast<float>(m_ConsoleHeight);
|
|
m_Height = static_cast<float>(m_ConsoleHeight);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if( m_ToVisible == false && m_Height > 0 )
|
|
|
|
|
|
|
+ else if(m_ToVisible == false && m_Height > 0)
|
|
|
{
|
|
{
|
|
|
m_Height -= delta_time * 1500;
|
|
m_Height -= delta_time * 1500;
|
|
|
|
|
|
|
|
- if( m_Height <= 0 )
|
|
|
|
|
|
|
+ if(m_Height <= 0)
|
|
|
{
|
|
{
|
|
|
m_Height = 0;
|
|
m_Height = 0;
|
|
|
m_Visible = false;
|
|
m_Visible = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( m_Visible == true )
|
|
|
|
|
|
|
+ if(m_Visible == true)
|
|
|
{
|
|
{
|
|
|
UpdateDraw();
|
|
UpdateDraw();
|
|
|
}
|
|
}
|
|
|
- else if( cv_console_notification.GetB() == true )
|
|
|
|
|
|
|
+ else if(cv_console_notification.GetB() == true)
|
|
|
{
|
|
{
|
|
|
UpdateNotification();
|
|
UpdateNotification();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::UpdateDraw()
|
|
Console::UpdateDraw()
|
|
|
{
|
|
{
|
|
|
float delta_time = Timer::getSingleton().GetSystemTimeDelta();
|
|
float delta_time = Timer::getSingleton().GetSystemTimeDelta();
|
|
|
|
|
|
|
|
- DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
|
|
|
|
|
- DEBUG_DRAW.SetScreenSpace( true );
|
|
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.05f, 0.06f, 0.2f, 0.95f ) );
|
|
|
|
|
- DEBUG_DRAW.SetZ( -0.5f );
|
|
|
|
|
- DEBUG_DRAW.Quad( 0.0f, 0.0f, static_cast<float>(m_ConsoleWidth), 0.0f, static_cast<float>(m_ConsoleWidth), m_Height, 0.0f, m_Height );
|
|
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.18f, 0.22f, 0.74f, 0.95f ) );
|
|
|
|
|
- DEBUG_DRAW.SetZ( -0.6f );
|
|
|
|
|
- DEBUG_DRAW.Line( 0.0f, m_Height, static_cast<float>(m_ConsoleWidth), m_Height );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
|
|
|
|
|
+ DEBUG_DRAW.SetScreenSpace(true);
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(0.05f, 0.06f, 0.2f, 0.95f));
|
|
|
|
|
+ DEBUG_DRAW.SetZ(-0.5f);
|
|
|
|
|
+ DEBUG_DRAW.Quad(0.0f, 0.0f, static_cast<float>(m_ConsoleWidth), 0.0f, static_cast<float>(m_ConsoleWidth), m_Height, 0.0f, m_Height);
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(0.18f, 0.22f, 0.74f, 0.95f));
|
|
|
|
|
+ DEBUG_DRAW.SetZ(-0.6f);
|
|
|
|
|
+ DEBUG_DRAW.Line(0.0f, m_Height, static_cast<float>(m_ConsoleWidth), m_Height);
|
|
|
|
|
|
|
|
int row = 1;
|
|
int row = 1;
|
|
|
- int rows = ( m_ConsoleHeight - 30 ) / 16;
|
|
|
|
|
|
|
+ int rows = (m_ConsoleHeight - 30) / 16;
|
|
|
int y = static_cast<int>(-m_ConsoleHeight + m_Height);
|
|
int y = static_cast<int>(-m_ConsoleHeight + m_Height);
|
|
|
int empty = rows - m_DisplayLine;
|
|
int empty = rows - m_DisplayLine;
|
|
|
- if( empty > 0 )
|
|
|
|
|
|
|
+ if(empty > 0)
|
|
|
{
|
|
{
|
|
|
y += empty * 16;
|
|
y += empty * 16;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- std::list< OutputLine >::iterator i;
|
|
|
|
|
- for( i = m_OutputLine.begin(); i != m_OutputLine.end(); ++i, ++row )
|
|
|
|
|
|
|
+ std::list<OutputLine>::iterator i;
|
|
|
|
|
+ for(i = m_OutputLine.begin(); i != m_OutputLine.end(); ++i, ++row)
|
|
|
{
|
|
{
|
|
|
- if( row > ( int )m_DisplayLine - rows && row <= ( int )m_DisplayLine )
|
|
|
|
|
|
|
+ if(row > (int)m_DisplayLine - rows && row <= (int)m_DisplayLine)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- DEBUG_DRAW.SetColour( ( *i ).colour );
|
|
|
|
|
- DEBUG_DRAW.Text( 5.0f, static_cast<float>(y), ( *i ).text );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetColour((*i).colour);
|
|
|
|
|
+ DEBUG_DRAW.Text(5.0f, static_cast<float>(y), (*i).text);
|
|
|
y += 16;
|
|
y += 16;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if( m_DisplayLine != m_OutputLine.size() )
|
|
|
|
|
|
|
+ if(m_DisplayLine != m_OutputLine.size())
|
|
|
{
|
|
{
|
|
|
Ogre::String temp = "";
|
|
Ogre::String temp = "";
|
|
|
- for( unsigned int i = 0; i < m_LineWidth; ++i )
|
|
|
|
|
|
|
+ for(unsigned int i = 0; i < m_LineWidth; ++i)
|
|
|
{
|
|
{
|
|
|
temp += "^";
|
|
temp += "^";
|
|
|
}
|
|
}
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 1.0f, 0.0f, 0.0f, 1.0f ) );
|
|
|
|
|
- DEBUG_DRAW.Text( 5.0f, static_cast<float>(y), temp );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(1.0f, 0.0f, 0.0f, 1.0f));
|
|
|
|
|
+ DEBUG_DRAW.Text(5.0f, static_cast<float>(y), temp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
m_CursorBlinkTime += delta_time;
|
|
m_CursorBlinkTime += delta_time;
|
|
|
- if( ( ( ( int )( m_CursorBlinkTime * 1000 ) ) >> 8 ) & 1 )
|
|
|
|
|
|
|
+ if((((int)(m_CursorBlinkTime * 1000)) >> 8) & 1)
|
|
|
{
|
|
{
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.88f, 0.88f, 0.88f, 1 ) );
|
|
|
|
|
- DEBUG_DRAW.Text( static_cast<float>(12 + m_CursorPosition * m_LetterWidth), static_cast<float>(-19 + m_Height), "_" );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(0.88f, 0.88f, 0.88f, 1));
|
|
|
|
|
+ DEBUG_DRAW.Text(static_cast<float>(12 + m_CursorPosition * m_LetterWidth), static_cast<float>(-19 + m_Height), "_");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
|
|
|
|
|
- DEBUG_DRAW.Text( 12, -20 + m_Height, m_InputLine);
|
|
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 0, 1, 0, 1 ) );
|
|
|
|
|
- DEBUG_DRAW.Text( static_cast<float>(12 + ( m_InputLine.size() * m_LetterWidth )), static_cast<float>(-20 + m_Height), m_AutoCompletition[ m_AutoCompletitionLine ] );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
|
|
|
|
|
+ DEBUG_DRAW.Text(12, -20 + m_Height, m_InputLine);
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(0, 1, 0, 1));
|
|
|
|
|
+ DEBUG_DRAW.Text(static_cast<float>(12 + (m_InputLine.size() * m_LetterWidth)), static_cast<float>(-20 + m_Height), m_AutoCompletition[m_AutoCompletitionLine]);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
|
|
|
|
|
- DEBUG_DRAW.Text( 12, -20 + m_Height, m_InputLine );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
|
|
|
|
|
+ DEBUG_DRAW.Text(12, -20 + m_Height, m_InputLine);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DEBUG_DRAW.SetZ( 0 );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetZ(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::UpdateNotification()
|
|
Console::UpdateNotification()
|
|
|
{
|
|
{
|
|
|
- DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
|
|
|
|
|
- DEBUG_DRAW.SetScreenSpace( true );
|
|
|
|
|
- DEBUG_DRAW.SetZ( -0.6f );
|
|
|
|
|
|
|
+ DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
|
|
|
|
|
+ DEBUG_DRAW.SetScreenSpace(true);
|
|
|
|
|
+ DEBUG_DRAW.SetZ(-0.6f);
|
|
|
|
|
|
|
|
std::list< OutputLine >::reverse_iterator i;
|
|
std::list< OutputLine >::reverse_iterator i;
|
|
|
- int y = ( m_OutputLine.size() > 10 ) ? 160 : m_OutputLine.size() * 16;
|
|
|
|
|
|
|
+ int y = (m_OutputLine.size() > 10) ? 160 : m_OutputLine.size() * 16;
|
|
|
int line = 0;
|
|
int line = 0;
|
|
|
float max_time = 3.0f;
|
|
float max_time = 3.0f;
|
|
|
|
|
|
|
|
- for( i = m_OutputLine.rbegin(); i != m_OutputLine.rend() && line < 10; ++i )
|
|
|
|
|
|
|
+ for(i = m_OutputLine.rbegin(); i != m_OutputLine.rend() && line < 10; ++i)
|
|
|
{
|
|
{
|
|
|
- float time = Timer::getSingleton().GetSystemTimeTotal() - ( *i ).time;
|
|
|
|
|
- if( time < max_time )
|
|
|
|
|
|
|
+ float time = Timer::getSingleton().GetSystemTimeTotal() - (*i).time;
|
|
|
|
|
+ if(time < max_time)
|
|
|
{
|
|
{
|
|
|
- Ogre::ColourValue colour = ( *i ).colour;
|
|
|
|
|
- colour.a = ( max_time - time ) / max_time;
|
|
|
|
|
- DEBUG_DRAW.SetColour( colour );
|
|
|
|
|
- DEBUG_DRAW.Text( 5.0f, static_cast<float>(y), ( *i ).text );
|
|
|
|
|
|
|
+ Ogre::ColourValue colour = (*i).colour;
|
|
|
|
|
+ colour.a = (max_time - time) / max_time;
|
|
|
|
|
+ DEBUG_DRAW.SetColour(colour);
|
|
|
|
|
+ DEBUG_DRAW.Text(5.0f, static_cast<float>(y), (*i).text);
|
|
|
y -= 16;
|
|
y -= 16;
|
|
|
++line;
|
|
++line;
|
|
|
}
|
|
}
|
|
@@ -421,24 +410,22 @@ Console::UpdateNotification()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::OnResize()
|
|
Console::OnResize()
|
|
|
{
|
|
{
|
|
|
// calculate width and height of console depending on size of application
|
|
// calculate width and height of console depending on size of application
|
|
|
- Ogre::RenderTarget *render_target( QGears::Application::getSingleton().getRenderWindow() );
|
|
|
|
|
|
|
+ Ogre::RenderTarget *render_target(QGears::Application::getSingleton().getRenderWindow());
|
|
|
m_ConsoleWidth = render_target->getWidth();
|
|
m_ConsoleWidth = render_target->getWidth();
|
|
|
m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
|
|
m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
|
|
|
- m_LineWidth = ( m_ConsoleWidth - 20 ) / 8;
|
|
|
|
|
|
|
+ m_LineWidth = (m_ConsoleWidth - 20) / 8;
|
|
|
|
|
|
|
|
- LOG_TRIVIAL( "Resized console width to " + Ogre::StringConverter::toString( m_ConsoleWidth ) + ", height to " + Ogre::StringConverter::toString( m_ConsoleHeight ) );
|
|
|
|
|
|
|
+ LOG_TRIVIAL("Resized console width to " + Ogre::StringConverter::toString(m_ConsoleWidth) + ", height to " + Ogre::StringConverter::toString(m_ConsoleHeight));
|
|
|
|
|
|
|
|
// update height of already opened console
|
|
// update height of already opened console
|
|
|
- m_Height = ( m_Height > m_ConsoleHeight) ? m_ConsoleHeight : m_Height;
|
|
|
|
|
|
|
+ m_Height = (m_Height > m_ConsoleHeight) ? m_ConsoleHeight : m_Height;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::SetToVisible()
|
|
Console::SetToVisible()
|
|
|
{
|
|
{
|
|
@@ -447,7 +434,6 @@ Console::SetToVisible()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::SetToHide()
|
|
Console::SetToHide()
|
|
|
{
|
|
{
|
|
@@ -455,7 +441,6 @@ Console::SetToHide()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
bool
|
|
bool
|
|
|
Console::IsVisible() const
|
|
Console::IsVisible() const
|
|
|
{
|
|
{
|
|
@@ -463,9 +448,8 @@ Console::IsVisible() const
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
-Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& colour )
|
|
|
|
|
|
|
+Console::AddTextToOutput(const Ogre::String& text, const Ogre::ColourValue& colour)
|
|
|
{
|
|
{
|
|
|
// go through line and add it to output correctly
|
|
// go through line and add it to output correctly
|
|
|
const char* str = text.c_str();
|
|
const char* str = text.c_str();
|
|
@@ -473,32 +457,32 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
|
|
|
unsigned int string_size = 0;
|
|
unsigned int string_size = 0;
|
|
|
bool indent = false;
|
|
bool indent = false;
|
|
|
unsigned int c = 0;
|
|
unsigned int c = 0;
|
|
|
- for( ; c < text.size(); ++c )
|
|
|
|
|
|
|
+ for(; c < text.size(); ++c)
|
|
|
{
|
|
{
|
|
|
// add space at start of string if we want indent
|
|
// add space at start of string if we want indent
|
|
|
- if( string_size == 0 && indent == true )
|
|
|
|
|
|
|
+ if(string_size == 0 && indent == true)
|
|
|
{
|
|
{
|
|
|
- output_line.push_back( ' ' );
|
|
|
|
|
|
|
+ output_line.push_back(' ');
|
|
|
++string_size;
|
|
++string_size;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( str[ c ] != '\n' )
|
|
|
|
|
|
|
+ if(str[c] != '\n')
|
|
|
{
|
|
{
|
|
|
- output_line.push_back( str[ c ] );
|
|
|
|
|
|
|
+ output_line.push_back(str[c]);
|
|
|
++string_size;
|
|
++string_size;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( str[ c ] == '\n' || string_size >= m_LineWidth || c >= text.size() - 1 )
|
|
|
|
|
|
|
+ if(str[c] == '\n' || string_size >= m_LineWidth || c >= text.size() - 1)
|
|
|
{
|
|
{
|
|
|
// if string is larger than output size than add indent
|
|
// if string is larger than output size than add indent
|
|
|
- indent = ( string_size >= m_LineWidth ) ? true : false;
|
|
|
|
|
|
|
+ indent = (string_size >= m_LineWidth) ? true : false;
|
|
|
|
|
|
|
|
- if( m_OutputLine.size() >= m_MaxOutputLine )
|
|
|
|
|
|
|
+ if(m_OutputLine.size() >= m_MaxOutputLine)
|
|
|
{
|
|
{
|
|
|
m_OutputLine.pop_front();
|
|
m_OutputLine.pop_front();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( m_OutputLine.size() == m_DisplayLine )
|
|
|
|
|
|
|
+ if(m_OutputLine.size() == m_DisplayLine)
|
|
|
{
|
|
{
|
|
|
++m_DisplayLine;
|
|
++m_DisplayLine;
|
|
|
}
|
|
}
|
|
@@ -507,7 +491,7 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
|
|
|
line.text = output_line;
|
|
line.text = output_line;
|
|
|
line.colour = colour;
|
|
line.colour = colour;
|
|
|
line.time = Timer::getSingleton().GetSystemTimeTotal();
|
|
line.time = Timer::getSingleton().GetSystemTimeTotal();
|
|
|
- m_OutputLine.push_back( line );
|
|
|
|
|
|
|
+ m_OutputLine.push_back(line);
|
|
|
|
|
|
|
|
output_line.clear();
|
|
output_line.clear();
|
|
|
string_size = 0;
|
|
string_size = 0;
|
|
@@ -515,14 +499,14 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// add one more string if text ended with \n
|
|
// add one more string if text ended with \n
|
|
|
- if( text.size() == 0 || str[ text.size() - 1 ] == '\n' )
|
|
|
|
|
|
|
+ if(text.size() == 0 || str[text.size() - 1] == '\n')
|
|
|
{
|
|
{
|
|
|
- if( m_OutputLine.size() >= m_MaxOutputLine )
|
|
|
|
|
|
|
+ if(m_OutputLine.size() >= m_MaxOutputLine)
|
|
|
{
|
|
{
|
|
|
m_OutputLine.pop_front();
|
|
m_OutputLine.pop_front();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( m_OutputLine.size() == m_DisplayLine )
|
|
|
|
|
|
|
+ if(m_OutputLine.size() == m_DisplayLine)
|
|
|
{
|
|
{
|
|
|
++m_DisplayLine;
|
|
++m_DisplayLine;
|
|
|
}
|
|
}
|
|
@@ -531,209 +515,205 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
|
|
|
line.text = "";
|
|
line.text = "";
|
|
|
line.colour = colour;
|
|
line.colour = colour;
|
|
|
line.time = Timer::getSingleton().GetSystemTimeTotal();
|
|
line.time = Timer::getSingleton().GetSystemTimeTotal();
|
|
|
- m_OutputLine.push_back( line );
|
|
|
|
|
|
|
+ m_OutputLine.push_back(line);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
-Console::ExecuteCommand( const Ogre::String& command )
|
|
|
|
|
|
|
+Console::ExecuteCommand(const Ogre::String& command)
|
|
|
{
|
|
{
|
|
|
bool handled = false;
|
|
bool handled = false;
|
|
|
-
|
|
|
|
|
- Ogre::StringVector params = StringTokenise( command );
|
|
|
|
|
|
|
+ Ogre::StringVector params = StringTokenise(command);
|
|
|
|
|
|
|
|
// is it cvar
|
|
// is it cvar
|
|
|
- ConfigVar* cvar = ConfigVarManager::getSingleton().Find( params[ 0 ] );
|
|
|
|
|
|
|
+ ConfigVar* cvar = ConfigVarManager::getSingleton().Find(params[0]);
|
|
|
|
|
|
|
|
- if( cvar != NULL )
|
|
|
|
|
|
|
+ if(cvar != nullptr)
|
|
|
{
|
|
{
|
|
|
handled = true;
|
|
handled = true;
|
|
|
|
|
|
|
|
- if( params.size() > 1 )
|
|
|
|
|
|
|
+ if(params.size() > 1)
|
|
|
{
|
|
{
|
|
|
- cvar->SetS( params[ 1 ] );
|
|
|
|
|
|
|
+ cvar->SetS(params[1]);
|
|
|
|
|
|
|
|
- AddTextToOutput( params[ 0 ] + " changed to \"" + params[ 1 ] + "\".\n" );
|
|
|
|
|
|
|
+ AddTextToOutput(params[0] + " changed to \"" + params[1] + "\".\n");
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- AddTextToOutput( params[ 0 ] + " = \"" + cvar->GetS() + "\".\n" +
|
|
|
|
|
|
|
+ AddTextToOutput(params[0] + " = \"" + cvar->GetS() + "\".\n" +
|
|
|
" default:\"" + cvar->GetDefaultValue() + "\".\n" +
|
|
" default:\"" + cvar->GetDefaultValue() + "\".\n" +
|
|
|
" description: " + cvar->GetDescription() + ".\n" );
|
|
" description: " + cvar->GetDescription() + ".\n" );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( handled == false )
|
|
|
|
|
|
|
+ if(handled == false)
|
|
|
{
|
|
{
|
|
|
// handle command
|
|
// handle command
|
|
|
- ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
|
|
|
|
|
- if( cmd != NULL )
|
|
|
|
|
|
|
+ ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
|
|
|
|
|
+ if(cmd != nullptr)
|
|
|
{
|
|
{
|
|
|
- cmd->GetHandler()( params );
|
|
|
|
|
|
|
+ cmd->GetHandler()(params);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- AddTextToOutput( "Can't find command \"" + params[ 0 ] + "\".\n" );
|
|
|
|
|
|
|
+ AddTextToOutput("Can't find command \"" + params[0] + "\".\n");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::ExecuteScript()
|
|
Console::ExecuteScript()
|
|
|
{
|
|
{
|
|
|
- ScriptManager::getSingleton().RunString( m_InputLine );
|
|
|
|
|
|
|
+ ScriptManager::getSingleton().RunString(m_InputLine);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::CompleteInput()
|
|
Console::CompleteInput()
|
|
|
{
|
|
{
|
|
|
bool add_slash = false;
|
|
bool add_slash = false;
|
|
|
|
|
|
|
|
- if( m_AutoCompletition.size() == 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() == 0)
|
|
|
{
|
|
{
|
|
|
// remove backslash
|
|
// remove backslash
|
|
|
- if( m_InputLine.size() > 0 && ( '\\' == m_InputLine[ 0 ] || '/' == m_InputLine[ 0 ] ) )
|
|
|
|
|
|
|
+ if(m_InputLine.size() > 0 && ('\\' == m_InputLine[0] || '/' == m_InputLine[0]))
|
|
|
{
|
|
{
|
|
|
- m_InputLine.erase( 0, 1 );
|
|
|
|
|
|
|
+ m_InputLine.erase(0, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
size_t input_size = m_InputLine.size();
|
|
size_t input_size = m_InputLine.size();
|
|
|
|
|
|
|
|
- Ogre::StringVector params = StringTokenise( m_InputLine );
|
|
|
|
|
|
|
+ Ogre::StringVector params = StringTokenise(m_InputLine);
|
|
|
|
|
|
|
|
- if( params.size() == 0 )
|
|
|
|
|
|
|
+ if(params.size() == 0)
|
|
|
{
|
|
{
|
|
|
// add cvars
|
|
// add cvars
|
|
|
int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
|
|
int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
|
|
|
- for( int i = 0; i < num_vars; ++i )
|
|
|
|
|
|
|
+ for(int i = 0; i < num_vars; ++i)
|
|
|
{
|
|
{
|
|
|
- m_AutoCompletition.push_back( ConfigVarManager::getSingleton().GetConfigVar( i )->GetName() );
|
|
|
|
|
|
|
+ m_AutoCompletition.push_back(ConfigVarManager::getSingleton().GetConfigVar(i)->GetName());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// add commands
|
|
// add commands
|
|
|
int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
|
|
int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
|
|
|
- for( int i = 0; i < num_cmds; ++i )
|
|
|
|
|
|
|
+ for(int i = 0; i < num_cmds; ++i)
|
|
|
{
|
|
{
|
|
|
- m_AutoCompletition.push_back( ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetName() );
|
|
|
|
|
|
|
+ m_AutoCompletition.push_back(ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
add_slash = true;
|
|
add_slash = true;
|
|
|
}
|
|
}
|
|
|
- else if( params.size() == 1 )
|
|
|
|
|
|
|
+ else if(params.size() == 1)
|
|
|
{
|
|
{
|
|
|
- m_InputLine = params[ 0 ];
|
|
|
|
|
|
|
+ m_InputLine = params[0];
|
|
|
|
|
|
|
|
// add cvars
|
|
// add cvars
|
|
|
int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
|
|
int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
|
|
|
- for( int i = 0; i < num_vars; ++i )
|
|
|
|
|
|
|
+ for(int i = 0; i < num_vars; ++i)
|
|
|
{
|
|
{
|
|
|
- Ogre::String name = ConfigVarManager::getSingleton().GetConfigVar( i )->GetName();
|
|
|
|
|
- unsigned int pos = name.find( m_InputLine );
|
|
|
|
|
- if( pos == 0 )
|
|
|
|
|
|
|
+ Ogre::String name = ConfigVarManager::getSingleton().GetConfigVar(i)->GetName();
|
|
|
|
|
+ unsigned int pos = name.find(m_InputLine);
|
|
|
|
|
+ if(pos == 0)
|
|
|
{
|
|
{
|
|
|
add_slash = true;
|
|
add_slash = true;
|
|
|
|
|
|
|
|
- if( input_size != name.size() )
|
|
|
|
|
|
|
+ if(input_size != name.size())
|
|
|
{
|
|
{
|
|
|
- Ogre::String part = name.substr( input_size, name.size() - input_size );
|
|
|
|
|
- m_AutoCompletition.push_back( part );
|
|
|
|
|
|
|
+ Ogre::String part = name.substr(input_size, name.size() - input_size);
|
|
|
|
|
+ m_AutoCompletition.push_back(part);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// add commands
|
|
// add commands
|
|
|
int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
|
|
int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
|
|
|
- for( int i = 0; i < num_cmds; ++i )
|
|
|
|
|
|
|
+ for(int i = 0; i < num_cmds; ++i)
|
|
|
{
|
|
{
|
|
|
- Ogre::String name = ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetName();
|
|
|
|
|
|
|
+ Ogre::String name = ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName();
|
|
|
|
|
|
|
|
- int pos = name.find( m_InputLine );
|
|
|
|
|
- if( pos == 0 )
|
|
|
|
|
|
|
+ int pos = name.find(m_InputLine);
|
|
|
|
|
+ if(pos == 0)
|
|
|
{
|
|
{
|
|
|
add_slash = true;
|
|
add_slash = true;
|
|
|
|
|
|
|
|
- if( name != params[ 0 ] )
|
|
|
|
|
|
|
+ if(name != params[0])
|
|
|
{
|
|
{
|
|
|
- Ogre::String part = name.substr( input_size, name.size() - input_size );
|
|
|
|
|
- m_AutoCompletition.push_back( part );
|
|
|
|
|
|
|
+ Ogre::String part = name.substr(input_size, name.size() - input_size);
|
|
|
|
|
+ m_AutoCompletition.push_back(part);
|
|
|
}
|
|
}
|
|
|
- else if( ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetCompletion() != NULL )
|
|
|
|
|
|
|
+ else if(ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion() != nullptr)
|
|
|
{
|
|
{
|
|
|
m_InputLine += " ";
|
|
m_InputLine += " ";
|
|
|
- ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetCompletion()( m_AutoCompletition );
|
|
|
|
|
|
|
+ ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion()(m_AutoCompletition);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if( params.size() > 1 )
|
|
|
|
|
|
|
+ else if(params.size() > 1)
|
|
|
{
|
|
{
|
|
|
- Ogre::String all_params = params[ 1 ];
|
|
|
|
|
|
|
+ Ogre::String all_params = params[1];
|
|
|
|
|
|
|
|
- for( size_t i = 2; i < params.size(); ++i )
|
|
|
|
|
|
|
+ for(size_t i = 2; i < params.size(); ++i)
|
|
|
{
|
|
{
|
|
|
- all_params += " " + params[ i ];
|
|
|
|
|
|
|
+ all_params += " " + params[i];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// add commands arguments
|
|
// add commands arguments
|
|
|
- ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
|
|
|
|
|
- if( cmd != NULL )
|
|
|
|
|
|
|
+ ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
|
|
|
|
|
+ if(cmd != nullptr)
|
|
|
{
|
|
{
|
|
|
add_slash = true;
|
|
add_slash = true;
|
|
|
|
|
|
|
|
- if( cmd->GetCompletion() != NULL )
|
|
|
|
|
|
|
+ if(cmd->GetCompletion() != nullptr)
|
|
|
{
|
|
{
|
|
|
Ogre::StringVector full_complete;
|
|
Ogre::StringVector full_complete;
|
|
|
- cmd->GetCompletion()( full_complete );
|
|
|
|
|
- if( full_complete.size() > 0 )
|
|
|
|
|
|
|
+ cmd->GetCompletion()(full_complete);
|
|
|
|
|
+ if(full_complete.size() > 0)
|
|
|
{
|
|
{
|
|
|
- std::sort( full_complete.begin(), full_complete.end() );
|
|
|
|
|
|
|
+ std::sort(full_complete.begin(), full_complete.end());
|
|
|
|
|
|
|
|
- for( size_t i = 0 ; i < full_complete.size(); ++i )
|
|
|
|
|
|
|
+ for(size_t i = 0 ; i < full_complete.size(); ++i)
|
|
|
{
|
|
{
|
|
|
- int pos = full_complete[ i ].find( all_params );
|
|
|
|
|
- if( pos == 0 && all_params != full_complete[ i ] )
|
|
|
|
|
|
|
+ int pos = full_complete[i].find(all_params);
|
|
|
|
|
+ if(pos == 0 && all_params != full_complete[i])
|
|
|
{
|
|
{
|
|
|
- Ogre::String part = full_complete[ i ].substr( all_params.size(), full_complete[ i ].size() - all_params.size() );
|
|
|
|
|
- m_AutoCompletition.push_back( part );
|
|
|
|
|
|
|
+ Ogre::String part = full_complete[i].substr(all_params.size(), full_complete[i].size() - all_params.size());
|
|
|
|
|
+ m_AutoCompletition.push_back(part);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- m_InputLine = params[ 0 ] + " " + all_params;
|
|
|
|
|
|
|
+ m_InputLine = params[0] + " " + all_params;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// if we found at least one match
|
|
// if we found at least one match
|
|
|
- if( add_slash == true )
|
|
|
|
|
|
|
+ if(add_slash == true)
|
|
|
{
|
|
{
|
|
|
m_InputLine = "/" + m_InputLine;
|
|
m_InputLine = "/" + m_InputLine;
|
|
|
}
|
|
}
|
|
|
m_CursorPosition = m_InputLine.size();
|
|
m_CursorPosition = m_InputLine.size();
|
|
|
|
|
|
|
|
// sort list
|
|
// sort list
|
|
|
- std::sort( m_AutoCompletition.begin(), m_AutoCompletition.end() );
|
|
|
|
|
|
|
+ std::sort(m_AutoCompletition.begin(), m_AutoCompletition.end());
|
|
|
m_AutoCompletitionLine = 0;
|
|
m_AutoCompletitionLine = 0;
|
|
|
|
|
|
|
|
- for( size_t i = 0; i < m_AutoCompletition.size(); ++i )
|
|
|
|
|
|
|
+ for(size_t i = 0; i < m_AutoCompletition.size(); ++i)
|
|
|
{
|
|
{
|
|
|
- AddTextToOutput( " " + m_InputLine + m_AutoCompletition[ i ] );
|
|
|
|
|
|
|
+ AddTextToOutput(" " + m_InputLine + m_AutoCompletition[i]);
|
|
|
}
|
|
}
|
|
|
- if( m_AutoCompletition.size() > 0 )
|
|
|
|
|
|
|
+ if(m_AutoCompletition.size() > 0)
|
|
|
{
|
|
{
|
|
|
- AddTextToOutput( "\n" );
|
|
|
|
|
|
|
+ AddTextToOutput("\n");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- if( m_AutoCompletitionLine < m_AutoCompletition.size() - 1 )
|
|
|
|
|
|
|
+ if(m_AutoCompletitionLine < m_AutoCompletition.size() - 1)
|
|
|
{
|
|
{
|
|
|
++m_AutoCompletitionLine;
|
|
++m_AutoCompletitionLine;
|
|
|
}
|
|
}
|
|
@@ -745,7 +725,6 @@ Console::CompleteInput()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::ResetAutoCompletion()
|
|
Console::ResetAutoCompletion()
|
|
|
{
|
|
{
|
|
@@ -754,31 +733,29 @@ Console::ResetAutoCompletion()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::AddInputToHistory()
|
|
Console::AddInputToHistory()
|
|
|
{
|
|
{
|
|
|
- if( m_History.size() >= m_HistorySize )
|
|
|
|
|
|
|
+ if(m_History.size() >= m_HistorySize)
|
|
|
{
|
|
{
|
|
|
m_History.pop_back();
|
|
m_History.pop_back();
|
|
|
}
|
|
}
|
|
|
- m_History.push_front( m_InputLine );
|
|
|
|
|
|
|
+ m_History.push_front(m_InputLine);
|
|
|
m_HistoryLine = -1;
|
|
m_HistoryLine = -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
Console::SetInputLineFromHistory()
|
|
Console::SetInputLineFromHistory()
|
|
|
{
|
|
{
|
|
|
ResetAutoCompletion();
|
|
ResetAutoCompletion();
|
|
|
|
|
|
|
|
- std::list< Ogre::String >::iterator i = m_History.begin();
|
|
|
|
|
- for( int count = 0; i != m_History.end(); ++i, ++count )
|
|
|
|
|
|
|
+ std::list<Ogre::String>::iterator i = m_History.begin();
|
|
|
|
|
+ for(int count = 0; i != m_History.end(); ++i, ++count)
|
|
|
{
|
|
{
|
|
|
- if( count == m_HistoryLine )
|
|
|
|
|
|
|
+ if(count == m_HistoryLine)
|
|
|
{
|
|
{
|
|
|
- m_InputLine = ( *i );
|
|
|
|
|
|
|
+ m_InputLine = (*i);
|
|
|
m_CursorPosition = m_InputLine.size();
|
|
m_CursorPosition = m_InputLine.size();
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -786,15 +763,14 @@ Console::SetInputLineFromHistory()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
void
|
|
void
|
|
|
-Console::messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String& logName, bool& skipThisMessage )
|
|
|
|
|
|
|
+Console::messageLogged(const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String& logName, bool& skipThisMessage)
|
|
|
{
|
|
{
|
|
|
Ogre::ColourValue colour = Ogre::ColourValue::White;
|
|
Ogre::ColourValue colour = Ogre::ColourValue::White;
|
|
|
- switch( ( int )lml )
|
|
|
|
|
|
|
+ switch((int)lml)
|
|
|
{
|
|
{
|
|
|
- case 2: colour = Ogre::ColourValue( 1, 1, 0, 1 ); break;
|
|
|
|
|
- case 3: colour = Ogre::ColourValue( 1, 0, 0, 1 ); break;
|
|
|
|
|
|
|
+ case 2: colour = Ogre::ColourValue(1, 1, 0, 1); break;
|
|
|
|
|
+ case 3: colour = Ogre::ColourValue(1, 0, 0, 1); break;
|
|
|
}
|
|
}
|
|
|
- AddTextToOutput( message, colour );
|
|
|
|
|
|
|
+ AddTextToOutput(message, colour);
|
|
|
}
|
|
}
|