26 #include <boost/tokenizer.hpp> 50 m_output(new
fcn::TextBox()),
51 m_outputscrollarea(new
fcn::ScrollArea(m_output)),
52 m_status(new
fcn::Label()),
53 m_toolsbutton(new
fcn::Button(
"Tools"))
79 m_input->addFocusListener(
this);
87 int32_t w, h, b, input_h, bbar_h, button_w;
91 input_h = getFont()->getHeight();
95 fcn::Color black(0x00,0,0,0xff);
96 fcn::Color white(0xff,0xff,0xff,0xff);
97 fcn::Color dark(50,60,50,0xff);
103 setForegroundColor(white);
104 setBackgroundColor(black);
112 m_input->setPosition(b, h - input_h - b - bbar_h);
113 m_input->setSize(w - 2*b, input_h);
115 m_status->setPosition(b, h - b - bbar_h);
121 m_output->setBackgroundColor(black);
127 m_input->setForegroundColor(white);
128 m_input->setBackgroundColor(black);
130 m_status->setForegroundColor(white);
131 m_status->setBackgroundColor(black);
156 std::string caption =
"FIFE Console - FPS: ";
158 caption += std::to_string(fps);
172 setPosition(getX(), 0);
238 FL_WARN(
_log,
LMsg(
"ConsoleExecuter not bind, but command received: ") << cmd.c_str());
251 boost::char_separator<char> separator(
"\n");
252 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
253 tokenizer tokens(s,separator);
254 for(tokenizer::iterator i = tokens.begin(); i != tokens.end(); ++i) {
260 unsigned rows =
m_output->getNumberOfRows();
262 std::vector<std::string> rows_text;
263 for(
size_t i=delta_rows; i != rows; ++i) {
264 rows_text.push_back(
m_output->getTextRow(i));
267 for(
size_t i=0; i != rows_text.size(); ++i) {
273 fcn::Rectangle rect(0,
m_output->getHeight(),0,0);
281 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.
fcn::Container * getTopContainer() const
Gets the top container.
void add(fcn::Widget *widget)
Adds a new widget.
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.
uint32_t getScreenWidth() const
void start()
Start the timer.
uint32_t getScreenHeight() const
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.
double getAverageFrameTime() const
Gets average frame time.
fcn::Button * m_toolsbutton
void remove(fcn::Widget *widget)
Removes a widget.
virtual const char * what() const
Returns the error message.
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.
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.