#include #include #include using namespace std; using namespace sf; int main() { setlocale(LC_ALL, "ru"); //шрифт Font font; font.loadFromFile("SFML FONTS\\Halogen_0.ttf"); //Создание окна RenderWindow window; window.create(VideoMode(1920, 1080), L"newwindow", Style::Close); window.setPosition(Vector2i(0, 0)); window.setVerticalSyncEnabled(true); window.setFramerateLimit(60); //Создание кнопок RectangleShape b(Vector2f(300, 72)); b.setFillColor(Color::White); b.setPosition(170, 160); RectangleShape b2(Vector2f(120, 30)); b2.setFillColor(Color::White); b2.setPosition(398, 315); //Текст на кнопках Text Okon; Okon.setFont(font); Okon.setString(L"Полноэкранный /\n *Оконный режим"); Okon.setPosition(200, 160); Okon.setFillColor(Color::Black); Text raz3; raz3.setFont(font); raz3.setString(L"1280x720"); raz3.setPosition(400, 315); raz3.setFillColor(Color::Black); raz3.setCharacterSize(20); //Загрузка заднего фона Texture texture; Sprite sprite; texture.loadFromFile("SFML BG\\OptionsText.png"); sprite.setTexture(texture); bool isFullscreen = true; while (window.isOpen()) { Vector2i mousePoz = Mouse::getPosition(window); Event event; while (window.pollEvent(event)) { if (event.type == Event::Closed) window.close(); //Кнопка оконного и полноэкранного режима if (event.type == Event::MouseButtonPressed) if (event.key.code == Mouse::Left) if (b.getGlobalBounds().contains(mousePoz.x, mousePoz.y)) { if (false == isFullscreen) { window.create(VideoMode(1920, 1080), "newwindow", Style::Close | sf::Style::Titlebar); isFullscreen = true; Okon.setString(L"*Полноэкранный /\n Оконный режим"); } else { window.create(VideoMode(1920, 1080), "newwindow", Style::Fullscreen); isFullscreen = false; Okon.setString(L"Полноэкранный /\n *Оконный режим"); } } //Кнопка изменения разрешения экрана if (event.type == Event::MouseButtonPressed) if (event.key.code == Mouse::Left) if (b2.getGlobalBounds().contains(mousePoz.x, mousePoz.y)) { cout << "Pressed" << endl; window.setSize(Vector2u(1280, 720)); raz3.setString(L"*1280x720"); } window.clear(); window.draw(sprite); window.draw(b); window.draw(b2); window.draw(Okon); window.draw(raz3); window.display(); } } return 0; }