2023-09-12 01:06:28 +08:00
|
|
|
#pragma once
|
|
|
|
|
2023-10-18 20:11:59 +08:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
|
2023-09-12 01:06:28 +08:00
|
|
|
#include "ExtensionMacros.h"
|
|
|
|
#include "base/Config.h"
|
|
|
|
#include <string>
|
2023-10-18 20:11:59 +08:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
2023-09-12 01:06:28 +08:00
|
|
|
|
|
|
|
NS_AX_BEGIN
|
|
|
|
class Node;
|
|
|
|
class Scene;
|
|
|
|
|
|
|
|
NS_AX_END
|
|
|
|
|
|
|
|
NS_AX_EXT_BEGIN
|
|
|
|
|
2023-10-18 20:11:59 +08:00
|
|
|
class InspectPropertyHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~InspectPropertyHandler() = default;
|
|
|
|
virtual bool isSupportedType(Node* node) = 0;
|
|
|
|
virtual void drawProperties(Node* node) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InspectorNodePropertyHandler : public InspectPropertyHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~InspectorNodePropertyHandler() override = default;
|
|
|
|
bool isSupportedType(Node* node) override;
|
|
|
|
void drawProperties(Node* node) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InspectorSpritePropertyHandler : public InspectPropertyHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~InspectorSpritePropertyHandler() override = default;
|
|
|
|
bool isSupportedType(Node* node) override;
|
|
|
|
void drawProperties(Node* node) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InspectorLabelProtocolPropertyHandler : public InspectPropertyHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~InspectorLabelProtocolPropertyHandler() override = default;
|
|
|
|
bool isSupportedType(Node* node) override;
|
|
|
|
void drawProperties(Node* node) override;
|
|
|
|
};
|
|
|
|
|
2023-09-12 01:06:28 +08:00
|
|
|
class Inspector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Inspector* getInstance();
|
|
|
|
static void destroyInstance();
|
2023-10-18 20:11:59 +08:00
|
|
|
static std::string getNodeTypeName(Node*);
|
2023-09-12 01:06:28 +08:00
|
|
|
static std::string demangle(const char* mangled);
|
|
|
|
void openForScene(Scene*);
|
|
|
|
void close();
|
|
|
|
|
2023-10-18 20:11:59 +08:00
|
|
|
bool addPropertyHandler(std::string_view handlerId, std::unique_ptr<InspectPropertyHandler> handler);
|
|
|
|
void removePropertyHandler(const std::string& handlerId);
|
|
|
|
|
2023-09-12 01:06:28 +08:00
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
void mainLoop();
|
2023-10-18 20:11:59 +08:00
|
|
|
void drawTreeRecursive(Node*, int index = 0);
|
2023-09-12 01:06:28 +08:00
|
|
|
void drawProperties();
|
|
|
|
|
|
|
|
ax::Node* _selected_node = nullptr;
|
|
|
|
ax::Scene* _target = nullptr;
|
2023-10-18 20:11:59 +08:00
|
|
|
|
|
|
|
std::unordered_map<std::string, std::unique_ptr<InspectPropertyHandler>> _propertyHandlers;
|
2023-09-12 01:06:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_AX_EXT_END
|