2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 26.03.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ENGINE_WINDOW_H
|
|
|
|
#define ENGINE_WINDOW_H
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "Button.h"
|
2022-07-11 16:58:05 +03:00
|
|
|
#include "../io/Screen.h"
|
|
|
|
#include "../io/Mouse.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-12 20:18:56 +03:00
|
|
|
class Window final {
|
2021-09-13 15:53:43 +03:00
|
|
|
private:
|
2021-10-03 07:47:05 +03:00
|
|
|
std::string _name;
|
|
|
|
std::string _backTexture;
|
|
|
|
std::vector<Button> _buttons;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-03 07:47:05 +03:00
|
|
|
sf::Sprite _back;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-28 16:58:02 +03:00
|
|
|
Vec2D _prevMousePosition{0, 0};
|
2021-09-19 15:44:31 +03:00
|
|
|
|
|
|
|
std::shared_ptr<Screen> _screen;
|
|
|
|
std::shared_ptr<Mouse> _mouse;
|
2021-09-13 15:53:43 +03:00
|
|
|
public:
|
2021-10-31 11:39:08 +03:00
|
|
|
explicit Window(std::shared_ptr<Screen> screen, std::shared_ptr<Mouse> mouse, std::string name = "Menu",
|
2021-11-05 23:14:12 +03:00
|
|
|
std::string backTexture = "") : _screen(screen), _mouse(mouse),
|
2021-10-31 11:39:08 +03:00
|
|
|
_name(std::move(name)), _backTexture(std::move(backTexture)) {}
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void addButton(int x, int y, int w, int h,
|
|
|
|
std::function<void()> click,
|
2021-10-31 11:39:08 +03:00
|
|
|
const std::string &text = "_button", double sx = 1, double sy = 1,
|
|
|
|
const std::string &texture = "", tPos usualState = {}, tPos selectedState = {},
|
|
|
|
tPos pressedState = {},
|
|
|
|
const std::string &font = Consts::MEDIUM_FONT, sf::Color textColor = {255, 255, 255});
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
void setTitle(const std::string &title) { _name = title; }
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
void setBackgroundTexture(const std::string &texture, double sx = 1, double sy = 1, int w = 1920, int h = 1080);
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-09-19 15:44:31 +03:00
|
|
|
void update();
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //MINECRAFT_3DZAVR_WINDOW_H
|