rnd-20060430-1-src
authorHolger Schemel <info@artsoft.org>
Sun, 30 Apr 2006 02:18:01 +0000 (04:18 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:51:36 +0000 (10:51 +0200)
* added setup option to display element token name in level editor

19 files changed:
ChangeLog
src/conf_gfx.c
src/conf_gfx.h
src/conftime.h
src/editor.c
src/events.c
src/files.c
src/init.c
src/init.h
src/libgame/image.c
src/libgame/image.h
src/libgame/system.c
src/libgame/system.h
src/main.c
src/main.h
src/screens.c
src/screens.h
src/tools.c
src/tools.h

index 32736a4dbcdfacc29c02096ed21ee4dfc8fbf000..e3694fcab1564ab5d8adbde68c49dd35be928338 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2006-04-28
        * added "CE score gets zero [of]" to custom element trigger conditions
+       * added setup option to display element token name in level editor
 
 2006-04-19
        * added compatibility code for Juergen Bonhagen's menu artwork settings
index b9e97c3008da0e9ca4c0ff7a20a3cc98f3164484..e2af8d07cd9ce406e8ad7b7a37a4a2575f3ae865 100644 (file)
@@ -4389,7 +4389,14 @@ struct ConfigInfo image_config[] =
   { "background.envelope_4.anim_mode",         "default"               },
   { "background.envelope_4.draw_masked",       "false"                 },
 
+  { "titlescreen_1",                           UNDEFINED_FILENAME      },
+  { "titlescreen_2",                           UNDEFINED_FILENAME      },
+  { "titlescreen_3",                           UNDEFINED_FILENAME      },
+  { "titlescreen_4",                           UNDEFINED_FILENAME      },
+  { "titlescreen_5",                           UNDEFINED_FILENAME      },
+
   { "background",                              UNDEFINED_FILENAME      },
+  { "background.TITLE",                                UNDEFINED_FILENAME      },
   { "background.MAIN",                         UNDEFINED_FILENAME      },
   { "background.LEVELS",                       UNDEFINED_FILENAME      },
   { "background.SCORES",                       UNDEFINED_FILENAME      },
index d97f30956b5a0cdbe682dbc5baa0c640548bbefd..4d6e27dbaa56781ae07ae68ab3f83ef0580e454f 100644 (file)
 #define IMG_BACKGROUND_ENVELOPE_2                      1520
 #define IMG_BACKGROUND_ENVELOPE_3                      1521
 #define IMG_BACKGROUND_ENVELOPE_4                      1522
-#define IMG_BACKGROUND                                 1523
-#define IMG_BACKGROUND_MAIN                            1524
-#define IMG_BACKGROUND_LEVELS                          1525
-#define IMG_BACKGROUND_SCORES                          1526
-#define IMG_BACKGROUND_EDITOR                          1527
-#define IMG_BACKGROUND_INFO                            1528
-#define IMG_BACKGROUND_INFO_ELEMENTS                   1529
-#define IMG_BACKGROUND_INFO_MUSIC                      1530
-#define IMG_BACKGROUND_INFO_CREDITS                    1531
-#define IMG_BACKGROUND_INFO_PROGRAM                    1532
-#define IMG_BACKGROUND_INFO_LEVELSET                   1533
-#define IMG_BACKGROUND_SETUP                           1534
-#define IMG_BACKGROUND_DOOR                            1535
+#define IMG_TITLESCREEN_1                              1523
+#define IMG_TITLESCREEN_2                              1524
+#define IMG_TITLESCREEN_3                              1525
+#define IMG_TITLESCREEN_4                              1526
+#define IMG_TITLESCREEN_5                              1527
+#define IMG_BACKGROUND                                 1528
+#define IMG_BACKGROUND_TITLE                           1529
+#define IMG_BACKGROUND_MAIN                            1530
+#define IMG_BACKGROUND_LEVELS                          1531
+#define IMG_BACKGROUND_SCORES                          1532
+#define IMG_BACKGROUND_EDITOR                          1533
+#define IMG_BACKGROUND_INFO                            1534
+#define IMG_BACKGROUND_INFO_ELEMENTS                   1535
+#define IMG_BACKGROUND_INFO_MUSIC                      1536
+#define IMG_BACKGROUND_INFO_CREDITS                    1537
+#define IMG_BACKGROUND_INFO_PROGRAM                    1538
+#define IMG_BACKGROUND_INFO_LEVELSET                   1539
+#define IMG_BACKGROUND_SETUP                           1540
+#define IMG_BACKGROUND_DOOR                            1541
 
-#define NUM_IMAGE_FILES                                        1536
+#define NUM_IMAGE_FILES                                        1542
 
 #endif /* CONF_GFX_H */
index fe9ec95ec33df4517bc661b6441fbff8cdc96c3e..f421ea5d71c872f5e0ecc70acb7233b283e1f264 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-04-28 20:25]"
+#define COMPILE_DATE_STRING "[2006-04-30 04:12]"
index 89c3de15a454bd066267500fa6aaa07ab01ac55c..631a5756fa9584a3c4969fac84c8c39d82d03da1 100644 (file)
@@ -7597,6 +7597,16 @@ static void DrawPropertiesInfo()
   int screen_line = 0;
   int i, x, y;
 
