Skip to content

Commit

Permalink
[WIP] fix: when scene is paused is must be possible to stop it
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Oct 9, 2024
1 parent ede0ecc commit e85d7ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/App/Entrypoint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main(void) {
renderer.WaitIdle(t);
}

if (scene.IsRunning()) scene.Stop();
if (scene.IsRunning() or scene.IsPaused()) scene.Stop();

app->Stop(scene);
delete app;
Expand Down
15 changes: 7 additions & 8 deletions src/Renderer/EditorLayer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,16 @@ namespace volt::renderer {
void EditorLayer::drawControls(runtime::Scene &s) noexcept {
if (ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_NoTitleBar)) {
if (s.IsRunning()) {
if (ImGui::Button("Pause")) {
s.Pause();
}
if (ImGui::Button("Pause")) s.Pause();
ImGui::SameLine();
if (ImGui::Button("Stop")) {
s.Stop();
}
if (ImGui::Button("Stop")) s.Stop();
}
else if (ImGui::Button("Play")) {
s.Play();
else if (s.IsPaused()) {
if (ImGui::Button("Play")) s.Play();
ImGui::SameLine();
if (ImGui::Button("Stop")) s.Stop();
}
else if (ImGui::Button("Play")) s.Play();
}
ImGui::End();
}
Expand Down
1 change: 1 addition & 0 deletions src/Runtime/Scene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace volt::runtime {
std::optional<Entity> FindEntityByID(core::SnowflakeID::value_type id);
std::optional<Entity> FindEntityByName(const std::string &name);
inline bool IsRunning(void) const noexcept { return m_running; }
inline bool IsPaused(void) const noexcept { return m_paused; }
void Play(void) noexcept;
void Pause(void) noexcept;
void Stop(void) noexcept;
Expand Down

0 comments on commit e85d7ac

Please sign in to comment.