diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 32e18e0..4f61b3e 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -87,8 +87,6 @@ void Engine::DrawMenu() static const int sButton = 225; glDisable(GL_LIGHTING); - - glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); glMatrixMode(GL_PROJECTION); @@ -130,8 +128,6 @@ void Engine::DrawMenu() glVertex2i(0, 300); glEnd(); - - MenuStartTexture.Bind(); glTranslated(80, -225, 0); glBegin(GL_QUADS); @@ -145,20 +141,6 @@ void Engine::DrawMenu() glVertex2i(0, 200); glEnd(); - - /*MenuResumeTexture.Bind(); - glTranslated(0, -100, 0); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2i(0, 125); - //glTexCoord2f(1, 0); - glVertex2i(sButton, 125); - glTexCoord2f(1, 1); - glVertex2i(sButton, 200); - glTexCoord2f(0, 1); - glVertex2i(0, 200); - glEnd();*/ - MenuOptionsTexture.Bind(); glTranslated(0, -100, 0); glBegin(GL_QUADS); @@ -283,43 +265,102 @@ void Engine::DrawOption() static const int sTitle = 400; static const int sButton = 225; - glDisable(GL_LIGHTING); + int centerX = Width() * 0.5f; + int centerY = Height() * 0.5f; + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, Width(), 0, Height(), -1, 1); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - MenuBGTexture.Bind(); - glLoadIdentity(); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2i(0, 0); - glTexCoord2f(1, 0); - glVertex2i(Width(), 0); // - glTexCoord2f(1, 1); - glVertex2i(Width(), Height()); - glTexCoord2f(0, 1); - glVertex2i(0, Height()); - glEnd(); - + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); - glEnable(GL_BLEND); - //glEnable(GL_LIGHTING); - glDisable(GL_BLEND); + glDisable(GL_STENCIL_TEST); + glDisable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + + glLoadIdentity(); + glOrtho(0, Width(), 0, Height(), -1, 1); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + MenuBGFlouTexture.Bind(); + glLoadIdentity(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(0, 0); + glTexCoord2f(1, 0); glVertex2i(Width(), 0); + glTexCoord2f(1, 1); glVertex2i(Width(), Height()); + glTexCoord2f(0, 1); glVertex2i(0, Height()); + glEnd(); + + glColor4f(0.85f, 0.95f, 0.0f, 1.0f); + m_textureOptions.Bind(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.175, centerY + Height() * 0.35); + glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.175, centerY + Height() * 0.35); + glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.175, centerY + Height() * 0.45); + glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.175, centerY + Height() * 0.45); + glEnd(); + + if (m_selectedOption == 0) { + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); + } + m_textureVolume.Bind(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.35, centerY + Height() * 0.2); + glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.2); + glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.25); + glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.35, centerY + Height() * 0.25); + glEnd(); + + glColor4f(0.85f, 0.95f, 0.0f, 1.0f); + if (m_selectedOption == 1) { + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); + } + m_textureGraphiques.Bind(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.4, centerY + Height() * 0.05); + glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.05); + glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.1); + glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.4, centerY + Height() * 0.1); + glEnd(); + + glColor4f(0.85f, 0.95f, 0.0f, 1.0f); + if (m_selectedOption == 2) { + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); + } + m_textureGameplay.Bind(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.375, centerY - Height() * 0.1); + glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.2, centerY - Height() * 0.1); + glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.2, centerY - Height() * 0.05); + glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.375, centerY - Height() * 0.05); + glEnd(); + + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glBindTexture(GL_TEXTURE_2D, 0); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.175, centerY - Height() * 0.1); + glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.1751, centerY - Height() * 0.1); + glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.1751, centerY + Height() * 0.25); + glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.175, centerY + Height() * 0.25); + glEnd(); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + + glEnable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); + glMatrixMode(GL_PROJECTION); glPopMatrix(); + glMatrixMode(GL_MODELVIEW); glPopMatrix(); - ShowCursor(); } void Engine::Init() { @@ -355,10 +396,8 @@ void Engine::Init() { return; else m_istarted = true; - // // Objet de skybox avec sa propre texture et son propre shader! m_skybox.Init(0.2f); - //m_skybox2.Init(1.f); // Objet de musique! //m_audio.ToggleMusicState(); @@ -442,11 +481,21 @@ void Engine::LoadResource() { LoadTexture(m_textureMultiText, TEXTURE_PATH "multi_player.png", false); LoadTexture(m_textureSoloMultiMenu, TEXTURE_PATH "single_multi.png", false); LoadTexture(m_textureTitle, TEXTURE_PATH "title.png", false); + LoadTexture(m_textureOptions, TEXTURE_PATH "Bouton/options.png", false); + LoadTexture(m_textureVolume, TEXTURE_PATH "Bouton/volume.png", false); + LoadTexture(m_textureMusique, TEXTURE_PATH "Bouton/musique.png", false); + LoadTexture(m_textureGraphiques, TEXTURE_PATH "Bouton/graphiques.png", false); + LoadTexture(m_textureSensibilite, TEXTURE_PATH "Bouton/sensibilite.png", false); + LoadTexture(m_textureResolution, TEXTURE_PATH "Bouton/resolution.png", false); + LoadTexture(m_texturePrincipal, TEXTURE_PATH "Bouton/principal.png", false); + LoadTexture(m_textureEffets, TEXTURE_PATH "Bouton/effets.png", false); + LoadTexture(m_textureGameplay, TEXTURE_PATH "Bouton/gameplay.png", false); + // Pourquoi on load 3 fois la meme texture? LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png"); LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png"); - LoadTexture(MenuBGOptionTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png"); + LoadTexture(MenuBGFlouTexture, TEXTURE_PATH "BackgroundMenuFlou.png"); LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png"); LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png"); @@ -693,9 +742,7 @@ void Engine::DisplayPovGun() { glPopMatrix(); } -void Engine::DisplayCurrentItem() { -} - +void Engine::DisplayCurrentItem() {} void Engine::DisplayHud(int timer) { glBindTexture(GL_TEXTURE_2D, 0); @@ -975,6 +1022,10 @@ void Engine::DisplaySingleOrMultiplayerMenu() { ShowCursor(); } +void Engine::DisplayAudioMenu() { + +} + void Engine::DrawHud(float elapsedTime, BlockType bloc) { // Setter le blend function, tout ce qui sera noir sera transparent glDisable(GL_STENCIL_TEST); @@ -1082,6 +1133,10 @@ int Engine::GetCountdown(float elapsedTime) { return m_countdown - (int)m_time; } +int Engine::GetOptionsChoice() { + return m_selectedOption; +} + void Engine::Render(float elapsedTime) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -1307,7 +1362,7 @@ void Engine::Render(float elapsedTime) { } else if (m_gamestate == GameState::SINGLEMULTI) DisplaySingleOrMultiplayerMenu(); - else if (m_gamestate == GameState::OPTIONS) + else if (m_gamestate == GameState::OPTIONS || m_gamestate == GameState::PAUSE) { DrawOption(); } @@ -1524,6 +1579,38 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 450 && m_mousemy <= 500)) m_gamestate = GameState::QUIT; } + else if (m_gamestate == GameState::OPTIONS) { + float centerX = Width() * 0.5f; + float centerY = Height() * 0.5f; + + float leftVol = centerX - Width() * 0.35f; + float rightVol = centerX - Width() * 0.2f; + float topVol = (Height() * 0.25f) + ((Height() * 0.25f) - (Height() * 0.2f)); + float bottomVol = (Height() * 0.2f) + ((Height() * 0.25f) - (Height() * 0.2f)); + + float leftGraph = centerX - Width() * 0.4f; + float rightGraph = centerX - Width() * 0.2f; + float topGraph = centerY - Height() * 0.05f; + float bottomGraph = centerY - Height() * 0.1f; + + float leftGameplay = centerX - Width() * 0.375f; + float rightGameplay = centerX - Width() * 0.2f; + float topGameplay = centerY + Height() * 0.1f; + float bottomGameplay = centerY + Height() * 0.05f; + + if (x > leftVol && x < rightVol && y > bottomVol && y < topVol) { + m_selectedOption = 0; // Volume + } + else if (x > leftGraph && x < rightGraph && y > bottomGraph && y < topGraph) { + m_selectedOption = 1; // Graphics + } + else if (x > leftGameplay && x < rightGameplay && y > bottomGameplay && y < topGameplay) { + m_selectedOption = 2; // Gameplay + } + else { + m_selectedOption = -1; + } + } else if (m_gamestate == GameState::SINGLEMULTI) { float buttonWidthProportion = 0.4f; diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 47f9439..a4b778d 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -47,6 +47,7 @@ public: private: int GetFps(float elapsedTime) const; int GetCountdown(float elapsedTime); + int GetOptionsChoice(); bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true); @@ -54,15 +55,16 @@ private: void SystemNotification(std::string systemLog); void KillNotification(Player killer, Player killed); void DisplayNotification(std::string message); - void ProcessNotificationQueue(); void DisplayCrosshair(); void DisplayPovGun(); void DisplayCurrentItem(); void DisplayHud(int timer); void DisplayInfo(float elapsedTime, BlockType bloc); void DisplaySingleOrMultiplayerMenu(); + void DisplayAudioMenu(); void DrawHud(float elapsedTime, BlockType bloc); void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f); + void ProcessNotificationQueue(); Connector m_conn; Shader m_shader01; @@ -84,6 +86,16 @@ private: Texture m_textureSoloText; Texture m_textureMultiText; Texture m_textureTitle; + Texture m_textureOptions; + Texture m_textureVolume; + Texture m_textureMusique; + Texture m_textureGraphiques; + Texture m_textureSensibilite; + Texture m_textureResolution; + Texture m_texturePrincipal; + Texture m_textureEffets; + Texture m_textureGameplay + ; TextureAtlas::TextureIndex texBoostHeal; @@ -104,11 +116,12 @@ private: std::chrono::high_resolution_clock::time_point m_startTime; //Menu - enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE, SINGLEMULTI }; + enum class GameState: uint8_t { MAIN_MENU, OPTIONS, SETTINGS, QUIT, NEWG, PLAY, PAUSE, SINGLEMULTI }; GameState m_gamestate = GameState::MAIN_MENU; Texture MenuTitleTexture; Texture MenuBGTexture; + Texture MenuBGFlouTexture; Texture MenuBGOptionTexture; Texture MenuStartTexture; Texture MenuQuitTexture; @@ -130,6 +143,7 @@ private: int m_countdown = COUNTDOWN; int m_nbReductionChunk = 4; int m_timerReductionChunk = 30; + int m_selectedOption = 0; bool m_damage = false; diff --git a/SQCSim2021/media/textures/BackgroundMenuFlou.png b/SQCSim2021/media/textures/BackgroundMenuFlou.png new file mode 100644 index 0000000..84840f7 Binary files /dev/null and b/SQCSim2021/media/textures/BackgroundMenuFlou.png differ diff --git a/SQCSim2021/media/textures/Bouton/BasicPlay.png b/SQCSim2021/media/textures/Bouton/BasicPlay.png deleted file mode 100644 index 109f65a..0000000 Binary files a/SQCSim2021/media/textures/Bouton/BasicPlay.png and /dev/null differ diff --git a/SQCSim2021/media/textures/Bouton/BasicQuit.png b/SQCSim2021/media/textures/Bouton/BasicQuit.png deleted file mode 100644 index db7ad29..0000000 Binary files a/SQCSim2021/media/textures/Bouton/BasicQuit.png and /dev/null differ diff --git a/SQCSim2021/media/textures/Bouton/effets.png b/SQCSim2021/media/textures/Bouton/effets.png new file mode 100644 index 0000000..13d8166 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/effets.png differ diff --git a/SQCSim2021/media/textures/Bouton/gameplay.png b/SQCSim2021/media/textures/Bouton/gameplay.png new file mode 100644 index 0000000..7d5033a Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/gameplay.png differ diff --git a/SQCSim2021/media/textures/Bouton/graphiques.png b/SQCSim2021/media/textures/Bouton/graphiques.png new file mode 100644 index 0000000..0c69556 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/graphiques.png differ diff --git a/SQCSim2021/media/textures/Bouton/musique.png b/SQCSim2021/media/textures/Bouton/musique.png new file mode 100644 index 0000000..6624e59 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/musique.png differ diff --git a/SQCSim2021/media/textures/Bouton/options.png b/SQCSim2021/media/textures/Bouton/options.png new file mode 100644 index 0000000..3055ff5 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/options.png differ diff --git a/SQCSim2021/media/textures/Bouton/principal.png b/SQCSim2021/media/textures/Bouton/principal.png new file mode 100644 index 0000000..f1ecde7 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/principal.png differ diff --git a/SQCSim2021/media/textures/Bouton/resolution.png b/SQCSim2021/media/textures/Bouton/resolution.png new file mode 100644 index 0000000..36739dc Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/resolution.png differ diff --git a/SQCSim2021/media/textures/Bouton/sensibilite.png b/SQCSim2021/media/textures/Bouton/sensibilite.png new file mode 100644 index 0000000..a2da5b5 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/sensibilite.png differ diff --git a/SQCSim2021/media/textures/Bouton/volume.png b/SQCSim2021/media/textures/Bouton/volume.png new file mode 100644 index 0000000..30e03b0 Binary files /dev/null and b/SQCSim2021/media/textures/Bouton/volume.png differ