summaryrefslogtreecommitdiff
path: root/src/port/ui/SceneExplorer.cpp
blob: 9e084280b49dce9df8a3b94829fd739850aa0644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "SceneExplorer.h"
#include "port/ui/PortMenu.h"
#include "UIWidgets.h"
#include "libultraship/src/Context.h"

#include <imgui.h>
#include <map>
#include <libultraship/libultraship.h>
#include <spdlog/fmt/fmt.h>
#include "spdlog/formatter.h"
#include <common_structs.h>
#include <defines.h>

#include "engine/editor/Editor.h"
#include "port/Game.h"

namespace Editor {

SceneExplorerWindow::~SceneExplorerWindow() {
    SPDLOG_TRACE("destruct scene explorer window");
}

void SceneExplorerWindow::DrawElement() {
    ImGui::Text("Scene");

    size_t id = 0; // id for now because we don't have unique names atm
    for (auto& object : gEditor.eGameObjects) {
        // Convert const char* to std::string before formatting
        std::string objectName = object->Name ? object->Name : "Obj";

        // Ensure unique label using index
        std::string label = fmt::format("{}##{}", objectName, id);

        if (ImGui::Button(label.c_str())) {
            gEditor.SelectObjectFromSceneExplorer(object);
        }
        id += 1;
    }
}
} // namespace Editor