Skip to content

Commit 9c826f2

Browse files
committed
Updated examples to new raylib 4.2 files API
1 parent 7ef0ae7 commit 9c826f2

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

examples/image_exporter/image_exporter.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ int main(int argc, char *argv[])
6666
//----------------------------------------------------------------------------------
6767
if (IsFileDropped())
6868
{
69-
int fileCount = 0;
70-
char **droppedFiles = LoadDroppedFiles(&fileCount);
69+
FilePathList droppedFiles = LoadDroppedFiles();
7170

72-
if (fileCount == 1)
71+
if (droppedFiles.count == 1)
7372
{
74-
Image imTemp = LoadImage(droppedFiles[0]);
73+
Image imTemp = LoadImage(droppedFiles.paths[0]);
7574

7675
if (imTemp.data != NULL)
7776
{
@@ -89,7 +88,7 @@ int main(int argc, char *argv[])
8988
}
9089
}
9190

92-
UnloadDroppedFiles();
91+
UnloadDroppedFiles(droppedFiles);
9392
}
9493

9594
if (btnExport)

examples/image_importer_raw/image_importer_raw.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,20 @@ int main()
8282
// Check if a file is dropped
8383
if (IsFileDropped())
8484
{
85-
int fileCount = 0;
86-
char **droppedFiles = LoadDroppedFiles(&fileCount);
85+
FilePathList droppedFiles = LoadDroppedFiles();
8786

8887
// Check file extensions for drag-and-drop
89-
if ((fileCount == 1) && IsFileExtension(droppedFiles[0], ".raw"))
88+
if ((droppedFiles.count == 1) && IsFileExtension(droppedFiles.paths[0], ".raw"))
9089
{
91-
FILE *imageFile = fopen(droppedFiles[0], "rb");
90+
FILE *imageFile = fopen(droppedFiles.paths[0], "rb");
9291
fseek(imageFile, 0L, SEEK_END);
9392
dataSize = ftell(imageFile);
9493
fclose(imageFile);
9594

9695
// NOTE: Returned string is just a pointer to droppedFiles[0],
9796
// we need to make a copy of that data somewhere else: fileName
98-
strcpy(fileNamePath, droppedFiles[0]);
99-
strcpy(fileName, GetFileName(droppedFiles[0]));
97+
strcpy(fileNamePath, droppedFiles.paths[0]);
98+
strcpy(fileName, GetFileName(droppedFiles.paths[0]));
10099

101100
// Try to guess possible raw values
102101
// Let's assume image is square, RGBA, 8 bit per channel
@@ -108,7 +107,7 @@ int main()
108107
importWindowActive = true;
109108
}
110109

111-
UnloadDroppedFiles();
110+
UnloadDroppedFiles(droppedFiles);
112111
}
113112

114113
// Check if load button has been pressed

examples/style_selector/style_selector.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,11 @@ int main()
140140

141141
if (IsFileDropped())
142142
{
143-
int dropFileCount = 0;
144-
char **droppedFiles = LoadDroppedFiles(&dropFileCount);
143+
FilePathList droppedFiles = LoadDroppedFiles();
145144

146-
if ((dropFileCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
145+
if ((droppedFiles.count > 0) && IsFileExtension(droppedFiles.paths[0], ".rgs")) GuiLoadStyle(droppedFiles.paths[0]);
147146

148-
UnloadDroppedFiles(); // Clear internal buffers
147+
UnloadDroppedFiles(droppedFiles); // Clear internal buffers
149148
}
150149

151150
if (visualStyleActive != prevVisualStyleActive)

examples/textbox_selection/textbox_selection.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,13 @@ int main(int argc, char **argv)
141141
// Fonts drag & drop logic
142142
if (IsFileDropped())
143143
{
144-
int count = 0;
145-
char **files = LoadDroppedFiles(&count);
144+
FilePathList droppedFiles = LoadDroppedFiles();
146145

147-
if (IsFileExtension(files[0], ".ttf") ||
148-
IsFileExtension(files[0], ".otf") ||
149-
IsFileExtension(files[0], ".fnt"))
146+
if (IsFileExtension(droppedFiles.paths[0], ".ttf") ||
147+
IsFileExtension(droppedFiles.paths[0], ".otf") ||
148+
IsFileExtension(droppedFiles.paths[0], ".fnt"))
150149
{
151-
Font fnt = LoadFont(files[0]);
150+
Font fnt = LoadFont(droppedFiles.paths[0]);
152151

153152
if (fnt.texture.id != 0)
154153
{
@@ -162,7 +161,7 @@ int main(int argc, char **argv)
162161
}
163162
}
164163

165-
UnloadDroppedFiles();
164+
UnloadDroppedFiles(droppedFiles);
166165
}
167166

168167
// Convert text to hex representation and draw it on screen

projects/VS2022/examples/test.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ i Int Range 0 32 0 100 1
2323
r Rect 0 0 0 100 200
2424
v2 Vec2 0 20.000000 20.000000
2525
v3 Vec3 0 12.000000 13.000000 14.000000
26-
v4 Vec4 1 12.000000 13.000000 14.000000 15.000000
27-
c Color 1 0 255 0 255
26+
v4 Vec4 0 12.000000 13.000000 14.000000 15.000000
27+
c Color 0 0 255 0 255

0 commit comments

Comments
 (0)