rnd-20070124-2-src
[rocksndiamonds.git] / src / screens.c
index a10615890ecf57ede3ee3068ad614a229e34d5fb..fa44e771c24fd1632412edd15630c186f533aaca 100644 (file)
@@ -505,8 +505,8 @@ static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
       if (pos_text != NULL && text != NULL)
       {
        struct MenuPosInfo *pos = pos_text;
-       int x = mSX + ALIGNED_XPOS(pos->x, pos->width, pos->align);
-       int y = mSY + pos->y;
+       int x = mSX + ALIGNED_MENU_XPOS(pos);
+       int y = mSY + ALIGNED_MENU_YPOS(pos);
 
        DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
        DrawText(x, y, text, font_text);
@@ -515,8 +515,8 @@ static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
       if (pos_input != NULL && input != NULL)
       {
        struct MenuPosInfo *pos = pos_input;
-       int x = mSX + ALIGNED_XPOS(pos->x, pos->width, pos->align);
-       int y = mSY + pos->y;
+       int x = mSX + ALIGNED_MENU_XPOS(pos);
+       int y = mSY + ALIGNED_MENU_YPOS(pos);
 
        DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
        DrawText(x, y, input, font_input);
@@ -553,8 +553,8 @@ static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
   if (rect == NULL)
     return FALSE;
 
-  int rect_x = ALIGNED_XPOS(rect->x, rect->width, rect->align);
-  int rect_y = rect->y;
+  int rect_x = ALIGNED_MENU_XPOS(rect);
+  int rect_y = ALIGNED_MENU_YPOS(rect);
 
   return (x >= rect_x && x < rect_x + rect->width &&
          y >= rect_y && y < rect_y + rect->height);
@@ -709,6 +709,41 @@ void DrawTitleScreenImage(int nr)
     title.auto_delay_final = graphic_info[graphic].auto_delay;
 }
 
+void DrawTitleScreenMessage(char *filename)
+{
+  int font_nr = FONT_TEXT_1;
+  int font_width;
+  int font_height;
+  int pad_x = 16;
+  int pad_y = 32;
+  int sx = pad_x;
+  int sy = pad_y;
+  int max_chars_per_line;
+  int max_lines_per_screen;
+  int last_game_status = game_status;  /* save current game status */
+
+  if (filename == NULL)
+    return;
+
+  SetDrawBackgroundMask(REDRAW_ALL);
+  SetWindowBackgroundImageIfDefined(IMG_BACKGROUND_MESSAGE);
+
+  ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
+
+  /* force MESSAGE font on title message screen */
+  game_status = GAME_MODE_MESSAGE;
+
+  font_width = getFontWidth(font_nr);
+  font_height = getFontHeight(font_nr);
+  max_chars_per_line = (WIN_XSIZE - 2 * pad_x) / font_width;
+  max_lines_per_screen = (WIN_YSIZE - pad_y) / font_height - 1;
+
+  DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
+                  max_lines_per_screen, FALSE);
+
+  game_status = last_game_status;      /* restore current game status */
+}
+
 void DrawTitleScreen()
 {
   KeyboardAutoRepeatOff();
@@ -780,7 +815,8 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading)
 
   if (setup.show_titlescreen &&
       ((levelset_has_changed &&
-       graphic_info[IMG_TITLESCREEN_1].bitmap != NULL) ||
+       (graphic_info[IMG_TITLESCREEN_1].bitmap != NULL ||
+        getLevelSetMessageFilename() != NULL)) ||
        (show_titlescreen_initial &&
        graphic_info[IMG_TITLESCREEN_INITIAL_1].bitmap != NULL)))
   {
@@ -948,9 +984,13 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 {
   static unsigned long title_delay = 0;
   static int title_nr = 0;
+  static boolean showing_message = FALSE;
+  char *filename = getLevelSetMessageFilename();
   boolean return_to_main_menu = FALSE;
   boolean use_fading_main_menu = TRUE;
   boolean use_cross_fading = !show_titlescreen_initial;                /* default */
+  boolean no_title_info = (graphic_info[IMG_TITLESCREEN_1].bitmap == NULL &&
+                          filename == NULL);
 
   if (button == MB_MENU_INITIALIZE)
   {
@@ -958,6 +998,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     title_delay = 0;
     title_nr = 0;
+    showing_message = FALSE;
 
     if (show_titlescreen_initial &&
        graphic_info[IMG_TITLESCREEN_INITIAL_1].bitmap == NULL)
@@ -965,7 +1006,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     if (game_status == GAME_MODE_INFO)
     {
-      if (graphic_info[IMG_TITLESCREEN_1].bitmap == NULL)
+      if (no_title_info)
       {
        DrawInfoScreen_NotAvailable("Title screen information:",
                                    "No title screen for this level set.");
@@ -988,7 +1029,20 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     game_status = last_game_status;    /* restore current game status */
 
-    DrawTitleScreenImage(title_nr);
+    if (graphic_info[getTitleScreenGraphic()].bitmap != NULL)
+    {
+      DrawTitleScreenImage(title_nr);
+    }
+    else
+    {
+      DrawTitleScreenMessage(filename);
+
+      showing_message = TRUE;
+
+      title.fade_delay_final = title.fade_delay;
+      title.post_delay_final = title.post_delay;
+      title.auto_delay_final = -1;
+    }
 
     FadeIn(REDRAW_ALL);
 
@@ -1010,8 +1064,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
   {
     int anim_mode;
 
-    if (game_status == GAME_MODE_INFO &&
-       graphic_info[IMG_TITLESCREEN_1].bitmap == NULL)
+    if (game_status == GAME_MODE_INFO && no_title_info)
     {
       FadeOut(REDRAW_FIELD);
 
@@ -1056,6 +1109,22 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
       DelayReached(&title_delay, 0);   /* reset delay counter */
     }
+    else if (!showing_message && filename != NULL)
+    {
+      if (use_cross_fading)
+       FadeCrossSaveBackbuffer();
+
+      DrawTitleScreenMessage(filename);
+
+      if (use_cross_fading)
+       FadeCross(REDRAW_ALL);
+      else
+       FadeIn(REDRAW_ALL);
+
+      DelayReached(&title_delay, 0);   /* reset delay counter */
+
+      showing_message = TRUE;
+    }
     else
     {
       FadeSoundsAndMusic();
@@ -1780,7 +1849,11 @@ static char *getHelpText(int element, int action, int direction)
 
 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
 {
+#if 1
+  int font_nr = FONT_INFO_ELEMENTS;
+#else
   int font_nr = FONT_LEVEL_NUMBER;
+#endif
   int font_width = getFontWidth(font_nr);
   int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
   int sy = mSY + 65 + 2 * 32 + 1;
@@ -2383,7 +2456,11 @@ void DrawInfoScreen_LevelSet()
   int ystart = 150;
   int ybottom = SYSIZE - 20;
   char *filename = getLevelSetInfoFilename();
+#if 1
+  int font_nr = FONT_INFO_LEVELSET;
+#else
   int font_nr = FONT_LEVEL_NUMBER;
+#endif
   int font_width = getFontWidth(font_nr);
   int font_height = getFontHeight(font_nr);
   int pad_x = 32;
@@ -2407,7 +2484,7 @@ void DrawInfoScreen_LevelSet()
 
   if (filename != NULL)
     DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
-                    max_lines_per_screen);
+                    max_lines_per_screen, TRUE);
   else
     DrawTextSCentered(ystart, FONT_TEXT_2,
                      "No information for this level set.");
@@ -2510,8 +2587,8 @@ void HandleTypeName(int newxpos, Key key)
   struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
 #if 1
   struct MenuPosInfo *pos = mci->pos_input;
-  int startx = mSX + ALIGNED_XPOS(pos->x, pos->width, pos->align);
-  int starty = mSY + pos->y;
+  int startx = mSX + ALIGNED_MENU_XPOS(pos);
+  int starty = mSY + ALIGNED_MENU_YPOS(pos);
 #endif
 #if 1
   static int xpos = 0;
@@ -3338,6 +3415,7 @@ static struct TokenInfo setup_info_editor[] =
   { TYPE_SWITCH,       &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
 #endif
   { TYPE_SWITCH,       &setup.editor.el_chars,         "Text Characters:" },
+  { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
   { TYPE_SWITCH,       &setup.editor.el_custom,  "Custom & Group Elements:" },
 #if 0
   { TYPE_SWITCH,       &setup.editor.el_headlines,     "Headlines:"    },