Skip to content

Commit

Permalink
Save a list of sound resource files in the "Sound" component instead …
Browse files Browse the repository at this point in the history
…of a single resource file
  • Loading branch information
Benualdo committed Sep 16, 2024
1 parent 683b1ba commit 9b3d4e0
Show file tree
Hide file tree
Showing 24 changed files with 222 additions and 122 deletions.
12 changes: 5 additions & 7 deletions data/Prefabs/Football.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,15 @@
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="Resource" name="m_soundRes" flags="Resource">
<Object class="SoundResource">
<Property type="String" name="m_name" flags="NotVisible" value="New SoundComponent"/>
<Property type="Uint32" name="m_uid" flags="" value="4096398380"/>
<Property type="Object" name="m_sounds">
<Object class="SoundResourceList">
<Property type="String" name="m_name" flags="NotVisible" value=""/>
<Property type="Uint32" name="m_uid" flags="" value="0"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value=""/>
<Property type="String" name="m_resourcePath" flags="NotVisible" value="data/Sounds/Soccer/shoot.wav"/>
<Property type="ResourceVector" name="m_resources" flags="Resource"/>
</Object>
</Property>
<Property type="EnumFlagsU32" name="m_soundSettings.m_flags" flags="Bitfield" value=""/>
<Property type="Float" name="m_soundSettings.m_volume" flags="HasRange" value="1"/>
</Object>
<Object class="MeshComponent">
<Property type="String" name="m_name" flags="NotVisible" value="MeshComponent #1"/>
Expand Down
12 changes: 5 additions & 7 deletions data/Prefabs/GJ.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,15 @@
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="Resource" name="m_soundRes" flags="Resource">
<Object class="SoundResource">
<Property type="String" name="m_name" flags="NotVisible" value="New SoundComponent"/>
<Property type="Uint32" name="m_uid" flags="" value="4234670508"/>
<Property type="Object" name="m_sounds">
<Object class="SoundResourceList">
<Property type="String" name="m_name" flags="NotVisible" value=""/>
<Property type="Uint32" name="m_uid" flags="" value="0"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value=""/>
<Property type="String" name="m_resourcePath" flags="NotVisible" value="data/Sounds/GJ/arg.wav"/>
<Property type="ResourceVector" name="m_resources" flags="Resource"/>
</Object>
</Property>
<Property type="EnumFlagsU32" name="m_soundSettings.m_flags" flags="Bitfield" value=""/>
<Property type="Float" name="m_soundSettings.m_volume" flags="HasRange" value="1"/>
</Object>
<Object class="MeshComponent">
<Property type="String" name="m_name" flags="NotVisible" value="MeshComponent #37"/>
Expand Down
24 changes: 10 additions & 14 deletions data/Scenes/Aiguelongue.scene
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Property type="Uint32" name="m_uid" flags="" value="289447141"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value=""/>
<Property type="ObjectPtr" name="m_root">
<Property type="ObjectPtr" name="m_root" flags="NotVisible">
<Object class="GameObject">
<Property type="String" name="m_name" value="Root"/>
<Property type="Uint32" name="m_uid" flags="" value="1945741270"/>
Expand Down Expand Up @@ -2708,17 +2708,15 @@
<Property type="Uint32" name="m_originalUID" flags="" value="2213048044"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="Resource" name="m_soundRes" flags="Resource">
<Object class="SoundResource">
<Property type="Object" name="m_sounds">
<Object class="SoundResourceList">
<Property type="String" name="m_name" flags="NotVisible" value=""/>
<Property type="Uint32" name="m_uid" flags="" value="2784075843"/>
<Property type="Uint32" name="m_originalUID" flags="" value="2816057046"/>
<Property type="Uint32" name="m_uid" flags="" value="0"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value=""/>
<Property type="String" name="m_resourcePath" flags="NotVisible" value="data/Sounds/BGM/tally-dub-brotheration-records-2016-140287.mp3"/>
<Property type="ResourceVector" name="m_resources" flags="Resource"/>
</Object>
</Property>
<Property type="EnumFlagsU32" name="m_soundSettings.m_flags" flags="Bitfield" value="PlayOnStart|Loop"/>
<Property type="Float" name="m_soundSettings.m_volume" flags="HasRange" value="0.2"/>
</Object>
</Property>
<Property type="ObjectPtrVector" name="m_children" flags="NotVisible"/>
Expand Down Expand Up @@ -2771,17 +2769,15 @@
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="Resource" name="m_soundRes" flags="Resource">
<Object class="SoundResource">
<Property type="Object" name="m_sounds">
<Object class="SoundResourceList">
<Property type="String" name="m_name" flags="NotVisible" value=""/>
<Property type="Uint32" name="m_uid" flags="" value="2816057046"/>
<Property type="Uint32" name="m_uid" flags="" value="0"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value=""/>
<Property type="String" name="m_resourcePath" flags="NotVisible" value=""/>
<Property type="ResourceVector" name="m_resources" flags="Resource"/>
</Object>
</Property>
<Property type="EnumFlagsU32" name="m_soundSettings.m_flags" flags="Bitfield" value=""/>
<Property type="Float" name="m_soundSettings.m_volume" flags="HasRange" value="1"/>
</Object>
</Property>
<Property type="ObjectPtrVector" name="m_children" flags="NotVisible"/>
Expand Down
Binary file added data/Sounds/GJ/arg.wav
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ void PlayerBehaviour::FixedUpdate(const Context & _context)
physicsBody->AddImpulse(dir * kickStrength);

