mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Added an interface to connect to the log, iLogReader. This is usefull for cConsole, and any external logger that need the internal log information.
Integrated this to cConsole. Fixed a bug in the console, now supports text with more than one line. Now the texture loading time is measured and reported in the log.
This commit is contained in:
@@ -13,13 +13,15 @@ using namespace EE::Window;
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
class EE_API cConsole{
|
||||
class EE_API cConsole : protected iLogReader {
|
||||
public:
|
||||
//! The Console Callback return a vector of parameters ( String )
|
||||
typedef cb::Callback1<void, const std::vector < String >& > ConsoleCallback;
|
||||
|
||||
cConsole( Window::cWindow * window = NULL );
|
||||
|
||||
cConsole( cFont* Font, const bool& MakeDefaultCommands = true, const bool& AttachToLog = true, const eeUint& MaxLogLines = 1024, const Uint32& TextureId = 0, Window::cWindow * window = NULL );
|
||||
|
||||
~cConsole();
|
||||
|
||||
/** Set the Console Height when it's Minimized ( Not Maximized ) */
|
||||
@@ -85,6 +87,7 @@ class EE_API cConsole{
|
||||
/** Creates the new console
|
||||
* @param Font The cFont pointer to class
|
||||
* @param MakeDefaultCommands Register the default commands provided by the class?
|
||||
* @param AttachToLog Attach the console to the cLog instance
|
||||
* @param MaxLogLines Maximun number of lines stored on the console
|
||||
* @param Background texture ( 0 if don't want a texture )
|
||||
* @param ConsoleColor The Console Background Color
|
||||
@@ -92,7 +95,7 @@ class EE_API cConsole{
|
||||
* @param FontColor The Console Font Color
|
||||
* @param FontLineColor The Console Line Font Color ( The Client Input )
|
||||
*/
|
||||
void Create( cFont* Font, const bool& MakeDefaultCommands = true, const eeUint& MaxLogLines = 1024, const Uint32& TextureId = 0 );
|
||||
void Create( cFont* Font, const bool& MakeDefaultCommands = true, const bool& AttachToLog = true, const eeUint& MaxLogLines = 1024, const Uint32& TextureId = 0 );
|
||||
|
||||
/** Add Text to Console */
|
||||
void PushText( const String& str );
|
||||
@@ -240,6 +243,8 @@ class EE_API cConsole{
|
||||
void PrintCommandsStartingWith( const String& start );
|
||||
|
||||
void PrivVideoResize();
|
||||
|
||||
void WriteLog( const std::string& Text );
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace EE { namespace Graphics {
|
||||
/** @brief This class loads texture fonts and draw strings to the screen. */
|
||||
class EE_API cTextureFont : public cFont {
|
||||
public:
|
||||
/** Creates an instance of a texture font */
|
||||
static cTextureFont * New( const std::string FontName );
|
||||
|
||||
cTextureFont( const std::string FontName );
|
||||
|
||||
/** The destructor will not unload the texture from memory. If you want that you'll have to remove it manually ( cTextureFactory::instance()->Remove( MyFontInstance->GetTexId() ) ). */
|
||||
|
||||
@@ -64,6 +64,8 @@ class EE_API cTextureLoader : public cObjectLoader {
|
||||
bool mIsDDS;
|
||||
int mIsDDSCompressed;
|
||||
|
||||
cTimeElapsed mTE;
|
||||
|
||||
void LoadFromPath();
|
||||
void LoadFromMemory();
|
||||
void LoadFromPack();
|
||||
|
||||
@@ -17,6 +17,8 @@ class EE_API cTTFFont : public cFont {
|
||||
/** Creates an instance of a true type font */
|
||||
static cTTFFont * New( const std::string FontName );
|
||||
|
||||
cTTFFont( const std::string FontName );
|
||||
|
||||
/** The destructor will not unload the texture from memory. If you want that you'll have to remove it manually ( cTextureFactory::instance()->Remove( MyFontInstance->GetTexId() ) ). */
|
||||
virtual ~cTTFFont();
|
||||
|
||||
@@ -92,8 +94,6 @@ class EE_API cTTFFont : public cFont {
|
||||
bool mThreadedLoading;
|
||||
bool mTexReady;
|
||||
|
||||
cTTFFont( const std::string FontName );
|
||||
|
||||
bool ThreadedLoading() const;
|
||||
|
||||
void ThreadedLoading( const bool& isThreaded );
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef EECLOG_H
|
||||
#define EECLOG_H
|
||||
|
||||
#include <list>
|
||||
#include <eepp/system/base.hpp>
|
||||
#include <eepp/system/tsingleton.hpp>
|
||||
#include <eepp/system/ciostreamfile.hpp>
|
||||
@@ -9,13 +10,19 @@
|
||||
|
||||
namespace EE { namespace System {
|
||||
|
||||
/** @brief The reader interface is usefull if you want to keep track of what is write in the log, for example for a console. */
|
||||
class iLogReader {
|
||||
public:
|
||||
virtual void WriteLog( const std::string& Text ) = 0;
|
||||
};
|
||||
|
||||
class EE_API cLog : protected cMutex {
|
||||
SINGLETON_DECLARE_HEADERS(cLog)
|
||||
|
||||
public:
|
||||
void Save(const std::string& filepath = "" );
|
||||
|
||||
void Write(const std::string& Text, const bool& newLine = true);
|
||||
void Write( std::string Text, const bool& newLine = true);
|
||||
|
||||
void Writef( const char* format, ... );
|
||||
|
||||
@@ -29,20 +36,27 @@ class EE_API cLog : protected cMutex {
|
||||
|
||||
void LiveWrite( const bool& lw );
|
||||
|
||||
void AddLogReader( iLogReader * reader );
|
||||
|
||||
void RemoveLogReader( iLogReader * reader );
|
||||
|
||||
~cLog();
|
||||
protected:
|
||||
cLog();
|
||||
private:
|
||||
std::string mData;
|
||||
std::string mFilePath;
|
||||
bool mSave;
|
||||
bool mConsoleOutput;
|
||||
bool mLiveWrite;
|
||||
cIOStreamFile * mFS;
|
||||
|
||||
void openfs();
|
||||
std::string mData;
|
||||
std::string mFilePath;
|
||||
bool mSave;
|
||||
bool mConsoleOutput;
|
||||
bool mLiveWrite;
|
||||
cIOStreamFile * mFS;
|
||||
std::list<iLogReader*> mReaders;
|
||||
|
||||
void closefs();
|
||||
void OpenFS();
|
||||
|
||||
void CloseFS();
|
||||
|
||||
void WriteToReaders( std::string& text );
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user