From be769d60b5be11049e31e32d6b43bd95313122a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Thu, 7 Jul 2022 08:45:56 +0200 Subject: [PATCH] editor: inspector mode --- Editor/Editor.cpp | 33 ++++++++++++++++++++++++++++----- Editor/Editor.h | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 1c930485e..0a8115a92 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -934,20 +934,22 @@ void EditorComponent::Load() ss += "Camera up: E, down: Q\n"; ss += "Duplicate entity: Ctrl + D\n"; ss += "Select All: Ctrl + A\n"; + ss += "Deselect All: Escape\n"; ss += "Undo: Ctrl + Z\n"; ss += "Redo: Ctrl + Y\n"; ss += "Copy: Ctrl + C\n"; ss += "Cut: Ctrl + X\n"; ss += "Paste: Ctrl + V\n"; - ss += "Delete: DELETE button\n"; + ss += "Delete: Delete button\n"; + ss += "Inspector mode: I button (hold), hovered entity information will be displayed near mouse position.\n"; ss += "Place Instances: Ctrl + Shift + Left mouse click (place clipboard onto clicked surface)\n"; ss += "Script Console / backlog: HOME button\n"; ss += "\n"; - ss += "You can find sample scenes in the models directory. Try to load one.\n"; + ss += "You can find sample scenes in the Content/models directory. Try to load one.\n"; ss += "You can also import models from .OBJ, .GLTF, .GLB files.\n"; ss += "You can find a program configuration file at Editor/config.ini\n"; - ss += "You can find sample LUA scripts in the scripts directory. Try to load one.\n"; - ss += "You can find a startup script at Editor/startup.lua (this will be executed on program start)\n"; + ss += "You can find sample LUA scripts in the Content/scripts directory. Try to load one.\n"; + ss += "You can find a startup script at Editor/startup.lua (this will be executed on program start, if exists)\n"; ss += "\nFor questions, bug reports, feedback, requests, please open an issue at:\n"; ss += "https://github.com/turanszkij/WickedEngine\n"; ss += "\nDevblog: https://wickedengine.net/\n"; @@ -1308,6 +1310,8 @@ void EditorComponent::Update(float dt) cameraWnd.camera_transform.UpdateTransform_Parented(cameraWnd.camera_target); } + inspector_mode = wi::input::Down((wi::input::BUTTON)'I'); + // Begin picking: unsigned int pickMask = rendererWnd.GetPickType(); Ray pickRay = wi::renderer::GetPickRay((long)currentMouse.x, (long)currentMouse.y, *this); @@ -1477,7 +1481,8 @@ void EditorComponent::Update(float dt) if ( wi::input::Down(wi::input::MOUSE_BUTTON_LEFT) || wi::input::Down(wi::input::MOUSE_BUTTON_RIGHT) || - paintToolWnd.GetMode() != PaintToolWindow::MODE_DISABLED + paintToolWnd.GetMode() != PaintToolWindow::MODE_DISABLED || + inspector_mode ) { hovered = wi::scene::Pick(pickRay, pickMask); @@ -2507,6 +2512,24 @@ void EditorComponent::Compose(CommandList cmd) const translator.Draw(camera, cmd); } + if (inspector_mode) + { + std::string str; + str += "Entity: " + std::to_string(hovered.entity); + const NameComponent* name = scene.names.GetComponent(hovered.entity); + if (name != nullptr) + { + str += "\nName: " + name->name; + } + XMFLOAT4 pointer = wi::input::GetPointer(); + wi::font::Params params; + params.position = XMFLOAT3(pointer.x - 10, pointer.y, 0); + params.shadowColor = wi::Color::Black(); + params.h_align = wi::font::WIFALIGN_RIGHT; + params.v_align = wi::font::WIFALIGN_CENTER; + wi::font::Draw(str, params, cmd); + } + RenderPath2D::Compose(cmd); } diff --git a/Editor/Editor.h b/Editor/Editor.h index 85f05dca4..d9d266cc9 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -151,6 +151,7 @@ public: Translator translator; wi::scene::PickResult hovered; + bool inspector_mode = false; wi::ecs::Entity grass_interaction_entity = wi::ecs::INVALID_ENTITY; void ClearSelected();