43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#include <td/display/state/MainMenuState.h>
|
|
|
|
#include <imgui.h>
|
|
#include <td/display/menu/MainMenu.h>
|
|
#include <td/display/state/DebugWorldState.h>
|
|
|
|
namespace td {
|
|
|
|
MainMenuState::MainMenuState(Display& a_Display) : DisplayState(a_Display) {
|
|
PushState<MainMenu>();
|
|
}
|
|
|
|
MainMenuState::~MainMenuState() {}
|
|
|
|
static int GetWindowFullScreenFlags() {
|
|
return ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBackground;
|
|
}
|
|
|
|
static void SetNextWindowFullScreen() {
|
|
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
|
ImGui::SetNextWindowPos(viewport->WorkPos);
|
|
ImGui::SetNextWindowSize(viewport->WorkSize);
|
|
}
|
|
|
|
void MainMenuState::Update(float a_Delta) {
|
|
SetNextWindowFullScreen();
|
|
ImGui::Begin("MainWindow", nullptr, GetWindowFullScreenFlags());
|
|
MainMenuStateStack::Update();
|
|
ImGui::End();
|
|
}
|
|
|
|
void MainMenuState::RenderBackButton() {
|
|
if (ImGui::Button("Back"))
|
|
PopState();
|
|
}
|
|
|
|
void MainMenuState::OnKeyDown(SDL_Keycode a_Key) {
|
|
if (a_Key == SDLK_ESCAPE)
|
|
PopState();
|
|
}
|
|
|
|
} // namespace td
|