Skip to content

Commit 1f39850

Browse files
committed
Implemented automation events
1 parent 6b4885e commit 1f39850

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

raylib/func.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,7 @@ static int cmd_loaddirectoryfilesex(int argc, slib_par_t *params, var_t *retval)
23702370
static int cmd_loaddroppedfiles(int argc, slib_par_t *params, var_t *retval) {
23712371
auto fnResult = LoadDroppedFiles();
23722372
v_setfilepathlist(retval, fnResult);
2373+
UnloadDroppedFiles(fnResult);
23732374
return 1;
23742375
}
23752376

raylib/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,14 @@ static void v_setwave(var_t *var, Wave &wave) {
819819
}
820820

821821
static void v_setfilepathlist(var_t *var, FilePathList &filePathList) {
822-
v_toarray1(var, filePathList.count);
822+
map_init(var);
823+
v_setint(map_add_var(var, "count", 0), filePathList.count);
824+
var_t *v_paths = map_add_var(var, "paths", 0);
825+
v_toarray1(v_paths, filePathList.count);
823826
for (unsigned index = 0; index < filePathList.count; index++) {
824-
var_p_t elem = v_elem(var, index);
827+
var_p_t elem = v_elem(v_paths, index);
825828
v_setstr(elem, filePathList.paths[index]);
826829
}
827-
UnloadDirectoryFiles(filePathList);
828830
}
829831

830832
static AutomationEvent get_param_automationevent(int argc, slib_par_t *params, int n) {

raylib/mkraylib.bas

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ func get_result_cast(byref fun)
197197
return result
198198
end
199199

200+
'
201+
' When the result is returned in a map and fnResult value should be cleared
202+
'
203+
func get_cleanup_fn(byref fun)
204+
local result = ""
205+
select case lower(trim(fun.name))
206+
case "loaddroppedfiles": result = " UnloadDroppedFiles(fnResult);"
207+
end select
208+
return result
209+
end
210+
200211
'
201212
' returns whether the function returns a string
202213
'
@@ -417,6 +428,8 @@ sub print_func(byref fun)
417428
else
418429
print " " + get_v_set_name(fun) + "(retval, fnResult);"
419430
endif
431+
local cleanup_fn = get_cleanup_fn(fun)
432+
if (len(cleanup_fn) > 0) then print cleanup_fn
420433
endif
421434
print " return 1;"
422435
print "}"

raylib/samples/core_automation_events.bas

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ while (!rl.WindowShouldClose())
8080
droppedFiles = rl.LoadDroppedFiles()
8181

8282
rem Supports loading .rgs style files (text or binary) and .png style palette images
83-
if (rl.IsFileExtension(droppedFiles.paths[0], ".txt.rae")) then
83+
if (rl.IsFileExtension(droppedFiles.paths[0], ".rae")) then
84+
print "loading dropped file"
8485
rl.UnloadAutomationEventList(aelist)
8586
aelist = rl.LoadAutomationEventList(droppedFiles.paths[0])
8687

@@ -93,9 +94,10 @@ while (!rl.WindowShouldClose())
9394

9495
reset_player()
9596
reset_camera()
97+
else
98+
print "Dropped file is invalid: "; droppedFiles.paths[0]
9699
endif
97-
98-
rl.UnloadDroppedFiles(droppedFiles) ' Unload filepaths from memory
100+
'UnloadDroppedFiles called as part of Loaddroppedfiles
99101
endif
100102

101103
REM Update player
@@ -250,13 +252,13 @@ while (!rl.WindowShouldClose())
250252
rl.DrawCircle(30, 175, 10, c.MAROON)
251253
if (((frameCounter/15)%2) == 1) then
252254
rl.DrawText(rl.TextFormat("RECORDING EVENTS... [%i]", aelist.count), 50, 170, 10, c.MAROON)
253-
else if (eventPlaying) then
254-
rl.DrawRectangle(10, 160, 290, 30, rl.fade(c.LIME, 0.3))
255-
rl.DrawRectangleLines(10, 160, 290, 30, rl.fade(c.DARKGREEN, 0.8))
256-
rl.DrawTriangle([20, 155 + 10], [20, 155 + 30], [40, 155 + 20], c.DARKGREEN)
257-
if (((frameCounter/15)%2) == 1) then
258-
rl.DrawText(rl.TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, c.DARKGREEN)
259-
endif
255+
endif
256+
else if (eventPlaying) then
257+
rl.DrawRectangle(10, 160, 290, 30, rl.fade(c.LIME, 0.3))
258+
rl.DrawRectangleLines(10, 160, 290, 30, rl.fade(c.DARKGREEN, 0.8))
259+
rl.DrawTriangle([20, 155 + 10], [20, 155 + 30], [40, 155 + 20], c.DARKGREEN)
260+
if (((frameCounter/15)%2) == 1) then
261+
rl.DrawText(rl.TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, c.DARKGREEN)
260262
endif
261263
endif
262264
rl.EndDrawing()

0 commit comments

Comments
 (0)