+#if 1
+  if (setup.editor.show_element_token)
+  {
+    DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
+             "[%s]", element_info[properties_element].token_name);
+    screen_line++;
+  }
+
+#else
+
 #if DEBUG
   if (IS_CUSTOM_ELEMENT(properties_element))
   {
@@ -7610,6 +7620,7 @@ static void DrawPropertiesInfo()
              "[Group Element %d]", properties_element - EL_GROUP_START + 1);
     screen_line++;
   }
+#endif
 #endif
 
   /* ----- print number of elements / percentage of this element in level */
index 1ae5caa917de49834af8f4cfaa5e05ba14bea906..002e4fdff521dc77e50a4a95195379905bdc7ec3 100644 (file)
@@ -420,6 +420,10 @@ void HandleButton(int mx, int my, int button)
 
   switch(game_status)
   {
+    case GAME_MODE_TITLE:
+      HandleTitleScreen(mx,my, 0,0, button);
+      break;
+
     case GAME_MODE_MAIN:
       HandleMainMenu(mx,my, 0,0, button);
       break;
@@ -735,6 +739,7 @@ void HandleKey(Key key, int key_status)
       HandleTypeName(0, key);
       break;
 
+    case GAME_MODE_TITLE:
     case GAME_MODE_MAIN:
     case GAME_MODE_LEVELS:
     case GAME_MODE_SETUP:
@@ -748,7 +753,9 @@ void HandleKey(Key key, int key_status)
        case KSYM_space:
 #endif
        case KSYM_Return:
-         if (game_status == GAME_MODE_MAIN)
+         if (game_status == GAME_MODE_TITLE)
+           HandleTitleScreen(0,0, 0,0, MB_MENU_CHOICE);
+         else if (game_status == GAME_MODE_MAIN)
            HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE);
           else if (game_status == GAME_MODE_LEVELS)
             HandleChooseLevel(0,0, 0,0, MB_MENU_CHOICE);
@@ -759,7 +766,9 @@ void HandleKey(Key key, int key_status)
          break;
 
        case KSYM_Escape:
-          if (game_status == GAME_MODE_LEVELS)
+         if (game_status == GAME_MODE_TITLE)
+           HandleTitleScreen(0,0, 0,0, MB_MENU_LEAVE);
+          else if (game_status == GAME_MODE_LEVELS)
             HandleChooseLevel(0,0, 0,0, MB_MENU_LEAVE);
          else if (game_status == GAME_MODE_SETUP)
            HandleSetupScreen(0,0, 0,0, MB_MENU_LEAVE);
@@ -1003,7 +1012,9 @@ void HandleJoystick()
          !DelayReached(&joystickmove_delay, GADGET_FRAME_DELAY))
        newbutton = dx = dy = 0;
 
-      if (game_status == GAME_MODE_MAIN)
+      if (game_status == GAME_MODE_TITLE)
+       HandleTitleScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
+      else if (game_status == GAME_MODE_MAIN)
        HandleMainMenu(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
       else if (game_status == GAME_MODE_LEVELS)
         HandleChooseLevel(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
index ea54c227d78e04282cd3e0a0fbf603f5c7b638b8..e6baec2532cc26d4636cb68c21a7e129e3f62798 100644 (file)
@@ -4978,8 +4978,9 @@ void SaveScore(int nr)
 #define SETUP_TOKEN_EDITOR_EL_HEADLINES                10
 #define SETUP_TOKEN_EDITOR_EL_USER_DEFINED     11
 #define SETUP_TOKEN_EDITOR_EL_DYNAMIC          12
+#define SETUP_TOKEN_EDITOR_SHOW_ELEMENT_TOKEN  13
 
-#define NUM_EDITOR_SETUP_TOKENS                        13
+#define NUM_EDITOR_SETUP_TOKENS                        14
 
 /* editor cascade setup */
 #define SETUP_TOKEN_EDITOR_CASCADE_BD          0
@@ -5097,6 +5098,7 @@ static struct TokenInfo editor_setup_tokens[] =
   { TYPE_SWITCH, &sei.el_headlines,    "editor.el_headlines"           },
   { TYPE_SWITCH, &sei.el_user_defined, "editor.el_user_defined"        },
   { TYPE_SWITCH, &sei.el_dynamic,      "editor.el_dynamic"             },
+  { TYPE_SWITCH, &sei.show_element_token,"editor.show_element_token"   },
 };
 
 static struct TokenInfo editor_cascade_setup_tokens[] =
@@ -5225,6 +5227,8 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->editor.el_user_defined = FALSE;
   si->editor.el_dynamic = TRUE;
 
+  si->editor.show_element_token = FALSE;
+
   si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME;
   si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME;
   si->shortcut.toggle_pause = DEFAULT_KEY_TOGGLE_PAUSE;
index 9b487df0ee4a7579bdf3a588df0a0f73d83bbbe3..a25394b6f09f7e7b5615eed538d3e1dcebae42df 100644 (file)
@@ -143,6 +143,15 @@ void InitElementSmallImages()
     InitElementSmallImagesScaledUp(special_graphics[i]);
 }
 
