Skip to content

Commit 3eb09fe

Browse files
authored
Merge pull request #319 from RobLoach/versions
Update AutomationEventList usage
2 parents c8a910e + 8f1689d commit 3eb09fe

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

include/AutomationEventList.hpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ class AutomationEventList : public ::AutomationEventList {
1515
set(automationEventList);
1616
}
1717

18-
AutomationEventList(unsigned int capacity = 16384,
19-
unsigned int count = 0,
20-
AutomationEvent *events = nullptr) : ::AutomationEventList{capacity, count, events} {
21-
// Nothing.
18+
/**
19+
* Load an empty automation events list.
20+
*/
21+
AutomationEventList() {
22+
set(::LoadAutomationEventList(0));
2223
}
2324

25+
/**
26+
* Load automation events list from file.
27+
*
28+
* @param fileName The file path to load the automation events list from.
29+
*/
2430
AutomationEventList(const char* fileName) {
2531
Load(fileName);
2632
}
@@ -82,12 +88,19 @@ class AutomationEventList : public ::AutomationEventList {
8288
* Update audio stream buffers with data
8389
*/
8490
void Unload() {
85-
#if RAYLIB_VERSION_MAJOR >= 5
86-
#if RAYLIB_VERSION_MINOR == 0
87-
::UnloadAutomationEventList(this);
88-
#elif RAYLIB_VERSION_MINOR >= 1
89-
::UnloadAutomationEventList(*this);
90-
#endif
91+
if (!IsReady()) {
92+
return;
93+
}
94+
95+
// The function signature of UnloadAutomationEventList() changes from raylib 5.0.
96+
#if RAYLIB_VERSION_MAJOR == 5
97+
#if RAYLIB_VERSION_MINOR == 0
98+
::UnloadAutomationEventList(this);
99+
#elif RAYLIB_VERSION_MINOR >= 1
100+
::UnloadAutomationEventList(*this);
101+
#endif
102+
#else
103+
::UnloadAutomationEventList(*this);
91104
#endif
92105
}
93106

include/raylib.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ extern "C" {
1515
#include RAYLIB_H_FILE // NOLINT
1616

1717
#if !defined(RAYLIB_VERSION_MAJOR) || !defined(RAYLIB_VERSION_MINOR)
18-
#if RAYLIB_VERSION_MAJOR < 5
19-
#error "raylib-cpp requires at least raylib 5.0.0"
18+
#error "raylib-cpp requires raylib >= 5"
2019
#endif
20+
21+
#if RAYLIB_VERSION_MAJOR < 5
22+
#error "raylib-cpp requires raylib >= 5"
2123
#endif
2224

2325
#if RAYLIB_VERSION_MAJOR > 5
24-
#error "raylib-cpp targets raylib 5. Use the `next` branch for the next version of raylib."
26+
#error "raylib-cpp requires raylib ~5.0. Use the `next` branch for the next version of raylib."
2527
#endif
2628

2729
#ifdef __cplusplus

0 commit comments

Comments
 (0)