Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Menu::show()
- {
- sf::Text title(Data::gameTitle,font,Data::sizeOfTitleFontInMenu);
- title.setStyle(sf::Text::Bold);
- title.setPosition(Data::windowWidth/2-title.getGlobalBounds().width/2,Data::titleTopMarginInMenu);
- sf::Text option[Data::numberOfOptionsInMenu];
- for(int i=1; i<=Data::numberOfOptionsInMenu; i++)
- {
- option[i].setFont(font);
- option[i].setCharacterSize(Data::sizeOfOptionsFontInMenu);
- option[i].setString(Data::OptionsInMenuContent[i]);
- option[i].setPosition(Data::windowWidth/2-title.getGlobalBounds().width/2,Data::optionTopMarginInMenu*i);
- }
- while(info->state == Info::MENU)
- {
- sf::Vector2f mouse(sf::Mouse::getPosition());
- sf::Event event;
- while(window->pollEvent(event))
- {
- if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape || event.type == sf::Event::Closed){
- window->close();
- }
- if(option[0].getGlobalBounds().contains(mouse) && event.type == sf::Event::MouseButtonReleased && event.key.code == sf::Mouse::Left){
- info->state = Info::GAME;
- }
- if(option[1].getGlobalBounds().contains(mouse) && event.type == sf::Event::MouseButtonReleased && event.key.code == sf::Mouse::Left){
- window->close();
- }
- }
- for(int i=0; i<Data::numberOfOptionsInMenu; i++)
- {
- if(option[i].getGlobalBounds().contains(mouse)){
- option[i].setColor(Data::colorOfCheckOptionInMenu);
- }
- else {
- option[i].setColor(Data::colorOfOptionInMenu);
- }
- }
- window->clear(Data::colorOfBackgroundInMenu);
- window->draw(title);
- for(int i=0; i<Data::numberOfOptionsInMenu; i++)
- {
- window->draw(option[i]);
- }
- window->display();
- }
- }
Add Comment
Please, Sign In to add comment