R-Type  2
Doom but in better
Loading...
Searching...
No Matches
MusicComponent.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** MusicComponent.hpp
6*/
7
14#pragma once
15
16#include <string>
17#include <SFML/Audio.hpp>
18
19#include "Log.hpp"
20#include "LogMacros.hpp"
21#include "Utilities.hpp"
22#include "CustomExceptions.hpp"
24
25namespace GUI
26{
27 namespace ECS
28 {
29 namespace Components
30 {
36 class MusicComponent : public EntityNode {
37 public:
47 MusicComponent(const std::uint32_t entityId);
53 MusicComponent(const MusicComponent &music);
60 MusicComponent(const std::uint32_t entityId, const MusicComponent &music);
67 MusicComponent(const std::string &filePath, const std::string &name);
75 MusicComponent(const std::string &filePath, const std::string &name, bool loop);
83 MusicComponent(const std::string &filePath, const std::string &name, float volume);
92 MusicComponent(const std::string &filePath, const std::string &name, float volume, bool loop);
100 MusicComponent(const std::string &filePath, const std::string &name, const std::string &application);
109 MusicComponent(const std::string &filePath, const std::string &name, const std::string &application, bool loop);
118 MusicComponent(const std::string &filePath, const std::string &name, const std::string &application, float volume);
128 MusicComponent(const std::string &filePath, const std::string &name, const std::string &application, float volume, bool loop);
129
137 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name);
146 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, bool loop);
155 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, float volume);
165 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, float volume, bool loop);
174 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application);
184 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application, bool loop);
194 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application, float volume);
205 MusicComponent(const std::uint32_t entityId, const std::string &filePath, const std::string &name, const std::string &application, float volume, bool loop);
206
211
217 void setVolume(float volume);
223 void setLoopMusic(bool loop);
229 void setMusicName(const std::string &name);
230
236 void setMusic(const std::string &filePath);
243 void setMusic(const std::string &filePath, const std::string &name);
251 void setMusic(const std::string &filePath, const std::string &name, float volume);
252
258 void setApplication(const std::string &application);
259
264 void play();
269 void stop();
274 void pause();
275
282 const bool isPaused() const;
289 const bool isPlaying() const;
296 const bool isStopped() const;
303 const bool isLooping() const;
310 const bool isInitialised() const;
311
317 void update(const MusicComponent &copy);
318
324 const float getVolume() const;
330 const std::string getMusicName() const;
336 const std::string getFilePath() const;
337
343 const std::string getApplication() const;
353 const std::string getInfo(const unsigned int indent = 0) const;
354
362
363 private:
364 float _volume = 100;
365 bool _isLooping = false;
366 bool _isPlaying = false;
367 bool _isPaused = false;
368 bool _isStopped = true;
369 bool _isInitialised = false;
370 std::string _name = "";
371 std::string _filePath = "";
372 std::string _application = "";
373 sf::Music _music;
374 };
375
384 std::ostream &operator<<(std::ostream &os, const MusicComponent &item);
385
386 }
387 }
388}
389
File in charge of containing the custom errors that are going to be used for custom description error...
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
Manages music playback and properties for an entity in the ECS system.
void setMusicName(const std::string &name)
Set the name of the music.
MusicComponent & operator=(const GUI::ECS::Components::MusicComponent &copy)
The '=' operator that will allow the user to seamlessly update their music component from another mus...
const bool isLooping() const
Check is the music is looping.
void setApplication(const std::string &application)
Set the Application context of the music.
void play()
Start playing the music.
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 ...
const float getVolume() const
Get the Volume of the music.
const std::string getFilePath() const
Get the File Path of the music stored in the component.
const bool isPlaying() const
Check if the music is playing.
void setMusic(const std::string &filePath)
Set the music file to load using a file path.
void setLoopMusic(bool loop)
Set if to play the music in a loop or only when asked to.
const bool isInitialised() const
Check if there is an instance of the music to be played in the component.
const bool isStopped() const
Check if the music is stopped.
const std::string getApplication() const
Get the Application context of the music stored in the component.
const std::string getMusicName() const
Get the name of the music stored in the component.
const bool isPaused() const
Check if the music is pause.
void setVolume(float volume)
Set the music Volume (0-100)
void update(const MusicComponent &copy)
Copy the values from an existing music component into the current instance.
std::ostream & operator<<(std::ostream &os, const AnimationComponent &item)
Outputs the animation's info to a stream.