+void InitScaledImages()
+{
+  int i;
+
+  /* scale normal images from static configuration, if not already scaled */
+  for (i = 0; i < NUM_IMAGE_FILES; i++)
+    ScaleImage(i, graphic_info[i].scale_up_factor);
+}
+
 #if 1
 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */
 void SetBitmaps_EM(Bitmap **em_bitmap)
@@ -1647,7 +1656,8 @@ static void ReinitializeGraphics()
   InitElementGraphicInfo();            /* element game graphic mapping */
   InitElementSpecialGraphicInfo();     /* element special graphic mapping */
 
-  InitElementSmallImages();            /* scale images to all needed sizes */
+  InitElementSmallImages();            /* scale elements to all needed sizes */
+  InitScaledImages();                  /* scale all other images, if needed */
   InitFontGraphicInfo();               /* initialize text drawing functions */
 
   InitGraphicInfo_EM();                        /* graphic mapping for EM engine */
@@ -4371,7 +4381,8 @@ void InitGfx()
   if (filename_font_initial == NULL)   /* should not happen */
     Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
 
-  /* create additional image buffers for double-buffering */
+  /* create additional image buffers for double-buffering and cross-fading */
+  bitmap_db_title = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
   bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
   bitmap_db_door  = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
 
@@ -4396,6 +4407,14 @@ void InitGfx()
   DrawInitText("Loading graphics:", 120, FC_GREEN);
 }
 
+void RedrawBackground()
+{
+  BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
+            0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+
+  redraw_mask = REDRAW_ALL;
+}
+
 void InitGfxBackground()
 {
   int x, y;
@@ -4404,8 +4423,8 @@ void InitGfxBackground()
   fieldbuffer = bitmap_db_field;
   SetDrawtoField(DRAW_BACKBUFFER);
 
-  BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
-            0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+  RedrawBackground();
+
   ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
   ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
 
@@ -4662,7 +4681,11 @@ void ReloadCustomArtwork(int force_reload)
 
   if (redraw_screen)
   {
+#if 1
+    RedrawBackground();
+#else
     InitGfxBackground();
+#endif
 
     /* force redraw of (open or closed) door graphics */
     SetDoorState(DOOR_OPEN_ALL);
index e3f8858523d179ca83ce1a3e0e634d32f4ba5587..75cf288d6be32540c1aba8807e38ccb7b7367f4c 100644 (file)
@@ -36,6 +36,7 @@ void InitElementPropertiesStatic(void);
 void InitElementPropertiesEngine(int);
 
 void ReloadCustomArtwork(int);
+void RedrawBackground();
 
 void KeyboardAutoRepeatOffUnlessAutoplay();
 
index 7f2577514be688a80619521e7ad16d71d6a71d5a..cb8de4c87ed46ab8397a46f8f6a852843cb3344b 100644 (file)
@@ -1049,6 +1049,19 @@ void CreateImageWithSmallImages(int pos, int zoom_factor)
   img_info->scaled_up = TRUE;
 }
 
+void ScaleImage(int pos, int zoom_factor)
+{
+  ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+  if (img_info == NULL || img_info->scaled_up)
+    return;
+
+  if (zoom_factor != 1)
+    ScaleBitmap(img_info->bitmap, zoom_factor);
+
+  img_info->scaled_up = TRUE;
+}
+
 void FreeAllImages()
 {
   FreeCustomArtworkLists(image_info);
index 3a2ac2023158aed2ddfb9f60c51d3bc9a87ce232..3791c4bc8578be5944fee672044813d45eaeca5d 100644 (file)
@@ -91,6 +91,7 @@ void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
 
 void ReloadCustomImages();
 void CreateImageWithSmallImages(int, int);
+void ScaleImage(int, int);
 
 void FreeAllImages();
 
index 94bcccdc9262eca5b8886676be68cd2228578346..adcc58ff4972e98c6c473ccb9548f1f0b094f05e 100644 (file)
@@ -794,19 +794,17 @@ Bitmap *ZoomBitmap(Bitmap *src_bitmap, int zoom_width, int zoom_height)
   return dst_bitmap;
 }
 
-void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor)
+static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor,
+                               boolean create_small_bitmaps)
 {
   Bitmap swap_bitmap;
   Bitmap *new_bitmap, *tmp_bitmap_1, *tmp_bitmap_2, *tmp_bitmap_8;
   int width_1, height_1, width_2, height_2, width_8, height_8;
   int new_width, new_height;
 
+  /* calculate new image dimensions for normal sized image */
   width_1  = old_bitmap->width  * zoom_factor;
   height_1 = old_bitmap->height * zoom_factor;
-  width_2  = width_1  / 2;
-  height_2 = height_1 / 2;
-  width_8  = width_1  / 8;
-  height_8 = height_1 / 8;
 
   /* get image with normal size (this might require scaling up) */
   if (zoom_factor != 1)
@@ -814,17 +812,26 @@ void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor)
   else
     tmp_bitmap_1 = old_bitmap;
 
