|
|
@@ -3,6 +3,7 @@
|
|
|
#include "GamePlayState.h"
|
|
|
#include "MainMenuState.h"
|
|
|
#include <imgui.h>
|
|
|
+#include <SDL2/SDL.h>
|
|
|
|
|
|
void PauseState::Enter(Engine& engine)
|
|
|
{
|
|
|
@@ -16,7 +17,7 @@ void PauseState::HandleEvents(Engine& engine, SDL_Event& event)
|
|
|
{
|
|
|
if (event.type == SDL_KEYDOWN)
|
|
|
{
|
|
|
- if (event.type.keysym.sym == SDLK_ESCAPE)
|
|
|
+ if (event.key.keysym.sym == SDLK_ESCAPE)
|
|
|
{
|
|
|
engine.RequestPopState();
|
|
|
}
|
|
|
@@ -50,15 +51,15 @@ void PauseState::RenderImGui(Engine& engine)
|
|
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x - ImGui::CalcTextSize("PAUSED").x) * 0.5f);
|
|
|
ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "PAUSED");
|
|
|
|
|
|
- ImGui::Dummy(ImVec2(0.0f, 100.0f));
|
|
|
+ ImGui::Dummy(ImVec2(0.0f, 60.0f));
|
|
|
|
|
|
float buttonWidth = 200.f;
|
|
|
float windowWidth = ImGui::GetWindowSize().x;
|
|
|
|
|
|
ImGui::SetCursorPosX((windowWidth - buttonWidth) * 0.5f);
|
|
|
- if (ImGui::Button("Back to Game", ImVec2(buttonWidth, 30)))
|
|
|
+ if (ImGui::Button("Resume Game", ImVec2(buttonWidth, 30)))
|
|
|
{
|
|
|
- SDL_Log("TODO: GamePlayState");
|
|
|
+ engine.RequestPopState();
|
|
|
}
|
|
|
|
|
|
ImGui::SetCursorPosX((windowWidth - buttonWidth) * 0.5f);
|
|
|
@@ -74,9 +75,12 @@ void PauseState::RenderImGui(Engine& engine)
|
|
|
}
|
|
|
|
|
|
ImGui::SetCursorPosX((windowWidth - buttonWidth) * 0.5f);
|
|
|
- if (ImGui::Button("Exit", ImVec2(buttonWidth, 30)))
|
|
|
+ if (ImGui::Button("Exit to Main Menu", ImVec2(buttonWidth, 30)))
|
|
|
{
|
|
|
- engine.StopRunning();
|
|
|
+ //engine.RequestStateChange(std::make_unique<MainMenuState>());
|
|
|
+ engine.stateManager.PopState(engine); // Drop PauseState
|
|
|
+ engine.stateManager.PopState(engine); // Drop GamePlayState
|
|
|
+ //engine.stateManager.ChangeState(std::make_unique<MainMenuState>(), engine);
|
|
|
}
|
|
|
|
|
|
ImGui::End();
|