Răsfoiți Sursa

Updated examples to new `raylib 4.2` files API

Ray 3 ani în urmă
părinte
comite
9c826f213f

+ 4 - 5
examples/image_exporter/image_exporter.c

@@ -66,12 +66,11 @@ int main(int argc, char *argv[])
         //----------------------------------------------------------------------------------
         if (IsFileDropped())
         {
-            int fileCount = 0;
-            char **droppedFiles = LoadDroppedFiles(&fileCount);
+            FilePathList droppedFiles = LoadDroppedFiles();
 
-            if (fileCount == 1)
+            if (droppedFiles.count == 1)
             {
-                Image imTemp = LoadImage(droppedFiles[0]);
+                Image imTemp = LoadImage(droppedFiles.paths[0]);
                 
                 if (imTemp.data != NULL)
                 {
@@ -89,7 +88,7 @@ int main(int argc, char *argv[])
                 }
             }
 
-            UnloadDroppedFiles();
+            UnloadDroppedFiles(droppedFiles);
         }
     
         if (btnExport)

+ 6 - 7
examples/image_importer_raw/image_importer_raw.c

@@ -82,21 +82,20 @@ int main()
         // Check if a file is dropped
         if (IsFileDropped())
         {
-            int fileCount = 0;
-            char **droppedFiles = LoadDroppedFiles(&fileCount);
+            FilePathList droppedFiles = LoadDroppedFiles();
 
             // Check file extensions for drag-and-drop
-            if ((fileCount == 1) && IsFileExtension(droppedFiles[0], ".raw"))
+            if ((droppedFiles.count == 1) && IsFileExtension(droppedFiles.paths[0], ".raw"))
             {
-                FILE *imageFile = fopen(droppedFiles[0], "rb");
+                FILE *imageFile = fopen(droppedFiles.paths[0], "rb");
                 fseek(imageFile, 0L, SEEK_END);
                 dataSize = ftell(imageFile);
                 fclose(imageFile);
                 
                 // NOTE: Returned string is just a pointer to droppedFiles[0],
                 // we need to make a copy of that data somewhere else: fileName
-                strcpy(fileNamePath, droppedFiles[0]);
-                strcpy(fileName, GetFileName(droppedFiles[0]));
+                strcpy(fileNamePath, droppedFiles.paths[0]);
+                strcpy(fileName, GetFileName(droppedFiles.paths[0]));
                 
                 // Try to guess possible raw values
                 // Let's assume image is square, RGBA, 8 bit per channel
@@ -108,7 +107,7 @@ int main()
                 importWindowActive = true;
             }
 
-            UnloadDroppedFiles();
+            UnloadDroppedFiles(droppedFiles);
         }
         
         // Check if load button has been pressed

+ 3 - 4
examples/style_selector/style_selector.c

@@ -140,12 +140,11 @@ int main()
 
         if (IsFileDropped())
         {
-            int dropFileCount = 0;
-            char **droppedFiles = LoadDroppedFiles(&dropFileCount);
+            FilePathList droppedFiles = LoadDroppedFiles();
 
-            if ((dropFileCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
+            if ((droppedFiles.count > 0) && IsFileExtension(droppedFiles.paths[0], ".rgs")) GuiLoadStyle(droppedFiles.paths[0]);
 
-            UnloadDroppedFiles();    // Clear internal buffers
+            UnloadDroppedFiles(droppedFiles);    // Clear internal buffers
         }
 
         if (visualStyleActive != prevVisualStyleActive)

+ 6 - 7
examples/textbox_selection/textbox_selection.c

@@ -141,14 +141,13 @@ int main(int argc, char **argv)
         // Fonts drag & drop logic
         if (IsFileDropped()) 
         {
-            int count = 0;
-            char **files = LoadDroppedFiles(&count);
+            FilePathList droppedFiles = LoadDroppedFiles();
             
-            if (IsFileExtension(files[0], ".ttf") || 
-                IsFileExtension(files[0], ".otf") || 
-                IsFileExtension(files[0], ".fnt"))
+            if (IsFileExtension(droppedFiles.paths[0], ".ttf") || 
+                IsFileExtension(droppedFiles.paths[0], ".otf") || 
+                IsFileExtension(droppedFiles.paths[0], ".fnt"))
             {
-                Font fnt = LoadFont(files[0]);
+                Font fnt = LoadFont(droppedFiles.paths[0]);
                 
                 if (fnt.texture.id != 0)
                 {
@@ -162,7 +161,7 @@ int main(int argc, char **argv)
                 }
             }
             
-            UnloadDroppedFiles();
+            UnloadDroppedFiles(droppedFiles);
         }
         
         // Convert text to hex representation and draw it on screen

+ 2 - 2
projects/VS2022/examples/test.props

@@ -23,5 +23,5 @@ i  Int Range 0 32 0 100 1
 r  Rect 0 0 0 100 200
 v2 Vec2 0 20.000000 20.000000
 v3 Vec3 0 12.000000 13.000000 14.000000
-v4 Vec4 1 12.000000 13.000000 14.000000 15.000000
-c  Color 1 0 255 0 255
+v4 Vec4 0 12.000000 13.000000 14.000000 15.000000
+c  Color 0 0 255 0 255