25 #include <fifechan/sdl/sdlinput.hpp>
26 #include <fifechan/key.hpp>
27 #include <fifechan/focushandler.hpp>
28 #include <fifechan.hpp>
58 m_fcn_gui(new fcn::Gui()),
60 m_fcn_topcontainer(new fcn::Container()),
62 m_input(new fcn::SDLInput()),
66 m_logic_executed(false) {
87 std::vector<GuiFont*>::iterator i =
m_fonts.begin();
96 FL_WARN(
_log,
"FifechanManager, FifechanGUI->getInput == 0 ... discarding events!");
103 case SDL_MOUSEBUTTONDOWN:
105 case SDL_MOUSEBUTTONUP:
126 case SDL_MOUSEMOTION:
149 case SDL_ACTIVEEVENT:
184 if( backend ==
"SDL" ) {
188 else if (backend ==
"OpenGL") {
204 std::string fontpath = path;
205 std::string fontglyphs = glyphs;
206 int32_t fontsize = size;
215 if(fontglyphs ==
"") {
221 if( bfs::extension(fontpath) ==
".ttf" || bfs::extension(fontpath) ==
".ttc" ) {
233 std::vector<GuiFont*>::iterator i =
m_fonts.begin();
245 std::vector<GuiFont*>::iterator it =
m_fonts.begin();
275 if(fcnevt.getType() == fcn::KeyEvent::Pressed)
277 else if(fcnevt.getType() == fcn::KeyEvent::Released)
280 FL_WARN(
_log,
LMsg(
"FifechanManager::translateKeyEvent() - ") <<
"Unknown event type: " << fcnevt.getType());
290 int32_t keyval = fcnevt.getKey().getValue();
293 keyevt.
setKey(
Key(static_cast<Key::KeyType>(keyval), keyval));
304 mouseevt.
setX(fcnevt.getX());
305 mouseevt.
setY(fcnevt.getY());
307 switch(fcnevt.getType()) {
308 case fcn::MouseEvent::Pressed:
311 case fcn::MouseEvent::Released:
314 case fcn::MouseEvent::Moved:
317 case fcn::MouseEvent::Clicked:
320 case fcn::MouseEvent::Entered:
323 case fcn::MouseEvent::Exited:
326 case fcn::MouseEvent::Dragged:
329 case fcn::MouseEvent::WheelMovedDown:
332 case fcn::MouseEvent::WheelMovedUp:
339 switch(fcnevt.getButton()) {
340 case fcn::MouseInput::Left:
343 case fcn::MouseInput::Right:
346 case fcn::MouseInput::Middle:
363 case fcn::Key::LeftAlt:
366 case fcn::Key::RightAlt:
369 case fcn::Key::LeftShift:
372 case fcn::Key::RightShift:
375 case fcn::Key::LeftControl:
378 case fcn::Key::RightControl:
381 case fcn::Key::Backspace:
384 case fcn::Key::Pause:
387 case fcn::Key::Space:
390 case fcn::Key::Escape:
393 case fcn::Key::Delete:
396 case fcn::Key::Insert:
405 case fcn::Key::PageUp:
408 case fcn::Key::PrintScreen:
411 case fcn::Key::PageDown:
459 case fcn::Key::NumLock:
462 case fcn::Key::CapsLock:
465 case fcn::Key::ScrollLock:
468 case fcn::Key::RightMeta:
471 case fcn::Key::LeftMeta:
474 case fcn::Key::LeftSuper:
477 case fcn::Key::RightSuper:
480 case fcn::Key::AltGr:
492 case fcn::Key::Right:
495 case fcn::Key::Enter:
501 if (value >= 1 && value <= 26) {
503 value = value - 1 +
'a';
504 }
else if (value >=
'A' && value <=
'Z') {
505 value = value -
'A' +
'a';
#define FL_WARN(logger, msg)
KeyEvent translateKeyEvent(const fcn::KeyEvent &evt)
void add(fcn::Widget *widget)
Adds a new widget.
virtual void turn()
Performs the GUI logic and draws the GUI accordingly.
fcn::FocusHandler * m_focushandler
void setKey(const Key &key)
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
virtual void setControlPressed(bool pressed)
FifechanManager()
Constructor.
virtual void setShiftPressed(bool pressed)
void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Resizes the top container.
GuiFont * setDefaultFont(const std::string &path, uint32_t size, const std::string &glyphs)
Set the global font properties.
virtual ~FifechanManager()
Destructor.
static Logger _log(LM_AUDIO)
virtual bool onSdlEvent(SDL_Event &evt)
Called when an SDL event is received from SDL.
virtual void setControlPressed(bool pressed)
virtual void setAltPressed(bool pressed)
GuiFont * createFont(const std::string &path="", uint32_t size=0, const std::string &glyphs="")
Gets font with given properties.
virtual void setShiftPressed(bool pressed)
virtual void setMetaPressed(bool pressed)
fcn::Container * m_fcn_topcontainer
GuiImageLoader * m_imgloader
SDL True Type Font implementation of Font.
std::vector< GuiFont * > m_fonts
void remove(fcn::Widget *widget)
Removes a widget.
Represents a key or a character.
std::set< fcn::Widget * > m_widgets
void releaseFont(GuiFont *font)
Releases given font.
void setNumericPad(bool ispad)
void setButton(MouseButtonType type)
virtual void setMetaPressed(bool pressed)
fcn::Graphics * m_gui_graphics
void setType(KeyEventType type)
void init(const std::string &backend, int32_t screenWidth, int32_t screenHeight)
Inits the Fifechan GUI Manager.
Pure abstract Font interface.
Overrides Guichan Graphics to enable usage of normal fife images & related facilities.
Imagefont that is able to read glyphs from single image sheet, see e.g.
MouseEvent translateMouseEvent(const fcn::MouseEvent &evt)
static int32_t convertFifechanKeyToFifeKey(int32_t value)
void setType(MouseEventType type)
void reLayout()
Layouts the console to match e.g.
virtual void setAltPressed(bool pressed)
fcn::Gui * getFifechanGUI() const
Gets the member pointer to the Fifechan GUI.
Overrides Guichan Graphics to enable usage of normal fife images & related facilities.