2014-06-16 21:18:15 +02:00
|
|
|
#pragma once
|
|
|
|
|
2015-08-11 23:55:58 +02:00
|
|
|
#include "lumix.h"
|
2015-07-30 09:18:37 +02:00
|
|
|
#include "core/array.h"
|
2014-06-29 15:20:21 +02:00
|
|
|
#include "core/delegate_list.h"
|
2015-07-30 09:18:37 +02:00
|
|
|
#include "core/quat.h"
|
|
|
|
#include "universe/component.h"
|
2014-06-16 21:18:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace Lumix
|
|
|
|
{
|
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
class Engine;
|
|
|
|
class EntityTemplateSystem;
|
2015-08-12 22:57:22 +02:00
|
|
|
class Hierarchy;
|
2015-07-30 09:18:37 +02:00
|
|
|
class IArrayDescriptor;
|
2015-07-22 00:33:10 +02:00
|
|
|
class IPlugin;
|
2015-07-30 09:18:37 +02:00
|
|
|
class IPropertyDescriptor;
|
2015-07-22 00:33:10 +02:00
|
|
|
class Path;
|
|
|
|
class PipelineInstance;
|
|
|
|
class RayCastModelHit;
|
2015-07-30 09:18:37 +02:00
|
|
|
class Universe;
|
|
|
|
|
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
namespace FS
|
|
|
|
{
|
|
|
|
class TCPFileServer;
|
|
|
|
}
|
2014-07-31 23:45:57 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
struct MouseButton
|
|
|
|
{
|
|
|
|
enum Value
|
2014-06-16 21:18:15 +02:00
|
|
|
{
|
2015-07-22 00:33:10 +02:00
|
|
|
LEFT,
|
|
|
|
MIDDLE,
|
|
|
|
RIGHT
|
|
|
|
};
|
|
|
|
};
|
2014-11-01 00:11:48 +01:00
|
|
|
|
2015-08-17 23:45:26 +02:00
|
|
|
class LUMIX_EDITOR_API WorldEditor
|
2015-07-22 00:33:10 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-07-25 00:09:11 +02:00
|
|
|
typedef Array<ComponentUID> ComponentList;
|
2015-07-22 00:33:10 +02:00
|
|
|
typedef class IEditorCommand* (*EditorCommandCreator)(WorldEditor&);
|
2014-07-05 23:19:02 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
enum class MouseFlags : int
|
|
|
|
{
|
|
|
|
ALT = 1,
|
|
|
|
CONTROL = 2
|
|
|
|
};
|
2014-08-04 23:09:36 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
class Plugin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Plugin() {}
|
2014-08-04 23:09:36 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void tick() = 0;
|
|
|
|
virtual bool
|
|
|
|
onEntityMouseDown(const RayCastModelHit& hit, int x, int y) = 0;
|
|
|
|
virtual void
|
|
|
|
onMouseMove(int x, int y, int rel_x, int rel_y, int mouse_flags) = 0;
|
|
|
|
virtual void onMouseUp(int x, int y, MouseButton::Value button) = 0;
|
|
|
|
};
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
public:
|
2015-08-02 15:36:52 +02:00
|
|
|
static WorldEditor* create(const char* base_path, Engine& engine);
|
2015-07-22 00:33:10 +02:00
|
|
|
static void destroy(WorldEditor* editor);
|
2015-04-05 18:08:50 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void update() = 0;
|
2015-08-14 22:12:51 +02:00
|
|
|
virtual void updateEngine() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void executeCommand(IEditorCommand* command) = 0;
|
2015-08-01 22:51:07 +02:00
|
|
|
virtual IEditorCommand* createEditorCommand(uint32_t command_type) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual Engine& getEngine() = 0;
|
|
|
|
virtual Universe* getUniverse() = 0;
|
2015-08-12 22:57:22 +02:00
|
|
|
virtual Hierarchy* getHierarchy() = 0;
|
|
|
|
virtual const Array<IScene*>& getScenes() const = 0;
|
|
|
|
virtual IScene* getScene(uint32_t hash) = 0;
|
|
|
|
virtual IScene* getSceneByComponentType(uint32_t hash) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual IAllocator& getAllocator() = 0;
|
|
|
|
virtual void renderIcons(PipelineInstance& pipeline) = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual ComponentUID getEditCamera() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual class Gizmo& getGizmo() = 0;
|
|
|
|
virtual void undo() = 0;
|
|
|
|
virtual void redo() = 0;
|
|
|
|
virtual void loadUniverse(const Path& path) = 0;
|
|
|
|
virtual void saveUniverse(const Path& path) = 0;
|
|
|
|
virtual void newUniverse() = 0;
|
|
|
|
virtual Path getUniversePath() const = 0;
|
|
|
|
virtual void showEntities() = 0;
|
|
|
|
virtual void hideEntities() = 0;
|
|
|
|
virtual void copyEntity() = 0;
|
|
|
|
virtual void pasteEntity() = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual ComponentUID getComponent(Entity entity, uint32_t type) = 0;
|
2015-07-24 08:42:35 +02:00
|
|
|
virtual ComponentList& getComponents(Entity entity) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void addComponent(uint32_t type_crc) = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual void cloneComponent(const ComponentUID& src, Entity entity) = 0;
|
|
|
|
virtual void destroyComponent(const ComponentUID& crc) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual Entity addEntity() = 0;
|
|
|
|
virtual void destroyEntities(const Entity* entities, int count) = 0;
|
|
|
|
virtual void selectEntities(const Entity* entities, int count) = 0;
|
|
|
|
virtual void selectEntitiesWithSameMesh() = 0;
|
|
|
|
virtual Entity addEntityAt(int camera_x, int camera_y) = 0;
|
|
|
|
virtual void setEntitiesPositions(const Array<Entity>& entity,
|
|
|
|
const Array<Vec3>& position) = 0;
|
2015-08-02 10:39:50 +02:00
|
|
|
virtual void setEntitiesScales(const Array<Entity>& entities,
|
|
|
|
const Array<float>& scales) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void setEntitiesRotations(const Array<Entity>& entity,
|
|
|
|
const Array<Quat>& rotations) = 0;
|
|
|
|
virtual void setEntityPositionAndRotaion(const Array<Entity>& entity,
|
|
|
|
const Array<Vec3>& position,
|
|
|
|
const Array<Quat>& rotation) = 0;
|
2015-07-24 08:42:35 +02:00
|
|
|
virtual void setEntityName(Entity entity, const char* name) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void snapToTerrain() = 0;
|
|
|
|
virtual void toggleGameMode() = 0;
|
|
|
|
virtual void navigate(float forward, float right, float speed) = 0;
|
|
|
|
virtual void setProperty(uint32_t component,
|
|
|
|
int index,
|
|
|
|
IPropertyDescriptor& property,
|
|
|
|
const void* data,
|
|
|
|
int size) = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual void addArrayPropertyItem(const ComponentUID& cmp,
|
2015-07-22 00:33:10 +02:00
|
|
|
IArrayDescriptor& property) = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual void removeArrayPropertyItem(const ComponentUID& cmp,
|
2015-07-22 00:33:10 +02:00
|
|
|
int index,
|
|
|
|
IArrayDescriptor& property) = 0;
|
|
|
|
virtual void onMouseDown(int x, int y, MouseButton::Value button) = 0;
|
|
|
|
virtual void
|
|
|
|
onMouseMove(int x, int y, int relx, int rely, int mouse_flags) = 0;
|
|
|
|
virtual void onMouseUp(int x, int y, MouseButton::Value button) = 0;
|
|
|
|
virtual float getMouseX() const = 0;
|
|
|
|
virtual float getMouseY() const = 0;
|
|
|
|
virtual void lookAtSelected() = 0;
|
|
|
|
virtual const char* getBasePath() = 0;
|
|
|
|
virtual const Array<Entity>& getSelectedEntities() const = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual DelegateList<void(const Array<Entity>&)>& entitySelected() = 0;
|
|
|
|
virtual DelegateList<void()>& universeCreated() = 0;
|
|
|
|
virtual DelegateList<void()>& universeDestroyed() = 0;
|
|
|
|
virtual DelegateList<void()>& universeLoaded() = 0;
|
2015-07-24 08:42:35 +02:00
|
|
|
virtual DelegateList<void(Entity, const char*)>& entityNameSet() = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual DelegateList<void(ComponentUID, const IPropertyDescriptor&)>&
|
2015-07-22 00:33:10 +02:00
|
|
|
propertySet() = 0;
|
2015-07-25 00:09:11 +02:00
|
|
|
virtual DelegateList<void(ComponentUID)>& componentAdded() = 0;
|
|
|
|
virtual DelegateList<void(ComponentUID)>& componentDestroyed() = 0;
|
2015-01-07 00:52:55 +01:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void addPlugin(Plugin& plugin) = 0;
|
|
|
|
virtual void removePlugin(Plugin& plugin) = 0;
|
2015-08-02 13:25:17 +02:00
|
|
|
virtual void getRelativePath(char* relative_path,
|
|
|
|
int max_length,
|
|
|
|
const char* source) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void getRelativePath(char* relative_path,
|
|
|
|
int max_length,
|
|
|
|
const Path& source) = 0;
|
|
|
|
virtual EntityTemplateSystem& getEntityTemplateSystem() = 0;
|
|
|
|
virtual Vec3 getCameraRaycastHit() = 0;
|
|
|
|
virtual void toggleMeasure() = 0;
|
|
|
|
virtual class MeasureTool* getMeasureTool() const = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void saveUndoStack(const Path& path) = 0;
|
|
|
|
virtual bool executeUndoStack(const Path& path) = 0;
|
|
|
|
virtual bool runTest(const Path& undo_stack_path,
|
|
|
|
const Path& result_universe_path) = 0;
|
|
|
|
virtual void registerEditorCommandCreator(const char* command_type,
|
|
|
|
EditorCommandCreator) = 0;
|
|
|
|
virtual bool isGameMode() const = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
protected:
|
|
|
|
virtual ~WorldEditor() {}
|
|
|
|
};
|
2013-12-02 01:24:53 +01:00
|
|
|
}
|