SQC-15_online #1
| @@ -139,6 +139,7 @@ | ||||
|     <ClInclude Include="define.h" /> | ||||
|     <ClInclude Include="matrix4.h" /> | ||||
|     <ClInclude Include="opensimplex.h" /> | ||||
|     <ClInclude Include="parameters.h" /> | ||||
|     <ClInclude Include="player.h" /> | ||||
|     <ClInclude Include="netprotocol.h" /> | ||||
|     <ClInclude Include="transformation.h" /> | ||||
| @@ -151,6 +152,7 @@ | ||||
|     <ClCompile Include="chunk.cpp" /> | ||||
|     <ClCompile Include="netprotocol.cpp" /> | ||||
|     <ClCompile Include="opensimplex.cpp" /> | ||||
|     <ClCompile Include="parameters.cpp" /> | ||||
|     <ClCompile Include="player.cpp" /> | ||||
|     <ClCompile Include="transformation.cpp" /> | ||||
|     <ClCompile Include="world.cpp" /> | ||||
|   | ||||
| @@ -54,6 +54,9 @@ | ||||
|     <ClInclude Include="transformation.h"> | ||||
|       <Filter>Fichiers d%27en-tête</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="parameters.h"> | ||||
|       <Filter>Fichiers d%27en-tête</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="world.cpp"> | ||||
| @@ -80,5 +83,8 @@ | ||||
|     <ClCompile Include="transformation.cpp"> | ||||
|       <Filter>Fichiers sources</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="parameters.cpp"> | ||||
|       <Filter>Fichiers sources</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
							
								
								
									
										67
									
								
								SQCSim-common/parameters.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								SQCSim-common/parameters.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| #include "parameters.h" | ||||
|  | ||||
| Parameters::Parameters() {} | ||||
|  | ||||
| Parameters::~Parameters() {} | ||||
|  | ||||
| void Parameters::SaveAudioParameters() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Parameters::SaveGraphicParameters() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Parameters::SaveGameParameters() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Parameters::LoadAudioParameters() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Parameters::LoadGraphicParameters() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Parameters::LoadGameParameters() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Parameters::SetAudioParameter(const std::string& key, const ParameterValue& value) { | ||||
| 	m_audioSettings[key] = value; | ||||
| } | ||||
|  | ||||
| void Parameters::SetGraphicParameter(const std::string& key, const ParameterValue& value) { | ||||
| 	m_graphicSettings[key] = value; | ||||
| } | ||||
|  | ||||
| void Parameters::SetGameParameter(const std::string& key, const ParameterValue& value) { | ||||
| 	m_gameplaySettings[key] = value; | ||||
| } | ||||
|  | ||||
| std::optional<ParameterValue> Parameters::GetAudioParameter(const std::string& key) const { | ||||
| 	auto it = m_audioSettings.find(key); | ||||
| 	if (it != m_audioSettings.end()) { | ||||
| 		return it->second; | ||||
| 	} | ||||
| 	return std::nullopt; | ||||
| } | ||||
|  | ||||
| std::optional<ParameterValue> Parameters::GetGraphicParameter(const std::string& key) const { | ||||
| 	auto it = m_graphicSettings.find(key); | ||||
| 	if (it != m_graphicSettings.end()) { | ||||
| 		return it->second; | ||||
| 	} | ||||
| 	return std::nullopt; | ||||
| } | ||||
|  | ||||
| std::optional<ParameterValue> Parameters::GetGameParameter(const std::string& key) const { | ||||
| 	auto it = m_gameplaySettings.find(key); | ||||
| 	if (it != m_gameplaySettings.end()) { | ||||
| 		return it->second; | ||||
| 	} | ||||
| 	return std::nullopt; | ||||
| } | ||||
|  | ||||
|  | ||||
							
								
								
									
										55
									
								
								SQCSim-common/parameters.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								SQCSim-common/parameters.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| #ifndef PARAMETERS_H | ||||
| #define PARAMETERS_H | ||||
|  | ||||
| #include <optional> | ||||
| #include <iostream> | ||||
| #include <fstream> | ||||
| #include <sstream> | ||||
| #include <variant> | ||||
| #include <string> | ||||
| #include <map> | ||||
|  | ||||
| using ParameterValue = std::variant<float, int, bool, std::string>; | ||||
|  | ||||
| class Parameters { | ||||
| public: | ||||
| 	Parameters(); | ||||
| 	~Parameters(); | ||||
|  | ||||
| 	void SaveAudioParameters(); | ||||
| 	void SaveGraphicParameters(); | ||||
| 	void SaveGameParameters(); | ||||
|  | ||||
| 	void LoadAudioParameters(); | ||||
| 	void LoadGraphicParameters(); | ||||
| 	void LoadGameParameters(); | ||||
|  | ||||
| 	void SetAudioParameter(const std::string& key, const ParameterValue& value); | ||||
| 	void SetGraphicParameter(const std::string& key, const ParameterValue& value); | ||||
| 	void SetGameParameter(const std::string& key, const ParameterValue& value); | ||||
|  | ||||
| 	std::optional<ParameterValue> GetAudioParameter(const std::string& key) const; | ||||
| 	std::optional<ParameterValue> GetGraphicParameter(const std::string& key) const; | ||||
| 	std::optional<ParameterValue> GetGameParameter(const std::string& key) const; | ||||
|  | ||||
| private: | ||||
| 	std::map<std::string, ParameterValue> m_audioSettings; | ||||
| 	std::map<std::string, ParameterValue> m_graphicSettings; | ||||
| 	std::map<std::string, ParameterValue> m_gameplaySettings; | ||||
|  | ||||
| 	// Audio | ||||
| 	float m_mainVolume; | ||||
| 	float m_musicVolume; | ||||
| 	float m_sfxVolume; | ||||
|  | ||||
| 	// Graphic | ||||
| 	float m_resolutionX; | ||||
| 	float m_resolutionY; | ||||
| 	bool m_fullscreen; | ||||
|  | ||||
| 	// Gameplay | ||||
| 	float m_mouseSensitivity; | ||||
|  | ||||
| }; | ||||
|  | ||||
| #endif // PARAMETERS_H | ||||
| @@ -28,7 +28,6 @@ | ||||
| #define BASE_WIDTH 640 | ||||
| #define BASE_HEIGHT 480 | ||||
|  | ||||
|  | ||||
| #define TEXTURE_PATH        "./media/textures/" | ||||
| #define SHADER_PATH		    "./media/shaders/" | ||||
| #define AUDIO_PATH			"./media/audio/" | ||||
|   | ||||
| @@ -101,13 +101,10 @@ private: | ||||
|     Texture PauseBGTexture; | ||||
|     Texture SplachScreenTexture; | ||||
|  | ||||
|     float m_scale; | ||||
|     float m_time = 0; | ||||
|     float m_time_SplashScreen = 0; | ||||
|     float m_titleX = 0; | ||||
|     float m_titleY = 0; | ||||
|     float m_Width = 0; | ||||
|     float m_Height = 0; | ||||
|  | ||||
|     int m_renderCount = 0; | ||||
|     int m_countdown = COUNTDOWN; | ||||
|   | ||||
| @@ -1 +0,0 @@ | ||||
| #include "parameters.h" | ||||
| @@ -1,8 +0,0 @@ | ||||
| #ifndef PARAMETERS_H | ||||
| #define PARAMETERS_H | ||||
|  | ||||
| class Parameters { | ||||
|  | ||||
| }; | ||||
|  | ||||
| #endif // PARAMETERS_H | ||||
		Reference in New Issue
	
	Block a user