diff --git a/src/input.c b/src/input.c index 337d3b91..720bfaef 100644 --- a/src/input.c +++ b/src/input.c @@ -21,6 +21,12 @@ */ #include +#include + +#ifdef __WIN32__ + #include + #include +#endif #include "global.h" #include "keyboard.h" @@ -29,6 +35,7 @@ #include "errors.h" #include "misc.h" #include "input.h" +#include "loadsave.h" #ifdef __VBCC__ #define __attribute__(x) @@ -86,6 +93,19 @@ short Joybutton_left_click=0; // Button number that serves as left click short Joybutton_right_click=0; // Button number that serves as right-click #endif + +void AcceptDND(void) +{ +#ifdef __WIN32__ + SDL_SysWMinfo wminfo; + SDL_VERSION(&wminfo.version); + SDL_GetWMInfo(&wminfo); + HWND hwnd = wminfo.window; + DragAcceptFiles(hwnd,TRUE); + SDL_EventState (SDL_SYSWMEVENT,SDL_ENABLE ); +#endif +} + int Has_shortcut(word function) { if (function == 0xFFFF) @@ -718,6 +738,33 @@ int Get_input(void) #endif // End of Joystick handling + case SDL_SYSWMEVENT: +#ifdef __WIN32__ + if(event.syswm.msg->msg == WM_DROPFILES) { + int fileCount; + HDROP hdrop = (HDROP)(event.syswm.msg->wParam); + if((fileCount = DragQueryFile(hdrop,(UINT)-1,(LPTSTR) NULL ,(UINT) 0)) > 0) { + char buf[MAX_PATH]; + T_IO_Context context; + char* flimit; + + DragQueryFile(hdrop,0 ,(LPTSTR) buf ,(UINT) MAX_PATH); + flimit = Find_last_slash(buf); + *(flimit++) = '\0'; + + // TODO : check if there are unsaved changes first ! + + Init_context_layered_image(&context, flimit, buf); + Load_image(&context); + Destroy_context(&context); + Redraw_layered_image(); + End_of_modification(); + Display_all_screen(); + } + } +#endif + break; + default: // DEBUG("Unhandled SDL event number : ",event.type); break; diff --git a/src/main.c b/src/main.c index 4b984eac..696fbbb9 100644 --- a/src/main.c +++ b/src/main.c @@ -85,6 +85,15 @@ extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); #endif +int test_colorcycling(void* useless) +{ + byte r = 0; + while(1) { + SDL_Delay(50); + Set_color(0,++r,0,0); + } +} + //--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles --- void Display_syntax(void) { @@ -818,6 +827,16 @@ int Init_program(int argc,char * argv[]) break; } } + +#if 0 + // Color cycling test + { + SDL_Thread* t = SDL_CreateThread(test_colorcycling, NULL); + } +#endif + + AcceptDND(); + return(1); }