Files
WickedEngine/Editor/NameWindow.cpp
T
Turánszki János 5a0c423ddd Updates:
- editor: quicksave, multiple scenes support, gui changes, additional shortcuts
- physics: improvements for handling multiple scenes, and removal of physics objects
- scripting: ability to override global scene and camera with custom scene and camera from cpp side
2022-07-14 15:21:28 +02:00

63 lines
1.3 KiB
C++

#include "stdafx.h"
#include "NameWindow.h"
#include "Editor.h"
using namespace wi::ecs;
using namespace wi::scene;
void NameWindow::Create(EditorComponent* _editor)
{
editor = _editor;
wi::gui::Window::Create("Name Window");
SetSize(XMFLOAT2(360, 80));
float x = 60;
float y = 0;
float step = 25;
float siz = 280;
float hei = 20;
nameInput.Create("");
nameInput.SetDescription("Name: ");
nameInput.SetPos(XMFLOAT2(x, y));
nameInput.SetSize(XMFLOAT2(siz, hei));
nameInput.OnInputAccepted([=](wi::gui::EventArgs args) {
NameComponent* name = editor->GetCurrentScene().names.GetComponent(entity);
if (name == nullptr)
{
name = &editor->GetCurrentScene().names.Create(entity);
}
name->name = args.sValue;
editor->RefreshEntityTree();
});
AddWidget(&nameInput);
Translate(XMFLOAT3((float)editor->GetLogicalWidth() - 450, 200, 0));
SetVisible(false);
SetEntity(INVALID_ENTITY);
}
void NameWindow::SetEntity(Entity entity)
{
this->entity = entity;
if (entity != INVALID_ENTITY)
{
SetEnabled(true);
NameComponent* name = editor->GetCurrentScene().names.GetComponent(entity);
if (name != nullptr)
{
nameInput.SetValue(name->name);
}
}
else
{
SetEnabled(false);
nameInput.SetValue("Select entity to modify name...");
}
}