Push menu pause fonctionnel
This commit is contained in:
parent
7c1f70646a
commit
c099a3b8eb
@ -50,7 +50,6 @@ enum GameState {
|
||||
SPLASH,
|
||||
LOBBY,
|
||||
OPTIONS,
|
||||
QUIT,
|
||||
PLAY,
|
||||
PAUSE
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ void Engine::LoadResource() {
|
||||
|
||||
LoadTexture(m_textureLobbyMenu, TEXTURE_PATH "menus/backgrounds/bgLobby.png", false);
|
||||
LoadTexture(m_textureMainMenu, TEXTURE_PATH "menus/backgrounds/bgMainMenu.png", false);
|
||||
//LoadTexture(m_texturePauseMenu, TEXTURE_PATH "menus/backgrounds/bgPause.png", false);
|
||||
LoadTexture(m_texturePauseMenu, TEXTURE_PATH "menus/backgrounds/bgPause.png", false);
|
||||
LoadTexture(m_textureOptionsMenu, TEXTURE_PATH "menus/backgrounds/bgOptions.png", false);
|
||||
LoadTexture(m_textureSplashScreen, TEXTURE_PATH "menus/backgrounds/bgSplash.png", false);
|
||||
|
||||
@ -111,6 +111,9 @@ void Engine::LoadResource() {
|
||||
LoadTexture(m_textureUhd, TEXTURE_PATH "menus/labels/labelUhd.png", false);
|
||||
LoadTexture(m_textureMenuTitle, TEXTURE_PATH "menus/labels/labelTitle.png", false);
|
||||
|
||||
LoadTexture(m_texturePauseResume, TEXTURE_PATH "menus/buttons/pause/pauseResume.png", false);
|
||||
LoadTexture(m_texturePauseMainMenu, TEXTURE_PATH "menus/buttons/pause/pauseMainMenu.png", false);
|
||||
|
||||
LoadTexture(m_textureMenuBack, TEXTURE_PATH "menus/buttons/main/mainBack.png", false);
|
||||
LoadTexture(m_textureMenuMulti, TEXTURE_PATH "menus/buttons/main/mainMulti.png", false);
|
||||
LoadTexture(m_textureMenuOptions, TEXTURE_PATH "menus/buttons/main/mainOptions.png", false);
|
||||
@ -317,6 +320,7 @@ void Engine::ProcessNotificationQueue() {
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
||||
@ -335,14 +339,10 @@ void Engine::DisplayCrosshair() {
|
||||
glLoadIdentity();
|
||||
glTranslated(Width() / 2 - crossSize / 2, Height() / 2 - crossSize / 2, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(crossSize, 0);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(crossSize, crossSize);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, crossSize);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0); glVertex2i(crossSize, 0);
|
||||
glTexCoord2f(1, 1); glVertex2i(crossSize, crossSize);
|
||||
glTexCoord2f(0, 1); glVertex2i(0, crossSize);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@ -461,18 +461,18 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
int timer = GetCountdown(elapsedTime);
|
||||
/*for (int i = 1; i < WORLD_SIZE_X; i++) {
|
||||
@ -506,14 +506,13 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void Engine::DisplayPovGun() {
|
||||
@ -526,12 +525,12 @@ void Engine::DisplayPovGun() {
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
float baseXOffsetPercentage = 0.4958;
|
||||
float baseWidthPercentage = 0.4688;
|
||||
@ -542,26 +541,21 @@ void Engine::DisplayPovGun() {
|
||||
float quadHeight = baseHeightPercentage * Height();
|
||||
|
||||
m_texturePovGun.Bind();
|
||||
glLoadIdentity();
|
||||
glTranslated(xTranslation, 0, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0); glVertex2i(quadWidth, 0);
|
||||
glTexCoord2f(1, 1); glVertex2i(quadWidth, quadHeight);
|
||||
glTexCoord2f(0, 1); glVertex2i(0, quadHeight);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0); glVertex2i(quadWidth, 0);
|
||||
glTexCoord2f(1, 1); glVertex2i(quadWidth, quadHeight);
|
||||
glTexCoord2f(0, 1); glVertex2i(0, quadHeight);
|
||||
glEnd();
|
||||
|
||||
// Reset du blend function
|
||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void Engine::PrintText(float x, float y, const std::string& t, float charSizeMultiplier) {
|
||||
@ -719,7 +713,6 @@ void Engine::DisplaySplashScreen() {
|
||||
}
|
||||
|
||||
void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
@ -728,7 +721,6 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||
|
||||
@ -758,7 +750,6 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
@ -795,6 +786,47 @@ void Engine::SetServerAddress(float elapsedTime) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void Engine::DisplayPauseMenu(float elapsedTime) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
m_texturePauseMenu.Bind();
|
||||
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(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_texturePauseResume.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(Width() * 0.025f, Height() * 0.75);
|
||||
glTexCoord2f(1, 0); glVertex2i(Width() * 0.33f, Height() * 0.75);
|
||||
glTexCoord2f(1, 1); glVertex2i(Width() * 0.33f, Height() * 0.95);
|
||||
glTexCoord2f(0, 1); glVertex2i(Width() * 0.025f, Height() * 0.95);
|
||||
glEnd();
|
||||
|
||||
m_texturePauseMainMenu.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(Width() * 0.67f, Height() * 0.75);
|
||||
glTexCoord2f(1, 0); glVertex2i(Width() * 0.9975f, Height() * 0.75);
|
||||
glTexCoord2f(1, 1); glVertex2i(Width() * 0.9975f, Height() * 0.95);
|
||||
glTexCoord2f(0, 1); glVertex2i(Width() * 0.67f, Height() * 0.95);
|
||||
glEnd();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Engine::DisplayMainMenu() {
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
@ -1248,6 +1280,20 @@ void Engine::Render(float elapsedTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gamestate == GameState::PAUSE) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
DisplayPauseMenu(elapsedTime);
|
||||
ShowCursor();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gamestate == GameState::PLAY) {
|
||||
HideCursor();
|
||||
CenterMouse();
|
||||
@ -1299,7 +1345,6 @@ void Engine::Render(float elapsedTime) {
|
||||
|
||||
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
||||
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
|
||||
|
||||
m_player.ApplyTransformation(remotePlayer, true, false);
|
||||
|
||||
m_mouseWU = m_mouseWD = m_key1 = m_key2 = false;
|
||||
@ -1535,7 +1580,6 @@ void Engine::Render(float elapsedTime) {
|
||||
}
|
||||
lsPck.clear();
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
for (auto& [key, player] : m_players) {
|
||||
RemotePlayer* rt = static_cast<RemotePlayer*>(player);
|
||||
@ -1557,7 +1601,6 @@ void Engine::Render(float elapsedTime) {
|
||||
|
||||
DrawHud(elapsedTime, bloc);
|
||||
DisplayPovGun();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1991,7 +2034,6 @@ char Engine::SimulateKeyboard(unsigned char key) {
|
||||
|
||||
if ((int)key != 38 && !m_invalidChar) {
|
||||
m_charChanged = true;
|
||||
std::cout << "Key pressed: " << (int)key << " (" << m_inputChar << ")" << std::endl;
|
||||
}
|
||||
|
||||
m_invalidChar = false;
|
||||
@ -2047,17 +2089,8 @@ void Engine::HandlePlayerInput(float elapsedTime) {
|
||||
|
||||
ss << m_currentInputString;
|
||||
m_charChanged = false;
|
||||
|
||||
if (lobbyTime < onInterval) {
|
||||
ss << "_";
|
||||
}
|
||||
else if (lobbyTime > onInterval && lobbyTime < offInterval) {
|
||||
ss << " ";
|
||||
}
|
||||
else {
|
||||
lobbyTime = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
ss << (lobbyTime < onInterval ? "_" : (lobbyTime > onInterval && lobbyTime < offInterval) ? " " : (lobbyTime = 0.0f, ""));
|
||||
PrintText(Width() * 0.6f, Height() * 0.4f, ss.str(), 2.0f);
|
||||
}
|
||||
|
||||
@ -2162,7 +2195,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
m_selectedPlayOptions = false;
|
||||
}
|
||||
else {
|
||||
m_gamestate = GameState::QUIT;
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2261,6 +2294,26 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
m_selectedGameplaySensitivityBar = true;
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::PAUSE) {
|
||||
float leftResume = centerX - Width() * 0.4735f;
|
||||
float rightResume = centerX - Width() * 0.1765f;
|
||||
float topResume = centerY - Height() * 0.271f;
|
||||
float bottomResume = centerY - Height() * 0.4415f;
|
||||
|
||||
float leftMainMenu = centerX + Width() * 0.17f;
|
||||
float rightMainMenu = centerX + Width() * 0.4875f;
|
||||
float topMainMenu = centerY - Height() * 0.255f;
|
||||
float bottomMainMenu = centerY - Height() * 0.4415f;
|
||||
|
||||
if (x > leftResume && x < rightResume && y > bottomResume && y < topResume) {
|
||||
m_gamestate = GameState::PLAY;
|
||||
m_audio.ToggleMusicState();
|
||||
}
|
||||
else if (x > leftMainMenu && x < rightMainMenu && y > bottomMainMenu && y < topMainMenu) {
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
m_selectedPlayOptions = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
|
@ -73,6 +73,8 @@ private:
|
||||
void SetPlayerUsername(float elapsedTime);
|
||||
void SetServerAddress(float elapsedTime);
|
||||
|
||||
void DisplayPauseMenu(float elapsedTime);
|
||||
|
||||
void DisplayOptionsMenu();
|
||||
void DisplayAudioMenu(float centerX, float centerY);
|
||||
void DisplayGraphicsMenu(float centerX, float centerY);
|
||||
@ -138,6 +140,9 @@ private:
|
||||
Texture m_textureCheck;
|
||||
Texture m_textureChecked;
|
||||
|
||||
Texture m_texturePauseResume;
|
||||
Texture m_texturePauseMainMenu;
|
||||
|
||||
Texture m_textureOptAudio;
|
||||
Texture m_textureOptBack;
|
||||
Texture m_textureOptGameplay;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 562 KiB After Width: | Height: | Size: 596 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/pause/pauseMainMenu.png
Normal file
BIN
SQCSim2021/media/textures/menus/buttons/pause/pauseMainMenu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/pause/pauseResume.png
Normal file
BIN
SQCSim2021/media/textures/menus/buttons/pause/pauseResume.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
Loading…
Reference in New Issue
Block a user