re-enabled storing selection from "last played level set" menu
[rocksndiamonds.git] / src / game_mm / mm_tools.c
index d7f4326e19ed2fd6ed5f4351701ba83c042ce3f5..e71fb1d444955acaf32a19dab121d76f3cfc9b77 100644 (file)
@@ -648,12 +648,18 @@ void DrawMiniLevel_MM(int size_x, int size_y, int scroll_x, int scroll_y)
 #define XSN_CHANGE_DELAY       30
 #define XSN_CHANGE_FACTOR      3
 #define XSN_ALPHA_DEFAULT      XSN_ALPHA_VALUE(95)
+#define XSN_ALPHA_VISIBLE      XSN_ALPHA_VALUE(50)
 #define XSN_DEBUG_STEPS                5
 
 static byte xsn_bits_0[] = { 0x05, 0x02, 0x05 };
 static byte xsn_bits_1[] = { 0x22, 0x6b, 0x14, 0x2a, 0x14, 0x6b, 0x22 };
 static byte xsn_bits_2[] = { 0x14, 0x08, 0x49, 0x36, 0x49, 0x08, 0x14 };
 
+char debug_xsn_mode[] = { 76,101,116,32,105,116,32,115,110,111,119,33,0 };
+
+void setHideSetupEntry(void *);
+void removeHideSetupEntry(void *);
+
 static struct
 {
   int size;
@@ -702,6 +708,8 @@ struct Xsn
   struct XsnItem items[XSN_MAX_ITEMS];
 
   Bitmap *bitmap;
+
+  int alpha;
 };
 
 static struct Xsn xsn = { 0 };
@@ -842,7 +850,7 @@ static void xsn_update_item(int nr)
       BlitBitmapMasked(xsn.bitmap, xsn.bitmap, xpos1, xsn.max_height,
                       xsize, xsn.max_height, xpos1, 0);
 
-      SDLSetAlpha(surface_masked, TRUE, XSN_ALPHA_DEFAULT);
+      SDLSetAlpha(surface_masked, TRUE, xsn.alpha);
 
       for (i = xpos1; i < xpos2; i++)
        xsn.height[i] = MIN(xsn.height[i] + shrink, xsn.area_ysize - 1);
@@ -913,7 +921,24 @@ static void DrawTileCursor_Xsn(int draw_target)
   if (DelayReached(&check_delay, check_delay_value))
   {
     percent = (debug ? debug_value * 100 / XSN_DEBUG_STEPS : xsn_percent());
+
+    if (debug)
+      setup.debug.xsn_percent = percent;
+
+    if (setup.debug.xsn_mode != AUTO)
+      percent = setup.debug.xsn_percent;
+
+    setup.debug.xsn_percent = percent;
+
     active = (percent > 0);
+
+    if ((active && !active_last) || setup.debug.xsn_mode != AUTO)
+      removeHideSetupEntry(&setup.debug.xsn_mode);
+    else if (!active && active_last)
+      setHideSetupEntry(&setup.debug.xsn_mode);
+
+    if (setup.debug.xsn_mode == FALSE)
+      active = FALSE;
   }
   else if (tile_cursor.xsn_debug)
   {
@@ -923,22 +948,13 @@ static void DrawTileCursor_Xsn(int draw_target)
 
     DelayReached(&check_delay, 0);
 
+    setup.debug.xsn_mode = (debug_value > 0);
     tile_cursor.xsn_debug = FALSE;
   }
 
   if (!active)
     return;
 
-  if (!active_last)
-  {
-    start_delay_value = (debug ? 0 : XSN_RND(XSN_START_DELAY * 2) * 1000);
-    started = FALSE;
-
-    DelayReached(&start_delay, 0);
-
-    reinitialize = TRUE;
-  }
-
   if (!initialized)
   {
     xsn.area_xsize = gfx.win_xsize;
@@ -978,6 +994,17 @@ static void DrawTileCursor_Xsn(int draw_target)
     initialized = TRUE;
   }
 
+  if (!active_last)
+  {
+    start_delay_value = (debug || setup.debug.xsn_mode == TRUE ? 0 :
+                        (XSN_START_DELAY + XSN_RND(XSN_START_DELAY)) * 1000);
+    started = FALSE;
+
+    DelayReached(&start_delay, 0);
+
+    reinitialize = TRUE;
+  }
+
   if (reinitialize)
   {
     xsn.num_items  = 0;
@@ -991,6 +1018,8 @@ static void DrawTileCursor_Xsn(int draw_target)
     xsn.change_type  = 0;
     xsn.change_dir   = 0;
 
+    xsn.alpha = XSN_ALPHA_DEFAULT;
+
     for (i = 0; i < xsn.max_items; i++)
       xsn_init_item(i);
   }
@@ -1021,8 +1050,8 @@ static void DrawTileCursor_Xsn(int draw_target)
     SDL_SetColorKey(surface_masked, SET_TRANSPARENT_PIXEL,
                    SDL_MapRGB(surface_masked->format, 0x00, 0x00, 0x00));
 
-    SDLSetAlpha(surface, TRUE, XSN_ALPHA_DEFAULT);
-    SDLSetAlpha(surface_masked, TRUE, XSN_ALPHA_DEFAULT);
+    SDLSetAlpha(surface, TRUE, xsn.alpha);
+    SDLSetAlpha(surface_masked, TRUE, xsn.alpha);
 
     SDLCreateBitmapTextures(xsn.bitmap);
 
@@ -1079,6 +1108,20 @@ static void DrawTileCursor_Xsn(int draw_target)
     change_delay_value = xsn.change_delay * 1000;
   }
 
+  int xsn_alpha_dx = (gfx.mouse_y > xsn.area_ysize - xsn.max_height ?
+                     (xsn.alpha > XSN_ALPHA_VISIBLE ? -1 : 0) :
+                     (xsn.alpha < XSN_ALPHA_DEFAULT ? +1 : 0));
+
+  if (xsn_alpha_dx != 0)
+  {
+    xsn.alpha += xsn_alpha_dx;
+
+    SDLSetAlpha(xsn.bitmap->surface_masked, TRUE, xsn.alpha);
+
+    SDLFreeBitmapTextures(xsn.bitmap);
+    SDLCreateBitmapTextures(xsn.bitmap);
+  }
+
   BlitToScreenMasked(xsn.bitmap, 0, 0, xsn.area_xsize, xsn.max_height,
                     0, xsn.area_ysize - xsn.max_height);