Skip to content

Commit

Permalink
Group debug gui
Browse files Browse the repository at this point in the history
  • Loading branch information
nemene21 committed Jul 12, 2024
1 parent 3b490d1 commit 9825541
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/imgui.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Window][Debug##Default]
Pos=26,39
Size=821,788
Size=753,986

5 changes: 5 additions & 0 deletions src/framework/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ void Entity::set_name(std::string new_name) {
name = new_name;
}

std::unordered_set<std::string>& Entity::get_groups() {
return groups;
}


std::vector<Component*> Entity::get_components() {
std::vector<Component*> comp_arr {};
for (auto comp: comps) {
Expand Down
1 change: 1 addition & 0 deletions src/framework/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Entity {
/// @param new_name The new name
/// @warning Do not rename entities while they are already in a scene
virtual void set_name(std::string new_name);
virtual std::unordered_set<std::string>& get_groups();

/// @brief Makes the entity be in a group
/// @param group Group name
Expand Down
11 changes: 9 additions & 2 deletions src/framework/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ void Framework::debug_gui() {
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.4f, 0.7f, 1.0f, 0.1f));

if (ImGui::CollapsingHeader(("Components##" + std::to_string(i)).c_str())) {
ImGui::Indent(25.f);
for (auto component: entity->get_components()) {
ImGui::Indent(25.f);
component->draw_gui_info();
ImGui::Unindent(25.f);
}
ImGui::Unindent(25.f);
}
if (ImGui::CollapsingHeader(("Groups##" + std::to_string(i)).c_str())) {
ImGui::Indent(25.f);
for (auto group: entity->get_groups()) {
ImGui::Text(group.c_str());
}
ImGui::Unindent(25.f);
}
ImGui::Unindent(25.f);
ImGui::PopStyleColor();
Expand Down

0 comments on commit 9825541

Please sign in to comment.