#include "ExteriorGenerationEditor.hpp"
#include "../components/CellGrid.hpp"
#include <imgui.h>

bool ExteriorGenerationEditor::renderComponent(flecs::entity entity, ExteriorGenerationComponent& exterior)
{
    bool modified = false;
    
    if (ImGui::CollapsingHeader("Exterior Generation", ImGuiTreeNodeFlags_DefaultOpen)) {
        ImGui::Indent();
        
        ImGui::Text("Converts interior walls to exterior on building outer edges");
        ImGui::Text("This runs AFTER all room processing is complete.");
        
        ImGui::Separator();
        
        // Floor Y
        if (ImGui::InputInt("Floor Y", &exterior.floorY)) {
            modified = true;
        }
        
        ImGui::Separator();
        ImGui::Text("Generate:");
        
        if (ImGui::Checkbox("Walls", &exterior.generateWalls)) modified = true;
        if (ImGui::Checkbox("Doors", &exterior.generateDoors)) modified = true;
        if (ImGui::Checkbox("Windows", &exterior.generateWindows)) modified = true;
        
        ImGui::Separator();
        
        // Target rooms
        ImGui::Text("Target Rooms: %zu", exterior.targetRooms.size());
        ImGui::TextDisabled("(Empty = all rooms)");
        if (!exterior.targetRooms.empty()) {
            for (size_t i = 0; i < exterior.targetRooms.size(); i++) {
                ImGui::Text("  Room %zu: ID %lu", i, exterior.targetRooms[i]);
            }
        }
        
        ImGui::Separator();
        
        // Status
        if (exterior.processed) {
            ImGui::TextColored(ImVec4(0, 1, 0, 1), "Status: Processed");
        } else {
            ImGui::TextColored(ImVec4(1, 1, 0, 1), "Status: Pending");
        }
        
        if (ImGui::Button("Generate Exterior Now")) {
            exterior.markDirty();
            modified = true;
        }
        
        ImGui::Unindent();
    }
    
    return modified;
}
