mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Added ability to pause the game, automatically goes into the editor camera
This commit is contained in:
@@ -325,39 +325,44 @@ namespace Nuake {
|
||||
ImGui::Dummy({ ImGui::GetContentRegionAvail().x / 2.0f - (76.0f / 2.0f), 8.0f });
|
||||
ImGui::SameLine();
|
||||
|
||||
if (Engine::IsPlayMode())
|
||||
if (Engine::IsPlayMode() && Engine::GetTimeScale() != 0.0f)
|
||||
{
|
||||
if (ImGui::Button(ICON_FA_PAUSE, ImVec2(30, 30)) || (Input::IsKeyDown(GLFW_KEY_F5)))
|
||||
{
|
||||
Engine::ExitPlayMode();
|
||||
Engine::SetGameState(GameState::Paused);
|
||||
|
||||
Engine::LoadScene(SceneSnapshot);
|
||||
Selection = EditorSelection();
|
||||
SetStatusMessage("Ready");
|
||||
SetStatusMessage("Paused");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)))
|
||||
{
|
||||
this->SceneSnapshot = Engine::GetCurrentScene()->Copy();
|
||||
|
||||
SetStatusMessage("Building .Net solution...");
|
||||
auto job = [this]()
|
||||
{
|
||||
ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
|
||||
};
|
||||
|
||||
Selection = EditorSelection();
|
||||
|
||||
JobSystem::Get().Dispatch(job, [this]()
|
||||
if (Engine::GetGameState() == GameState::Paused)
|
||||
{
|
||||
SetStatusMessage("Entering play mode...");
|
||||
Engine::EnterPlayMode();
|
||||
Engine::SetGameState(GameState::Playing);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SceneSnapshot = Engine::GetCurrentScene()->Copy();
|
||||
|
||||
std::string statusMessage = ICON_FA_RUNNING + std::string(" Playing...");
|
||||
SetStatusMessage(statusMessage.c_str(), { 97.0 / 255.0, 0, 1, 1});
|
||||
});
|
||||
SetStatusMessage("Building .Net solution...");
|
||||
auto job = [this]()
|
||||
{
|
||||
ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
|
||||
};
|
||||
|
||||
Selection = EditorSelection();
|
||||
|
||||
JobSystem::Get().Dispatch(job, [this]()
|
||||
{
|
||||
SetStatusMessage("Entering play mode...");
|
||||
Engine::EnterPlayMode();
|
||||
|
||||
std::string statusMessage = ICON_FA_RUNNING + std::string(" Playing...");
|
||||
SetStatusMessage(statusMessage.c_str(), { 97.0 / 255.0, 0, 1, 1 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginItemTooltip())
|
||||
@@ -1954,7 +1959,7 @@ namespace Nuake {
|
||||
ImVec2 work_area_size = ImGui::GetCurrentWindow()->Size;
|
||||
ImVec2 window_pos = ImVec2((corner & 1) ? (work_area_pos.x + work_area_size.x - DISTANCE) : (work_area_pos.x + DISTANCE), (corner & 2) ? (work_area_pos.y + work_area_size.y - DISTANCE) : (work_area_pos.y + DISTANCE));
|
||||
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
||||
ImGui::SetNextWindowPos(window_pos + ImVec2(0, 36), ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::SetNextWindowViewport(viewport->ID);
|
||||
}
|
||||
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
||||
|
||||
Reference in New Issue
Block a user