FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
fifechanmanager.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 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_GUI_FIFECHANMANAGER_H
23 #define FIFE_GUI_FIFECHANMANAGER_H
24 
25 // Standard C++ library includes
26 #include <set>
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/base/fife_stdint.h"
36 #include "util/base/singleton.h"
38 
39 #include "gui/guimanager.h"
40 
41 namespace fcn {
42 
43  class Gui;
44  class Container;
45  class Widget;
46  class SDLInput;
47  class FocusHandler;
48 
49 }
50 
51 
52 namespace FIFE {
53 
54  class GuiImageLoader;
55  class Console;
56  class Cursor;
57  class KeyEvent;
58  class MouseEvent;
59  class IFont;
60  class GuiFont;
61 
62 
63  /* GUI Fifechan Manager.
64  *
65  * This class controls the Fifechan GUI system in FIFE.
66  */
68  public IGUIManager,
69  public DynamicSingleton<FifechanManager>
70  {
71  public:
77  virtual ~FifechanManager();
78 
83  fcn::Gui* getFifechanGUI() const;
84 
89  virtual void turn();
90 
96  void init(const std::string& backend, int32_t screenWidth, int32_t screenHeight);
97 
105  void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
106 
111  void add(fcn::Widget* widget);
112 
117  void remove(fcn::Widget* widget);
118 
123  fcn::Container* getTopContainer() const { return m_fcn_topcontainer; }
124 
129  Console* getConsole() const { return m_console; };
130 
136  void setConsoleEnabled(bool console);
137 
143  bool isConsoleEnabled() const;
144 
149  void setCursor(Cursor* cursor) { m_cursor = cursor; }
150 
155  Cursor* getCursor() const { return m_cursor; }
156 
159  GuiFont* setDefaultFont(const std::string& path, uint32_t size, const std::string& glyphs);
160 
163  GuiFont* getDefaultFont() { return m_defaultfont; };
164 
167  GuiFont* createFont(const std::string& path = "", uint32_t size = 0, const std::string& glyphs = "");
168 
171  void releaseFont(GuiFont* font);
172 
173  void invalidateFonts();
174 
175  virtual bool onSdlEvent(SDL_Event& evt);
176 
177  KeyEvent translateKeyEvent(const fcn::KeyEvent& evt);
178  MouseEvent translateMouseEvent(const fcn::MouseEvent& evt);
179 
187  void setTabbingEnabled(bool tabbing);
188 
195  bool isTabbingEnabled() const;
196 
197  protected:
198  static int32_t convertFifechanKeyToFifeKey(int32_t value);
199 
200  private:
201  // The Fifechan GUI.
202  fcn::Gui* m_fcn_gui;
203  // Fifechan Graphics
204  fcn::Graphics* m_gui_graphics;
205  // Focus handler for input management
206  fcn::FocusHandler* m_focushandler;
207  // The top container of the GUI.
208  fcn::Container* m_fcn_topcontainer;
209  // The imageloader.
211  // The input controller.
212  fcn::SDLInput *m_input;
213  // The console.
215  // Acess to the Cursor class.
217  //The default font
219  // The fonts used
220  std::vector<GuiFont*> m_fonts;
221  // Added widgets
222  std::set<fcn::Widget*> m_widgets;
223 
224  // Used to accept mouse motion events that leave widget space
227  // Track last motion event position
228  int32_t m_lastMotionX;
229  int32_t m_lastMotionY;
230 
231  // default font settings
232  std::string m_fontpath;
233  std::string m_fontglyphs;
234  int32_t m_fontsize;
235 
236  // true, if fifechan logic has already been executed for this round
238  // True if the console should be created
240 
241  std::string m_backend;
242  };
243 
244 }
245 
246 #endif
void setCursor(Cursor *cursor)
Sets the cursor.
Class for mouse events.
Definition: mouseevent.h:42
fcn::FocusHandler * m_focushandler
GuiFont * getDefaultFont()
Gets the default font.
fcn::SDLInput * m_input
Console * getConsole() const
Gets the console.
fcn::Container * m_fcn_topcontainer
Another Singleton.
Definition: singleton.h:82
GuiImageLoader * m_imgloader
std::vector< GuiFont * > m_fonts
std::set< fcn::Widget * > m_widgets
fcn::Graphics * m_gui_graphics
Cursor class manages mouse cursor handling.
Definition: cursor.h:73
Class for key events.
Definition: keyevent.h:45
fcn::Container * getTopContainer() const
Gets the top container.
Cursor * getCursor() const
Gets the cursor.
Ingame Console.
Definition: console.h:64
unsigned int uint32_t
Definition: core.h:40