FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
console.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_FIFECHAN_ADDON_CONSOLE_H
23 #define FIFE_FIFECHAN_ADDON_CONSOLE_H
24 
25 // Standard C++ library includes
26 #include <string>
27 
28 // 3rd party library includes
29 #include <fifechan.hpp>
30 
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
35 #include "util/time/timer.h"
36 
37 namespace FIFE {
38 
39  class CommandLine;
40  class GuiFont;
41 
46  public:
49  virtual ~ConsoleExecuter() {}
50 
53  virtual void onToolsClick() = 0;
54 
58  virtual std::string onConsoleCommand(const std::string& command) = 0;
59  };
60 
61 
64  class Console : public fcn::Container, public fcn::ActionListener, public fcn::FocusListener {
65  public:
68  Console();
69 
72  virtual ~Console();
73 
76  void println(const std::string & s);
77 
83  void show();
84 
89  void hide();
90 
93  void clear();
94 
99  void toggleShowHide();
100 
109  void execute(std::string cmd);
110 
114  void updateCaption();
115 
119  void updateAnimation();
120 
123  void action(const fcn::ActionEvent & event);
124 
127  void setConsoleExecuter(ConsoleExecuter* const consoleexec);
128 
131  void removeConsoleExecuter();
132 
135  void reLayout();
136 
139  void setIOFont(GuiFont* font);
140 
143  void focusLost(const fcn::Event& event);
144  private:
145 
148 
150  fcn::TextBox* m_output;
151  fcn::ScrollArea* m_outputscrollarea;
152  fcn::Label* m_status;
153  fcn::Button* m_toolsbutton;
154  static const unsigned m_maxOutputRows;
155 
156  std::string m_prompt;
157 
158  int32_t m_hiddenPos;
160 
161  bool m_hiding;
162 
165 
166  void doShow();
167  void doHide();
168  };
169 }
170 #endif
virtual void onToolsClick()=0
Called when console tools button is clicked.
CommandLine * m_input
Definition: console.h:149
virtual std::string onConsoleCommand(const std::string &command)=0
Called when user has typed command to console and pressed enter.
A Command line widget.
Definition: commandline.h:43
Timer m_animationTimer
Definition: console.h:164
int32_t m_hiddenPos
Definition: console.h:158
virtual ~ConsoleExecuter()
Destructor.
Definition: console.h:49
std::string m_prompt
Definition: console.h:156
Console executer is listener interface for console activity.
Definition: console.h:45
fcn::Button * m_toolsbutton
Definition: console.h:153
bool m_hiding
Definition: console.h:161
fcn::Label * m_status
Definition: console.h:152
static const unsigned m_maxOutputRows
Definition: console.h:154
Simple Timer class.
Definition: timer.h:61
Timer m_fpsTimer
Definition: console.h:163
Ingame Console.
Definition: console.h:64
ConsoleExecuter * m_consoleexec
Definition: console.h:147
fcn::ScrollArea * m_outputscrollarea
Definition: console.h:151
bool m_isAttached
Definition: console.h:146
int32_t m_animationDelta
Definition: console.h:159
fcn::TextBox * m_output
Definition: console.h:150