rnd-20031129-2-src
[rocksndiamonds.git] / src / editor.c
index 0eea3c6da24218245c1a3c75980280f089e1b789..061d1304d3a92227dd2c880bb00cf235d3b79d45 100644 (file)
@@ -5530,7 +5530,6 @@ char *getElementDescriptionFilename(int element)
   return NULL;
 }
 
-#if 1
 static boolean PrintInfoText(char *text, int font_nr, int start_line)
 {
   int font_height = getFontHeight(font_nr);
@@ -5548,8 +5547,6 @@ static boolean PrintInfoText(char *text, int font_nr, int start_line)
   return TRUE;
 }
 
-#if 1
-
 static int PrintElementDescriptionFromFile(char *filename, int start_line)
 {
   int font_nr = FONT_TEXT_2;
@@ -5637,320 +5634,6 @@ static int PrintElementDescriptionFromFile(char *filename, int start_line)
   return (current_line - start_line);
 }
 
-#else
-
-static int PrintElementDescriptionFromFile(char *filename, int start_line)
-{
-  int font_nr = FONT_TEXT_2;
-  int font_width = getFontWidth(font_nr);
-  int font_height = getFontHeight(font_nr);
-  int pad_x = ED_SETTINGS_XPOS(0);
-  int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
-  int sx = SX + pad_x;
-  int sy = SY + pad_y;
-  int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
-  int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
-  int current_line = start_line;
-  char line[MAX_LINE_LEN];
-  char buffer[max_chars_per_line + 1];
-  int buffer_len;
-  FILE *file;
-
-  if (filename == NULL)
-    return 0;
-
-  if (!(file = fopen(filename, MODE_READ)))
-    return 0;
-
-  buffer[0] = '\0';
-  buffer_len = 0;
-
-  while(!feof(file))
-  {
-    char *line_ptr, *word_ptr;
-    boolean last_line_was_empty = TRUE;
-
-    /* read next line of input file */
-    if (!fgets(line, MAX_LINE_LEN, file))
-      break;
-
-    /* skip comments (lines directly beginning with '#') */
-    if (line[0] == '#')
-      continue;
-
-    /* cut trailing newline from input line */
-    for (line_ptr = line; *line_ptr; line_ptr++)
-    {
-      if (*line_ptr == '\n' || *line_ptr == '\r')
-      {
-       *line_ptr = '\0';
-       break;
-      }
-    }
-
-    if (strlen(line) == 0)             /* special case: force empty line */
-      strcpy(line, "\n");
-
-    word_ptr = line;
-
-    while (*word_ptr)
-    {
-      boolean print_buffer = FALSE;
-      int word_len;
-
-      /* skip leading whitespaces */
-      while (*word_ptr == ' ' || *word_ptr == '\t')
-       word_ptr++;
-
-      line_ptr = word_ptr;
-      word_len = 0;
-
-      /* look for end of next word */
-      while (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0')
-      {
-       line_ptr++;
-       word_len++;
-      }
-
-      if (word_len == 0)
-      {
-       continue;
-      }
-      else if (*word_ptr == '\n')      /* special case: force empty line */
-      {
-       if (buffer_len == 0)
-         word_ptr++;
-
-       /* prevent printing of multiple empty lines */
-       if (buffer_len > 0 || !last_line_was_empty)
-         print_buffer = TRUE;
-      }
-      else if (word_len < max_chars_per_line - buffer_len)
-      {
-       /* word fits into text buffer -- add word */
-
-       if (buffer_len > 0)
-         buffer[buffer_len++] = ' ';
-
-       strncpy(&buffer[buffer_len], word_ptr, word_len);
-       buffer_len += word_len;
-       buffer[buffer_len] = '\0';
-       word_ptr += word_len;
-      }
-      else if (buffer_len > 0)
-      {
-       /* not enough space left for word in text buffer -- print buffer */
-
-       print_buffer = TRUE;
-      }
-      else
-      {
-       /* word does not fit at all into empty text buffer -- cut word */
-
-       strncpy(buffer, word_ptr, max_chars_per_line);
-       buffer[max_chars_per_line] = '\0';
-       word_ptr += max_chars_per_line;
-       print_buffer = TRUE;
-      }
-
-      if (print_buffer)
-      {
-       if (current_line >= max_lines_per_screen)
-       {
-         fclose(file);
-
-         return (current_line - start_line);
-       }
-
-       DrawText(sx, sy + current_line * font_height, buffer, font_nr);
-       current_line++;
-
-       last_line_was_empty = (buffer_len == 0);
-
-       buffer[0] = '\0';
-       buffer_len = 0;
-       print_buffer = FALSE;
-      }
-    }
-  }
-
-  fclose(file);
-
-  if (buffer_len > 0 && current_line < max_lines_per_screen)
-  {
-    DrawText(sx, sy + current_line * font_height, buffer, font_nr);
-    current_line++;
-  }
-
-  return (current_line - start_line);
-}
-#endif
-
-#else
-
-static boolean PrintInfoText(char *text, int font_nr, int screen_line)
-{
-  int font_height = getFontHeight(font_nr);
-  int pad_x = ED_SETTINGS_XPOS(0);
-  int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
-  int sx = SX + pad_x;
-  int sy = SY + pad_y;
-  int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
-
-  if (screen_line >= max_lines_per_screen)
-    return FALSE;
-
-  DrawText(sx, sy + screen_line * font_height, text, font_nr);
-
-  return TRUE;
-}
-
-static int PrintElementDescriptionFromFile(char *filename, int screen_line)
-{
-  int font_nr = FONT_TEXT_2;
-  int font_width = getFontWidth(font_nr);
-  int pad_x = ED_SETTINGS_XPOS(0);
-  int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
-  char line[MAX_LINE_LEN];
-  char buffer[max_chars_per_line + 1];
-  int buffer_len;
-  int lines_printed = 0;
-  FILE *file;
-
-  if (filename == NULL)
-    return 0;
-
-  if (!(file = fopen(filename, MODE_READ)))
-    return 0;
-
-  buffer[0] = '\0';
-  buffer_len = 0;
-
-  while(!feof(file))
-  {
-    char *line_ptr, *word_ptr;
-    boolean last_line_was_empty = TRUE;
-
-    /* read next line of input file */
-    if (!fgets(line, MAX_LINE_LEN, file))
-      break;
-
-    /* skip comments (lines directly beginning with '#') */
-    if (line[0] == '#')
-      continue;
-
-    /* cut trailing newline from input line */
-    for (line_ptr = line; *line_ptr; line_ptr++)
-    {
-      if (*line_ptr == '\n' || *line_ptr == '\r')
-      {
-       *line_ptr = '\0';
-       break;
-      }
-    }
-
-    if (strlen(line) == 0)             /* special case: force empty line */
-      strcpy(line, "\n");
-
-    word_ptr = line;
-
-#if 0
-    printf("::: got line '%s'...\n", line);
-#endif
-
-    while (*word_ptr)
-    {
-      boolean print_buffer = FALSE;
-      int word_len;
-
-      /* skip leading whitespaces */
-      while (*word_ptr == ' ' || *word_ptr == '\t')
-       word_ptr++;
-
-      line_ptr = word_ptr;
-      word_len = 0;
-
-      /* look for end of next word */
-      while (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0')
-      {
-       line_ptr++;
-       word_len++;
-      }
-
-      if (word_len == 0)
-      {
-       continue;
-      }
-      else if (*word_ptr == '\n')      /* special case: force empty line */
-      {
-       if (buffer_len == 0)
-         word_ptr++;
-
-       /* prevent printing of multiple empty lines */
-       if (buffer_len > 0 || !last_line_was_empty)
-         print_buffer = TRUE;
-      }
-      else if (word_len < max_chars_per_line - buffer_len)
-      {
-       /* word fits into text buffer -- add word */
-
-       if (buffer_len > 0)
-         buffer[buffer_len++] = ' ';
-
-       strncpy(&buffer[buffer_len], word_ptr, word_len);
-       buffer_len += word_len;
-       buffer[buffer_len] = '\0';
-       word_ptr += word_len;
-      }
-      else if (buffer_len > 0)
-      {
-       /* not enough space left for word in text buffer -- print buffer */
-
-       print_buffer = TRUE;
-      }
-      else
-      {
-       /* word does not fit at all into empty text buffer -- cut word */
-
-       strncpy(buffer, word_ptr, max_chars_per_line);
-       buffer[max_chars_per_line] = '\0';
-       word_ptr += max_chars_per_line;
-       print_buffer = TRUE;
-      }
-
-      if (print_buffer)
-      {
-#if 0
-       printf("::: printing '%s'...\n", buffer);
-#endif
-
-       if (!PrintInfoText(buffer, font_nr, screen_line + lines_printed))
-       {
-         fclose(file);
-
-         return lines_printed;
-       }
-
-       last_line_was_empty = (buffer_len == 0);
-       lines_printed++;
-
-       buffer[0] = '\0';
-       buffer_len = 0;
-       print_buffer = FALSE;
-      }
-    }
-  }
-
-  fclose(file);
-
-  if (buffer_len > 0)
-    if (PrintInfoText(buffer, font_nr, screen_line + lines_printed))
-      lines_printed++;
-
-  return lines_printed;
-}
-#endif
-
 static void DrawPropertiesTabulatorGadgets()
 {
   struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];