-  /* get image with 1/2 of normal size (for use in the level editor) */
-  if (zoom_factor != 2)
-    tmp_bitmap_2 = ZoomBitmap(tmp_bitmap_1, width_1 / 2, height_1 / 2);
-  else
-    tmp_bitmap_2 = old_bitmap;
+  if (create_small_bitmaps)
+  {
+    /* calculate new image dimensions for small images */
+    width_2  = width_1  / 2;
+    height_2 = height_1 / 2;
+    width_8  = width_1  / 8;
+    height_8 = height_1 / 8;
+
+    /* get image with 1/2 of normal size (for use in the level editor) */
+    if (zoom_factor != 2)
+      tmp_bitmap_2 = ZoomBitmap(tmp_bitmap_1, width_1 / 2, height_1 / 2);
+    else
+      tmp_bitmap_2 = old_bitmap;
 
-  /* get image with 1/8 of normal size (for use on the preview screen) */
-  if (zoom_factor != 8)
-    tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_1, width_1 / 8, height_1 / 8);
-  else
-    tmp_bitmap_8 = old_bitmap;
+    /* get image with 1/8 of normal size (for use on the preview screen) */
+    if (zoom_factor != 8)
+      tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_1, width_1 / 8, height_1 / 8);
+    else
+      tmp_bitmap_8 = old_bitmap;
+  }
 
   /* if image was scaled up, create new clipmask for normal size image */
   if (zoom_factor != 1)
@@ -851,25 +858,39 @@ void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor)
 #endif
   }
 
-  new_width  = width_1;
-  new_height = height_1 + (height_1 + 1) / 2;     /* prevent odd height */
+  if (create_small_bitmaps)
+  {
+    new_width  = width_1;
+    new_height = height_1 + (height_1 + 1) / 2;     /* prevent odd height */
 
-  new_bitmap = CreateBitmap(new_width, new_height, DEFAULT_DEPTH);
+    new_bitmap = CreateBitmap(new_width, new_height, DEFAULT_DEPTH);
 
-  BlitBitmap(tmp_bitmap_1, new_bitmap, 0, 0, width_1, height_1, 0, 0);
-  BlitBitmap(tmp_bitmap_2, new_bitmap, 0, 0, width_1 / 2, height_1 / 2,
-            0, height_1);
-  BlitBitmap(tmp_bitmap_8, new_bitmap, 0, 0, width_1 / 8, height_1 / 8,
-            3 * width_1 / 4, height_1);
+    BlitBitmap(tmp_bitmap_1, new_bitmap, 0, 0, width_1, height_1, 0, 0);
+    BlitBitmap(tmp_bitmap_2, new_bitmap, 0, 0, width_1 / 2, height_1 / 2,
+              0, height_1);
+    BlitBitmap(tmp_bitmap_8, new_bitmap, 0, 0, width_1 / 8, height_1 / 8,
+              3 * width_1 / 4, height_1);
+  }
+  else
+  {
+    new_width  = width_1;
+    new_height = height_1;
 
-  if (zoom_factor != 1)
-    FreeBitmap(tmp_bitmap_1);
+    new_bitmap = tmp_bitmap_1; /* directly use tmp_bitmap_1 as new bitmap */
+  }
+
+  if (create_small_bitmaps)
+  {
+    /* if no small bitmaps created, tmp_bitmap_1 is used as new bitmap now */
+    if (zoom_factor != 1)
+      FreeBitmap(tmp_bitmap_1);
 
-  if (zoom_factor != 2)
-    FreeBitmap(tmp_bitmap_2);
+    if (zoom_factor != 2)
+      FreeBitmap(tmp_bitmap_2);
 
-  if (zoom_factor != 8)
-    FreeBitmap(tmp_bitmap_8);
+    if (zoom_factor != 8)
+      FreeBitmap(tmp_bitmap_8);
+  }
 
   /* replace image with extended image (containing normal, 1/2 and 1/8 size) */
 #if defined(TARGET_SDL)
@@ -885,7 +906,17 @@ void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor)
   old_bitmap->width  = new_bitmap->width;
   old_bitmap->height = new_bitmap->height;
 