// Play sound
if (auto * soundComponent = ball->GetGameObject()->GetComponentT<vg::engine::ISoundComponent>())
soundComponent->Play();
//if (auto * soundComponent = ball->GetGameObject()->GetComponentT<vg::engine::ISoundComponent>())
// soundComponent->Play();
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/editor/Editor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@
<ClInclude Include="ImGui\Menu\Inspector\Component\ImGuiComponentInspectorMenu.hpp">
<Filter>ImGui\Menu\Inspector\Component</Filter>
</ClInclude>
<ClInclude Include="ImGui\ObjectHandler\Material\ImGuiMaterialResourceListHandler.hpp">
<ClInclude Include="ImGui\ObjectHandler\Material\ImGuiMaterialListHandler.hpp">
<Filter>ImGui\ObjectHandler\Material</Filter>
</ClInclude>
<ClInclude Include="ImGui\ObjectHandler\Material\ImGuiMaterialModelTypeHandler.hpp">
<Filter>ImGui\ObjectHandler\Material</Filter>
</ClInclude>
<ClInclude Include="ImGui\ObjectHandler\Animation\ImGuiAnimationResourceListHandler.hpp">
<ClInclude Include="ImGui\ObjectHandler\Animation\ImGuiAnimationListHandler.hpp">
<Filter>ImGui\ObjectHandler\Animation</Filter>
</ClInclude>
<ClInclude Include="ImGui\ObjectHandler\ImGuiResourceListHandler.hpp">
Expand Down Expand Up @@ -280,6 +280,9 @@
<ClInclude Include="ImGui\Extensions\imGuiExtensions.h">
<Filter>ImGui\Extensions</Filter>
</ClInclude>
<ClInclude Include="ImGui\ObjectHandler\Audio\ImGuiSoundListHandler.hpp">
<Filter>ImGui\ObjectHandler\Audio</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Editor.def" />
Expand Down Expand Up @@ -427,5 +430,8 @@
<Filter Include="ImGui\Menu\ObjectHandle">
<UniqueIdentifier>{56071f0d-1c14-4ae5-8346-d5210971fcdb}</UniqueIdentifier>
</Filter>
<Filter Include="ImGui\ObjectHandler\Audio">
<UniqueIdentifier>{c500a89e-9b95-4221-9ead-f614c560bcdc}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
24 changes: 24 additions & 0 deletions src/editor/ImGui/ObjectHandler/Audio/ImGuiSoundListHandler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "engine/Component/Animation/AnimationResourceList.h"
#include "core/File/File.h"

using namespace vg::core;

namespace vg::editor
{
class ImGuiSoundListHandler : public ImGuiResourceListHandler
{
public:
//--------------------------------------------------------------------------------------
bool displayObject(IObject * _object, ObjectContext & _objectContext) final
{
return displayResourceList(_object, "Sound", "m_resources");
}
};

VG_AUTO_REGISTER_IMGUI_OBJECT_HANDLER(SoundResourceList, ImGuiSoundListHandler);
}



8 changes: 5 additions & 3 deletions src/editor/ImGui/ObjectHandler/ImGuiObjectHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace vg::editor
#include "Material/ImGuiMaterialModelTypeHandler.hpp"

