-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.cpp
More file actions
53 lines (46 loc) · 1.35 KB
/
Copy pathWindow.cpp
File metadata and controls
53 lines (46 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Window.h"
GameWindow::GameWindow(sf::VideoMode mode, const sf::String& title, sf::Uint32 style)
: m_bIsFullscreen(false)
{
m_windowedSize = { mode.width, mode.height };
if (style == sf::Style::Fullscreen)
{
m_bIsFullscreen = true;
mode = sf::VideoMode::getDesktopMode();
m_windowedSize = { 1200, 900 };
}
create(mode, title, style);
setFramerateLimit(70);
setKeyRepeatEnabled(false);
}
void GameWindow::toggleFullscreen()
{
if (m_bIsFullscreen) {
create(sf::VideoMode(getWindowedSize().x, getWindowedSize().y), "Tiles", sf::Style::Default);
}
else {
create(sf::VideoMode::getDesktopMode(), "Tiles", sf::Style::Fullscreen);
}
setView(sf::View({ 0.f, 0.f, (float)getSize().x, (float)getSize().y }));
m_bIsFullscreen = !m_bIsFullscreen;
}
void GameWindow::updateWindowedSize()
{
if (!m_bIsFullscreen)
{
m_windowedSize = getSize();
setView(sf::View({ 0.f, 0.f, (float)getSize().x, (float)getSize().y }));
}
}
bool GameWindow::isFullscreen() const
{
return m_bIsFullscreen;
}
sf::Vector2u GameWindow::getWindowedSize() const
{
return m_windowedSize;
}
sf::Vector2f GameWindow::getScale() const
{
return { getSize().x / (float)sf::VideoMode::getDesktopMode().width, getSize().y / (float)sf::VideoMode::getDesktopMode().height };
}