FIFE
2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_VIDEO_GUI_GUIMANAGER_H 00023 #define FIFE_VIDEO_GUI_GUIMANAGER_H 00024 00025 // Standard C++ library includes 00026 #include <set> 00027 00028 // 3rd party library includes 00029 #include <guichan.hpp> 00030 00031 // FIFE includes 00032 // These includes are split up in two parts, separated by one empty line 00033 // First block: files included from the FIFE root src directory 00034 // Second block: files included from the same folder 00035 #include "util/base/singleton.h" 00036 #include "eventchannel/sdl/ec_isdleventlistener.h" 00037 // #include "eventchannel/mouse/ec_imouselistener.h" 00038 // #include "eventchannel/key/ec_ikeylistener.h" 00039 00040 namespace gcn { 00041 00042 class Gui; 00043 class Container; 00044 class Widget; 00045 class SDLInput; 00046 class FocusHandler; 00047 00048 } 00049 00050 00051 namespace FIFE { 00052 00053 class ImagePool; 00054 class GuiImageLoader; 00055 class Console; 00056 class KeyEvent; 00057 class MouseEvent; 00058 class AbstractFont; 00059 class GuiFont; 00060 00061 /* GUI Manager. 00062 * 00063 * This class controls the GUI system in FIFE. 00064 */ 00065 class GUIManager : 00066 public DynamicSingleton<GUIManager>, 00067 public ISdlEventListener 00068 { 00069 public: 00072 GUIManager(ImagePool& pool); 00075 virtual ~GUIManager(); 00076 00081 gcn::Gui* getGuichanGUI() const; 00082 00087 void turn(); 00088 00094 void init(gcn::Graphics* graphics, int screenWidth, int screenHeight); 00095 00103 void resizeTopContainer(unsigned int x, unsigned int y, unsigned int width, unsigned int height); 00104 00109 void add(gcn::Widget* widget); 00114 void remove(gcn::Widget* widget); 00119 gcn::Container* getTopContainer() const { return m_gcn_topcontainer; } 00120 00125 Console* getConsole() const { return m_console; }; 00126 00129 GuiFont* setDefaultFont(const std::string& path, unsigned int size, const std::string& glyphs); 00130 00133 GuiFont* createFont(const std::string& path = "", unsigned int size = 0, const std::string& glyphs = ""); 00134 00137 void releaseFont(GuiFont* font); 00138 00139 void invalidateFonts(); 00140 00141 bool onSdlEvent(SDL_Event& evt); 00142 00143 KeyEvent translateKeyEvent(const gcn::KeyEvent& evt); 00144 MouseEvent translateMouseEvent(const gcn::MouseEvent& evt); 00145 00146 protected: 00147 static int convertGuichanKeyToFifeKey(int value); 00148 00149 private: 00150 // The Guichan GUI. 00151 gcn::Gui* m_gcn_gui; 00152 // Focus handler for input management 00153 gcn::FocusHandler* m_focushandler; 00154 // The top container of the GUI. 00155 gcn::Container* m_gcn_topcontainer; 00156 // The imageloader. 00157 GuiImageLoader* m_imgloader; 00158 // The input controller. 00159 gcn::SDLInput *m_input; 00160 // The console. 00161 Console *m_console; 00162 // The fonts used 00163 std::vector<GuiFont*> m_fonts; 00164 // Added widgets 00165 std::set<gcn::Widget*> m_widgets; 00166 00167 // Used to accept mouse motion events that leave widget space 00168 bool m_had_mouse; 00169 00170 // pool used for images 00171 ImagePool& m_pool; 00172 00173 // default font settings 00174 std::string m_fontpath; 00175 std::string m_fontglyphs; 00176 int m_fontsize; 00177 00178 // true, if guichan logic has already been executed for this round 00179 bool m_logic_executed; 00180 }; 00181 00182 } 00183 00184 #endif