mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Added audio emitter editor panel
This commit is contained in:
91
Editor/src/ComponentsPanel/AudioEmitterPanel.h
Normal file
91
Editor/src/ComponentsPanel/AudioEmitterPanel.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
#include "ComponentPanel.h"
|
||||
|
||||
#include <src/Core/FileSystem.h>
|
||||
#include <src/Core/Maths.h>
|
||||
#include <src/Scene/Components/AudioEmitterComponent.h>
|
||||
#include <src/Scene/Entities/ImGuiHelper.h>
|
||||
|
||||
|
||||
class AudioEmitterPanel : ComponentPanel
|
||||
{
|
||||
public:
|
||||
AudioEmitterPanel() = default;
|
||||
~AudioEmitterPanel() = default;
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<AudioEmitterComponent>())
|
||||
return;
|
||||
|
||||
auto& component = entity.GetComponent<AudioEmitterComponent>();
|
||||
BeginComponentTable(AUDIO EMITTER, AudioEmitterComponent);
|
||||
{
|
||||
{
|
||||
ImGui::Text("Audio File");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
std::string path = component.FilePath;
|
||||
ImGui::Button(component.FilePath.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0));
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_AudioFile"))
|
||||
{
|
||||
char* file = (char*)payload->Data;
|
||||
std::string fullPath = std::string(file, 256);
|
||||
path = Nuake::FileSystem::AbsoluteToRelative(fullPath);
|
||||
component.FilePath = path;
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.FilePath, "");
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Playing");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##Playing", &component.IsPlaying);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.IsPlaying, false);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Volume");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::DragFloat("##Volume", &component.Volume, 0.00f, 1.0f);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.Volume, 1.0f);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Playback Speed");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::DragFloat("##PlaybackSpeed", &component.PlaybackSpeed, 0.01f, 0.0001f);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.PlaybackSpeed, 1.0f);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Pan");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::DragFloat("##Pan", &component.Pan, 0.01f, -1.0f, 1.0f);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.Pan, 0.0f);
|
||||
}
|
||||
}
|
||||
EndComponentTable();
|
||||
}
|
||||
};
|
||||
@@ -111,6 +111,7 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity)
|
||||
mCylinderColliderPanel.Draw(entity);
|
||||
mMeshColliderPanel.Draw(entity);
|
||||
mCharacterControllerPanel.Draw(entity);
|
||||
mAudioEmitterPanel.Draw(entity);
|
||||
}
|
||||
|
||||
void EditorSelectionPanel::DrawAddComponentMenu(Nuake::Entity entity)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../ComponentsPanel/ParticleEmitterPanel.h"
|
||||
#include "../ComponentsPanel/SkinnedModelPanel.h"
|
||||
#include "../ComponentsPanel/BonePanel.h"
|
||||
#include "../ComponentsPanel/AudioEmitterPanel.h"
|
||||
|
||||
class EditorSelectionPanel
|
||||
{
|
||||
@@ -43,6 +44,7 @@ private:
|
||||
CharacterControllerPanel mCharacterControllerPanel;
|
||||
ParticleEmitterPanel mParticleEmitterPanel;
|
||||
BonePanel mBonePanel;
|
||||
AudioEmitterPanel mAudioEmitterPanel;
|
||||
|
||||
Ref<Nuake::File> currentFile;
|
||||
Ref<Nuake::Resource> selectedResource;
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Nuake {
|
||||
float Volume = 1.0f;
|
||||
float Pan = 0.0f;
|
||||
float PlaybackSpeed = 1.0f;
|
||||
bool IsPlaying = false;
|
||||
std::string FilePath;
|
||||
|
||||
json Serialize();
|
||||
bool Deserialize(const json& j);
|
||||
|
||||
Reference in New Issue
Block a user