R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GUI::ECS::Components::MusicComponent Class Reference

Manages music playback and properties for an entity in the ECS system. More...

#include <MusicComponent.hpp>

Inheritance diagram for GUI::ECS::Components::MusicComponent:
Inheritance graph
Collaboration diagram for GUI::ECS::Components::MusicComponent:
Collaboration graph

Public Member Functions

 MusicComponent ()
 Default constructor.
 
 MusicComponent (const std::uint32_t entityId)
 Constructor with an entity ID.
 
 MusicComponent (const MusicComponent &music)
 Copy constructor.
 
 MusicComponent (const std::uint32_t entityId, const MusicComponent &music)
 Constructor with an entity ID and another MusicComponent to copy.
 
 MusicComponent (const std::string &filePath, const std::string &name)
 Constructor that initializes the music with a file path and name.
 
 MusicComponent (const std::string &filePath, const std::string &name, bool loop)
 Constructor that initializes the music with a file path, name, and looping option.
 
 MusicComponent (const std::string &filePath, const std::string &name, float volume)
 Constructor that initializes the music with a file path, name, and volume.
 
 MusicComponent (const std::string &filePath, const std::string &name, float volume, bool loop)
 Constructor that initializes the music with a file path, name, volume, and looping option.
 
 MusicComponent (const std::string &filePath, const std::string &name, const std::string &application)
 Constructor that initializes the music with a file path, name, and associated application.
 
 MusicComponent (const std::string &filePath, const std::string &name, const std::string &application, bool loop)
 Constructor that initializes the music with a file path, name, associated application, and looping option.
 
 MusicComponent (const std::string &filePath, const std::string &name, const std::string &application, float volume)
 Constructor that initializes the music with a file path, name, associated application, and volume.
 
 MusicComponent (const std::string &filePath, const std::string &name, const std::string &application, float volume, bool loop)
 Constructor that initializes the music with a file path, name, associated application, volume, and looping option.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name)
 Constructor that initializes the music with an entity ID, file path, and name.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, bool loop)
 Constructor that initializes the music with an entity ID, file path, name, and looping option.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, float volume)
 Constructor that initializes the music with an entity ID, file path, name, and volume.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, float volume, bool loop)
 Constructor that initializes the music with an entity ID, file path, name, volume, and looping option.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application)
 Constructor that initializes the music with an entity ID, file path, name, and associated application.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application, bool loop)
 Constructor that initializes the music with an entity ID, file path, name, associated application, and looping option.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application, float volume)
 Constructor that initializes the music with an entity ID, file path, name, associated application, and volume.
 
 MusicComponent (const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application, float volume, bool loop)
 Constructor that initializes the music with an entity ID, file path, name, associated application, volume, and looping option.
 
 ~MusicComponent ()
 Destructor.
 
void setVolume (float volume)
 Set the music Volume (0-100)
 
void setLoopMusic (bool loop)
 Set if to play the music in a loop or only when asked to.
 
void setMusicName (const std::string &name)
 Set the name of the music.
 
void setMusic (const std::string &filePath)
 Set the music file to load using a file path.
 
void setMusic (const std::string &filePath, const std::string &name)
 Set the Music file to load via a file path as well as setting the name of the music.
 
void setMusic (const std::string &filePath, const std::string &name, float volume)
 Set the Music file to load via file path as well as it's name and volume.
 
void setApplication (const std::string &application)
 Set the Application context of the music.
 
void play ()
 Start playing the music.
 
void stop ()
 Stop the music.
 
void pause ()
 Pause the music.
 
const bool isPaused () const
 Check if the music is pause.
 
const bool isPlaying () const
 Check if the music is playing.
 
const bool isStopped () const
 Check if the music is stopped.
 
const bool isLooping () const
 Check is the music is looping.
 
const bool isInitialised () const
 Check if there is an instance of the music to be played in the component.
 
void update (const MusicComponent &copy)
 Copy the values from an existing music component into the current instance.
 
const float getVolume () const
 Get the Volume of the music.
 
const std::string getMusicName () const
 Get the name of the music stored in the component.
 
const std::string getFilePath () const
 Get the File Path of the music stored in the component.
 
const std::string getApplication () const
 Get the Application context of the music stored in the component.
 
const std::string getInfo (const unsigned int indent=0) const
 This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.
 
MusicComponentoperator= (const GUI::ECS::Components::MusicComponent &copy)
 The '=' operator that will allow the user to seamlessly update their music component from another music component.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

Manages music playback and properties for an entity in the ECS system.

Definition at line 36 of file MusicComponent.hpp.

Constructor & Destructor Documentation

