summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2018-11-26 17:15:00 +0100
committerRay <[email protected]>2018-11-26 17:15:00 +0100
commitc6b526de664af7ab6d7ebaf535c981309ce789d4 (patch)
tree991436661869cd7febfde6e58d67579e886c2ccc /src
parent2deb35be2746a9cbe7f1696c301045f58d4eb67c (diff)
downloadraylib-c6b526de664af7ab6d7ebaf535c981309ce789d4.tar.gz
raylib-c6b526de664af7ab6d7ebaf535c981309ce789d4.zip
Support file drag & drop on Web
Using by default memory filesystem (MEMFS), provided by Emscripten
Diffstat (limited to 'src')
-rw-r--r--src/core.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/core.c b/src/core.c
index 14bf6622..ff015894 100644
--- a/src/core.c
+++ b/src/core.c
@@ -397,10 +397,9 @@ static double targetTime = 0.0; // Desired time for one frame, if 0
static unsigned char configFlags = 0; // Configuration flags (bit based)
static bool showLogo = false; // Track if showing logo at init is enabled
-#if defined(PLATFORM_DESKTOP)
static char **dropFilesPath; // Store dropped files paths as strings
static int dropFilesCount = 0; // Count dropped files strings
-#endif
+
static char **dirFilesPath; // Store directory files paths as strings
static int dirFilesCount = 0; // Count directory files strings
@@ -449,8 +448,6 @@ static void ScrollCallback(GLFWwindow *window, double xoffset, double yoffset);
static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored
-#endif
-#if defined(PLATFORM_DESKTOP)
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
#endif
@@ -1692,29 +1689,20 @@ bool ChangeDirectory(const char *dir)
// Check if a file has been dropped into window
bool IsFileDropped(void)
{
-#if defined(PLATFORM_DESKTOP)
if (dropFilesCount > 0) return true;
else return false;
-#else
- return false;
-#endif
}
// Get dropped files names
char **GetDroppedFiles(int *count)
{
-#if defined(PLATFORM_DESKTOP)
*count = dropFilesCount;
return dropFilesPath;
-#else
- return NULL;
-#endif
}
// Clear dropped files paths buffer
void ClearDroppedFiles(void)
{
-#if defined(PLATFORM_DESKTOP)
if (dropFilesCount > 0)
{
for (int i = 0; i < dropFilesCount; i++) free(dropFilesPath[i]);
@@ -1723,11 +1711,10 @@ void ClearDroppedFiles(void)
dropFilesCount = 0;
}
-#endif
}
// Get file modification time (last write time)
-RLAPI long GetFileModTime(const char *fileName)
+long GetFileModTime(const char *fileName)
{
struct stat result = { 0 };
@@ -2381,9 +2368,7 @@ static bool InitGraphicsDevice(int width, int height)
glfwSetCharCallback(window, CharCallback);
glfwSetScrollCallback(window, ScrollCallback);
glfwSetWindowIconifyCallback(window, WindowIconifyCallback);
-#if defined(PLATFORM_DESKTOP)
glfwSetDropCallback(window, WindowDropCallback);
-#endif
glfwMakeContextCurrent(window);
@@ -3319,9 +3304,7 @@ static void WindowIconifyCallback(GLFWwindow *window, int iconified)
if (iconified) windowMinimized = true; // The window was iconified
else windowMinimized = false; // The window was restored
}
-#endif
-#if defined(PLATFORM_DESKTOP)
// GLFW3 Window Drop Callback, runs when drop files into window
// NOTE: Paths are stored in dinamic memory for further retrieval
// Everytime new files are dropped, old ones are discarded