vectozavr-shooter/engine/Screen.h

58 lines
1.5 KiB
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 14.01.2021.
//
#ifndef ENGINE_SCREEN_H
#define ENGINE_SCREEN_H
#include <string>
#include "Triangle.h"
#include <SFML/Graphics.hpp>
#include <map>
#include "utils/Time.h"
#include "Mouse.h"
2021-09-13 15:53:43 +03:00
class Screen final {
2021-09-13 15:53:43 +03:00
private:
int _w = 1920;
int _h = 1080;
2021-09-13 15:53:43 +03:00
std::string _title;
2021-09-13 15:53:43 +03:00
sf::Color _background;
2021-09-13 15:53:43 +03:00
2021-10-09 13:41:12 +03:00
std::string _font = "engine/fonts/Roboto-Thin.ttf";
2021-09-13 15:53:43 +03:00
std::shared_ptr<sf::RenderWindow> _window;
2021-09-13 15:53:43 +03:00
public:
void open(int screenWidth = 1920, int screenHeight = 1080, const std::string& name = "engine", bool verticalSync = true, sf::Color background = sf::Color(255, 255, 255), sf::Uint32 style = sf::Style::Default);
void display();
void clear();
bool hasFocus() const { return _window->hasFocus(); }
2021-09-13 15:53:43 +03:00
void drawTriangle(const Triangle& triangle);
void drawTetragon(const Vec2D& p1, const Vec2D& p2, const Vec2D& p3, const Vec2D& p4, sf::Color color);
void drawText(const std::string& string, const Vec2D& position, int size, sf::Color color);
void drawText(const sf::Text& text);
void drawSprite(const sf::Sprite& sprite);
2021-09-13 15:53:43 +03:00
void setTitle(const std::string& title);
[[nodiscard]] std::string title() const { return _title; };
2021-09-13 15:53:43 +03:00
bool isOpen();
[[nodiscard]] int width() const {return _window->getSize().x;}
[[nodiscard]] int height() const {return _window->getSize().y;}
2021-09-13 15:53:43 +03:00
void close();
void debugText(const std::string& text);
void attachMouse(std::shared_ptr<Mouse> mouse);
2021-09-13 15:53:43 +03:00
};
#endif //INC_3DZAVR_SCREEN_H