26 #include <boost/bind.hpp>
27 #include <boost/lexical_cast.hpp>
28 #include <boost/regex.hpp>
29 #include <boost/tokenizer.hpp>
53 m_output(new fcn::TextBox()),
54 m_outputscrollarea(new fcn::ScrollArea(m_output)),
55 m_status(new fcn::Label()),
56 m_toolsbutton(new fcn::Button(
"Tools"))
82 m_input->addFocusListener(
this);
90 int32_t w, h, b, input_h, bbar_h, button_w;
94 input_h = getFont()->getHeight();
98 fcn::Color black(0x00,0,0,0xff);
99 fcn::Color white(0xff,0xff,0xff,0xff);
100 fcn::Color dark(50,60,50,0xff);
106 setForegroundColor(white);
107 setBackgroundColor(black);
115 m_input->setPosition(b, h - input_h - b - bbar_h);
116 m_input->setSize(w - 2*b, input_h);
118 m_status->setPosition(b, h - b - bbar_h);
124 m_output->setBackgroundColor(black);
130 m_input->setForegroundColor(white);
131 m_input->setBackgroundColor(black);
133 m_status->setForegroundColor(white);
134 m_status->setBackgroundColor(black);
159 std::string caption =
"FIFE Console - FPS: ";
161 caption += boost::lexical_cast<std::string>(fps);
175 setPosition(getX(), 0);
241 FL_WARN(
_log,
LMsg(
"ConsoleExecuter not bind, but command received: ") << cmd.c_str());
254 boost::char_separator<char> separator(
"\n");
255 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
256 tokenizer tokens(s,separator);
257 for(tokenizer::iterator i = tokens.begin(); i != tokens.end(); ++i) {
263 unsigned rows =
m_output->getNumberOfRows();
265 std::vector<std::string> rows_text;
266 for(
size_t i=delta_rows; i != rows; ++i) {
267 rows_text.push_back(
m_output->getTextRow(i));
270 for(
size_t i=0; i != rows_text.size(); ++i) {
276 fcn::Rectangle rect(0,
m_output->getHeight(),0,0);
284 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.
void focusLost(const fcn::Event &event)
Hide if we loose focus.
void add(fcn::Widget *widget)
Adds a new widget.
virtual const char * what() const
Returns the error message.
uint32_t getScreenHeight() const
void setConsoleExecuter(ConsoleExecuter *const consoleexec)
Sets executer for the console.
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.
void setIOFont(GuiFont *font)
Sets the font used for the input and output areas.
void removeConsoleExecuter()
Removes executer for the console.
void start()
Start the timer.
GuiFont * createFont(const std::string &path="", uint32_t size=0, const std::string &glyphs="")
Gets font with given properties.
static FifechanManager * instance()
Console executer is listener interface for console activity.
fcn::Button * m_toolsbutton
uint32_t getScreenWidth() const
void remove(fcn::Widget *widget)
Removes a widget.
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 fifechan toplevel container and pushes an input Context so t...
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.
fcn::Container * getTopContainer() const
Gets the top container.
void reLayout()
Layouts the console to match e.g.
ConsoleExecuter * m_consoleexec
fcn::ScrollArea * m_outputscrollarea
#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 fcn::ActionEvent &event)
Callback from fifechan to respond to button press.
void clear()
Clear the console output.