Get drag-and-drop working again

This commit is contained in:
Clownacy 2020-04-01 21:43:04 +01:00
parent b3591ba3da
commit 0182ab6eb3
4 changed files with 19 additions and 1 deletions

View file

@ -11,6 +11,7 @@ BOOL PlatformBackend_GetBasePath(char *string_buffer);
void PlatformBackend_HideMouse(void); void PlatformBackend_HideMouse(void);
void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height); void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height); void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
void PlaybackBackend_EnableDragAndDrop(void);
BOOL PlatformBackend_SystemTask(void); BOOL PlatformBackend_SystemTask(void);
void PlatformBackend_ShowMessageBox(const char *title, const char *message); void PlatformBackend_ShowMessageBox(const char *title, const char *message);
unsigned long PlatformBackend_GetTicks(void); unsigned long PlatformBackend_GetTicks(void);

View file

@ -217,6 +217,13 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
Backend_HandleWindowResize(width, height); Backend_HandleWindowResize(width, height);
} }
static void DragAndDropCallback(GLFWwindow *window, int count, const char **paths)
{
(void)window;
LoadProfile(paths[0]);
}
void PlatformBackend_Init(void) void PlatformBackend_Init(void)
{ {
glfwInit(); glfwInit();
@ -313,6 +320,11 @@ void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int wid
} }
} }
void PlaybackBackend_EnableDragAndDrop(void)
{
glfwSetDropCallback(window, DragAndDropCallback);
}
BOOL PlatformBackend_SystemTask(void) BOOL PlatformBackend_SystemTask(void)
{ {
if (glfwWindowShouldClose(window)) if (glfwWindowShouldClose(window))

View file

@ -85,6 +85,11 @@ void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int wid
SDL_SetCursor(cursor); SDL_SetCursor(cursor);
} }
void PlaybackBackend_EnableDragAndDrop(void)
{
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
}
BOOL PlatformBackend_SystemTask(void) BOOL PlatformBackend_SystemTask(void)
{ {
while (SDL_PollEvent(NULL) || !bActive) while (SDL_PollEvent(NULL) || !bActive)

View file

@ -270,7 +270,7 @@ int main(int argc, char *argv[])
} }
#ifdef DEBUG_SAVE #ifdef DEBUG_SAVE
//SDL_EventState(SDL_DROPFILE, SDL_ENABLE); PlaybackBackend_EnableDragAndDrop();
#endif #endif
// Set up window icon // Set up window icon