#include "ImGuiResourceListHandler.hpp"
#include "Material/ImGuiMaterialResourceListHandler.hpp"
#include "Animation/ImGuiAnimationResourceListHandler.hpp"
#include "Animation/ImGuiSkeletonObjectHandler.hpp"

#include "Material/ImGuiMaterialListHandler.hpp"
#include "Animation/ImGuiAnimationListHandler.hpp"
#include "Animation/ImGuiSkeletonObjectHandler.hpp"
#include "Audio/ImGuiSoundListHandler.hpp"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace vg::core;

namespace vg::editor
{
class ImGuiMaterialResourceListHandler : public ImGuiResourceListHandler
class ImGuiMaterialListHandler : public ImGuiResourceListHandler
{
public:
//--------------------------------------------------------------------------------------
Expand All @@ -17,7 +17,7 @@ namespace vg::editor
}
};

VG_AUTO_REGISTER_IMGUI_OBJECT_HANDLER(MaterialResourceList, ImGuiMaterialResourceListHandler);
VG_AUTO_REGISTER_IMGUI_OBJECT_HANDLER(MaterialResourceList, ImGuiMaterialListHandler);
}


Expand Down
12 changes: 11 additions & 1 deletion src/editor/ImGui/Window/ImGuiWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,8 +1428,18 @@ namespace vg::editor

IProperty::Callback pFunc = _prop->GetPropertyCallback();

if (ImGui::Button(displayName))
float textWidth = ImGui::CalcTextSize(displayName).x;
float minWidth = style::button::SizeSmall.x;
float buttonWidth = std::max(textWidth + ImGui::GetStyle().FramePadding.x * 2, minWidth);

if (ImGui::Button(displayName, ImVec2(buttonWidth,0)))
pFunc(_object);

if (auto * desc = _prop->GetDescription())
{
if (ImGui::IsItemHovered())
ImGui::SetTooltip(desc);
}
}
break;

Expand Down
5 changes: 3 additions & 2 deletions src/editor/editor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@
<ClInclude Include="ImGui\Menu\ObjectHandle\ObjectHandleMenu.hpp" />
<ClInclude Include="ImGui\Menu\Scene\ImGuiSceneMenu.h" />
<ClInclude Include="ImGui\Menu\Scene\ImGuiSceneMenu.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Animation\ImGuiAnimationResourceListHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Animation\ImGuiAnimationListHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Animation\ImGuiSkeletonObjectHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Audio\ImGuiSoundListHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\GameObject\ImGuiGameObjectHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\ImGuiObjectHandler.h" />
<ClInclude Include="ImGui\ObjectHandler\Material\ImGuiMaterialModelTypeHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Material\ImGuiMaterialResourceListHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Material\ImGuiMaterialListHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\ImGuiResourceListHandler.hpp" />
<ClInclude Include="ImGui\ObjectHandler\Texture\ImGuiTextureHandler.hpp" />
<ClInclude Include="ImGui\PropertyHandler\ImGuiPropertyHandler.h" />
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Component/Animation/AnimationResourceList.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace vg::engine
{
class AnimationResourceList : public ResourceList<AnimationResource>
class AnimationResourceList final : public ResourceList<AnimationResource>
{
public:
VG_CLASS_DECL(AnimationResourceList, ResourceList<AnimationResource>);
Expand Down
3 changes: 2 additions & 1 deletion src/engine/Component/Audio/AudioComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "engine/Precomp.h"

#include "Sound/SoundComponent.hpp"
#include "Sound/SoundComponent.hpp"
#include "Sound/SoundResourceList.hpp"
14 changes: 4 additions & 10 deletions src/engine/Component/Audio/Sound/SoundComponent.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "engine/ISoundComponent.h"
#include "engine/Resource/Audio/SoundResource.h"
#include "engine/Component/Audio/Sound/SoundResourceList.h"

namespace vg::engine
{
Expand All @@ -18,16 +18,10 @@ namespace vg::engine
void OnPlay() final override;
void OnStop() final override;

audio::PlaySoundHandle Play() final override;
bool Stop() final override;

protected:
static bool playSound(IObject * _object);
static bool stopSound(IObject * _object);
//audio::PlaySoundHandle Play() final override;
//bool Stop() final override;

private:
SoundResource m_soundRes;
audio::SoundSettings m_soundSettings;
audio::PlaySoundHandle m_playSoundHandle = 0;
SoundResourceList m_sounds;
};
}
Loading

0 comments on commit 9b3d4e0

Please sign in to comment.