added warning only once per file when using fallback artwork
[rocksndiamonds.git] / src / libgame / text.c
index 117c9b1cda08765556a2549163ab6326a8559221..eb36ab2285a47c42e0f8394e49a4d7850d419cf2 100644 (file)
@@ -136,8 +136,12 @@ int maxWordLengthInRequestString(char *text)
 // simple text drawing functions
 // ============================================================================
 
-void DrawInitText(char *text, int ypos, int font_nr)
+static void DrawInitTextExt(char *text, int ypos, int font_nr, boolean update)
 {
+  LimitScreenUpdates(TRUE);
+
+  UPDATE_BUSY_STATE();
+
   if (window != NULL &&
       gfx.draw_init_text &&
       gfx.num_fonts > 0 &&
@@ -148,31 +152,27 @@ void DrawInitText(char *text, int ypos, int font_nr)
     int width = video.width;
     int height = getFontHeight(font_nr);
 
-    ClearRectangle(drawto, 0, y, width, height);
-    DrawTextExt(drawto, x, y, text, font_nr, BLIT_OPAQUE);
+    ClearRectangleOnBackground(drawto, 0, y, width, height);
+    DrawTextExt(drawto, x, y, text, font_nr, BLIT_MASKED);
 
-    BlitBitmap(drawto, window, 0, 0, video.width, video.height, 0, 0);
+    if (update)
+      BlitBitmap(drawto, window, 0, 0, video.width, video.height, 0, 0);
   }
 }
 
-void DrawInitTextHead(char *text)
+void DrawInitText(char *text, int ypos, int font_nr)
 {
-  // always draw headlines when loading initial stuff
-  LimitScreenUpdates(FALSE);
-
-  UPDATE_BUSY_STATE();
+  DrawInitTextExt(text, ypos, font_nr, FALSE);
+}
 
-  DrawInitText(text, 120, FC_GREEN);
+void DrawInitTextHead(char *text)
+{
+  DrawInitTextExt(text, 120, FC_GREEN, FALSE);
 }
 
 void DrawInitTextItem(char *text)
 {
-  // limit drawing (potentially many) loading items
-  LimitScreenUpdates(TRUE);
-
-  UPDATE_BUSY_STATE();
-
-  DrawInitText(text, 150, FC_YELLOW);
+  DrawInitTextExt(text, 150, FC_YELLOW, TRUE);
 }
 
 void DrawTextF(int x, int y, int font_nr, char *format, ...)
@@ -371,6 +371,15 @@ char *GetTextBufferFromFile(char *filename, int max_lines)
 
   closeFile(file);
 
+  if (getTextEncoding(buffer) == TEXT_ENCODING_UTF_8)
+  {
+    char *body_latin1 = getLatin1FromUTF8(buffer);
+
+    checked_free(buffer);
+
+    buffer = body_latin1;
+  }
+
   return buffer;
 }
 
@@ -646,6 +655,17 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
   return current_line;
 }
 
+int DrawTextBufferS(int x, int y, char *text_buffer, int font_nr,
+                   int line_length, int cut_length, int max_lines,
+                   int line_spacing, int mask_mode, boolean autowrap,
+                   boolean centered, boolean parse_comments)
+{
+  return DrawTextBuffer(gfx.sx + x, gfx.sy + y, text_buffer, font_nr,
+                       line_length, cut_length, max_lines,
+                       line_spacing, mask_mode, autowrap,
+                       centered, parse_comments);
+}
+
 int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr,
                     int line_length, int cut_length, int max_lines,
                     int line_spacing, int mask_mode, boolean autowrap,