-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphicsSettings.cpp
More file actions
79 lines (67 loc) · 1.71 KB
/
GraphicsSettings.cpp
File metadata and controls
79 lines (67 loc) · 1.71 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "stdafx.h"
#include "GraphicsSettings.h"
// Constructors and Destructor: // Default Distructor
GraphicsSettings::GraphicsSettings()
{
this->title = "DEFAULT";
this->resolution = sf::VideoMode::getDesktopMode();
this->fullscreen = 0;
this->style = sf::Style::Titlebar | sf::Style::Close;
this->frameRateLimit = 60;
this->verticalSync = false;
this->contextSettings.antialiasingLevel = 0;
this->videoModes = sf::VideoMode::getFullscreenModes();
}
//Fucntions:
void GraphicsSettings::saveToFile(const std::string file_path)
{
std::ofstream out;
out.open(file_path);
if (out.is_open())
{
out << this->title << "\n";
out << this->resolution.width << " " << this->resolution.height << "\n";
out << this->fullscreen << "\n";
out << this->frameRateLimit << "\n";
out << this->verticalSync << "\n";
out << this->contextSettings.antialiasingLevel << "\n";
}
out.close();
}
void GraphicsSettings::loadFromFile(const std::string file_path)
{
std::ifstream in;
in.open(file_path);
if (in.is_open())
{
std::getline(in, title);
in >> this->resolution.width >> this->resolution.height;
in >> this->fullscreen;
in >> this->frameRateLimit;
in >> this->verticalSync;
in >> this->contextSettings.antialiasingLevel;
}
else
{
std::string className = typeid(*this).name();
className.erase(0, 6);
std::cout << "ERROR:: " << className << "::loadFromFile::Failed to load: " << file_path << std::endl;
}
in.close();
if (this->fullscreen == 0)
{
this->style = sf::Style::Titlebar | sf::Style::Close;
}
else if (this->fullscreen == 1)
{
this->style = sf::Style::Fullscreen;
}
else if (this->fullscreen == 2)
{
this->style = sf::Style::None;
}
else
{
this->style = sf::Style::Default;
}
}