Compare commits
6 Commits
SQC-31
...
SQC32_sauv
Author | SHA1 | Date | |
---|---|---|---|
|
4a9ad70d48 | ||
|
1ab83a85a7 | ||
|
2ab201e93c | ||
|
8e041a314d | ||
|
6bb3ee9667 | ||
|
f654c5effa |
@@ -45,10 +45,18 @@ enum ANIM_TYPE { STILL = 0, SHOOTING = 8, JUMPING = 16, JUMPINGSHOOTING = 24, DE
|
|||||||
enum ANIM_POS {FRONT, QUARTER_FRONT_LEFT, QUATER_FRONT_RIGHT, PROFIL_LEFT, PROFIL_RIGHT, QUARTER_BACK_LEFT, QUARTER_BACK_RIGHT, BACK , POS_LAST};
|
enum ANIM_POS {FRONT, QUARTER_FRONT_LEFT, QUATER_FRONT_RIGHT, PROFIL_LEFT, PROFIL_RIGHT, QUARTER_BACK_LEFT, QUARTER_BACK_RIGHT, BACK , POS_LAST};
|
||||||
typedef uint64_t Timestamp;
|
typedef uint64_t Timestamp;
|
||||||
|
|
||||||
|
enum Resolution {
|
||||||
|
HD = 0, // 1280x720 (High Definition)
|
||||||
|
FHD, // 1920x1080 (Full HD)
|
||||||
|
QHD, // 2560x1440 (Quad HD)
|
||||||
|
UHD // 3840x2160 (Ultra HD)
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#pragma comment(lib,"wsock32.lib") // Pour pouvoir faire fonctionner le linker sans le vcxproject
|
#pragma comment(lib,"wsock32.lib") // Pour pouvoir faire fonctionner le linker sans le vcxproject
|
||||||
#pragma comment(lib,"ws2_32.lib")
|
#pragma comment(lib,"ws2_32.lib")
|
||||||
|
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
<ClInclude Include="mesh.h" />
|
<ClInclude Include="mesh.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
<ClInclude Include="remoteplayer.h" />
|
<ClInclude Include="remoteplayer.h" />
|
||||||
|
<ClInclude Include="settings.h" />
|
||||||
<ClInclude Include="shader.h" />
|
<ClInclude Include="shader.h" />
|
||||||
<ClInclude Include="skybox.h" />
|
<ClInclude Include="skybox.h" />
|
||||||
<ClInclude Include="texture.h" />
|
<ClInclude Include="texture.h" />
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
<ClCompile Include="mesh.cpp" />
|
<ClCompile Include="mesh.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
<ClCompile Include="remoteplayer.cpp" />
|
<ClCompile Include="remoteplayer.cpp" />
|
||||||
|
<ClCompile Include="settings.cpp" />
|
||||||
<ClCompile Include="shader.cpp" />
|
<ClCompile Include="shader.cpp" />
|
||||||
<ClCompile Include="skybox.cpp" />
|
<ClCompile Include="skybox.cpp" />
|
||||||
<ClCompile Include="texture.cpp" />
|
<ClCompile Include="texture.cpp" />
|
||||||
|
@@ -56,6 +56,9 @@
|
|||||||
<ClInclude Include="booster.h">
|
<ClInclude Include="booster.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="settings.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="engine.cpp">
|
<ClCompile Include="engine.cpp">
|
||||||
@@ -103,5 +106,8 @@
|
|||||||
<ClCompile Include="booster.cpp">
|
<ClCompile Include="booster.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="settings.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@@ -48,3 +48,7 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v
|
|||||||
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
|
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
|
||||||
|
|
||||||
void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
|
void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
|
||||||
|
|
||||||
|
float Audio::GetMusicVolume() const {
|
||||||
|
return m_music->getVolume();
|
||||||
|
}
|
||||||
|
@@ -33,6 +33,8 @@ public:
|
|||||||
void ToggleMusicState();
|
void ToggleMusicState();
|
||||||
|
|
||||||
void PauseEngine();
|
void PauseEngine();
|
||||||
|
|
||||||
|
float GetMusicVolume() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIO_H__
|
#endif // AUDIO_H__
|
||||||
|
@@ -76,7 +76,7 @@ void Engine::DrawSplachScreen()
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
m_gamestate = GameState::MAIN_MENU;
|
m_gamestate = GameState::OPTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ void Engine::DrawMenu()
|
|||||||
glVertex2i(0, 200);
|
glVertex2i(0, 200);
|
||||||
glEnd();*/
|
glEnd();*/
|
||||||
|
|
||||||
MenuOptionsTexture.Bind();
|
/*MenuOptionsTexture.Bind();
|
||||||
glTranslated(0, -100, 0);
|
glTranslated(0, -100, 0);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
@@ -170,7 +170,7 @@ void Engine::DrawMenu()
|
|||||||
glVertex2i(sButton, 200);
|
glVertex2i(sButton, 200);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, 200);
|
glVertex2i(0, 200);
|
||||||
glEnd();
|
glEnd();*/
|
||||||
|
|
||||||
MenuQuitTexture.Bind();
|
MenuQuitTexture.Bind();
|
||||||
glTranslated(0, -100, 0);
|
glTranslated(0, -100, 0);
|
||||||
@@ -188,7 +188,7 @@ void Engine::DrawMenu()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MenuOptionsTexture.Bind();
|
/*MenuOptionsTexture.Bind();
|
||||||
glTranslated(200, 0, 0);
|
glTranslated(200, 0, 0);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
@@ -201,7 +201,7 @@ void Engine::DrawMenu()
|
|||||||
glVertex2i(0, 200);
|
glVertex2i(0, 200);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
/*WireFrameTexture.Bind();
|
WireFrameTexture.Bind();
|
||||||
glTranslated(0, 300, 0);
|
glTranslated(0, 300, 0);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
@@ -212,9 +212,9 @@ void Engine::DrawMenu()
|
|||||||
glVertex2i(sButton, 200);
|
glVertex2i(sButton, 200);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, 200);
|
glVertex2i(0, 200);
|
||||||
glEnd();*/
|
glEnd();
|
||||||
|
|
||||||
/*OnOffBtnTexture.Bind();
|
OnOffBtnTexture.Bind();
|
||||||
glTranslated(200, 0, 0);
|
glTranslated(200, 0, 0);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
@@ -226,7 +226,7 @@ void Engine::DrawMenu()
|
|||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, 200);
|
glVertex2i(0, 200);
|
||||||
glEnd();
|
glEnd();
|
||||||
glTranslated(-400, -300, 0);*/
|
glTranslated(-400, -300, 0);
|
||||||
|
|
||||||
MusicTexture.Bind();
|
MusicTexture.Bind();
|
||||||
glTranslated(200, 200, 0);
|
glTranslated(200, 200, 0);
|
||||||
@@ -265,7 +265,7 @@ void Engine::DrawMenu()
|
|||||||
glVertex2i(sButton, 200);
|
glVertex2i(sButton, 200);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, 200);
|
glVertex2i(0, 200);
|
||||||
glEnd();
|
glEnd();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//glEnable(GL_LIGHTING);
|
//glEnable(GL_LIGHTING);
|
||||||
@@ -278,7 +278,7 @@ void Engine::DrawMenu()
|
|||||||
ShowCursor();
|
ShowCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DrawOption()
|
void Engine::DrawPause()
|
||||||
{
|
{
|
||||||
static const int sTitle = 400;
|
static const int sTitle = 400;
|
||||||
static const int sButton = 225;
|
static const int sButton = 225;
|
||||||
@@ -295,36 +295,19 @@ void Engine::DrawOption()
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
MenuBGTexture.Bind();
|
PauseBGTexture.Bind();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex2i(0, 0);
|
glVertex2i(0, 0);
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
glVertex2i(Width(), 0); //
|
glVertex2i(800, 0);
|
||||||
glTexCoord2f(1, 1);
|
glTexCoord2f(1, 1);
|
||||||
glVertex2i(Width(), Height());
|
glVertex2i(800, 600);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, Height());
|
glVertex2i(0, 600);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
//glEnable(GL_LIGHTING);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
ShowCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::Init() {
|
|
||||||
|
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@@ -457,9 +440,7 @@ void Engine::LoadResource() {
|
|||||||
|
|
||||||
LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||||
LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||||
|
LoadTexture(PauseBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||||
LoadTexture(MenuBGOptionTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
|
||||||
|
|
||||||
LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png");
|
LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png");
|
||||||
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
||||||
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
||||||
@@ -1313,15 +1294,14 @@ void Engine::Render(float elapsedTime) {
|
|||||||
lsPck.clear();
|
lsPck.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::MAIN_MENU)
|
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
||||||
{
|
{
|
||||||
DrawMenu();
|
if (!m_soloMultiChoiceMade) {
|
||||||
}
|
DisplaySingleOrMultiplayerMenu();
|
||||||
else if (m_gamestate == GameState::SINGLEMULTI)
|
}
|
||||||
DisplaySingleOrMultiplayerMenu();
|
else {
|
||||||
else if (m_gamestate == GameState::OPTIONS)
|
DrawMenu();
|
||||||
{
|
}
|
||||||
DrawOption();
|
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::PAUSE)
|
else if (m_gamestate == GameState::PAUSE)
|
||||||
{
|
{
|
||||||
@@ -1534,13 +1514,11 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
else if (m_gamestate == GameState::MAIN_MENU)
|
else if (m_gamestate == GameState::MAIN_MENU)
|
||||||
{
|
{
|
||||||
if ((m_mousemx >= 285 && m_mousemx <= 490) && (m_mousemy >= 150 && m_mousemy <= 250))
|
if ((m_mousemx >= 285 && m_mousemx <= 490) && (m_mousemy >= 150 && m_mousemy <= 250))
|
||||||
m_gamestate = GameState::SINGLEMULTI;
|
m_gamestate = GameState::PLAY;
|
||||||
if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 300 && m_mousemy <= 400))
|
if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 300 && m_mousemy <= 400))
|
||||||
m_gamestate = GameState::OPTIONS;
|
|
||||||
if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 450 && m_mousemy <= 500))
|
|
||||||
m_gamestate = GameState::QUIT;
|
m_gamestate = GameState::QUIT;
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::SINGLEMULTI)
|
else if (m_gamestate == GameState::OPTIONS)
|
||||||
{
|
{
|
||||||
float buttonWidthProportion = 0.4f;
|
float buttonWidthProportion = 0.4f;
|
||||||
float buttonHeightProportion = 0.075f;
|
float buttonHeightProportion = 0.075f;
|
||||||
|
@@ -24,14 +24,14 @@
|
|||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "remoteplayer.h"
|
#include "remoteplayer.h"
|
||||||
#include "booster.h"
|
#include "booster.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
virtual void DrawMenu();
|
virtual void DrawMenu();
|
||||||
virtual void DrawOption();
|
virtual void DrawPause();
|
||||||
virtual void DrawSplachScreen();
|
virtual void DrawSplachScreen();
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
@@ -64,10 +64,6 @@ private:
|
|||||||
void DrawHud(float elapsedTime, BlockType bloc);
|
void DrawHud(float elapsedTime, BlockType bloc);
|
||||||
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Connector m_conn;
|
Connector m_conn;
|
||||||
Shader m_shader01;
|
Shader m_shader01;
|
||||||
BlockInfo* m_blockinfo[BTYPE_LAST];
|
BlockInfo* m_blockinfo[BTYPE_LAST];
|
||||||
@@ -99,6 +95,7 @@ private:
|
|||||||
irrklang::ISound *m_whoosh[MAX_BULLETS];
|
irrklang::ISound *m_whoosh[MAX_BULLETS];
|
||||||
|
|
||||||
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
||||||
|
Settings m_parameters = Settings(m_audio);
|
||||||
|
|
||||||
Bullet* m_bullets[MAX_BULLETS];
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
@@ -107,20 +104,15 @@ private:
|
|||||||
std::chrono::high_resolution_clock::time_point m_startTime;
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
||||||
|
|
||||||
//Menu
|
//Menu
|
||||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY,SINGLEMULTI };
|
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
||||||
|
|
||||||
GameState m_gamestate = GameState::MAIN_MENU;
|
GameState m_gamestate = GameState::MAIN_MENU;
|
||||||
Texture MenuTitleTexture;
|
Texture MenuTitleTexture;
|
||||||
Texture MenuBGTexture;
|
Texture MenuBGTexture;
|
||||||
Texture MenuBGOptionTexture;
|
|
||||||
Texture MenuStartTexture;
|
Texture MenuStartTexture;
|
||||||
Texture MenuQuitTexture;
|
Texture MenuQuitTexture;
|
||||||
Texture MenuOptionsTexture;
|
Texture MenuOptionsTexture;
|
||||||
Texture PauseBGTexture;
|
Texture PauseBGTexture;
|
||||||
Texture SplachScreenTexture;
|
Texture SplachScreenTexture;
|
||||||
Texture MusicTexture; //TODO
|
|
||||||
Texture OnOffBtnTexture;//TODO
|
|
||||||
Texture BackBtnTexture;//TODO
|
|
||||||
|
|
||||||
|
|
||||||
float m_scale;
|
float m_scale;
|
||||||
@@ -128,8 +120,6 @@ private:
|
|||||||
float m_time_SplashScreen = 0;
|
float m_time_SplashScreen = 0;
|
||||||
float m_titleX = 0;
|
float m_titleX = 0;
|
||||||
float m_titleY = 0;
|
float m_titleY = 0;
|
||||||
float m_Width = 0;
|
|
||||||
float m_Height = 0;
|
|
||||||
|
|
||||||
int m_renderCount = 0;
|
int m_renderCount = 0;
|
||||||
int m_countdown = COUNTDOWN;
|
int m_countdown = COUNTDOWN;
|
||||||
|
146
SQCSim2021/settings.cpp
Normal file
146
SQCSim2021/settings.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
Settings::Settings(Audio& audio)
|
||||||
|
: m_audio(audio),
|
||||||
|
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 Settings::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 Settings::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 Settings::GetMainVolume() const {
|
||||||
|
return m_mainVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetMainVolume(float volume) {
|
||||||
|
m_mainVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::GetMusicVolume() {
|
||||||
|
m_musicVolume = m_audio.GetMusicVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetMusicVolume(float volume) {
|
||||||
|
m_musicVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetSfxVolume() const {
|
||||||
|
return m_sfxVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetSfxVolume(float volume) {
|
||||||
|
m_sfxVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetBrightness() const {
|
||||||
|
return m_brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetBrightness(float brightness) {
|
||||||
|
m_brightness = brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetContrast() const {
|
||||||
|
return m_contrast;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetContrast(float contrast) {
|
||||||
|
m_contrast = contrast;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::GetFullscreen() const {
|
||||||
|
return m_fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetFullscreen(bool fullscreen) {
|
||||||
|
m_fullscreen = fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Resolution& Settings::GetResolution() const {
|
||||||
|
return m_resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetResolution(const Resolution& resolution) {
|
||||||
|
m_resolution = resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetMouseSensitivity() const {
|
||||||
|
return m_mouseSensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetMouseSensitivity(float sensitivity) {
|
||||||
|
m_mouseSensitivity = sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::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;
|
||||||
|
}
|
||||||
|
}
|
70
SQCSim2021/settings.h
Normal file
70
SQCSim2021/settings.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef SETTINGS_H__
|
||||||
|
#define SETTINGS_H__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "define.h"
|
||||||
|
#include "audio.h"
|
||||||
|
|
||||||
|
class Settings {
|
||||||
|
public:
|
||||||
|
Settings(Audio& audio);
|
||||||
|
|
||||||
|
void SaveFile(const std::string& filename);
|
||||||
|
void LoadFile(const std::string& filename);
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
float GetMainVolume() const;
|
||||||
|
void SetMainVolume(float volume);
|
||||||
|
|
||||||
|
void GetMusicVolume();
|
||||||
|
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& m_audio;
|
||||||
|
// 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