-  FreeBitmap(new_bitmap);
+  FreeBitmap(new_bitmap);      /* this actually frees the _old_ bitmap now */
+}
+
+void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor)
+{
+  CreateScaledBitmaps(old_bitmap, zoom_factor, TRUE);
+}
+
+void ScaleBitmap(Bitmap *old_bitmap, int zoom_factor)
+{
+  CreateScaledBitmaps(old_bitmap, zoom_factor, FALSE);
 }
 
 
index 8eb5d9ab99e8eceb795a11521214400540a9e044..174a95ed6cf46a4f986723b6c48b18ee8716725e 100644 (file)
@@ -649,6 +649,8 @@ struct SetupEditorInfo
   boolean el_dynamic;
 
   boolean el_headlines;
+
+  boolean show_element_token;
 };
 
 struct SetupEditorCascadeInfo
@@ -996,6 +998,7 @@ void ReloadCustomImage(Bitmap *, char *);
 
 Bitmap *ZoomBitmap(Bitmap *, int, int);
 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
+void ScaleBitmap(Bitmap *, int);
 
 void SetMouseCursor(int);
 
index c4b8a2b1e65bb8fbb677a13c5cf8ab88b0ac78cc..f317b46d515451b834c415c58e1504fd236a2a22 100644 (file)
@@ -20,7 +20,9 @@
 #include "events.h"
 #include "config.h"
 
-Bitmap                *bitmap_db_field, *bitmap_db_door;
+Bitmap                *bitmap_db_title;
+Bitmap                *bitmap_db_field;
+Bitmap                *bitmap_db_door;
 DrawBuffer            *fieldbuffer;
 DrawBuffer            *drawto_field;
 
index 670711500babb17db6313394ca4708ac42c74f2c..774c97c73a10b1e3d9221549410b4dc8cc914427 100644 (file)
 #define MAX_ELEMENT_NAME_LEN   32
 #define MAX_TAPES_PER_SET      1024
 #define MAX_SCORE_ENTRIES      100
+#define MAX_NUM_TITLE_SCREENS  5
+
 #define MAX_NUM_AMOEBA         100
+
 #if 0  /* game.h */
 #define MAX_INVENTORY_SIZE     1000
 #define STD_NUM_KEYS           4
 #define MAX_NUM_KEYS           8
 #endif
+
 #define NUM_BELTS              4
 #define NUM_BELT_PARTS         3
 #define MIN_ENVELOPE_XSIZE     1
 
 /* values for special image configuration suffixes (must match game mode) */
 #define GFX_SPECIAL_ARG_DEFAULT                0
-#define GFX_SPECIAL_ARG_MAIN           1
-#define GFX_SPECIAL_ARG_LEVELS         2
-#define GFX_SPECIAL_ARG_SCORES         3
-#define GFX_SPECIAL_ARG_EDITOR         4
-#define GFX_SPECIAL_ARG_INFO           5
-#define GFX_SPECIAL_ARG_SETUP          6
-#define GFX_SPECIAL_ARG_PLAYING                7
-#define GFX_SPECIAL_ARG_DOOR           8
-#define GFX_SPECIAL_ARG_PREVIEW                9
-#define GFX_SPECIAL_ARG_CRUMBLED       10
+#define GFX_SPECIAL_ARG_TITLE          1
+#define GFX_SPECIAL_ARG_MAIN           2
+#define GFX_SPECIAL_ARG_LEVELS         3
+#define GFX_SPECIAL_ARG_SCORES         4
+#define GFX_SPECIAL_ARG_EDITOR         5
+#define GFX_SPECIAL_ARG_INFO           6
+#define GFX_SPECIAL_ARG_SETUP          7
+#define GFX_SPECIAL_ARG_PLAYING                8
+#define GFX_SPECIAL_ARG_DOOR           9
+#define GFX_SPECIAL_ARG_PREVIEW                10
+#define GFX_SPECIAL_ARG_CRUMBLED       11
 
-#define NUM_SPECIAL_GFX_ARGS           11
+#define NUM_SPECIAL_GFX_ARGS           12
 
 
 /* values for image configuration suffixes */
 
 /* values for game_status (must match special image configuration suffixes) */
 #define GAME_MODE_DEFAULT              0
-#define GAME_MODE_MAIN                 1
-#define GAME_MODE_LEVELS               2
-#define GAME_MODE_SCORES               3
-#define GAME_MODE_EDITOR               4
-#define GAME_MODE_INFO                 5
-#define GAME_MODE_SETUP                        6
-#define GAME_MODE_PLAYING              7
-#define GAME_MODE_PSEUDO_DOOR          8
-#define GAME_MODE_PSEUDO_PREVIEW       9
-#define GAME_MODE_PSEUDO_CRUMBLED      10
+#define GAME_MODE_TITLE                        1
+#define GAME_MODE_MAIN                 2
+#define GAME_MODE_LEVELS               3
+#define GAME_MODE_SCORES               4
+#define GAME_MODE_EDITOR               5
+#define GAME_MODE_INFO                 6
+#define GAME_MODE_SETUP                        7
+#define GAME_MODE_PLAYING              8
+#define GAME_MODE_PSEUDO_DOOR          9
+#define GAME_MODE_PSEUDO_PREVIEW       10
+#define GAME_MODE_PSEUDO_CRUMBLED      11
 
 /* there are no special config file suffixes for these modes */