◆ MusicComponent() [1/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( )

Default constructor.

Definition at line 16 of file MusicComponent.cpp.

◆ MusicComponent() [2/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId)

Constructor with an entity ID.

Parameters
entityIdThe ID of the entity associated with this component.

Definition at line 21 of file MusicComponent.cpp.

◆ MusicComponent() [3/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const MusicComponent & music)

Copy constructor.

Parameters
musicThe MusicComponent instance to copy from.

Definition at line 26 of file MusicComponent.cpp.

◆ MusicComponent() [4/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const MusicComponent & music )

Constructor with an entity ID and another MusicComponent to copy.

Parameters
entityIdThe ID of the entity associated with this component.
musicThe MusicComponent instance to copy from.

Definition at line 32 of file MusicComponent.cpp.

◆ MusicComponent() [5/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name )

Constructor that initializes the music with a file path and name.

Parameters
filePathThe file path of the music.
nameThe name of the music.

Definition at line 38 of file MusicComponent.cpp.

◆ MusicComponent() [6/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
bool loop )

Constructor that initializes the music with a file path, name, and looping option.

Parameters
filePathThe file path of the music.
nameThe name of the music.
loopWhether the music should loop.

Definition at line 46 of file MusicComponent.cpp.

◆ MusicComponent() [7/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
float volume )

Constructor that initializes the music with a file path, name, and volume.

Parameters
filePathThe file path of the music.
nameThe name of the music.
volumeThe volume of the music (0-100).

Definition at line 55 of file MusicComponent.cpp.

◆ MusicComponent() [8/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
float volume,
bool loop )

Constructor that initializes the music with a file path, name, volume, and looping option.

Parameters
filePathThe file path of the music.
nameThe name of the music.
volumeThe volume of the music (0-100).
loopWhether the music should loop.

Definition at line 64 of file MusicComponent.cpp.

◆ MusicComponent() [9/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
const std::string & application )

Constructor that initializes the music with a file path, name, and associated application.

Parameters
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.

Definition at line 74 of file MusicComponent.cpp.

◆ MusicComponent() [10/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
const std::string & application,
bool loop )

Constructor that initializes the music with a file path, name, associated application, and looping option.

Parameters
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.
loopWhether the music should loop.

Definition at line 83 of file MusicComponent.cpp.

◆ MusicComponent() [11/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
const std::string & application,
float volume )

Constructor that initializes the music with a file path, name, associated application, and volume.

Parameters
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.
volumeThe volume of the music (0-100).

Definition at line 93 of file MusicComponent.cpp.

◆ MusicComponent() [12/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::string & filePath,
const std::string & name,
const std::string & application,
float volume,
bool loop )

Constructor that initializes the music with a file path, name, associated application, volume, and looping option.

Parameters
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.
volumeThe volume of the music (0-100).
loopWhether the music should loop.

Definition at line 103 of file MusicComponent.cpp.

◆ MusicComponent() [13/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name )

Constructor that initializes the music with an entity ID, file path, and name.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.

Definition at line 114 of file MusicComponent.cpp.

◆ MusicComponent() [14/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
bool loop )

Constructor that initializes the music with an entity ID, file path, name, and looping option.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
loopWhether the music should loop.

Definition at line 122 of file MusicComponent.cpp.

◆ MusicComponent() [15/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
float volume )

Constructor that initializes the music with an entity ID, file path, name, and volume.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
volumeThe volume of the music (0-100).

Definition at line 131 of file MusicComponent.cpp.

◆ MusicComponent() [16/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
float volume,
bool loop )

Constructor that initializes the music with an entity ID, file path, name, volume, and looping option.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
volumeThe volume of the music (0-100).
loopWhether the music should loop.

Definition at line 140 of file MusicComponent.cpp.

◆ MusicComponent() [17/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
const std::string & application )

Constructor that initializes the music with an entity ID, file path, name, and associated application.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.

Definition at line 150 of file MusicComponent.cpp.

◆ MusicComponent() [18/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
const std::string & application,
bool loop )

Constructor that initializes the music with an entity ID, file path, name, associated application, and looping option.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.
loopWhether the music should loop.

Definition at line 159 of file MusicComponent.cpp.

◆ MusicComponent() [19/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
const std::string & application,
float volume )

Constructor that initializes the music with an entity ID, file path, name, associated application, and volume.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.
volumeThe volume of the music (0-100).

Definition at line 169 of file MusicComponent.cpp.

◆ MusicComponent() [20/20]

GUI::ECS::Components::MusicComponent::MusicComponent ( const std::uint32_t entityId,
const std::string & filePath,
const std::string & name,
const std::string & application,
float volume,
bool loop )

Constructor that initializes the music with an entity ID, file path, name, associated application, volume, and looping option.

Parameters
entityIdThe ID of the entity associated with this component.
filePathThe file path of the music.
nameThe name of the music.
applicationThe name of the application associated with the music.
volumeThe volume of the music (0-100).
loopWhether the music should loop.

Definition at line 181 of file MusicComponent.cpp.

◆ ~MusicComponent()

GUI::ECS::Components::MusicComponent::~MusicComponent ( )

Destructor.

Definition at line 192 of file MusicComponent.cpp.

Member Function Documentation

◆ getApplication()

const std::string GUI::ECS::Components::MusicComponent::getApplication ( ) const

Get the Application context of the music stored in the component.

Returns
const std::string

Definition at line 343 of file MusicComponent.cpp.

◆ getFilePath()

const std::string GUI::ECS::Components::MusicComponent::getFilePath ( ) const

Get the File Path of the music stored in the component.

Returns
const std::string

Definition at line 338 of file MusicComponent.cpp.

◆ getInfo()

const std::string GUI::ECS::Components::MusicComponent::getInfo ( const unsigned int indent = 0) const

This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.

Parameters
indentThe level to which the class should be indented in the dump.
Returns
const std::string The formatted output.

Definition at line 348 of file MusicComponent.cpp.

◆ getMusicName()

const std::string GUI::ECS::Components::MusicComponent::getMusicName ( ) const

Get the name of the music stored in the component.

Returns
const std::string

Definition at line 333 of file MusicComponent.cpp.

◆ getVolume()

const float GUI::ECS::Components::MusicComponent::getVolume ( ) const

Get the Volume of the music.

Returns
const float

Definition at line 328 of file MusicComponent.cpp.

◆ isInitialised()

const bool GUI::ECS::Components::MusicComponent::isInitialised ( ) const

Check if there is an instance of the music to be played in the component.

Returns
true
false

Definition at line 307 of file MusicComponent.cpp.

◆ isLooping()

const bool GUI::ECS::Components::MusicComponent::isLooping ( ) const

Check is the music is looping.

Returns
true if the music is set to loop
false if the music is not set to loop

Definition at line 302 of file MusicComponent.cpp.

◆ isPaused()

const bool GUI::ECS::Components::MusicComponent::isPaused ( ) const

Check if the music is pause.

Returns
true if it is paused
false if it is playing or stopped

Definition at line 287 of file MusicComponent.cpp.

◆ isPlaying()

const bool GUI::ECS::Components::MusicComponent::isPlaying ( ) const

Check if the music is playing.

Returns
true if it is playing
false if it is paused or stopped

Definition at line 292 of file MusicComponent.cpp.

◆ isStopped()

const bool GUI::ECS::Components::MusicComponent::isStopped ( ) const

Check if the music is stopped.

Returns
true if the music is stopped
false if it is playing or paused

Definition at line 297 of file MusicComponent.cpp.

◆ operator=()

GUI::ECS::Components::MusicComponent & GUI::ECS::Components::MusicComponent::operator= ( const GUI::ECS::Components::MusicComponent & copy)

The '=' operator that will allow the user to seamlessly update their music component from another music component.

Parameters
copy
Returns
MusicComponent&

Definition at line 369 of file MusicComponent.cpp.

◆ pause()

void GUI::ECS::Components::MusicComponent::pause ( )

Pause the music.

Definition at line 276 of file MusicComponent.cpp.

◆ play()

void GUI::ECS::Components::MusicComponent::play ( )

Start playing the music.

Definition at line 254 of file MusicComponent.cpp.

◆ setApplication()

void GUI::ECS::Components::MusicComponent::setApplication ( const std::string & application)

Set the Application context of the music.

Parameters
application

Definition at line 249 of file MusicComponent.cpp.

◆ setLoopMusic()

void GUI::ECS::Components::MusicComponent::setLoopMusic ( bool loop)

Set if to play the music in a loop or only when asked to.

Parameters
loop

Definition at line 208 of file MusicComponent.cpp.

◆ setMusic() [1/3]

void GUI::ECS::Components::MusicComponent::setMusic ( const std::string & filePath)

Set the music file to load using a file path.

Parameters
filePath

Definition at line 221 of file MusicComponent.cpp.

◆ setMusic() [2/3]

void GUI::ECS::Components::MusicComponent::setMusic ( const std::string & filePath,
const std::string & name )

Set the Music file to load via a file path as well as setting the name of the music.

Parameters
filePath
name

Definition at line 236 of file MusicComponent.cpp.

◆ setMusic() [3/3]

void GUI::ECS::Components::MusicComponent::setMusic ( const std::string & filePath,
const std::string & name,
float volume )

Set the Music file to load via file path as well as it's name and volume.

Parameters
filePath
name
volume

Definition at line 242 of file MusicComponent.cpp.

◆ setMusicName()

void GUI::ECS::Components::MusicComponent::setMusicName ( const std::string & name)

Set the name of the music.

Parameters
name

Definition at line 216 of file MusicComponent.cpp.

◆ setVolume()

void GUI::ECS::Components::MusicComponent::setVolume ( float volume)

Set the music Volume (0-100)

Parameters
volume

Definition at line 194 of file MusicComponent.cpp.

◆ stop()

void GUI::ECS::Components::MusicComponent::stop ( )

Stop the music.

Definition at line 265 of file MusicComponent.cpp.

◆ update()

void GUI::ECS::Components::MusicComponent::update ( const MusicComponent & copy)

Copy the values from an existing music component into the current instance.

Parameters
copyThe music component to copy from

Definition at line 312 of file MusicComponent.cpp.


The documentation for this class was generated from the following files: