From 08cec3728476f7cf8b51c193e4aab31b4057e461 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Sun, 6 Oct 2019 15:25:46 +0100 Subject: [PATCH] added sound naming to editor --- Editor/SoundWindow.cpp | 29 ++++++++++++++++++++++++++++- Editor/SoundWindow.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Editor/SoundWindow.cpp b/Editor/SoundWindow.cpp index 38fded427..c6b308188 100644 --- a/Editor/SoundWindow.cpp +++ b/Editor/SoundWindow.cpp @@ -19,7 +19,7 @@ SoundWindow::SoundWindow(wiGUI* gui) : GUI(gui) float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight(); soundWindow = new wiWindow(GUI, "Sound Window"); - soundWindow->SetSize(XMFLOAT2(440, 200)); + soundWindow->SetSize(XMFLOAT2(440, 240)); soundWindow->SetEnabled(false); GUI->AddWidget(soundWindow); @@ -61,6 +61,21 @@ SoundWindow::SoundWindow(wiGUI* gui) : GUI(gui) filenameLabel->SetSize(XMFLOAT2(400, 20)); soundWindow->AddWidget(filenameLabel); + nameField = new wiTextInputField("SoundName"); + nameField->SetTooltip("Enter a sound name to identify this entity..."); + nameField->SetPos(XMFLOAT2(x, y += step)); + nameField->SetSize(XMFLOAT2(300, 20)); + nameField->OnInputAccepted([&](wiEventArgs args) { + NameComponent* name = wiSceneSystem::GetScene().names.GetComponent(entity); + if (name == nullptr) + { + name = &wiSceneSystem::GetScene().names.Create(entity); + } + *name = args.sValue; + }); + soundWindow->AddWidget(nameField); + nameField->SetEnabled(false); + playstopButton = new wiButton("Play"); playstopButton->SetTooltip("Play/Stop selected sound instance."); playstopButton->SetPos(XMFLOAT2(x, y += step)); @@ -136,10 +151,20 @@ void SoundWindow::SetEntity(Entity entity) Scene& scene = wiSceneSystem::GetScene(); SoundComponent* sound = scene.sounds.GetComponent(entity); + NameComponent* name = scene.names.GetComponent(entity); if (sound != nullptr) { filenameLabel->SetText(sound->filename); + if (name == nullptr) + { + nameField->SetText("Enter a sound name..."); + } + else + { + nameField->SetText(name->name); + } + nameField->SetEnabled(true); playstopButton->SetEnabled(true); loopedCheckbox->SetEnabled(true); loopedCheckbox->SetCheck(sound->IsLooped()); @@ -157,6 +182,8 @@ void SoundWindow::SetEntity(Entity entity) else { filenameLabel->SetText(""); + nameField->SetText(""); + nameField->SetEnabled(false); playstopButton->SetEnabled(false); loopedCheckbox->SetEnabled(false); volumeSlider->SetEnabled(false); diff --git a/Editor/SoundWindow.h b/Editor/SoundWindow.h index d63b75404..3963fd9af 100644 --- a/Editor/SoundWindow.h +++ b/Editor/SoundWindow.h @@ -23,6 +23,7 @@ public: wiWindow* soundWindow; wiLabel* filenameLabel; + wiTextInputField* nameField; wiButton* addButton; wiButton* playstopButton; wiCheckBox* loopedCheckbox;