Updated raylib-cpp header files

This commit is contained in:
2025-09-08 22:06:21 -04:00
parent a0a658ca8a
commit fff611cc72
45 changed files with 2533 additions and 2382 deletions

View File

@@ -3,9 +3,9 @@
#include <string>
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./RaylibException.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./raylib.hpp"
namespace raylib {
/**
@@ -17,12 +17,12 @@ namespace raylib {
* @endcode
*/
class Sound : public ::Sound {
public:
public:
Sound(const Sound&) = delete;
Sound& operator=(const Sound&) = delete;
Sound() {
stream = { nullptr, nullptr, 0, 0, 0 };
stream = {nullptr, nullptr, 0, 0, 0};
frameCount = 0;
}
@@ -30,10 +30,10 @@ class Sound : public ::Sound {
// Nothing.
}
Sound(Sound&& other) {
Sound(Sound&& other) noexcept {
set(other);
other.stream = { nullptr, nullptr, 0, 0, 0 };
other.stream = {nullptr, nullptr, 0, 0, 0};
other.frameCount = 0;
}
@@ -42,25 +42,19 @@ class Sound : public ::Sound {
*
* @throws raylib::RaylibException Throws if the Sound failed to load.
*/
Sound(const std::string& fileName) {
Load(fileName);
}
Sound(const std::string& fileName) { Load(fileName); }
/**
* Loads a sound from the given Wave.
*
* @throws raylib::RaylibException Throws if the Sound failed to load.
*/
Sound(const ::Wave& wave) {
Load(wave);
}
Sound(const ::Wave& wave) { Load(wave); }
~Sound() {
Unload();
}
~Sound() { Unload(); }
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(::AudioStream, Stream, stream)
GETTER(unsigned int, FrameCount, frameCount)
GETTER(::AudioStream, Stream, stream)
Sound& operator=(Sound&& other) noexcept {
if (this == &other) {
@@ -70,7 +64,7 @@ class Sound : public ::Sound {
Unload();
set(other);
other.frameCount = 0;
other.stream = { nullptr, nullptr, 0, 0, 0 };
other.stream = {nullptr, nullptr, 0, 0, 0};
return *this;
}
@@ -78,7 +72,7 @@ class Sound : public ::Sound {
/**
* Update sound buffer with new data
*/
inline Sound& Update(const void *data, int samplesCount) {
Sound& Update(const void* data, int samplesCount) {
::UpdateSound(*this, data, samplesCount);
return *this;
}
@@ -86,7 +80,7 @@ class Sound : public ::Sound {
/**
* Update sound buffer with new data, assuming it's the same sample count.
*/
inline Sound& Update(const void *data) {
Sound& Update(const void* data) {
::UpdateSound(*this, data, static_cast<int>(frameCount));
return *this;
}
@@ -94,7 +88,7 @@ class Sound : public ::Sound {
/**
* Unload sound
*/
inline void Unload() {
void Unload() {
// Protect against calling UnloadSound() twice.
if (frameCount != 0) {
::UnloadSound(*this);
@@ -105,7 +99,7 @@ class Sound : public ::Sound {
/**
* Play a sound
*/
inline Sound& Play() {
Sound& Play() {
::PlaySound(*this);
return *this;
}
@@ -113,7 +107,7 @@ class Sound : public ::Sound {
/**
* Stop playing a sound
*/
inline Sound& Stop() {
Sound& Stop() {
::StopSound(*this);
return *this;
}
@@ -121,7 +115,7 @@ class Sound : public ::Sound {
/**
* Pause a sound
*/
inline Sound& Pause() {
Sound& Pause() {
::PauseSound(*this);
return *this;
}
@@ -129,7 +123,7 @@ class Sound : public ::Sound {
/**
* Resume a paused sound
*/
inline Sound& Resume() {
Sound& Resume() {
::ResumeSound(*this);
return *this;
}
@@ -137,14 +131,12 @@ class Sound : public ::Sound {
/**
* Check if a sound is currently playing
*/
inline bool IsPlaying() const {
return ::IsSoundPlaying(*this);
}
[[nodiscard]] bool IsPlaying() const { return ::IsSoundPlaying(*this); }
/**
* Set volume for a sound (1.0 is max level)
*/
inline Sound& SetVolume(float volume) {
Sound& SetVolume(float volume) {
::SetSoundVolume(*this, volume);
return *this;
}
@@ -152,7 +144,7 @@ class Sound : public ::Sound {
/**
* Set pitch for a sound (1.0 is base level)
*/
inline Sound& SetPitch(float pitch) {
Sound& SetPitch(float pitch) {
::SetSoundPitch(*this, pitch);
return *this;
}
@@ -160,7 +152,7 @@ class Sound : public ::Sound {
/**
* Set pan for a sound (0.5 is center)
*/
inline Sound& SetPan(float pan = 0.5f) {
Sound& SetPan(float pan = 0.5f) {
::SetSoundPan(*this, pan);
return *this;
}
@@ -172,8 +164,8 @@ class Sound : public ::Sound {
*/
void Load(const std::string& fileName) {
set(::LoadSound(fileName.c_str()));
if (!IsReady()) {
throw new RaylibException("Failed to load Sound from file");
if (!IsValid()) {
throw RaylibException("Failed to load Sound from file");
}
}
@@ -184,8 +176,8 @@ class Sound : public ::Sound {
*/
void Load(const ::Wave& wave) {
set(::LoadSoundFromWave(wave));
if (!IsReady()) {
throw new RaylibException("Failed to load Wave");
if (!IsValid()) {
throw RaylibException("Failed to load Wave");
}
}
@@ -194,18 +186,15 @@ class Sound : public ::Sound {
*
* @return True or false depending on whether the Sound buffer is loaded.
*/
bool IsReady() const {
return ::IsSoundReady(*this);
}
protected:
[[nodiscard]] bool IsValid() const { return ::IsSoundValid(*this); }
protected:
void set(const ::Sound& sound) {
frameCount = sound.frameCount;
stream = sound.stream;
}
};
} // namespace raylib
} // namespace raylib
using RSound = raylib::Sound;
#endif // RAYLIB_CPP_INCLUDE_SOUND_HPP_
#endif // RAYLIB_CPP_INCLUDE_SOUND_HPP_