Skip to content

Commit

Permalink
[#26]: Disable Play/Save buttons, when there's no active Level
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Aug 1, 2021
1 parent b6da491 commit 9c9bd7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 6 additions & 1 deletion editor/GUI/EditorGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <backends/imgui_impl_opengl3.h>
#include <fmt/format.h>
#include <imgui.h>
#include <imgui_internal.h>

namespace dgame {

Expand Down Expand Up @@ -158,7 +159,9 @@ EditorGUI::Render()
ImGui::SetNextWindowPos({0, 0});
ImGui::SetNextWindowSize(ImVec2(m_windowWidth, toolsWindowHeight));
ImGui::Begin("Tools");
ImGui::PushStyleColor(ImGuiCol_Button, {0.45f, 0.0f, 0.2f, 0.8f});
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.45f, 0.0f, 0.2f, 0.8f});
ImGui::PushDisabled(m_currentLevel == nullptr);

if (ImGui::Button("Play"))
{
m_parent.PlayLevel();
Expand All @@ -174,6 +177,8 @@ EditorGUI::Render()
m_parent.SaveLevel(levelName);
}
}
ImGui::PopDisabled();

ImGui::SameLine();
if (ImGui::Button("Load"))
{
Expand Down
14 changes: 9 additions & 5 deletions engine/FileManager/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,15 @@ FileManager::FileDialog(const std::vector< std::pair< std::string, std::string >
assert(output);

std::string buffer(FILE_DIALOG_MAX_BUFFER, 0);
fgets(buffer.data(), FILE_DIALOG_MAX_BUFFER, output);

// fgets includes \n character at the end, remove it
// buffer.back() = '\0';
buffer[strcspn(buffer.c_str(), "\n")] = 0;
if (fgets(buffer.data(), FILE_DIALOG_MAX_BUFFER, output))
{
// fgets includes \n character at the end, remove it
buffer[strcspn(buffer.c_str(), "\n")] = 0;
}
else
{
buffer = "";
}

pclose(output);

Expand Down

0 comments on commit 9c9bd7d

Please sign in to comment.