diff --git a/lib/Ray/sources/Window.cpp b/lib/Ray/sources/Window.cpp index 71f531d6..151cd615 100644 --- a/lib/Ray/sources/Window.cpp +++ b/lib/Ray/sources/Window.cpp @@ -193,4 +193,23 @@ bool RAY::Window::isReady() const void RAY::Window::setExitKey(RAY::Controller::Keyboard::Key key) { SetExitKey(key); +} + +unsigned RAY::Window::getConfigFlags(void) const +{ + return this->_flags; +} + +RAY::Window &RAY::Window::setConfigFlags(unsigned flags) +{ + if (this->_isOpen) + SetWindowState(flags); + this->_flags = flags; + return *this; +} + +RAY::Window &RAY::Window::toggleFullscreen() +{ + ToggleFullscreen(); + return *this; } \ No newline at end of file diff --git a/lib/Ray/sources/Window.hpp b/lib/Ray/sources/Window.hpp index 036e01ef..81d4b1e4 100644 --- a/lib/Ray/sources/Window.hpp +++ b/lib/Ray/sources/Window.hpp @@ -139,6 +139,14 @@ namespace RAY { //! @info Calling this function override the previous closing key void setExitKey(Controller::Keyboard::Key key); + //! @return the configuration flgs for the window + unsigned getConfigFlags(void) const; + + //! @param flag the configuration flgs for the window + RAY::Window &setConfigFlags(unsigned flags); + + //! @brief set window to fullscreen + RAY::Window &toggleFullscreen(); private: //! @brief Creates window, and opens it if openNow is set to true diff --git a/sources/Runner/SettingsMenuScene.cpp b/sources/Runner/SettingsMenuScene.cpp index 49a27031..9a7e60d9 100644 --- a/sources/Runner/SettingsMenuScene.cpp +++ b/sources/Runner/SettingsMenuScene.cpp @@ -177,17 +177,22 @@ namespace BBM }); auto &fullscreen = scene->addEntity("fullscreen text") .addComponent(1920 / 2.5, 1080 - 100 - 50, 0) - .addComponent("Fullscreen: On", 70, RAY::Vector2(), BLACK) + .addComponent("Fullscreen: Off", 70, RAY::Vector2(), BLACK) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + RAY::Window &window = RAY::Window::getInstance(); + unsigned oldFlags = window.getConfigFlags(); + + if (oldFlags == FLAG_WINDOW_RESIZABLE) + window.toggleFullscreen(); + else + window.setConfigFlags(FLAG_WINDOW_RESIZABLE); if (text->getString().find("Off") != std::string::npos) { text->setText("Fullscreen: On"); - //do } else { text->setText("Fullscreen: Off"); - //do } }) .addComponent([](WAL::Entity &entity, WAL::Wal &)