added quickly toggling team mode by clicking on main menu "name/team" text
[rocksndiamonds.git] / src / tools.c
index 451ef014e103daaac8476837e92bb5412d49bb56..6763d611a6d9ac384dc0228337f934afe45fcc39 100644 (file)
@@ -2274,7 +2274,9 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame)
          !IN_SCR_FIELD(sxx, syy))
        continue;
 
-      if (Feld[xx][yy] == EL_ELEMENT_SNAPPING)
+      // do not crumble fields that are being digged or snapped
+      if (Feld[xx][yy] == EL_EMPTY ||
+         Feld[xx][yy] == EL_ELEMENT_SNAPPING)
        continue;
 
       element = TILE_GFX_ELEMENT(xx, yy);
@@ -3514,14 +3516,11 @@ static void DrawPreviewLevelExt(boolean restart)
   }
 }
 
-static void DrawPreviewPlayers(void)
+void DrawPreviewPlayers(void)
 {
   if (game_status != GAME_MODE_MAIN)
     return;
 
-  if (!network.enabled && !setup.team_mode)
-    return;
-
   boolean player_found[MAX_PLAYERS];
   int num_players = 0;
   int i, x, y;
@@ -3570,6 +3569,9 @@ static void DrawPreviewPlayers(void)
   ClearRectangleOnBackground(drawto, max_xpos, max_ypos,
                             max_players_width, max_players_height);
 
+  if (!network.enabled && !setup.team_mode)
+    return;
+
   // only draw players if level is suited for team mode
   if (num_players < 2)
     return;
@@ -4811,17 +4813,17 @@ static boolean RequestEnvelope(char *text, unsigned int req_state)
 
 boolean Request(char *text, unsigned int req_state)
 {
-  boolean overlay_active = GetOverlayActive();
+  boolean overlay_enabled = GetOverlayEnabled();
   boolean result;
 
-  SetOverlayActive(FALSE);
+  SetOverlayEnabled(FALSE);
 
   if (global.use_envelope_request)
     result = RequestEnvelope(text, req_state);
   else
     result = RequestDoor(text, req_state);
 
-  SetOverlayActive(overlay_active);
+  SetOverlayEnabled(overlay_enabled);
 
   return result;
 }
@@ -9403,29 +9405,58 @@ void SetLevelSetInfo(char *identifier, int level_nr)
   levelset.level_nr = level_nr;
 }
 
-boolean CheckIfPlayfieldViewportHasChanged(void)
+boolean CheckIfAllViewportsHaveChanged(void)
 {
-  // if game status has not changed, playfield viewport has not changed either
+  // if game status has not changed, viewports have not changed either
   if (game_status == game_status_last)
     return FALSE;
 
-  // check if playfield viewport has changed with current game status
+  // check if all viewports have changed with current game status
+
   struct RectWithBorder *vp_playfield = &viewport.playfield[game_status];
+  struct RectWithBorder *vp_door_1    = &viewport.door_1[game_status];
+  struct RectWithBorder *vp_door_2    = &viewport.door_2[game_status];
   int new_real_sx      = vp_playfield->x;
   int new_real_sy      = vp_playfield->y;
   int new_full_sxsize  = vp_playfield->width;
   int new_full_sysize  = vp_playfield->height;
+  int new_dx           = vp_door_1->x;
+  int new_dy           = vp_door_1->y;
+  int new_dxsize       = vp_door_1->width;
+  int new_dysize       = vp_door_1->height;
+  int new_vx           = vp_door_2->x;
+  int new_vy           = vp_door_2->y;
+  int new_vxsize       = vp_door_2->width;
+  int new_vysize       = vp_door_2->height;
+
+  boolean playfield_viewport_has_changed =
+    (new_real_sx != REAL_SX ||
+     new_real_sy != REAL_SY ||
+     new_full_sxsize != FULL_SXSIZE ||
+     new_full_sysize != FULL_SYSIZE);
+
+  boolean door_1_viewport_has_changed =
+    (new_dx != DX ||
+     new_dy != DY ||
+     new_dxsize != DXSIZE ||
+     new_dysize != DYSIZE);
+
+  boolean door_2_viewport_has_changed =
+    (new_vx != VX ||
+     new_vy != VY ||
+     new_vxsize != VXSIZE ||
+     new_vysize != VYSIZE ||
+     game_status_last == GAME_MODE_EDITOR);
 
-  return (new_real_sx != REAL_SX ||
-         new_real_sy != REAL_SY ||
-         new_full_sxsize != FULL_SXSIZE ||
-         new_full_sysize != FULL_SYSIZE);
+  return (playfield_viewport_has_changed &&
+         door_1_viewport_has_changed &&
+         door_2_viewport_has_changed);
 }
 
-boolean CheckIfGlobalBorderOrPlayfieldViewportHasChanged(void)
+boolean CheckFadeAll(void)
 {
   return (CheckIfGlobalBorderHasChanged() ||
-         CheckIfPlayfieldViewportHasChanged());
+         CheckIfAllViewportsHaveChanged());
 }
 
 void ChangeViewportPropertiesIfNeeded(void)
@@ -9442,11 +9473,14 @@ void ChangeViewportPropertiesIfNeeded(void)
   struct RectWithBorder *vp_door_3    = &viewport.door_2[GAME_MODE_EDITOR];
   int new_win_xsize    = vp_window->width;
   int new_win_ysize    = vp_window->height;
-  int border_size      = vp_playfield->border_size;
-  int new_sx           = vp_playfield->x + border_size;
-  int new_sy           = vp_playfield->y + border_size;
-  int new_sxsize       = vp_playfield->width  - 2 * border_size;
-  int new_sysize       = vp_playfield->height - 2 * border_size;
+  int border_left      = vp_playfield->border_left;
+  int border_right     = vp_playfield->border_right;
+  int border_top       = vp_playfield->border_top;
+  int border_bottom    = vp_playfield->border_bottom;
+  int new_sx           = vp_playfield->x      + border_left;
+  int new_sy           = vp_playfield->y      + border_top;
+  int new_sxsize       = vp_playfield->width  - border_left - border_right;
+  int new_sysize       = vp_playfield->height - border_top  - border_bottom;
   int new_real_sx      = vp_playfield->x;
   int new_real_sy      = vp_playfield->y;
   int new_full_sxsize  = vp_playfield->width;
@@ -9551,8 +9585,8 @@ void ChangeViewportPropertiesIfNeeded(void)
     }
 
     // add current and new door 2 area if position or size has changed
-    if (new_dx != VX || new_dy != VY ||
-       new_dxsize != VXSIZE || new_dysize != VYSIZE)
+    if (new_vx != VX || new_vy != VY ||
+       new_vxsize != VXSIZE || new_vysize != VYSIZE)
     {
       JoinRectangles(&FADE_SX, &FADE_SY, &FADE_SXSIZE, &FADE_SYSIZE,
                     VX, VY, VXSIZE, VYSIZE);