26 #include <boost/bind.hpp>
27 #include <boost/lexical_cast.hpp>
28 #include <boost/regex.hpp>
29 #include <boost/tokenizer.hpp>
55 m_outputscrollarea(new gcn::ScrollArea(m_output)),
56 m_status(new gcn::Label()),
57 m_toolsbutton(new gcn::Button(
"Tools"))
83 m_input->addFocusListener(
this);
91 int32_t w, h, b, input_h, bbar_h, button_w;
95 input_h = getFont()->getHeight();
99 gcn::Color black(0x00,0,0,0xff);
100 gcn::Color white(0xff,0xff,0xff,0xff);
101 gcn::Color dark(50,60,50,0xff);
107 setForegroundColor(white);
108 setBackgroundColor(black);
116 m_input->setPosition(b, h - input_h - b - bbar_h);
117 m_input->setSize(w - 2*b, input_h);
119 m_status->setPosition(b, h - b - bbar_h);
125 m_output->setBackgroundColor(black);
131 m_input->setForegroundColor(white);
132 m_input->setBackgroundColor(black);
134 m_status->setForegroundColor(white);
135 m_status->setBackgroundColor(black);
160 std::string caption =
"FIFE Console - FPS: ";
162 caption += boost::lexical_cast<std::string>(fps);
176 setPosition(getX(), 0);
242 FL_WARN(
_log,
LMsg(
"ConsoleExecuter not bind, but command received: ") << cmd.c_str());
255 boost::char_separator<char> separator(
"\n");
256 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
257 tokenizer tokens(s,separator);
258 for(tokenizer::iterator i = tokens.begin(); i != tokens.end(); ++i) {
264 unsigned rows =
m_output->getNumberOfRows();
266 std::vector<std::string> rows_text;
267 for(
size_t i=delta_rows; i != rows; ++i) {
268 rows_text.push_back(
m_output->getTextRow(i));
271 for(
size_t i=0; i != rows_text.size(); ++i) {
277 gcn::Rectangle rect(0,
m_output->getHeight(),0,0);
285 FL_WARN(
_log,
"ConsoleExecuter not bind, but tools button clicked");
#define FL_WARN(logger, msg)
virtual void onToolsClick()=0
Called when console tools button is clicked.
virtual const char * what() const
Returns the error message.
uint32_t getScreenHeight() const
void setConsoleExecuter(ConsoleExecuter *const consoleexec)
Sets executer for the console.
gcn::ScrollArea * m_outputscrollarea
virtual std::string onConsoleCommand(const std::string &command)=0
Called when user has typed command to console and pressed enter.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
void execute(std::string cmd)
Execute a command Normally just sends the command to runString() Checks whether the cmd is just one t...
void hide()
Hide the console Removes itself from the toplevel container and pops it's input context.
void setCallback(const type_callback &cb)
Set callback on pressing the ENTER key.
void updateAnimation()
Update the scroll in/out animation.
static Logger _log(LM_AUDIO)
void setInterval(int32_t msec)
Set the interval in milliseconds.
GuiFont * createFont(const std::string &path="", uint32_t size=0, const std::string &glyphs="")
Gets font with given properties.
void remove(gcn::Widget *widget)
Removes a widget.
void setIOFont(GuiFont *font)
Sets the font used for the input and output areas.
void add(gcn::Widget *widget)
Adds a new widget.
void removeConsoleExecuter()
Removes executer for the console.
void start()
Start the timer.
static GUIChanManager * instance()
void focusLost(const gcn::Event &event)
Hide if we loose focus.
Console executer is listener interface for console activity.
uint32_t getScreenWidth() const
gcn::Container * getTopContainer() const
Gets the top container.
double getAverageFrameTime() const
Gets average frame time.
void println(const std::string &s)
Print one or more lines to the console output.
void show()
Show the console Adds the Console to the guichan toplevel container and pushes an input Context so th...
void toggleShowHide()
Toggle the console Toggles whether the Console is shown or not.
virtual ~Console()
Destructor.
void stop()
Stop the timer.
static const unsigned m_maxOutputRows
void updateCaption()
Update the FPS caption.
void reLayout()
Layouts the console to match e.g.
ConsoleExecuter * m_consoleexec
UTF-8 aware version of the TextBox class.
gcn::Button * m_toolsbutton
#define FL_DBG(logger, msg)
void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Set the color the text should be rendered in.
void setCallback(const type_callback &callback)
Set the callback that will be called.
void action(const gcn::ActionEvent &event)
Callback from guichan to respond to button press.
void clear()
Clear the console output.