1
0
Fork 0

World/Debug: Properly check the MapEdit status

If a Dear ImGui window is collapsed or closed, ImGui::Begin returns false.
Check it properly to bypass rendering if is indeed not needed.
This commit is contained in:
Teo-CD 2024-01-28 22:05:20 +00:00
parent 43970df494
commit 66ec111f5d

View file

@ -274,7 +274,7 @@ void World::step(const float& stepTime) {
player.rotate(player.currentRotationSpeed*stepTime); player.rotate(player.currentRotationSpeed*stepTime);
#ifdef IMGUI #ifdef IMGUI
ImGui::Begin("MapEdit"); if (ImGui::Begin("MapEdit")) {
static int blockToPlace = 1; static int blockToPlace = 1;
/* /*
@ -325,7 +325,8 @@ void World::step(const float& stepTime) {
ImGui::PushStyleColor(ImGuiCol_Header, blockColor); ImGui::PushStyleColor(ImGuiCol_Header, blockColor);
if (ImGui::Selectable("", currentBlock != BlockType::AIR, 0, ImVec2(10, 10))) { if (ImGui::Selectable("", currentBlock != BlockType::AIR, 0, ImVec2(10, 10))) {
map[x + w*y] = currentBlock == (BlockType)blockToPlace ? BlockType::AIR : (BlockType)blockToPlace; map[x + w * y] =
currentBlock == (BlockType) blockToPlace ? BlockType::AIR : (BlockType) blockToPlace;
} }
ImGui::PopStyleColor(2); ImGui::PopStyleColor(2);
ImGui::PopID(); ImGui::PopID();
@ -342,7 +343,7 @@ void World::step(const float& stepTime) {
ImGui::RadioButton("Window", &blockToPlace, (int) BlockType::WINDOW); ImGui::RadioButton("Window", &blockToPlace, (int) BlockType::WINDOW);
ImGui::Unindent(); ImGui::Unindent();
ImGui::EndGroup(); ImGui::EndGroup();
}
ImGui::End(); ImGui::End();
#endif #endif
} }