Push changement pour Parametres -> Settings
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
#include "parameters.h"
|
||||
|
||||
Parameters::Parameters()
|
||||
: m_mainVolume(0.5f),
|
||||
m_musicVolume(0.5f),
|
||||
m_sfxVolume(0.5f),
|
||||
m_resolution(FHD),
|
||||
m_fullscreen(false),
|
||||
m_brightness(0.5f),
|
||||
m_contrast(0.5f),
|
||||
m_mouseSensitivity(0.5f) {
|
||||
ApplyResolution(m_resolution);
|
||||
}
|
||||
|
||||
void Parameters::SaveFile(const std::string& filename) {
|
||||
std::ofstream file(filename);
|
||||
if (!file.is_open()) {
|
||||
std::cerr << "Failed to open file for saving parameters" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
file << m_mainVolume << '\n';
|
||||
file << m_musicVolume << '\n';
|
||||
file << m_sfxVolume << '\n';
|
||||
|
||||
file << static_cast<int>(m_resolution) << '\n';
|
||||
file << m_fullscreen << '\n';
|
||||
file << m_brightness << '\n';
|
||||
file << m_contrast << '\n';
|
||||
|
||||
file << m_mouseSensitivity << '\n';
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void Parameters::LoadFile(const std::string& filename) {
|
||||
std::ifstream file(filename);
|
||||
if (!file.is_open()) {
|
||||
std::cerr << "Failed to open file for loading parameters" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
file >> m_mainVolume;
|
||||
file >> m_musicVolume;
|
||||
file >> m_sfxVolume;
|
||||
|
||||
int resolutionValue;
|
||||
file >> resolutionValue;
|
||||
m_resolution = static_cast<Resolution>(resolutionValue);
|
||||
|
||||
file >> m_fullscreen;
|
||||
file >> m_brightness;
|
||||
file >> m_contrast;
|
||||
|
||||
file >> m_mouseSensitivity;
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
float Parameters::GetMainVolume() const {
|
||||
return m_mainVolume;
|
||||
}
|
||||
|
||||
void Parameters::SetMainVolume(float volume) {
|
||||
m_mainVolume = volume;
|
||||
}
|
||||
|
||||
float Parameters::GetMusicVolume() const {
|
||||
return m_musicVolume;
|
||||
}
|
||||
|
||||
void Parameters::SetMusicVolume(float volume) {
|
||||
m_musicVolume = volume;
|
||||
}
|
||||
|
||||
float Parameters::GetSfxVolume() const {
|
||||
return m_sfxVolume;
|
||||
}
|
||||
|
||||
void Parameters::SetSfxVolume(float volume) {
|
||||
m_sfxVolume = volume;
|
||||
}
|
||||
|
||||
float Parameters::GetBrightness() const {
|
||||
return m_brightness;
|
||||
}
|
||||
|
||||
void Parameters::SetBrightness(float brightness) {
|
||||
m_brightness = brightness;
|
||||
}
|
||||
|
||||
float Parameters::GetContrast() const {
|
||||
return m_contrast;
|
||||
}
|
||||
|
||||
void Parameters::SetContrast(float contrast) {
|
||||
m_contrast = contrast;
|
||||
}
|
||||
|
||||
bool Parameters::GetFullscreen() const {
|
||||
return m_fullscreen;
|
||||
}
|
||||
|
||||
void Parameters::SetFullscreen(bool fullscreen) {
|
||||
m_fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
const Resolution& Parameters::GetResolution() const {
|
||||
return m_resolution;
|
||||
}
|
||||
|
||||
void Parameters::SetResolution(const Resolution& resolution) {
|
||||
m_resolution = resolution;
|
||||
}
|
||||
|
||||
float Parameters::GetMouseSensitivity() const {
|
||||
return m_mouseSensitivity;
|
||||
}
|
||||
|
||||
void Parameters::SetMouseSensitivity(float sensitivity) {
|
||||
m_mouseSensitivity = sensitivity;
|
||||
}
|
||||
|
||||
void Parameters::ApplyResolution(Resolution resolution) {
|
||||
switch (resolution) {
|
||||
case HD:
|
||||
m_rezWidth = 1280;
|
||||
m_rezHeight = 720;
|
||||
break;
|
||||
case FHD:
|
||||
m_rezWidth = 1920;
|
||||
m_rezHeight = 1080;
|
||||
break;
|
||||
case QHD:
|
||||
m_rezWidth = 2560;
|
||||
m_rezHeight = 1440;
|
||||
break;
|
||||
case UHD:
|
||||
m_rezWidth = 3840;
|
||||
m_rezHeight = 2160;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
#ifndef PARAMETERS_H
|
||||
#define PARAMETERS_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "define.h"
|
||||
|
||||
class Parameters {
|
||||
public:
|
||||
Parameters();
|
||||
|
||||
void SaveFile(const std::string& filename);
|
||||
void LoadFile(const std::string& filename);
|
||||
|
||||
// Audio
|
||||
float GetMainVolume() const;
|
||||
void SetMainVolume(float volume);
|
||||
|
||||
float GetMusicVolume() const;
|
||||
void SetMusicVolume(float volume);
|
||||
|
||||
float GetSfxVolume() const;
|
||||
void SetSfxVolume(float volume);
|
||||
|
||||
// Graphic
|
||||
float GetBrightness() const;
|
||||
void SetBrightness(float brightness);
|
||||
|
||||
float GetContrast() const;
|
||||
void SetContrast(float contrast);
|
||||
|
||||
bool GetFullscreen() const;
|
||||
void SetFullscreen(bool fullscreen);
|
||||
|
||||
const Resolution& GetResolution() const;
|
||||
void SetResolution(const Resolution& resolution);
|
||||
|
||||
// Gameplay
|
||||
float GetMouseSensitivity() const;
|
||||
void SetMouseSensitivity(float sensitivity);
|
||||
|
||||
void ApplyResolution(Resolution resolution);
|
||||
|
||||
private:
|
||||
// Audio
|
||||
float m_mainVolume;
|
||||
float m_musicVolume;
|
||||
float m_sfxVolume;
|
||||
|
||||
// Graphic
|
||||
Resolution m_resolution;
|
||||
bool m_fullscreen;
|
||||
int m_rezWidth;
|
||||
int m_rezHeight;
|
||||
float m_brightness;
|
||||
float m_contrast;
|
||||
|
||||
// Gameplay
|
||||
float m_mouseSensitivity;
|
||||
};
|
||||
|
||||
#endif // PARAMETERS_H
|
Reference in New Issue
Block a user