-#define GAME_MODE_PSEUDO_TYPENAME      11
-#define GAME_MODE_QUIT                 12
+#define GAME_MODE_PSEUDO_TYPENAME      12
+#define GAME_MODE_QUIT                 13
 
 /* special definitions currently only used for custom artwork configuration */
 #define MUSIC_PREFIX_BACKGROUND                0
@@ -2237,10 +2243,12 @@ struct HelpAnimInfo
 };
 
 
-extern Bitmap                 *bitmap_db_field, *bitmap_db_door;
+extern Bitmap                 *bitmap_db_title;
+extern Bitmap                 *bitmap_db_field;
+extern Bitmap                 *bitmap_db_door;
 extern Pixmap                  tile_clipmask[];
-extern DrawBuffer            *fieldbuffer;
-extern DrawBuffer            *drawto_field;
+extern DrawBuffer             *fieldbuffer;
+extern DrawBuffer             *drawto_field;
 
 extern int                     game_status;
 extern boolean                 level_editor_test_game;
index 5fd02c715e3f07e4358a73e323c2529406c271ab..0743c5147429bda0140b4b3050a4ac8b4bc72bba 100644 (file)
@@ -285,9 +285,74 @@ static int getLevelRangeTextPos()
   return getNextLevelButtonPos() + 1;
 }
 
+void DrawTitleScreenImage(int nr)
+{
+  int graphic = IMG_TITLESCREEN_1 + nr;
+  Bitmap *bitmap = graphic_info[graphic].bitmap;
+  int width  = graphic_info[graphic].src_image_width;
+  int height = graphic_info[graphic].src_image_height;
+  int src_x = 0, src_y = 0;
+  int dst_x, dst_y;
+
+  if (bitmap == NULL)
+    return;
+
+  if (width > WIN_XSIZE)
+  {
+    src_x = (width - WIN_XSIZE) / 2;
+    width = WIN_XSIZE;
+  }
+
+  if (height > WIN_YSIZE)
+  {
+    src_y = (height - WIN_YSIZE) / 2;
+    height = WIN_YSIZE;
+  }
+
+  dst_x = (WIN_XSIZE - width) / 2;
+  dst_y = (WIN_YSIZE - height) / 2;
+
+#if 1
+  ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
+#else
+  DrawBackground(0, 0, WIN_XSIZE, WIN_YSIZE);
+#endif
+
+  if (DrawingOnBackground(dst_x, dst_y))
+    BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
+  else
+    BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
+
+  redraw_mask = REDRAW_ALL;
+}
+
+void DrawTitleScreen()
+{
+  KeyboardAutoRepeatOff();
+
+  SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
+
+#if 0
+  CloseDoor(DOOR_CLOSE_1);
+#endif
+
+  HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
+
+  PlayMenuSound();
+  PlayMenuMusic();
+
+#if 1
+  FadeIn(1000);
+#else
+  FadeToFront();
+#endif
+  StopAnimation();
+}
+
 void DrawMainMenu()
 {
   static LevelDirTree *leveldir_last_valid = NULL;
+  boolean levelset_has_changed = FALSE;
   char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
 #if 1
   char *level_text = "Levelset";
@@ -327,6 +392,9 @@ void DrawMainMenu()
   if (!validLevelSeries(leveldir_current))
     leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
 
+  if (leveldir_current != leveldir_last_valid)
+    levelset_has_changed = TRUE;
+
   /* store valid level series information */
   leveldir_last_valid = leveldir_current;
 
@@ -337,6 +405,14 @@ void DrawMainMenu()
   SetDrawtoField(DRAW_BACKBUFFER);
 #endif
 
+  if (levelset_has_changed && graphic_info[IMG_TITLESCREEN_1].bitmap != NULL)
+  {
+    game_status = GAME_MODE_TITLE;
+    DrawTitleScreen();
+
+    return;
+  }
+
 #if 0
   /* map gadgets for main menu screen */
   MapTapeButtons();
@@ -502,6 +578,71 @@ static void gotoTopLevelDir()
 }
 #endif
 
