rnd-20080426-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 26 Apr 2008 00:22:23 +0000 (02:22 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:56:59 +0000 (10:56 +0200)
src/conftime.h
src/events.c
src/events.h
src/game.c
src/libgame/sdl.c
src/libgame/sdl.h

index 163f51b688a8be45feec8adaf18ac06399197962..544efe05cca654731782a9b5b35d70228c7abe0e 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2008-02-06 23:42"
+#define COMPILE_DATE_STRING "2008-04-26 02:20"
index 811d8f9ae87e01fdfc9b03eddfa96f93823a7160..6d52228b5d4a050eb8e632cb0abe29cfc81d0325 100644 (file)
@@ -223,6 +223,10 @@ void HandleOtherEvents(Event *event)
     case SDL_JOYBUTTONUP:
       HandleJoystickEvent(event);
       break;
+
+    case SDL_SYSWMEVENT:
+      HandleWindowManagerEvent(event);
+      break;
 #endif
 
     default:
@@ -413,6 +417,13 @@ void HandleClientMessageEvent(ClientMessageEvent *event)
     CloseAllAndExit(0);
 }
 
+void HandleWindowManagerEvent(Event *event)
+{
+#if defined(TARGET_SDL)
+  SDLHandleWindowManagerEvent(event);
+#endif
+}
+
 void HandleButton(int mx, int my, int button, int button_nr)
 {
   static int old_mx = 0, old_my = 0;
index 16b15ebdf747b2f96944c83b70a93ddb14811d22..7cde0e00f57ff12dd946995e06c50ef96f584d46 100644 (file)
@@ -28,7 +28,8 @@ void HandleButtonEvent(ButtonEvent *);
 void HandleMotionEvent(MotionEvent *);
 void HandleKeyEvent(KeyEvent *);
 void HandleFocusEvent(FocusChangeEvent *);
-void HandleClientMessageEvent(ClientMessageEvent *event);
+void HandleClientMessageEvent(ClientMessageEvent *);
+void HandleWindowManagerEvent(Event *);
 
 void HandleNoEvent(void);
 
index f99a7627ed5b1039efa550375a786215b9eb4033..653cd8c2588dca28d182da5ebdecaeb38381063a 100644 (file)
@@ -65,6 +65,8 @@
 
 #define USE_GFX_RESET_WHEN_NOT_MOVING  (USE_NEW_STUFF          * 1)
 
+#define USE_NEW_PLAYER_ASSIGNMENTS     (USE_NEW_STUFF          * 1)
+
 #define USE_DELAYED_GFX_REDRAW         (USE_NEW_STUFF          * 0)
 
 #if USE_DELAYED_GFX_REDRAW
@@ -4038,6 +4040,52 @@ void InitGame()
     if (game.belt_dir[i] == MV_NONE)
       game.belt_dir_nr[i] = 3;         /* not moving, next moving left */
 
+#if USE_NEW_PLAYER_ASSIGNMENTS
+  /* check if any connected player was not found in playfield */
+  for (i = 0; i < MAX_PLAYERS; i++)
+  {
+    struct PlayerInfo *player = &stored_player[i];
+
+    if (player->connected && !player->present)
+    {
+      for (j = 0; j < MAX_PLAYERS; j++)
+      {
+       struct PlayerInfo *some_player = &stored_player[j];
+       int jx = some_player->jx, jy = some_player->jy;
+
+       /* assign first free player found that is present in the playfield */
+       if (some_player->present && !some_player->connected)
+       {
+         player->present = FALSE;
+         player->active = FALSE;
+
+         some_player->present = TRUE;
+         some_player->active = TRUE;
+
+         /*
+         player->initial_element = some_player->initial_element;
+         player->artwork_element = some_player->artwork_element;
+
+         player->block_last_field       = some_player->block_last_field;
+         player->block_delay_adjustment = some_player->block_delay_adjustment;
+         */
+
+         StorePlayer[jx][jy] = some_player->element_nr;
+
+         some_player->jx = some_player->last_jx = jx;
+         some_player->jy = some_player->last_jy = jy;
+
+         if (local_player == player)
+           local_player = some_player;
+
+         break;
+       }
+      }
+    }
+  }
+
+#else
+
   /* check if any connected player was not found in playfield */
   for (i = 0; i < MAX_PLAYERS; i++)
   {
@@ -4066,6 +4114,7 @@ void InitGame()
          player->block_delay_adjustment = some_player->block_delay_adjustment;
 
          StorePlayer[jx][jy] = player->element_nr;
+
          player->jx = player->last_jx = jx;
          player->jy = player->last_jy = jy;
 
@@ -4074,6 +4123,7 @@ void InitGame()
       }
     }
   }
+#endif
 
   if (tape.playing)
   {
index ab3ac82d20e80fa80ebb2f1ea29ad41f790a2da0..f751fe85be2a5e568b94c6929f3ea79fc5f3d0ee 100644 (file)
@@ -296,6 +296,26 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
     }
   }
 
+
+#if 1
+  SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
+
+#if defined(PLATFORM_WIN32)
+  {
+    SDL_SysWMinfo wminfo;
+    HWND hwnd;
+
+    SDL_VERSION(&wminfo.version);
+    SDL_GetWMInfo(&wminfo);
+
+    hwnd = wminfo.window;
+
+    DragAcceptFiles(hwnd, TRUE);
+  }
+#endif
+#endif
+
+
   return success;
 }
 
@@ -1787,6 +1807,36 @@ void SDLNextEvent(Event *event)
   }
 }
 
+void SDLHandleWindowManagerEvent(Event *event)
+{
+#if defined(PLATFORM_WIN32)
+  SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event;
+  SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg);
+
+  if (syswmmsg->msg == WM_DROPFILES)
+  {
+    HDROP hdrop = (HDROP)syswmmsg->wParam;
+    int i, num_files;
+
+    printf("::: SDL_SYSWMEVENT:\n");
+
+    num_files = DragQueryFile(hdrop, 0xffffffff, NULL, 0);
+
+    for (i = 0; i < num_files; i++)
+    {
+      int buffer_len = DragQueryFile(hdrop, i, NULL, 0);
+      char buffer[buffer_len + 1];
+
+      DragQueryFile(hdrop, i, buffer, buffer_len + 1);
+
+      printf("::: - '%s'\n", buffer);
+    }
+
+    DragFinish((HDROP)syswmmsg->wParam);
+  }
+#endif
+}
+
 
 /* ========================================================================= */
 /* joystick functions                                                        */
index 19ead5e5200254255dd6ff022ee4a7c4fb3dee5c..62196e1aadff8bc25ca1b67a080eb4b4bd35c0b2 100644 (file)
@@ -19,7 +19,9 @@
 #include <SDL_mixer.h>
 #include <SDL_net.h>
 #include <SDL_thread.h>
-
+#if defined(PLATFORM_WIN32)
+#include <SDL_syswm.h>
+#endif
 
 /* definitions needed for "system.c" */
 
@@ -375,6 +377,7 @@ void SDLOpenAudio(void);
 void SDLCloseAudio(void);
 
 void SDLNextEvent(Event *);
+void SDLHandleWindowManagerEvent(Event *);
 
 void HandleJoystickEvent(Event *);
 void SDLInitJoysticks(void);