- editor project
- build system fixes
- dummy data editor panels mock
This commit is contained in:
2026-09-16 02:28:42 -07:00
parent 169ff4a277
commit dffb7b7972
11 changed files with 241 additions and 9 deletions
+27
View File
@@ -0,0 +1,27 @@
#include "asset_browser_panel.hpp"
#include <imgui.h>
void AssetBrowserPanel::onUpdate(const sophia::FrameInfo&) {
ImGui::Begin("Asset Browser");
ImGui::BeginChild("Folders", ImVec2(150, 0), true);
for (int i = 0; i < static_cast<int>(folders.size()); i++) {
if (ImGui::Selectable(folders[static_cast<size_t>(i)].name.c_str(),
selectedFolder == i)) {
selectedFolder = i;
}
}
ImGui::EndChild();
ImGui::SameLine();
ImGui::BeginChild("Files", ImVec2(0, 0), true);
const Folder& folder = folders[static_cast<size_t>(selectedFolder)];
for (const std::string& file : folder.files) {
ImGui::Selectable(file.c_str());
}
ImGui::EndChild();
ImGui::End();
}
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <sophia/frame_info.hpp>
#include <sophia/ui/panel.hpp>
#include <string>
#include <vector>
class AssetBrowserPanel : public sophia::Panel {
public:
AssetBrowserPanel() : Panel{"Asset Browser"} {}
void onUpdate(const sophia::FrameInfo& frameInfo) override;
private:
struct Folder {
std::string name;
std::vector<std::string> files;
};
std::vector<Folder> folders = {
{"Models", {"player_capsule.fbx", "ground_plane.fbx", "enemy_grunt.fbx"}},
{"Textures",
{"brick_diffuse.png", "grass_albedo.png", "player_diffuse.png"}},
{"Materials", {"player_mat.mat", "ground_mat.mat"}},
{"Scripts", {"PlayerController.lua", "EnemyAI.lua"}},
{"Scenes", {"MainMenu.scene", "Level_01.scene"}},
};
int selectedFolder = 0;
};
+36
View File
@@ -0,0 +1,36 @@
#include "inspector_panel.hpp"
#include <imgui.h>
#include <cstdio>
void InspectorPanel::onUpdate(const sophia::FrameInfo&) {
ImGui::Begin("Inspector");
char nameBuf[128];
std::snprintf(nameBuf, sizeof(nameBuf), "%s", name.c_str());
if (ImGui::InputText("Name", nameBuf, sizeof(nameBuf))) {
name = nameBuf;
}
ImGui::Text("Tag: %s", tag.c_str());
ImGui::Separator();
if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::DragFloat3("Position", &position.x, 0.1f);
ImGui::DragFloat3("Rotation", &rotation.x, 0.1f);
ImGui::DragFloat3("Scale", &scale.x, 0.1f);
}
if (ImGui::CollapsingHeader("Mesh Renderer",
ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Text("Mesh: %s", meshName.c_str());
ImGui::Text("Material: %s", materialName.c_str());
}
if (ImGui::CollapsingHeader("Script", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Text("%s", scriptName.c_str());
}
ImGui::End();
}
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include <glm/glm.hpp>
#include <sophia/frame_info.hpp>
#include <sophia/ui/panel.hpp>
#include <string>
class InspectorPanel : public sophia::Panel {
public:
InspectorPanel() : Panel{"Inspector"} {}
void onUpdate(const sophia::FrameInfo& frameInfo) override;
private:
std::string name = "Player";
std::string tag = "Player";
glm::vec3 position{0.0f, 1.0f, 0.0f};
glm::vec3 rotation{0.0f, 0.0f, 0.0f};
glm::vec3 scale{1.0f, 1.0f, 1.0f};
std::string meshName = "player_capsule.fbx";
std::string materialName = "player_mat";
std::string scriptName = "PlayerController.lua";
};
+34
View File
@@ -0,0 +1,34 @@
#include "scene_hierarchy_panel.hpp"
#include <imgui.h>
void SceneHierarchyPanel::drawNode(const Node& node) {
if (node.children.empty()) {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf |
ImGuiTreeNodeFlags_NoTreePushOnOpen |
ImGuiTreeNodeFlags_SpanAvailWidth;
if (node.name == selected) {
flags |= ImGuiTreeNodeFlags_Selected;
}
ImGui::TreeNodeEx(node.name.c_str(), flags);
if (ImGui::IsItemClicked()) {
selected = node.name;
}
return;
}
if (ImGui::TreeNodeEx(node.name.c_str(), ImGuiTreeNodeFlags_SpanAvailWidth)) {
for (const Node& child : node.children) {
drawNode(child);
}
ImGui::TreePop();
}
}
void SceneHierarchyPanel::onUpdate(const sophia::FrameInfo&) {
ImGui::Begin("Scene Hierarchy");
for (const Node& node : nodes) {
drawNode(node);
}
ImGui::End();
}
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <sophia/frame_info.hpp>
#include <sophia/ui/panel.hpp>
#include <string>
#include <vector>
class SceneHierarchyPanel : public sophia::Panel {
public:
SceneHierarchyPanel() : Panel{"Scene Hierarchy"} {}
void onUpdate(const sophia::FrameInfo& frameInfo) override;
private:
struct Node {
std::string name;
std::vector<Node> children;
};
void drawNode(const Node& node);
std::vector<Node> nodes = {
{"Main Camera", {}},
{"Directional Light", {}},
{"Ground", {}},
{"Player", {}},
{"Enemies", {{"Enemy_01", {}}, {"Enemy_02", {}}, {"Enemy_03", {}}}},
{"Props", {{"Crate_01", {}}, {"Crate_02", {}}}},
};
std::string selected;
};