+void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
+{
+  static int title_nr = 0;
+  boolean return_to_main_menu = FALSE;
+  boolean use_cross_fading = TRUE;
+  int fade_delay = 1000;
+  int post_delay = 500;
+
+  if (button == MB_MENU_INITIALIZE)
+  {
+    title_nr = 0;
+
+    DrawTitleScreenImage(title_nr);
+
+    return;
+  }
+  else if (button == MB_MENU_LEAVE)
+  {
+    return_to_main_menu = TRUE;
+  }
+  else if (button == MB_MENU_CHOICE)
+  {
+    title_nr++;
+
+    if (!use_cross_fading)
+    {
+      FadeOut(fade_delay);
+      Delay(post_delay);
+    }
+
+    if (title_nr < MAX_NUM_TITLE_SCREENS &&
+       graphic_info[IMG_TITLESCREEN_1 + title_nr].bitmap != NULL)
+    {
+      Bitmap *drawto_last = drawto;
+
+      if (use_cross_fading)
+       drawto = bitmap_db_title;
+
+      DrawTitleScreenImage(title_nr);
+
+      drawto = drawto_last;
+
+      if (use_cross_fading)
+       FadeCross(bitmap_db_title, fade_delay);
+      else
+       FadeIn(fade_delay);
+    }
+    else
+    {
+      FadeOut(fade_delay);
+      Delay(post_delay);
+
+      return_to_main_menu = TRUE;
+    }
+  }
+
+  if (return_to_main_menu)
+  {
+    RedrawBackground();
+
+    game_status = GAME_MODE_MAIN;
+    DrawMainMenu();
+  }
+}
+
 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 {
   static unsigned long level_delay = 0;
@@ -2146,6 +2287,7 @@ static struct TokenInfo setup_info_game[] =
 
 static struct TokenInfo setup_info_editor[] =
 {
+#if 0
   { TYPE_SWITCH,       &setup.editor.el_boulderdash,   "Boulder Dash:" },
   { TYPE_SWITCH,       &setup.editor.el_emerald_mine,  "Emerald Mine:" },
   { TYPE_SWITCH, &setup.editor.el_emerald_mine_club,   "Emerald Mine Club:" },
@@ -2154,12 +2296,15 @@ static struct TokenInfo setup_info_editor[] =
   { TYPE_SWITCH,       &setup.editor.el_supaplex,      "Supaplex:"     },
   { TYPE_SWITCH,       &setup.editor.el_diamond_caves, "Diamond Caves II:" },
   { TYPE_SWITCH,       &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
+#endif
   { TYPE_SWITCH,       &setup.editor.el_chars,         "Text Characters:" },
   { TYPE_SWITCH,       &setup.editor.el_custom,  "Custom & Group Elements:" },
   { TYPE_SWITCH,       &setup.editor.el_headlines,     "Headlines:"    },
   { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
   { TYPE_SWITCH,       &setup.editor.el_dynamic,  "Dynamic level elements:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_SWITCH, &setup.editor.show_element_token,     "Show element token:" },
+  { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
   { 0,                 NULL,                   NULL                    }
index 949267f001e0586a8b9e2ffd078ca0648785d53a..e895c4feefa9610b74200a8b745989bb8308cdad 100644 (file)
@@ -24,6 +24,7 @@
 void DrawMainMenu(void);
 void DrawHallOfFame(int);
 
+void HandleTitleScreen(int, int, int, int, int);
 void HandleMainMenu(int, int, int, int, int);
 void HandleChooseLevel(int, int, int, int, int);
 void HandleHallOfFame(int, int, int, int, int);
index b6e9f10ad881393db27c0bd77980af36f9e15760..6f2c96e21840bccbc7aefb193e3f0d710fe6b253 100644 (file)
@@ -241,7 +241,8 @@ void BackToFront()
   if (redraw_mask & REDRAW_ALL)
   {
     BlitBitmap(backbuffer, window, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
-    redraw_mask = 0;
+
+    redraw_mask = REDRAW_NONE;
   }
 
   if (redraw_mask & REDRAW_FIELD)
@@ -413,6 +414,114 @@ void FadeToFront()
   BackToFront();
 }
 
+#define FADE_MODE_FADE_IN      0
+#define FADE_MODE_FADE_OUT     1
+#define FADE_MODE_CROSSFADE    2
+
+static void FadeExt(Bitmap *bitmap_cross, int fade_ms, int fade_mode)
+{
+  SDL_Surface *surface_screen = backbuffer->surface;
+  SDL_Surface *surface_screen_copy = NULL;
+  SDL_Surface *surface_black = NULL;
+  SDL_Surface *surface_cross;          /* initialized later */
+  boolean fade_reverse;                        /* initialized later */
+  unsigned int flags = SDL_SRCALPHA;
+  unsigned int time_last, time_current;
+  float alpha;
+  int alpha_final;
+
+  /* use same surface type as screen surface */
+  if ((surface_screen->flags & SDL_HWSURFACE))
+    flags |= SDL_HWSURFACE;
+  else
+    flags |= SDL_SWSURFACE;
+
+  /* create surface for copy of screen buffer */
+  if ((surface_screen_copy =
+       SDL_CreateRGBSurface(flags,
+                           surface_screen->w,
+                           surface_screen->h,
+                           surface_screen->format->BitsPerPixel,
+                           surface_screen->format->Rmask,
+                           surface_screen->format->Gmask,
+                           surface_screen->format->Bmask,
+                           surface_screen->format->Amask)) == NULL)
+    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+  SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL);
+
+  /* create black surface for fading from/to black */
+  if ((surface_black =
+       SDL_CreateRGBSurface(flags,
+                           surface_screen->w,
+                           surface_screen->h,
+                           surface_screen->format->BitsPerPixel,
+                           surface_screen->format->Rmask,
+                           surface_screen->format->Gmask,
+                           surface_screen->format->Bmask,
+                           surface_screen->format->Amask)) == NULL)
+    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+  SDL_FillRect(surface_black, NULL, SDL_MapRGB(surface_screen->format, 0,0,0));
+
+  fade_reverse = (fade_mode == FADE_MODE_FADE_IN ? TRUE : FALSE);
+  surface_cross = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_cross->surface :
+                  surface_black);
+
+  time_current = SDL_GetTicks();
+
+  for (alpha = 0.0; alpha < 255.0;)
+  {
+    time_last = time_current;
+    time_current = SDL_GetTicks();
+    alpha += 255 * ((float)(time_current - time_last) / fade_ms);
+    alpha_final = (int)(fade_reverse ? 255.0 - alpha : alpha);
+    alpha_final = MIN(MAX(0, alpha_final), 255);
+
+    /* draw existing image to screen buffer */
+    SDL_BlitSurface(surface_screen_copy, NULL, surface_screen, NULL);
+
+    /* draw new image to screen buffer using alpha blending */
+    SDL_SetAlpha(surface_cross, SDL_SRCALPHA, alpha_final);
+    SDL_BlitSurface(surface_cross, NULL, surface_screen, NULL);
+
+    /* draw screen buffer to visible display */
+    SDL_Flip(surface_screen);
+  }
+
+  SDL_FreeSurface(surface_screen_copy);
+  SDL_FreeSurface(surface_black);
+
+  redraw_mask = REDRAW_NONE;
+}
+
+void FadeIn(int fade_ms)
+{
+#ifdef TARGET_SDL
+  FadeExt(NULL, fade_ms, FADE_MODE_FADE_IN);
+#else
+  BackToFront();
+#endif
+}
+
+void FadeOut(int fade_ms)
+{
+#ifdef TARGET_SDL
+  FadeExt(NULL, fade_ms, FADE_MODE_FADE_OUT);
+#else
+  BackToFront();
+#endif
+}
+
+void FadeCross(Bitmap *bitmap, int fade_ms)
+{
+#ifdef TARGET_SDL
+  FadeExt(bitmap, fade_ms, FADE_MODE_CROSSFADE);
+#else
+  BackToFront();
+#endif
+}
+
 void SetMainBackgroundImageIfDefined(int graphic)
 {
   if (graphic_info[graphic].bitmap)
@@ -2513,7 +2622,7 @@ unsigned int MoveDoor(unsigned int door_state)
     door_2.height = VYSIZE;
 
   if (door_state == DOOR_GET_STATE)
-    return(door1 | door2);
+    return (door1 | door2);
 
   if (door_state & DOOR_SET_STATE)
   {
@@ -2522,7 +2631,7 @@ unsigned int MoveDoor(unsigned int door_state)
     if (door_state & DOOR_ACTION_2)
       door2 = door_state & DOOR_ACTION_2;
 
-    return(door1 | door2);
+    return (door1 | door2);
   }
 
   if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
@@ -2765,13 +2874,15 @@ unsigned int MoveDoor(unsigned int door_state)
        door_2_done = (a == VXSIZE);
       }
 
-      BackToFront();
+      if (!(door_state & DOOR_NO_DELAY))
+      {
+       BackToFront();
 
-      if (game_status == GAME_MODE_MAIN)
-       DoAnimation();
+       if (game_status == GAME_MODE_MAIN)
+         DoAnimation();
 
-      if (!(door_state & DOOR_NO_DELAY))
        WaitUntilDelayReached(&door_delay, door_delay_value);
+      }
     }
   }
 
index b1d0dd86d0287562067d61b86d3404d9a73461d7..10b4890bd1310656f6925a1b7ff9fe43990d11ef 100644 (file)
@@ -65,6 +65,11 @@ void SetDrawtoField(int);
 void RedrawPlayfield(boolean, int, int, int, int);
 void BackToFront();
 void FadeToFront();
+
+void FadeIn(int);
+void FadeOut(int);
+void FadeCross(Bitmap *, int);
+
 void ClearWindow();
 void SetMainBackgroundImageIfDefined(int);
 void SetMainBackgroundImage(int);