70 lines
1.4 KiB
C
70 lines
1.4 KiB
C
|
#ifndef SIMPLECONSOLEOVERLAY
|
||
|
#define SIMPLECONSOLEOVERLAY
|
||
|
|
||
|
#include "Variables.h"
|
||
|
|
||
|
#include <SDL/SDL.h>
|
||
|
#include <string>
|
||
|
|
||
|
namespace Engine {
|
||
|
|
||
|
class OverlayBase;
|
||
|
|
||
|
class SimpleConsoleOverlay : public OverlayBase {
|
||
|
public:
|
||
|
SimpleConsoleOverlay () {
|
||
|
mActive = false;
|
||
|
mDrawLogBar = false;
|
||
|
};
|
||
|
virtual ~SimpleConsoleOverlay() {};
|
||
|
|
||
|
virtual bool OnKeyDown (const SDL_keysym &keysym);
|
||
|
virtual bool OnKeyUp (const SDL_keysym &keysym) {
|
||
|
if(mActive)
|
||
|
return true;
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
virtual void Draw ();
|
||
|
|
||
|
void DrawLogBar ();
|
||
|
void DrawConsole ();
|
||
|
|
||
|
/** \brief Returns the last n lines */
|
||
|
const std::vector<std::string> GetLastLines (const unsigned int n);
|
||
|
/** \brief Returns true if the Console is active */
|
||
|
bool GetActive () { return mActive; };
|
||
|
/** \brief Activates or deactivates the the Console */
|
||
|
void SetActive (bool active) {
|
||
|
if (active) {
|
||
|
SDL_EnableUNICODE (1);
|
||
|
SDL_EnableKeyRepeat (500, 50);
|
||
|
}
|
||
|
else {
|
||
|
SDL_EnableUNICODE (-1);
|
||
|
SDL_EnableKeyRepeat (0, 100);
|
||
|
}
|
||
|
mActive = active;
|
||
|
};
|
||
|
void SetDrawLogBar (bool value) { mDrawLogBar = value; };
|
||
|
|
||
|
/** \brief Draws the console with the current content */
|
||
|
void DrawLastLines ();
|
||
|
void DrawCurrentInput ();
|
||
|
|
||
|
private:
|
||
|
std::vector<std::string> mLastLines;
|
||
|
std::string mCurrentInput;
|
||
|
bool mActive;
|
||
|
bool mDrawLogBar;
|
||
|
|
||
|
float mLeft;
|
||
|
float mTop;
|
||
|
float mRight;
|
||
|
float mBottom;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif /* SIMPLECONSOLEOVERLAY */
|