Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/tools/editor/include/prismeditor.hpp

68 lines
1.7 KiB
C++
Executable file

#pragma once
#include <string>
#include "commoneditor.hpp"
#include "undostack.hpp"
class Scene;
class Editor {
public:
std::string path;
bool has_been_docked = false;
bool modified = false;
bool wants_to_close = false;
std::string get_window_title() {
auto window_class = get_window_class();
return get_title() + "###" + std::to_string(window_class.ClassId);
}
virtual Scene* get_scene() const {
return nullptr;
}
virtual bool has_menubar() const { return false; }
virtual std::string get_title() const { return ""; }
virtual void draw([[maybe_unused]] CommonEditor* editor) {}
virtual void setup_windows([[maybe_unused]] ImGuiID dockspace) {}
ImGuiWindowClass get_window_class() const {
ImGuiWindowClass window_class = {};
window_class.ClassId = ImGui::GetID(this);
window_class.DockingAllowUnclassed = true;
return window_class;
}
std::string get_window_name(std::string title) {
return title + "##" + std::to_string((uint64_t)this);
}
bool begin(std::string title, bool* p_open = nullptr) {
return ImGui::Begin(get_window_name(title).c_str(), p_open);
}
UndoStack undo_stack;
};
class PrismEditor : public CommonEditor {
public:
PrismEditor();
void renderEditor(GFXCommandBuffer* command_buffer) override;
void drawUI() override;
void updateEditor(float deltaTime) override;
void object_selected(prism::Object object) override;
void asset_selected(const std::filesystem::path& path, AssetType type) override;
private:
void open_asset(prism::path path);
void setup_editor(Editor* editor);
};
std::string get_filename(std::string path);