Push menu options de base

This commit is contained in:
mduval76
2023-12-01 09:49:00 -05:00
parent 15882dc506
commit 28082a018d
14 changed files with 155 additions and 54 deletions

View File

@@ -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;