Skip to content

Commit

Permalink
ObjectExplorer: Components now show the entire list of children
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Mar 27, 2020
1 parent f9fc29f commit 1836f83
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/ObjectExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,49 @@ void ObjectExplorer::handle_game_object(REGameObject* game_object) {

void ObjectExplorer::handle_component(REComponent* component) {
make_tree_offset(component, offsetof(REComponent, ownerGameObject), "Owner");
make_tree_offset(component, offsetof(REComponent, childComponent), "ChildComponent");
//make_tree_offset(component, offsetof(REComponent, childComponent), "ChildComponent");

auto children_offset = offsetof(REComponent, childComponent);
auto children_ptr = Address(component).get(children_offset).to<void*>();

// Draw children
if (children_ptr != nullptr) {
auto made_node = ImGui::TreeNode((uint8_t*)component + children_offset, "0x%X: ChildComponents", children_offset);
context_menu(children_ptr);

if (made_node) {
int32_t count = 0;

// Iterate the children
for (auto child = component->childComponent; child != nullptr && child != component; child = child->childComponent) {
// uh oh
if (!utility::re_managed_object::is_managed_object(child)) {
continue;
}

auto child_name = utility::re_managed_object::get_type_name(child);

made_node = widget_with_context(child, [&]() { return stretched_tree_node(child, "%i", count++); });
auto tree_hovered = ImGui::IsItemHovered();

// Draw the variable name with a color
if (tree_hovered) {
make_same_line_text(child_name, VARIABLE_COLOR_HIGHLIGHT);
}
else {
make_same_line_text(child_name, VARIABLE_COLOR);
}

if (made_node) {
handle_address(child);
ImGui::TreePop();
}
}

ImGui::TreePop();
}
}

make_tree_offset(component, offsetof(REComponent, prevComponent), "PrevComponent");
make_tree_offset(component, offsetof(REComponent, nextComponent), "NextComponent");
}
Expand Down

0 comments on commit 1836f83

Please sign in to comment.