Closed richelbilderbeek closed 5 years ago
Is your feature request related to a problem? Please describe.
Currently, sfml_menu_screen::exec is too long. OCLint is right to complain.
sfml_menu_screen::exec
void sfml_menu_screen::exec() //!OCLINT indeed to long, please fix { if (m_close_at >= 0) close(game_state::aboutscreen); while(active(game_state::menuscreen)) { sf::Event event; while (m_window.pollEvent(event)) { sf::View view = m_window.getDefaultView(); switch (event.type) { case sf::Event::Closed: close(); break; case sf::Event::Resized: sfml_window_manager::get().update(); view.setSize(static_cast<float>(m_window.getSize().x), static_cast<float>(m_window.getSize().y)); m_window.setView(view); break; case sf::Event::KeyPressed: switch (event.key.code) { case sf::Keyboard::C: close(game_state::playing); break; case sf::Keyboard::T: close(game_state::aboutscreen); break; case sf::Keyboard::Q: close(); break; default: break; } break; case sf::Event::MouseButtonPressed: if (m_button1.is_clicked(event, m_window)) close(game_state::loading); if (m_button2.is_clicked(event, m_window)) close(game_state::aboutscreen); if (m_button3.is_clicked(event, m_window)) close(); break; default: sfml_window_manager::get().process(); break; } } set_positions(); draw_objects(); } }
Describe the solution you'd like
Simplify the code to:
void sfml_menu_screen::exec() { if (m_close_at >= 0) close(game_state::aboutscreen); while(active(game_state::menuscreen)) { sf::Event event; while (m_window.pollEvent(event)) { process_event(event); } set_positions(); draw_objects(); } }
Move the code to a new member function sfml_menu_screen::process_event.
sfml_menu_screen::process_event
Describe alternatives you've considered
None.
Additional context
@Rijk-van-Putten: well done :+1:
Is your feature request related to a problem? Please describe.
Currently,
sfml_menu_screen::exec
is too long. OCLint is right to complain.Describe the solution you'd like
Simplify the code to:
Move the code to a new member function
sfml_menu_screen::process_event
.Describe alternatives you've considered
None.
Additional context
None.